From ec76a20b2fe4e9ffcfbe755166455b19abe3c2d3 Mon Sep 17 00:00:00 2001 From: yp9522 Date: Mon, 14 Jul 2025 18:19:35 +0800 Subject: [PATCH] add common_components tdd Change-Id: Ic356656558aaf13693eca37d79a373327868b931 Signed-off-by: yp9522 --- common_components/base/tests/c_string_test.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common_components/base/tests/c_string_test.cpp b/common_components/base/tests/c_string_test.cpp index 56b0436ac5..88b998aac0 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 -- Gitee