File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 88
99#include " src/string/memcmp.h"
1010#include " utils/UnitTest/Test.h"
11- #include < cstring>
1211
1312TEST (LlvmLibcMemcmpTest, CmpZeroByte) {
1413 const char *lhs = " ab" ;
@@ -39,14 +38,19 @@ TEST(LlvmLibcMemcmpTest, Sweep) {
3938 char lhs[kMaxSize ];
4039 char rhs[kMaxSize ];
4140
42- memset (lhs, ' a' , sizeof (lhs));
43- memset (rhs, ' a' , sizeof (rhs));
44- for (int i = 0 ; i < kMaxSize ; ++i)
41+ const auto reset = [](char *const ptr) {
42+ for (size_t i = 0 ; i < kMaxSize ; ++i)
43+ ptr[i] = ' a' ;
44+ };
45+
46+ reset (lhs);
47+ reset (rhs);
48+ for (size_t i = 0 ; i < kMaxSize ; ++i)
4549 EXPECT_EQ (__llvm_libc::memcmp (lhs, rhs, i), 0 );
4650
47- memset (lhs, ' a ' , sizeof (lhs) );
48- memset (rhs, ' a ' , sizeof (rhs) );
49- for (int i = 0 ; i < kMaxSize ; ++i) {
51+ reset (lhs);
52+ reset (rhs);
53+ for (size_t i = 0 ; i < kMaxSize ; ++i) {
5054 rhs[i] = ' b' ;
5155 EXPECT_EQ (__llvm_libc::memcmp (lhs, rhs, kMaxSize ), -1 );
5256 rhs[i] = ' a' ;
You can’t perform that action at this time.
0 commit comments