tests/test_buffer.c

changeset 1006
8ee818fa29f7
parent 985
68754c7de906
child 1007
81b2986d2b04
equal deleted inserted replaced
1005:67fa386ce600 1006:8ee818fa29f7
601 return cxBufferWrite(ptr, size, nitems > 2 ? 2 : nitems, buffer); 601 return cxBufferWrite(ptr, size, nitems > 2 ? 2 : nitems, buffer);
602 } 602 }
603 } 603 }
604 604
605 CX_TEST(test_buffer_write_size_one_fit) { 605 CX_TEST(test_buffer_write_size_one_fit) {
606 CxBuffer buf, target; 606 CxBuffer buf;
607 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
608 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 607 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
609 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 608 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
610 buf.capacity = 8; 609 buf.capacity = 8;
611 buf.size = buf.pos = 4; 610 buf.size = buf.pos = 4;
612 const char *data = "test"; 611 const char *data = "test";
618 CX_TEST_ASSERT(buf.capacity == 8); 617 CX_TEST_ASSERT(buf.capacity == 8);
619 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); 618 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8));
620 } 619 }
621 620
622 cxBufferDestroy(&buf); 621 cxBufferDestroy(&buf);
623 cxBufferDestroy(&target);
624 } 622 }
625 623
626 CX_TEST(test_buffer_write_size_one_discard) { 624 CX_TEST(test_buffer_write_size_one_discard) {
627 CxBuffer buf, target; 625 CxBuffer buf;
628 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
629 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 626 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
630 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 627 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
631 buf.capacity = 8; 628 buf.capacity = 8;
632 buf.size = buf.pos = 4; 629 buf.size = buf.pos = 4;
633 const char *data = "testing"; 630 const char *data = "testing";
638 CX_TEST_ASSERT(buf.pos == 8); 635 CX_TEST_ASSERT(buf.pos == 8);
639 CX_TEST_ASSERT(buf.capacity == 8); 636 CX_TEST_ASSERT(buf.capacity == 8);
640 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9)); 637 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9));
641 } 638 }
642 cxBufferDestroy(&buf); 639 cxBufferDestroy(&buf);
643 cxBufferDestroy(&target);
644 } 640 }
645 641
646 CX_TEST(test_buffer_write_size_one_extend) { 642 CX_TEST(test_buffer_write_size_one_extend) {
647 CxBuffer buf, target; 643 CxBuffer buf;
648 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
649 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 644 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
650 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 645 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
651 buf.capacity = 8; 646 buf.capacity = 8;
652 buf.size = buf.pos = 4; 647 buf.size = buf.pos = 4;
653 buf.flags |= CX_BUFFER_AUTO_EXTEND; 648 buf.flags |= CX_BUFFER_AUTO_EXTEND;
659 CX_TEST_ASSERT(buf.pos == 11); 654 CX_TEST_ASSERT(buf.pos == 11);
660 CX_TEST_ASSERT(buf.capacity >= 11); 655 CX_TEST_ASSERT(buf.capacity >= 11);
661 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); 656 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11));
662 } 657 }
663 cxBufferDestroy(&buf); 658 cxBufferDestroy(&buf);
664 cxBufferDestroy(&target);
665 } 659 }
666 660
667 CX_TEST(test_buffer_write_multibyte_fit) { 661 CX_TEST(test_buffer_write_multibyte_fit) {
668 CxBuffer buf, target; 662 CxBuffer buf;
669 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
670 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 663 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
671 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 664 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
672 buf.capacity = 8; 665 buf.capacity = 8;
673 buf.size = buf.pos = 4; 666 buf.size = buf.pos = 4;
674 const char *data = "test"; 667 const char *data = "test";
679 CX_TEST_ASSERT(buf.pos == 8); 672 CX_TEST_ASSERT(buf.pos == 8);
680 CX_TEST_ASSERT(buf.capacity == 8); 673 CX_TEST_ASSERT(buf.capacity == 8);
681 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); 674 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8));
682 } 675 }
683 cxBufferDestroy(&buf); 676 cxBufferDestroy(&buf);
684 cxBufferDestroy(&target);
685 } 677 }
686 678
687 CX_TEST(test_buffer_write_multibyte_discard) { 679 CX_TEST(test_buffer_write_multibyte_discard) {
688 CxBuffer buf, target; 680 CxBuffer buf;
689 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
690 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 681 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
691 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 682 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
692 buf.capacity = 8; 683 buf.capacity = 8;
693 buf.size = 4; 684 buf.size = 4;
694 buf.pos = 3; 685 buf.pos = 3;
701 CX_TEST_ASSERT(buf.pos == 7); 692 CX_TEST_ASSERT(buf.pos == 7);
702 CX_TEST_ASSERT(buf.capacity == 8); 693 CX_TEST_ASSERT(buf.capacity == 8);
703 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretest\0", 8)); 694 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretest\0", 8));
704 } 695 }
705 cxBufferDestroy(&buf); 696 cxBufferDestroy(&buf);
706 cxBufferDestroy(&target);
707 } 697 }
708 698
709 CX_TEST(test_buffer_write_multibyte_extend) { 699 CX_TEST(test_buffer_write_multibyte_extend) {
710 CxBuffer buf, target; 700 CxBuffer buf;
711 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
712 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 701 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
713 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 702 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
714 buf.capacity = 8; 703 buf.capacity = 8;
715 buf.size = 4; 704 buf.size = 4;
716 buf.pos = 3; 705 buf.pos = 3;
724 CX_TEST_ASSERT(buf.pos == 9); 713 CX_TEST_ASSERT(buf.pos == 9);
725 CX_TEST_ASSERT(buf.capacity >= 9); 714 CX_TEST_ASSERT(buf.capacity >= 9);
726 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretester", 9)); 715 CX_TEST_ASSERT(0 == memcmp(buf.space, "pretester", 9));
727 } 716 }
728 cxBufferDestroy(&buf); 717 cxBufferDestroy(&buf);
729 cxBufferDestroy(&target);
730 } 718 }
731 719
732 CX_TEST(test_buffer_put_fit) { 720 CX_TEST(test_buffer_put_fit) {
733 CxBuffer buf, target; 721 CxBuffer buf;
734 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
735 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 722 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
736 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 723 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
737 buf.capacity = 8; 724 buf.capacity = 8;
738 buf.size = buf.pos = 4; 725 buf.size = buf.pos = 4;
739 CX_TEST_DO { 726 CX_TEST_DO {
743 CX_TEST_ASSERT(buf.pos == 5); 730 CX_TEST_ASSERT(buf.pos == 5);
744 CX_TEST_ASSERT(buf.capacity == 8); 731 CX_TEST_ASSERT(buf.capacity == 8);
745 CX_TEST_ASSERT(0 == memcmp(buf.space, "prepa\0", 6)); 732 CX_TEST_ASSERT(0 == memcmp(buf.space, "prepa\0", 6));
746 } 733 }
747 cxBufferDestroy(&buf); 734 cxBufferDestroy(&buf);
748 cxBufferDestroy(&target);
749 } 735 }
750 736
751 CX_TEST(test_buffer_put_discard) { 737 CX_TEST(test_buffer_put_discard) {
752 CxBuffer buf, target; 738 CxBuffer buf;
753 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
754 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 739 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
755 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 740 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
756 buf.capacity = 8; 741 buf.capacity = 8;
757 buf.size = 4; 742 buf.size = 4;
758 buf.pos = 8; 743 buf.pos = 8;
763 CX_TEST_ASSERT(buf.pos == 8); 748 CX_TEST_ASSERT(buf.pos == 8);
764 CX_TEST_ASSERT(buf.capacity == 8); 749 CX_TEST_ASSERT(buf.capacity == 8);
765 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0\0", 9)); 750 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0\0", 9));
766 } 751 }
767 cxBufferDestroy(&buf); 752 cxBufferDestroy(&buf);
768 cxBufferDestroy(&target);
769 } 753 }
770 754
771 CX_TEST(test_buffer_put_extend) { 755 CX_TEST(test_buffer_put_extend) {
772 CxBuffer buf, target; 756 CxBuffer buf;
773 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
774 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 757 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
775 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 758 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
776 buf.capacity = 8; 759 buf.capacity = 8;
777 buf.size = 4; 760 buf.size = 4;
778 buf.pos = 8; 761 buf.pos = 8;
784 CX_TEST_ASSERT(buf.pos == 9); 767 CX_TEST_ASSERT(buf.pos == 9);
785 CX_TEST_ASSERT(buf.capacity >= 9); 768 CX_TEST_ASSERT(buf.capacity >= 9);
786 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0a", 9)); 769 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0\0\0\0a", 9));
787 } 770 }
788 cxBufferDestroy(&buf); 771 cxBufferDestroy(&buf);
789 cxBufferDestroy(&target);
790 } 772 }
791 773
792 CX_TEST(test_buffer_put_string_fit) { 774 CX_TEST(test_buffer_put_string_fit) {
793 CxBuffer buf, target; 775 CxBuffer buf;
794 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
795 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 776 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
796 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 777 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
797 buf.capacity = 8; 778 buf.capacity = 8;
798 buf.size = buf.pos = 4; 779 buf.size = buf.pos = 4;
799 const char *data = "test"; 780 const char *data = "test";
804 CX_TEST_ASSERT(buf.pos == 8); 785 CX_TEST_ASSERT(buf.pos == 8);
805 CX_TEST_ASSERT(buf.capacity == 8); 786 CX_TEST_ASSERT(buf.capacity == 8);
806 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8)); 787 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest", 8));
807 } 788 }
808 cxBufferDestroy(&buf); 789 cxBufferDestroy(&buf);
809 cxBufferDestroy(&target);
810 } 790 }
811 791
812 CX_TEST(test_buffer_put_string_discard) { 792 CX_TEST(test_buffer_put_string_discard) {
813 CxBuffer buf, target; 793 CxBuffer buf;
814 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
815 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 794 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
816 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 795 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
817 buf.capacity = 8; 796 buf.capacity = 8;
818 buf.size = buf.pos = 4; 797 buf.size = buf.pos = 4;
819 const char *data = "testing"; 798 const char *data = "testing";
824 CX_TEST_ASSERT(buf.pos == 8); 803 CX_TEST_ASSERT(buf.pos == 8);
825 CX_TEST_ASSERT(buf.capacity == 8); 804 CX_TEST_ASSERT(buf.capacity == 8);
826 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9)); 805 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0", 9));
827 } 806 }
828 cxBufferDestroy(&buf); 807 cxBufferDestroy(&buf);
829 cxBufferDestroy(&target);
830 } 808 }
831 809
832 CX_TEST(test_buffer_put_string_extend) { 810 CX_TEST(test_buffer_put_string_extend) {
833 CxBuffer buf, target; 811 CxBuffer buf;
834 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
835 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 812 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
836 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 813 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
837 buf.capacity = 8; 814 buf.capacity = 8;
838 buf.size = buf.pos = 4; 815 buf.size = buf.pos = 4;
839 buf.flags |= CX_BUFFER_AUTO_EXTEND; 816 buf.flags |= CX_BUFFER_AUTO_EXTEND;
845 CX_TEST_ASSERT(buf.pos == 11); 822 CX_TEST_ASSERT(buf.pos == 11);
846 CX_TEST_ASSERT(buf.capacity >= 11); 823 CX_TEST_ASSERT(buf.capacity >= 11);
847 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11)); 824 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptesting", 11));
848 } 825 }
849 cxBufferDestroy(&buf); 826 cxBufferDestroy(&buf);
850 cxBufferDestroy(&target); 827 }
828
829 CX_TEST(test_buffer_terminate) {
830 CxBuffer buf;
831 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
832 memcpy(buf.space, "prepAAAAAA\0\0\0\0\0\0", 16);
833 buf.capacity = 8;
834 buf.size = buf.pos = 4;
835 const char *data = "test";
836 CX_TEST_DO {
837 size_t written = cxBufferPutString(&buf, data);
838 CX_TEST_ASSERT(0 != cxBufferTerminate(&buf));
839 CX_TEST_ASSERT(written == 4);
840 CX_TEST_ASSERT(buf.size == 8);
841 CX_TEST_ASSERT(buf.pos == 8);
842 CX_TEST_ASSERT(buf.capacity == 8);
843 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptestAA", 10));
844 buf.flags |= CX_BUFFER_AUTO_EXTEND;
845 CX_TEST_ASSERT(0 == cxBufferTerminate(&buf));
846 CX_TEST_ASSERT(buf.size == 8);
847 CX_TEST_ASSERT(buf.pos == 8);
848 CX_TEST_ASSERT(buf.capacity > 8);
849 CX_TEST_ASSERT(0 == memcmp(buf.space, "preptest\0A", 10));
850 }
851 cxBufferDestroy(&buf);
851 } 852 }
852 853
853 CX_TEST(test_buffer_write_size_overflow) { 854 CX_TEST(test_buffer_write_size_overflow) {
854 CxBuffer buf, target; 855 CxBuffer buf;
855 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
856 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 856 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
857 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 857 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
858 buf.capacity = 8; 858 buf.capacity = 8;
859 buf.size = buf.pos = 4; 859 buf.size = buf.pos = 4;
860 const char *data = "testing"; 860 const char *data = "testing";
865 CX_TEST_ASSERT(buf.pos == 4); 865 CX_TEST_ASSERT(buf.pos == 4);
866 CX_TEST_ASSERT(buf.size == 4); 866 CX_TEST_ASSERT(buf.size == 4);
867 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5)); 867 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5));
868 } 868 }
869 cxBufferDestroy(&buf); 869 cxBufferDestroy(&buf);
870 cxBufferDestroy(&target);
871 } 870 }
872 871
873 CX_TEST(test_buffer_write_capacity_overflow) { 872 CX_TEST(test_buffer_write_capacity_overflow) {
874 CxBuffer buf, target; 873 CxBuffer buf;
875 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
876 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 874 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
877 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16); 875 memcpy(buf.space, "prep\0\0\0\0\0\0\0\0\0\0\0\0", 16);
878 buf.capacity = 8; 876 buf.capacity = 8;
879 buf.size = buf.pos = 4; 877 buf.size = buf.pos = 4;
880 buf.flags |= CX_BUFFER_AUTO_EXTEND; 878 buf.flags |= CX_BUFFER_AUTO_EXTEND;
886 CX_TEST_ASSERT(buf.pos == 4); 884 CX_TEST_ASSERT(buf.pos == 4);
887 CX_TEST_ASSERT(buf.size == 4); 885 CX_TEST_ASSERT(buf.size == 4);
888 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5)); 886 CX_TEST_ASSERT(0 == memcmp(buf.space, "prep\0", 5));
889 } 887 }
890 cxBufferDestroy(&buf); 888 cxBufferDestroy(&buf);
891 cxBufferDestroy(&target);
892 } 889 }
893 890
894 CX_TEST(test_buffer_write_only_overwrite) { 891 CX_TEST(test_buffer_write_only_overwrite) {
895 CxBuffer buf, target; 892 CxBuffer buf;
896 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
897 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT); 893 cxBufferInit(&buf, NULL, 16, cxDefaultAllocator, CX_BUFFER_DEFAULT);
898 memcpy(buf.space, "preptest\0\0\0\0\0\0\0\0", 16); 894 memcpy(buf.space, "preptest\0\0\0\0\0\0\0\0", 16);
899 buf.capacity = 8; 895 buf.capacity = 8;
900 buf.pos = 3; 896 buf.pos = 3;
901 buf.size = 8; 897 buf.size = 8;
907 CX_TEST_ASSERT(buf.size == 8); 903 CX_TEST_ASSERT(buf.size == 8);
908 CX_TEST_ASSERT(buf.pos == 7); 904 CX_TEST_ASSERT(buf.pos == 7);
909 CX_TEST_ASSERT(0 == memcmp(buf.space, "preXXX\0t", 8)); 905 CX_TEST_ASSERT(0 == memcmp(buf.space, "preXXX\0t", 8));
910 } 906 }
911 cxBufferDestroy(&buf); 907 cxBufferDestroy(&buf);
912 cxBufferDestroy(&target);
913 } 908 }
914 909
915 CX_TEST(test_buffer_write_flush_at_capacity) { 910 CX_TEST(test_buffer_write_flush_at_capacity) {
916 CxBuffer buf, target; 911 CxBuffer buf, target;
917 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND); 912 cxBufferInit(&target, NULL, 16, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND);
1156 cx_test_register(suite, test_buffer_put_discard); 1151 cx_test_register(suite, test_buffer_put_discard);
1157 cx_test_register(suite, test_buffer_put_extend); 1152 cx_test_register(suite, test_buffer_put_extend);
1158 cx_test_register(suite, test_buffer_put_string_fit); 1153 cx_test_register(suite, test_buffer_put_string_fit);
1159 cx_test_register(suite, test_buffer_put_string_discard); 1154 cx_test_register(suite, test_buffer_put_string_discard);
1160 cx_test_register(suite, test_buffer_put_string_extend); 1155 cx_test_register(suite, test_buffer_put_string_extend);
1156 cx_test_register(suite, test_buffer_terminate);
1161 cx_test_register(suite, test_buffer_write_size_overflow); 1157 cx_test_register(suite, test_buffer_write_size_overflow);
1162 cx_test_register(suite, test_buffer_write_capacity_overflow); 1158 cx_test_register(suite, test_buffer_write_capacity_overflow);
1163 cx_test_register(suite, test_buffer_write_only_overwrite); 1159 cx_test_register(suite, test_buffer_write_only_overwrite);
1164 cx_test_register(suite, test_buffer_write_flush_at_capacity); 1160 cx_test_register(suite, test_buffer_write_flush_at_capacity);
1165 cx_test_register(suite, test_buffer_write_flush_at_threshold); 1161 cx_test_register(suite, test_buffer_write_flush_at_threshold);

mercurial