diff --git a/common_components/base/tests/c_string_test.cpp b/common_components/base/tests/c_string_test.cpp index 56b0436ac55873a17bfd6cd19d706b945a9fa16b..88b998aac0e39cfce06773682ff1222298b7c74e 100755 --- a/common_components/base/tests/c_string_test.cpp +++ b/common_components/base/tests/c_string_test.cpp @@ -274,4 +274,14 @@ HWTEST_F_L0(CStringTest, ConstructTest) EXPECT_EQ(nonEmptyStr.Length(), static_cast(0)); EXPECT_EQ(nonEmptyStr.Str()[0], '\0'); } + +HWTEST_F_L0(CStringTest, CStringSubscriptOperatorTest) +{ + const CString constStr("hello world"); + EXPECT_EQ(constStr[0], 'h'); + + CString mutableStr("mutable"); + mutableStr[0] = 'M'; + EXPECT_EQ(mutableStr[0], 'M'); +} } \ No newline at end of file