Lines Matching refs:state

256   StringTestState<char> state(SMALL);  in TEST()  local
257 for (size_t i = 1; i < state.n; i++) { in TEST()
258 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
259 memset(state.ptr2, '\2', state.MAX_LEN); in TEST()
260 state.ptr2[state.MAX_LEN - 1] = '\0'; in TEST()
261 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN); in TEST()
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()
267 strcpy(state.ptr + state.MAX_LEN - 1, state.ptr1); in TEST()
269 EXPECT_TRUE(strcat(state.ptr2, state.ptr1) == state.ptr2); in TEST()
270 EXPECT_TRUE(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN) == 0); in TEST()
438 StringTestState<char> state(SMALL); in TEST() local
439 for (size_t i = 1; i < state.n; i++) { in TEST()
440 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { 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()
448 size_t pos = random() % state.MAX_LEN; in TEST()
450 if (pos >= state.len[i] - 1) { in TEST()
452 expected = state.ptr1 + state.len[i] - 1; in TEST()
457 state.ptr1[pos] = seek_char; in TEST()
458 expected = state.ptr1 + pos; in TEST()
461 ASSERT_TRUE(strchr(state.ptr1, seek_char) == expected); in TEST()
474 StringTestState<char> state(SMALL); in TEST() local
475 for (size_t i = 1; i < state.n; i++) { in TEST()
476 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
477 memset(state.ptr1, 'v', state.MAX_LEN); in TEST()
478 memset(state.ptr2, 'n', state.MAX_LEN); in TEST()
479 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
480 state.ptr2[state.len[i] - 1] = '\0'; in TEST()
482 size_t pos = 1 + (random() % (state.MAX_LEN - 1)); in TEST()
485 if (pos >= state.len[i] - 1) { in TEST()
486 memcpy(state.ptr1, state.ptr2, state.len[i]); in TEST()
488 actual = strcmp(state.ptr1, state.ptr2); in TEST()
490 memcpy(state.ptr1, state.ptr2, pos); in TEST()
491 if (state.ptr1[pos] > state.ptr2[pos]) { in TEST()
493 } else if (state.ptr1[pos] == state.ptr2[pos]) { in TEST()
494 state.ptr1[pos + 1] = '\0'; in TEST()
495 state.ptr2[pos + 1] = '\0'; in TEST()
500 actual = strcmp(state.ptr1, state.ptr2); in TEST()
509 StringTestState<char> state(SMALL); in TEST() local
510 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
511 size_t pos = random() % state.MAX_LEN; in TEST()
513 memset(state.ptr1, '\2', pos); in TEST()
514 state.ptr1[pos] = '\0'; in TEST()
515 state.ptr1[state.MAX_LEN - 1] = '\0'; in TEST()
517 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
519 memset(state.ptr2, '\1', state.MAX_LEN); in TEST()
520 state.ptr2[state.MAX_LEN - 1] = '\0'; in TEST()
522 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN); in TEST()
523 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1); in TEST()
524 state.ptr[2 * state.MAX_LEN - 1] = '\0'; in TEST()
526 ASSERT_TRUE(stpcpy(state.ptr2, state.ptr1) == state.ptr2 + strlen(state.ptr1)); in TEST()
527 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 || in TEST()
528 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0)); in TEST()
533 StringTestState<char> state(SMALL); in TEST() local
534 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
535 size_t pos = random() % state.MAX_LEN; in TEST()
537 memset(state.ptr1, '\2', pos); in TEST()
538 state.ptr1[pos] = '\0'; in TEST()
539 state.ptr1[state.MAX_LEN - 1] = '\0'; in TEST()
541 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
543 memset(state.ptr2, '\1', state.MAX_LEN); in TEST()
544 state.ptr2[state.MAX_LEN - 1] = '\0'; in TEST()
546 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN); in TEST()
547 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1); in TEST()
548 state.ptr[2 * state.MAX_LEN - 1] = '\0'; in TEST()
550 ASSERT_TRUE(strcpy(state.ptr2, state.ptr1) == state.ptr2); in TEST()
551 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN)) != 0 || in TEST()
552 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0)); in TEST()
558 StringTestState<char> state(SMALL); in TEST() local
559 for (size_t i = 0; i < state.n; i++) { in TEST()
560 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
561 memset(state.ptr2, '\2', state.MAX_LEN + state.len[i]); in TEST()
562 state.ptr2[state.MAX_LEN - 1] = '\0'; in TEST()
563 memcpy(state.ptr, state.ptr2, state.MAX_LEN + state.len[i]); in TEST()
565 size_t pos = random() % state.MAX_LEN; in TEST()
566 memset(state.ptr1, '\3', pos); in TEST()
567 state.ptr1[pos] = '\0'; in TEST()
568 if (pos < state.len[i]) { in TEST()
569 memcpy(state.ptr + state.MAX_LEN - 1, state.ptr1, pos + 1); 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()
587 StringTestState<char> state(SMALL); in TEST() local
588 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
590 memset(state.ptr1, rand, state.MAX_LEN); in TEST()
592 size_t pos = random() % state.MAX_LEN; in TEST()
593 if (pos < state.MAX_LEN) { in TEST()
594 state.ptr1[pos] = '\0'; in TEST()
596 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
598 memset(state.ptr2, 'I', state.MAX_LEN); in TEST()
599 memcpy(state.ptr + state.MAX_LEN, state.ptr2, state.MAX_LEN); in TEST()
601 if (pos > state.MAX_LEN - 1) { in TEST()
602 memcpy(state.ptr + state.MAX_LEN, state.ptr1, state.MAX_LEN); in TEST()
603 state.ptr[2 * state.MAX_LEN - 1] = '\0'; in TEST()
605 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1); in TEST()
608 ASSERT_EQ(strlcpy(state.ptr2, state.ptr1, state.MAX_LEN), strlen(state.ptr1)); in TEST()
609 ASSERT_FALSE((memcmp(state.ptr1, state.ptr, state.MAX_LEN) != 0) || in TEST()
610 (memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN) != 0)); in TEST()
618 StringTestState<char> state(SMALL); in TEST() local
619 for (size_t i = 1; i < state.n; i++) { in TEST()
620 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
621 memset(state.ptr2, '\2', state.MAX_LEN); in TEST()
622 state.ptr2[state.MAX_LEN - 1] = '\0'; in TEST()
623 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN); 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()
629 size_t pos = strlen(state.ptr1); in TEST()
631 size_t actual = random() % state.len[i]; in TEST()
632 strncpy(state.ptr + state.MAX_LEN - 1, state.ptr1, std::min(actual, pos)); in TEST()
633 state.ptr[state.MAX_LEN + std::min(actual, pos) - 1] = '\0'; in TEST()
635 ASSERT_TRUE(strncat(state.ptr2, state.ptr1, actual) == state.ptr2); in TEST()
636 ASSERT_EQ(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN), 0); in TEST()
642 StringTestState<char> state(SMALL); in TEST() local
643 for (size_t i = 1; i < state.n; i++) { in TEST()
644 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
645 memset(state.ptr1, 'v', state.MAX_LEN); in TEST()
646 memset(state.ptr2, 'n', state.MAX_LEN); in TEST()
647 state.ptr1[state.len[i] - 1] = '\0'; in TEST()
648 state.ptr2[state.len[i] - 1] = '\0'; in TEST()
650 size_t pos = 1 + (random() % (state.MAX_LEN - 1)); 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()
658 memcpy(state.ptr1, state.ptr2, pos); in TEST()
659 if (state.ptr1[pos] > state.ptr2[pos]) { in TEST()
661 } else if (state.ptr1[pos] == state.ptr2[pos]) { in TEST()
662 state.ptr1[pos + 1] = '\0'; in TEST()
663 state.ptr2[pos + 1] = '\0'; in TEST()
668 actual = strncmp(state.ptr1, state.ptr2, state.len[i]); in TEST()
677 StringTestState<char> state(SMALL); in TEST() local
678 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
679 memset(state.ptr1, 'J', state.MAX_LEN); in TEST()
681 size_t ptr1_len = random() % state.MAX_LEN; in TEST()
682 state.ptr1[ptr1_len] = '\0'; in TEST()
684 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
686 memset(state.ptr2, '\1', state.MAX_LEN); in TEST()
689 size_t copy_len = random() % state.MAX_LEN; in TEST()
692 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN); in TEST()
693 memcpy(state.ptr + state.MAX_LEN, state.ptr1, copy_len); in TEST()
696 memset(state.ptr + state.MAX_LEN + ptr1_len, '\0', copy_len - ptr1_len); in TEST()
702 ASSERT_EQ(state.ptr2 + expected_end, stpncpy(state.ptr2, state.ptr1, copy_len)); in TEST()
705 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr, state.MAX_LEN)); in TEST()
707 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN)); in TEST()
712 StringTestState<char> state(SMALL); in TEST() local
713 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
716 memset(state.ptr1, 'K', state.MAX_LEN); in TEST()
718 size_t ptr1_len = random() % state.MAX_LEN; in TEST()
719 state.ptr1[ptr1_len] = '\0'; in TEST()
721 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
723 memset(state.ptr2, '\1', state.MAX_LEN); in TEST()
726 size_t copy_len = random() % state.MAX_LEN; in TEST()
729 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN); in TEST()
730 memcpy(state.ptr + state.MAX_LEN, state.ptr1, copy_len); in TEST()
733 memset(state.ptr + state.MAX_LEN + ptr1_len, '\0', copy_len - ptr1_len); in TEST()
739 ASSERT_EQ(state.ptr2 + expected_end, stpncpy(state.ptr2, state.ptr1, copy_len)); in TEST()
742 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr, state.MAX_LEN)); in TEST()
744 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr + state.MAX_LEN, state.MAX_LEN)); in TEST()
750 StringTestState<char> state(SMALL); in TEST() local
751 for (size_t i = 1; i < state.n; i++) { in TEST()
752 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { 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()
760 size_t pos = random() % state.MAX_LEN; in TEST()
762 if (pos >= state.len[i] - 1) { in TEST()
764 expected = state.ptr1 + state.len[i] - 1; in TEST()
769 state.ptr1[pos] = seek_char; in TEST()
770 expected = state.ptr1 + pos; in TEST()
773 ASSERT_TRUE(strrchr(state.ptr1, seek_char) == expected); in TEST()
780 StringTestState<char> state(SMALL); in TEST() local
781 for (size_t i = 0; i < state.n; i++) { in TEST()
782 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
783 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
785 size_t pos = random() % state.MAX_LEN; in TEST()
787 if (pos >= state.len[i]) { in TEST()
790 state.ptr1[pos] = seek_char; in TEST()
791 expected = state.ptr1 + pos; in TEST()
794 ASSERT_TRUE(memchr(state.ptr1, seek_char, state.len[i]) == expected); in TEST()
809 StringTestState<char> state(SMALL); in TEST() local
810 for (size_t i = 0; i < state.n; i++) { in TEST()
811 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
812 memset(state.ptr1, ~seek_char, state.len[i]); in TEST()
814 size_t pos = random() % state.MAX_LEN; in TEST()
816 if (pos >= state.len[i]) { in TEST()
819 state.ptr1[pos] = seek_char; in TEST()
820 expected = state.ptr1 + pos; in TEST()
823 ASSERT_TRUE(memrchr(state.ptr1, seek_char, state.len[i]) == expected); in TEST()
829 StringTestState<char> state(SMALL); in TEST() local
830 for (size_t i = 0; i < state.n; i++) { in TEST()
831 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
834 memset(state.ptr1, c1, state.MAX_LEN); in TEST()
835 memset(state.ptr2, c1, state.MAX_LEN); in TEST()
837 int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]); in TEST()
838 state.ptr2[pos] = c2; in TEST()
841 int actual = memcmp(state.ptr1, state.ptr2, state.MAX_LEN); in TEST()
849 StringTestState<wchar_t> state(SMALL); in TEST() local
851 for (size_t i = 0; i < state.n; i++) { in TEST()
852 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
856 wmemset(state.ptr1, c1, state.MAX_LEN); in TEST()
857 wmemset(state.ptr2, c1, state.MAX_LEN); in TEST()
859 int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]); in TEST()
860 state.ptr2[pos] = c2; in TEST()
863 int actual = wmemcmp(state.ptr1, state.ptr2, (size_t) state.MAX_LEN); in TEST()
871 StringTestState<char> state(LARGE); in TEST() local
873 for (size_t i = 0; i < state.n - 1; i++) { in TEST()
874 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { 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()
885 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN)); in TEST()
891 StringTestState<char> state(LARGE); in TEST() local
893 for (size_t i = 0; i < state.n - 1; i++) { in TEST()
894 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
895 memset(state.ptr1, ~ch, state.MAX_LEN); in TEST()
896 memcpy(state.ptr2, state.ptr1, state.MAX_LEN); 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()
900 state.ptr1[k] = ch; in TEST()
903 ASSERT_TRUE(memset(state.ptr2 + pos, ch, state.len[i]) == state.ptr2 + pos); in TEST()
905 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN)); in TEST()
911 StringTestState<char> state(LARGE); in TEST() local
912 for (size_t i = 0; i < state.n - 1; i++) { in TEST()
913 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
914 memset(state.ptr1, 'Q', 2 * state.MAX_LEN); 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()
919 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_LEN); 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()
924 ASSERT_EQ(0, memcmp(state.ptr2, state.ptr1, 2 * state.MAX_LEN)); in TEST()
1009 StringTestState<char> state(LARGE); in TEST() local
1010 for (size_t i = 0; i < state.n; i++) { in TEST()
1011 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
1012 memset(state.ptr1, '4', state.MAX_LEN); in TEST()
1013 memset(state.ptr1 + state.MAX_LEN, 'a', state.MAX_LEN); in TEST()
1014 memcpy(state.ptr2, state.ptr1, 2 * state.MAX_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()
1020 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, 2 * state.MAX_LEN)); in TEST()
1026 StringTestState<char> state(LARGE); in TEST() local
1027 for (state.BeginIterations(); state.HasNextIteration(); state.NextIteration()) { in TEST()
1028 memset(state.ptr1, 'R', state.MAX_LEN); in TEST()
1030 size_t start = random() % state.MAX_LEN; in TEST()
1031 size_t end = start + random() % (state.MAX_LEN - start); in TEST()
1033 memcpy(state.ptr2, state.ptr1, start); in TEST()
1034 memset(state.ptr2 + start, '\0', end - start); in TEST()
1035 memcpy(state.ptr2 + end, state.ptr1 + end, state.MAX_LEN - end); in TEST()
1037 bzero(state.ptr1 + start, end - start); in TEST()
1039 ASSERT_EQ(0, memcmp(state.ptr1, state.ptr2, state.MAX_LEN)); in TEST()