Home | History | Annotate | Download | only in tests

Lines Matching refs:MAX_LEN

143   StringTestState(size_t MAX_LEN) : MAX_LEN(MAX_LEN) {
146 // TODO: fix the tests to not sometimes use twice their specified "MAX_LEN".
147 glob_ptr = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
148 glob_ptr1 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
149 glob_ptr2 = reinterpret_cast<Character*>(memalign(sysconf(_SC_PAGESIZE), 2 * sizeof(Character) * MAX_LEN + max_alignment));
173 const size_t MAX_LEN;
183 // smallest (0) and biggest (MAX_LEN) lengths. Avoid repeats.
189 size_t l = static_cast<size_t>(exp(log(static_cast<double>(MAX_LEN)) * i / ITER));
194 len[n++] = MAX_LEN;
204 memset(state.ptr2, '\2', state.MAX_LEN);
205 state.ptr2[state.MAX_LEN - 1] = '\0';
206 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
212 strcpy(state.ptr + state.MAX_LEN - 1, state.ptr1);
215 EXPECT_TRUE(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN) == 0);
395 size_t pos = random() % state.MAX_LEN;
419 memset(state.ptr1, 'v', state.MAX_LEN);
420 memset(state.ptr2, 'n', state.MAX_LEN);
424 size_t pos = 1 + (random() % (state.MAX_LEN - 1));
455 size_t pos = random() % state.MAX_LEN;
459 state.ptr1[state.MAX_LEN - 1] = '\0';
461 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
463 memset(state.ptr2, '\1', state.MAX_LEN);
464 state.ptr2[state.MAX_LEN - 1] = '\0';
466 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
467 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
468 state.ptr[2 * state.MAX_LEN - 1] = '\0';
471 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 ||
472 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
481 size_t pos = random() % state.MAX_LEN;
485 state.ptr1[state.MAX_LEN - 1] = '\0';
487 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
489 memset(state.ptr2, '\1', state.MAX_LEN);
490 state.ptr2[state.MAX_LEN - 1] = '\0';
492 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
493 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
494 state.ptr[2 * state.MAX_LEN - 1] = '\0';
497 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 ||
498 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
509 memset(state.ptr2, '\2', state.MAX_LEN + state.len[i]);
510 state.ptr2[state.MAX_LEN - 1] = '\0';
511 memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]);
513 size_t pos = random() % state.MAX_LEN;
517 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, pos + 1);
519 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, state.len[i]);
520 state.ptr[state.MAX_LEN + state.len[i] - 1] = '\0';
523 strlcat(state.ptr2, state.ptr1, state.MAX_LEN + state.len[i]);
525 ASSERT_TRUE(memcmp(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]) == 0);
543 memset(state.ptr1, rand, state.MAX_LEN);
545 size_t pos = random() % state.MAX_LEN;
546 if (pos < state.MAX_LEN) {
549 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
551 memset(state.ptr2, random() & 255, state.MAX_LEN);
552 memcpy(state.ptr + state.MAX_LEN, state.ptr2, state.MAX_LEN);
554 if (pos > state.MAX_LEN - 1) {
555 memcpy(state.ptr + state.MAX_LEN, state.ptr1, state.MAX_LEN);
556 state.ptr[2 * state.MAX_LEN - 1] = '\0';
558 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1);
561 ASSERT_EQ(strlcpy(state.ptr2, state.ptr1, state.MAX_LEN), strlen(state.ptr1));
562 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0) ||
563 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0));
576 memset(state.ptr2, '\2', state.MAX_LEN);
577 MAX_LEN - 1] = '\0';
578 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN);
587 strncpy(state.ptr + state.MAX_LEN - 1, state.ptr1, std::min(actual, pos));
588 state.ptr[state.MAX_LEN + std::min(actual, pos) - 1] = '\0';
591 ASSERT_EQ(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN), 0);
602 memset(state.ptr1, 'v', state.MAX_LEN);
603 memset(state.ptr2, 'n', state.MAX_LEN);
607 size_t pos = 1 + (random() % (state.MAX_LEN - 1));
640 memset(state.ptr1, (random() % 254) + 2, state.MAX_LEN);
642 size_t ptr1_len = random() % state.MAX_LEN;
645 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
647 memset(state.ptr2, '\1', state.MAX_LEN);
650 size_t copy_len = random() % state.MAX_LEN;
653 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
654 memcpy(state.ptr + state.MAX_LEN, state.ptr1, copy_len);
657 memset(state.ptr + state.MAX_LEN + ptr1_len, '\0', copy_len - ptr1_len);
666 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr, state.MAX_LEN));
668 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN));
679 memset(state.ptr1, (random() % 254) + 2, state.MAX_LEN);
681 size_t ptr1_len = random() % state.MAX_LEN;
684 memcpy(state.ptr, state.ptr1, state.MAX_LEN);
686 memset(state.ptr2, '\1', state.MAX_LEN);
689 size_t copy_len = random() % state.MAX_LEN;
692 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN);
693 memcpy(state.ptr + state.MAX_LEN, state.ptr1, copy_len);
696 memset(state.ptr + state.MAX_LEN + ptr1_len, '\0', copy_len - ptr1_len);
705 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr, state.MAX_LEN));
707 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN));
725 size_t pos = random() % state.MAX_LEN;
752 size_t pos = random() % state.MAX_LEN;
783 size_t pos = random() % state.MAX_LEN;
805 memset(state.ptr1, c1, state.MAX_LEN);
806 memset(state.ptr2, c1, state.MAX_LEN);
812 int actual = memcmp(state.ptr1, state.ptr2, state.MAX_LEN);
829 wmemset(state.ptr1, c1, state.MAX_LEN);
830 wmemset(state.ptr2, c1, state.MAX_LEN);
836 int actual = wmemcmp(state.ptr1, state.ptr2, (size_t) state.MAX_LEN);
850 size_t pos = random() % (state.MAX_LEN - state.len[i]);
853 memset(state.ptr1 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
856 memset(state.ptr2 + state.len[i], ~rand, state.MAX_LEN - state.len[i]);
860 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
872 memset(state.ptr1, ~ch, state.MAX_LEN);
873 memcpy(state.ptr2, state.ptr1, state.MAX_LEN);
875 size_t pos = random () % (state.MAX_LEN - state.len[i]);
882 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));
893 memset(state.ptr1, random() & 255, 2 * state.MAX_LEN);
895 size_t pos = random() % (state.MAX_LEN - state.len[i]);
898 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
903 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr1, 2 * state.MAX_LEN));
993 memset(state.ptr1, random() & 255, state.MAX_LEN);
994 memset(state.ptr1 + state.MAX_LEN, random() & 255, state.MAX_LEN);
995 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN);
997 size_t start = random() % (2 * state.MAX_LEN - state.len[i]);
1001 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, 2 * state.MAX_LEN));
1011 memset(state.ptr1, random() & 255, state.MAX_LEN);
1013 size_t start = random() % state.MAX_LEN;
1014 size_t end = start + random() % (state.MAX_LEN - start);
1018 memcpy(state.ptr2 + end, state.ptr1 + end, state.MAX_LEN - end);
1022 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN));