Lines Matching refs:len
214 size_t len[ITER + 1]; member in StringTestState
228 len[n++] = 0; in InitLenArray()
231 if (l != len[n - 1]) { in InitLenArray()
232 len[n++] = l; in InitLenArray()
235 len[n++] = MAX_LEN; in InitLenArray()
263 memset(state.ptr1, 'L', state.len[i]); in TEST()
264 state.ptr1[random() % state.len[i]] = '\0'; in TEST()
265 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
442 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
444 memset(state.ptr1, '\1', state.len[i]); in TEST()
446 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
450 if (pos >= state.len[i] - 1) { in TEST()
452 expected = state.ptr1 + state.len[i] - 1; in TEST()
479 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
480 state.ptr2[state.len[i] - 1] = '\0'; in TEST()
485 if (pos >= state.len[i] - 1) { in TEST()
486 memcpy(state.ptr1, state.ptr2, state.len[i]); in TEST()
561 memset(state.ptr2, '\2', state.MAX_LEN + state.len[i]); in TEST()
563 memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]); in TEST()
568 if (pos < state.len[i]) { in TEST()
571 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, state.len[i]); in TEST()
572 state.ptr[state.MAX_LEN + state.len[i] - 1] = '\0'; in TEST()
575 strlcat(state.ptr2, state.ptr1, state.MAX_LEN + state.len[i]); in TEST()
577 ASSERT_TRUE(memcmp(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]) == 0); in TEST()
625 memset(state.ptr1, 'I', state.len[i]); in TEST()
626 state.ptr1[random() % state.len[i]] = '\0'; in TEST()
627 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
631 size_t actual = random() % state.len[i]; in TEST()
647 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
648 state.ptr2[state.len[i] - 1] = '\0'; in TEST()
653 if (pos >= state.len[i] - 1) { in TEST()
654 memcpy(state.ptr1, state.ptr2, state.len[i]); in TEST()
656 actual = strncmp(state.ptr1, state.ptr2, state.len[i]); in TEST()
668 actual = strncmp(state.ptr1, state.ptr2, state.len[i]); in TEST()
754 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
756 memset(state.ptr1, '\1', state.len[i]); in TEST()
758 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
762 if (pos >= state.len[i] - 1) { in TEST()
764 expected = state.ptr1 + state.len[i] - 1; in TEST()
783 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
787 if (pos >= state.len[i]) { in TEST()
794 ASSERT_TRUE(memchr(state.ptr1, seek_char, state.len[i]) == expected); in TEST()
812 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
816 if (pos >= state.len[i]) { in TEST()
823 ASSERT_TRUE(memrchr(state.ptr1, seek_char, state.len[i]) == expected); in TEST()
837 int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]); in TEST()
859 int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]); in TEST()
875 size_t pos = random() % (state.MAX_LEN - state.len[i]); in TEST()
877 memset(state.ptr1, rand, state.len[i]); in TEST()
878 memset(state.ptr1 + state.len[i], ~rand, state.MAX_LEN - state.len[i]); in TEST()
880 memset(state.ptr2, rand, state.len[i]); in TEST()
881 memset(state.ptr2 + state.len[i], ~rand, state.MAX_LEN - state.len[i]); in TEST()
882 memset(state.ptr2 + pos, '\0', state.len[i]); in TEST()
884 ASSERT_FALSE(memcpy(state.ptr2 + pos, state.ptr1 + pos, state.len[i]) != state.ptr2 + pos); in TEST()
898 size_t pos = random () % (state.MAX_LEN - state.len[i]); in TEST()
899 for (size_t k = pos; k < pos + state.len[i]; k++) { in TEST()
903 ASSERT_TRUE(memset(state.ptr2 + pos, ch, state.len[i]) == state.ptr2 + pos); in TEST()
916 size_t pos = random() % (state.MAX_LEN - state.len[i]); in TEST()
918 memset(state.ptr1, 'R', state.len[i]); in TEST()
920 memcpy(state.ptr, state.ptr1, state.len[i]); in TEST()
921 memcpy(state.ptr1 + pos, state.ptr, state.len[i]); in TEST()
923 ASSERT_TRUE(memmove(state.ptr2 + pos, state.ptr2, state.len[i]) == state.ptr2 + pos); in TEST()
930 size_t len = 600000; in TEST() local
933 char* ptr = reinterpret_cast<char*>(malloc(sizeof(char) * len)); in TEST()
934 char* ptr1 = reinterpret_cast<char*>(malloc(2 * sizeof(char) * len)); in TEST()
935 char* glob_ptr2 = reinterpret_cast<char*>(malloc(2 * sizeof(char) * len + max_alignment)); in TEST()
944 memset(ptr1, 'S', 2 * len); in TEST()
945 memset(ptr1, 'T', len); in TEST()
946 memcpy(ptr2, ptr1, 2 * len); in TEST()
947 memcpy(ptr, ptr1, len); in TEST()
948 memcpy(ptr1 + pos, ptr, len); in TEST()
950 ASSERT_TRUE(memmove(ptr2 + pos, ptr, len) == ptr2 + pos); in TEST()
951 ASSERT_EQ(0, memcmp(ptr2, ptr1, 2 * len)); in TEST()
1016 size_t start = random() % (2 * state.MAX_LEN - state.len[i]); in TEST()
1017 memcpy(state.ptr2 + start, state.ptr1, state.len[i]); in TEST()
1019 bcopy(state.ptr1, state.ptr1 + start, state.len[i]); in TEST()
1043 static void DoMemcpyTest(uint8_t* src, uint8_t* dst, size_t len) { in DoMemcpyTest() argument
1044 memset(src, (len % 255) + 1, len); in DoMemcpyTest()
1045 memset(dst, 0, len); in DoMemcpyTest()
1047 ASSERT_EQ(dst, memcpy(dst, src, len)); in DoMemcpyTest()
1048 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoMemcpyTest()
1059 static void DoMemmoveTest(uint8_t* src, uint8_t* dst, size_t len) { in DoMemmoveTest() argument
1060 memset(src, (len % 255) + 1, len); in DoMemmoveTest()
1061 memset(dst, 0, len); in DoMemmoveTest()
1063 ASSERT_EQ(dst, memmove(dst, src, len)); in DoMemmoveTest()
1064 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoMemmoveTest()
1075 static void DoMemsetTest(uint8_t* buf, size_t len) { in DoMemsetTest() argument
1076 for (size_t i = 0; i < len; i++) { in DoMemsetTest()
1079 int value = (len % 255) + 1; in DoMemsetTest()
1080 ASSERT_EQ(buf, memset(buf, value, len)); in DoMemsetTest()
1081 for (size_t i = 0; i < len; i++) { in DoMemsetTest()
1090 static void DoStrlenTest(uint8_t* buf, size_t len) { in DoStrlenTest() argument
1091 if (len >= 1) { in DoStrlenTest()
1092 memset(buf, (32 + (len % 96)), len - 1); in DoStrlenTest()
1093 buf[len-1] = '\0'; in DoStrlenTest()
1094 ASSERT_EQ(len-1, strlen(reinterpret_cast<char*>(buf))); in DoStrlenTest()
1106 static void DoStrcpyTest(uint8_t* src, uint8_t* dst, size_t len) { in DoStrcpyTest() argument
1107 if (len >= 1) { in DoStrcpyTest()
1108 memset(src, (32 + (len % 96)), len - 1); in DoStrcpyTest()
1109 src[len-1] = '\0'; in DoStrcpyTest()
1110 memset(dst, 0, len); in DoStrcpyTest()
1113 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoStrcpyTest()
1126 static void DoStrlcpyTest(uint8_t* src, uint8_t* dst, size_t len) { in DoStrlcpyTest() argument
1127 if (len >= 1) { in DoStrlcpyTest()
1128 memset(src, (32 + (len % 96)), len - 1); in DoStrlcpyTest()
1129 src[len-1] = '\0'; in DoStrlcpyTest()
1130 memset(dst, 0, len); in DoStrlcpyTest()
1131 ASSERT_EQ(len-1, strlcpy(reinterpret_cast<char*>(dst), in DoStrlcpyTest()
1132 reinterpret_cast<char*>(src), len)); in DoStrlcpyTest()
1133 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoStrlcpyTest()
1155 static void DoStpcpyTest(uint8_t* src, uint8_t* dst, size_t len) { in DoStpcpyTest() argument
1156 if (len >= 1) { in DoStpcpyTest()
1157 memset(src, (32 + (len % 96)), len - 1); in DoStpcpyTest()
1158 src[len-1] = '\0'; in DoStpcpyTest()
1159 memset(dst, 0, len); in DoStpcpyTest()
1160 ASSERT_EQ(dst+len-1, reinterpret_cast<uint8_t*>(stpcpy(reinterpret_cast<char*>(dst), in DoStpcpyTest()
1162 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoStpcpyTest()
1175 static size_t LargeSetIncrement(size_t len) { in LargeSetIncrement() argument
1176 if (len >= 4096) { in LargeSetIncrement()
1178 } else if (len >= 1024) { in LargeSetIncrement()
1180 } else if (len >= 256) { in LargeSetIncrement()
1188 static void DoStrcatTest(uint8_t* src, uint8_t* dst, size_t len) { in DoStrcatTest() argument
1189 if (len >= 1) { in DoStrcatTest()
1190 int value = 32 + (len % 96); in DoStrcatTest()
1191 memset(src, value, len - 1); in DoStrcatTest()
1192 src[len-1] = '\0'; in DoStrcatTest()
1194 if (len >= STRCAT_DST_LEN) { in DoStrcatTest()
1203 memset(dst+i-1, 0, len-i); in DoStrcatTest()
1204 src[len-i] = '\0'; in DoStrcatTest()
1208 ASSERT_TRUE(memcmp(src, dst+i-1, len-i+1) == 0); in DoStrcatTest()
1221 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoStrcatTest()
1235 static void DoStrlcatTest(uint8_t* src, uint8_t* dst, size_t len) { in DoStrlcatTest() argument
1236 if (len >= 1) { in DoStrlcatTest()
1237 int value = 32 + (len % 96); in DoStrlcatTest()
1238 memset(src, value, len - 1); in DoStrlcatTest()
1239 src[len-1] = '\0'; in DoStrlcatTest()
1241 if (len >= STRCAT_DST_LEN) { in DoStrlcatTest()
1250 memset(dst+i-1, 0, len-i); in DoStrlcatTest()
1251 src[len-i] = '\0'; in DoStrlcatTest()
1252 ASSERT_EQ(len-1, strlcat(reinterpret_cast<char*>(dst), in DoStrlcatTest()
1253 reinterpret_cast<char*>(src), len)); in DoStrlcatTest()
1255 ASSERT_TRUE(memcmp(src, dst+i-1, len-i+1) == 0); in DoStrlcatTest()
1266 ASSERT_EQ(len-1, strlcat(reinterpret_cast<char*>(dst), in DoStrlcatTest()
1267 reinterpret_cast<char*>(src), len)); in DoStrlcatTest()
1268 ASSERT_TRUE(memcmp(src, dst, len) == 0); in DoStrlcatTest()
1290 static void DoStrcmpTest(uint8_t* buf1, uint8_t* buf2, size_t len) { in DoStrcmpTest() argument
1291 if (len >= 1) { in DoStrcmpTest()
1292 memset(buf1, (32 + (len % 96)), len - 1); in DoStrcmpTest()
1293 buf1[len-1] = '\0'; in DoStrcmpTest()
1294 memset(buf2, (32 + (len % 96)), len - 1); in DoStrcmpTest()
1295 buf2[len-1] = '\0'; in DoStrcmpTest()
1312 size_t len; in DoStrcmpFailTest() local
1314 len = len2; in DoStrcmpFailTest()
1316 len = len1; in DoStrcmpFailTest()
1319 if (len > 1) { in DoStrcmpFailTest()
1320 buf1[len-1] = '\0'; in DoStrcmpFailTest()
1321 buf2[len-1] = '\0'; in DoStrcmpFailTest()
1324 buf1[len-2] = diff_c; in DoStrcmpFailTest()
1328 buf1[len-2] = c; in DoStrcmpFailTest()
1329 buf2[len-2] = diff_c; in DoStrcmpFailTest()
1343 static void DoMemcmpTest(uint8_t* buf1, uint8_t* buf2, size_t len) { in DoMemcmpTest() argument
1344 memset(buf1, len+1, len); in DoMemcmpTest()
1345 memset(buf2, len+1, len); in DoMemcmpTest()
1346 ASSERT_EQ(0, memcmp(buf1, buf2, len)); in DoMemcmpTest()
1350 size_t len; in DoMemcmpFailTest() local
1352 len = len2; in DoMemcmpFailTest()
1354 len = len1; in DoMemcmpFailTest()
1357 memset(buf1, len2+1, len); in DoMemcmpFailTest()
1358 buf1[len-1] = len2; in DoMemcmpFailTest()
1359 memset(buf2, len2+1, len); in DoMemcmpFailTest()
1360 ASSERT_NE(0, memcmp(buf1, buf2, len)); in DoMemcmpFailTest()
1362 buf1[len-1] = len2+1; in DoMemcmpFailTest()
1363 buf2[len-1] = len2; in DoMemcmpFailTest()
1364 ASSERT_NE(0, memcmp(buf1, buf2, len)); in DoMemcmpFailTest()
1375 static void DoMemchrTest(uint8_t* buf, size_t len) { in DoMemchrTest() argument
1376 if (len >= 1) { in DoMemchrTest()
1377 int value = len % 128; in DoMemchrTest()
1378 int search_value = (len % 128) + 1; in DoMemchrTest()
1379 memset(buf, value, len); in DoMemchrTest()
1381 ASSERT_EQ(nullptr, memchr(buf, search_value, len)); in DoMemchrTest()
1382 if (len >= 2) { in DoMemchrTest()
1385 ASSERT_EQ(&buf[0], memchr(buf, search_value, len)); in DoMemchrTest()
1388 buf[len - 1] = search_value; in DoMemchrTest()
1390 ASSERT_EQ(&buf[len - 1], memchr(buf, search_value, len)); in DoMemchrTest()
1403 static void DoStrchrTest(uint8_t* buf, size_t len) { in DoStrchrTest() argument
1404 if (len >= 1) { in DoStrchrTest()
1405 char value = 32 + (len % 96); in DoStrchrTest()
1406 char search_value = 33 + (len % 96); in DoStrchrTest()
1407 memset(buf, value, len - 1); in DoStrchrTest()
1408 buf[len - 1] = '\0'; in DoStrchrTest()
1412 ASSERT_EQ(reinterpret_cast<char*>(&buf[len - 1]), strchr(reinterpret_cast<char*>(buf), '\0')); in DoStrchrTest()
1413 if (len >= 2) { in DoStrchrTest()
1420 buf[len - 2] = search_value; in DoStrchrTest()
1423 ASSERT_EQ(reinterpret_cast<char*>(&buf[len - 2]), strchr(reinterpret_cast<char*>(buf), in DoStrchrTest()
1437 static void DoStrrchrTest(uint8_t* buf, size_t len) { in DoStrrchrTest() argument
1438 if (len >= 1) { in DoStrrchrTest()
1439 char value = 32 + (len % 96); in DoStrrchrTest()
1440 char search_value = 33 + (len % 96); in DoStrrchrTest()
1441 memset(buf, value, len - 1); in DoStrrchrTest()
1442 buf[len - 1] = '\0'; in DoStrrchrTest()
1446 ASSERT_EQ(reinterpret_cast<char*>(&buf[len - 1]), strrchr(reinterpret_cast<char*>(buf), '\0')); in DoStrrchrTest()
1447 if (len >= 2) { in DoStrrchrTest()
1454 buf[len - 2] = search_value; in DoStrrchrTest()
1457 ASSERT_EQ(reinterpret_cast<char*>(&buf[len - 2]), strrchr(reinterpret_cast<char*>(buf), in DoStrrchrTest()
1515 static void DoMemcpySameTest(uint8_t* buffer, size_t len) { in DoMemcpySameTest() argument
1516 memcpy(buffer, g_memcpy_same_buffer.data(), len); in DoMemcpySameTest()
1517 ASSERT_EQ(buffer, memcpy(buffer, buffer, len)); in DoMemcpySameTest()
1518 ASSERT_TRUE(memcmp(buffer, g_memcpy_same_buffer.data(), len) == 0); in DoMemcpySameTest()