Skip to content

Commit 504ee76

Browse files
committed
[bugfix]components:libc:cplusplus: Repair the comment code.
os:cxx_Semaphore.c Correct the error and replace implementation with constructor on line 15. utest:tc_thread.cpp Function comments for utest_tc_init and utest_tc_cleanup,return value information: RT_EOK on success on line 58,66. utest:tc_atomic.cpp 1. Change the comment symbol from '//' to '/**/' to comply with rtthread specifications.For utest:tc_atomic.cpp and tc_smartptr.cpp, select the original respository files without modification. 2. Modify the comments of the functions utest_tc_init, utest_tc_cleanup, testcase and UTEST_TC_EXPORT in tc_atomic.cpp. On the premise of conforming to RT-Thread coding standards, maintain consistency with the comment style of the tc_thread.cpp file. utest:tc_smartptr.cpp Modify the comments of the functions utest_tc_init, utest_tc_cleanup, testcase and UTEST_TC_EXPORT in tc_smartptr.cpp. On the premise of conforming to RT-Thread coding standards, maintain consistency with the comment style of the tc_thread.cpp file. signed-off-by: Liu Chengtao<[email protected]>
1 parent 0d6b97c commit 504ee76

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

components/libc/cplusplus/os/cxx_Semaphore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
using namespace rtthread;
1313

1414
/**
15-
* @brief Semaphore class implementation.
15+
* @brief Semaphore class constructor.
1616
* @param name Semaphore name
1717
* @param count Initial semaphore count
1818
*/

components/libc/cplusplus/utest/tc_atomic.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void test_atomic_basic_int32(void)
112112
val.fetch_and(14);
113113
uassert_int_equal(val.load(), 10);
114114

115-
val.fetch_or(11); //1010
115+
val.fetch_or(11); /* 1010 */
116116
uassert_int_equal(val.load(), 11);
117117

118118
val.fetch_xor(4);
@@ -158,8 +158,8 @@ static void test_atomic_basic_int64(void)
158158

159159
val.fetch_and(14);
160160
uassert_int_equal(val.load(), 10);
161-
162-
val.fetch_or(11); //1010
161+
162+
val.fetch_or(11); /* 1010 */
163163
uassert_int_equal(val.load(), 11);
164164

165165
val.fetch_xor(4);
@@ -217,7 +217,7 @@ static void test_memory_order(void)
217217
{
218218
std::atomic<int> x(0);
219219
std::atomic<int> y(0);
220-
// Simple test for memory order
220+
/* Simple test for memory order */
221221
x.store(1, std::memory_order_release);
222222
y.store(2, std::memory_order_release);
223223
uassert_int_equal(x.load(std::memory_order_acquire), 1);
@@ -234,22 +234,26 @@ static void test_compare_exchange_weak(void)
234234
int desired = 2;
235235
while (!val.compare_exchange_weak(expected, desired))
236236
{
237-
expected = 1; // reset
237+
/* Reset */
238+
expected = 1;
238239
}
239240
uassert_int_equal(val.load(), 2);
240241
}
241-
// Test case initialization function.
242+
/* Test case initialization function. */
242243
static rt_err_t utest_tc_init(void)
243244
{
244245
return RT_EOK;
245246
}
246247

247-
// Test case cleanup function.
248+
/* Test case cleanup function.*/
248249
static rt_err_t utest_tc_cleanup(void)
249250
{
250251
return RT_EOK;
251252
}
252253

254+
/**
255+
* @brief Main test case function that runs the test.
256+
*/
253257
static void testcase(void)
254258
{
255259
/* Test load and store operations for int32_t atomic variables in multi-threaded environment */
@@ -269,4 +273,6 @@ static void testcase(void)
269273
/* Test compare_exchange_weak operation */
270274
UTEST_UNIT_RUN(test_compare_exchange_weak);
271275
}
276+
277+
/* Export the test case with initialization and cleanup functions and a timeout of 10 ticks. */
272278
UTEST_TC_EXPORT(testcase, "components.libc.cpp.atomic_tc", utest_tc_init, utest_tc_cleanup, 10);

components/libc/cplusplus/utest/tc_smartptr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void test_shared_ptr(void)
3737

3838
/**
3939
* @brief Test case initialization function.
40+
* @return RT_EOK on success.
4041
*/
4142
static rt_err_t utest_tc_init(void)
4243
{
@@ -45,17 +46,23 @@ static rt_err_t utest_tc_init(void)
4546

4647
/**
4748
* @brief Test case cleanup function.
49+
* @return RT_EOK on success.
4850
*/
4951
static rt_err_t utest_tc_cleanup(void)
5052
{
5153
return RT_EOK;
5254
}
5355

56+
/**
57+
* @brief Main test case function that runs the test.
58+
*/
5459
static void testcase(void)
5560
{
5661
/* Test unique_ptr basic operations */
5762
UTEST_UNIT_RUN(test_unique_ptr);
5863
/* Test shared_ptr basic operations */
5964
UTEST_UNIT_RUN(test_shared_ptr);
6065
}
66+
67+
/* Export the test case with initialization and cleanup functions and a timeout of 10 ticks. */
6168
UTEST_TC_EXPORT(testcase, "components.libc.cpp.smartptr_tc", utest_tc_init, utest_tc_cleanup, 10);

components/libc/cplusplus/utest/tc_thread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ static void test_thread(void)
5555

5656
/**
5757
* @brief Test case initialization function.
58+
* @return RT_EOK on success.
5859
*/
59-
6060
static rt_err_t utest_tc_init(void)
6161
{
6262
return RT_EOK;
6363
}
6464
/**
6565
* @brief Test case cleanup function.
66+
* @return RT_EOK on success.
6667
*/
6768
static rt_err_t utest_tc_cleanup(void)
6869
{

0 commit comments

Comments
 (0)