479 }; |
479 }; |
480 |
480 |
481 class PointerArrayList : public HighLevelTest { |
481 class PointerArrayList : public HighLevelTest { |
482 }; |
482 }; |
483 |
483 |
|
484 |
|
485 TEST_F(LinkedList, cxListAdd) { |
|
486 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
|
487 verifyAdd(list, false); |
|
488 } |
|
489 |
|
490 TEST_F(PointerLinkedList, cxListAdd) { |
|
491 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
|
492 verifyAdd(list, true); |
|
493 } |
|
494 |
|
495 TEST_F(ArrayList, cxListAdd) { |
|
496 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); |
|
497 verifyAdd(list, false); |
|
498 } |
|
499 |
|
500 TEST_F(PointerArrayList, cxListAdd) { |
|
501 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 8)); |
|
502 verifyAdd(list, true); |
|
503 } |
|
504 |
|
505 TEST_F(LinkedList, cxListInsert) { |
|
506 verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
507 } |
|
508 |
|
509 TEST_F(PointerLinkedList, cxListInsert) { |
|
510 verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
511 } |
|
512 |
|
513 TEST_F(ArrayList, cxListInsert) { |
|
514 verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 2))); |
|
515 } |
|
516 |
|
517 TEST_F(PointerArrayList, cxListInsert) { |
|
518 verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 2))); |
|
519 } |
|
520 |
|
521 TEST_F(LinkedList, cxListInsertArray) { |
|
522 verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
523 } |
|
524 |
|
525 TEST_F(PointerLinkedList, cxListInsertArray) { |
|
526 verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)), true); |
|
527 } |
|
528 |
|
529 TEST_F(ArrayList, cxListInsertArray) { |
|
530 verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4))); |
|
531 } |
|
532 |
|
533 TEST_F(PointerArrayList, cxListInsertArray) { |
|
534 verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)), true); |
|
535 } |
|
536 |
|
537 TEST_F(LinkedList, cxListRemove) { |
|
538 verifyRemove(linkedListFromTestData()); |
|
539 } |
|
540 |
|
541 TEST_F(PointerLinkedList, cxListRemove) { |
|
542 verifyRemove(pointerLinkedListFromTestData()); |
|
543 } |
|
544 |
|
545 TEST_F(ArrayList, cxListRemove) { |
|
546 verifyRemove(arrayListFromTestData()); |
|
547 } |
|
548 |
|
549 TEST_F(PointerArrayList, cxListRemove) { |
|
550 verifyRemove(pointerArrayListFromTestData()); |
|
551 } |
|
552 |
|
553 TEST_F(LinkedList, cxListFindRemove) { |
|
554 verifyFindRemove(linkedListFromTestData()); |
|
555 } |
|
556 |
|
557 TEST_F(PointerLinkedList, cxListFindRemove) { |
|
558 verifyFindRemove(pointerLinkedListFromTestData()); |
|
559 } |
|
560 |
|
561 TEST_F(ArrayList, cxListFindRemove) { |
|
562 verifyFindRemove(arrayListFromTestData()); |
|
563 } |
|
564 |
|
565 TEST_F(PointerArrayList, cxListFindRemove) { |
|
566 verifyFindRemove(pointerArrayListFromTestData()); |
|
567 } |
|
568 |
|
569 TEST_F(LinkedList, cxListClear) { |
|
570 verifyClear(linkedListFromTestData()); |
|
571 } |
|
572 |
|
573 TEST_F(PointerLinkedList, cxListClear) { |
|
574 verifyClear(pointerLinkedListFromTestData()); |
|
575 } |
|
576 |
|
577 TEST_F(ArrayList, cxListClear) { |
|
578 verifyClear(arrayListFromTestData()); |
|
579 } |
|
580 |
|
581 TEST_F(PointerArrayList, cxListClear) { |
|
582 verifyClear(pointerArrayListFromTestData()); |
|
583 } |
|
584 |
|
585 TEST_F(LinkedList, cxListSwap) { |
|
586 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
587 } |
|
588 |
|
589 TEST_F(PointerLinkedList, cxListSwap) { |
|
590 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
591 } |
|
592 |
|
593 TEST_F(ArrayList, cxListSwap) { |
|
594 verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 16))); |
|
595 } |
|
596 |
|
597 TEST_F(PointerArrayList, cxListSwap) { |
|
598 verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 16))); |
|
599 } |
|
600 |
|
601 TEST_F(LinkedList, cxListSwapNoSBO) { |
|
602 CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
|
603 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
604 CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
|
605 } |
|
606 |
|
607 TEST_F(PointerLinkedList, cxListSwapNoSBO) { |
|
608 CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
|
609 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
610 CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
|
611 } |
|
612 |
|
613 TEST_F(LinkedList, cxListAt) { |
|
614 verifyAt(linkedListFromTestData()); |
|
615 } |
|
616 |
|
617 TEST_F(PointerLinkedList, cxListAt) { |
|
618 verifyAt(pointerLinkedListFromTestData()); |
|
619 } |
|
620 |
|
621 TEST_F(ArrayList, cxListAt) { |
|
622 verifyAt(arrayListFromTestData()); |
|
623 } |
|
624 |
|
625 TEST_F(PointerArrayList, cxListAt) { |
|
626 verifyAt(pointerArrayListFromTestData()); |
|
627 } |
|
628 |
|
629 TEST_F(LinkedList, cxListFind) { |
|
630 verifyFind(linkedListFromTestData()); |
|
631 } |
|
632 |
|
633 TEST_F(PointerLinkedList, cxListFind) { |
|
634 verifyFind(pointerLinkedListFromTestData()); |
|
635 } |
|
636 |
|
637 TEST_F(ArrayList, cxListFind) { |
|
638 verifyFind(arrayListFromTestData()); |
|
639 } |
|
640 |
|
641 TEST_F(PointerArrayList, cxListFind) { |
|
642 verifyFind(pointerArrayListFromTestData()); |
|
643 } |
|
644 |
|
645 TEST_F(LinkedList, cxListSort) { |
|
646 verifySort(linkedListFromTestData()); |
|
647 } |
|
648 |
|
649 TEST_F(PointerLinkedList, cxListSort) { |
|
650 verifySort(pointerLinkedListFromTestData()); |
|
651 } |
|
652 |
|
653 TEST_F(ArrayList, cxListSort) { |
|
654 verifySort(arrayListFromTestData()); |
|
655 } |
|
656 |
|
657 TEST_F(PointerArrayList, cxListSort) { |
|
658 verifySort(pointerArrayListFromTestData()); |
|
659 } |
|
660 |
|
661 TEST_F(LinkedList, Iterator) { |
|
662 verifyIterator(linkedListFromTestData()); |
|
663 } |
|
664 |
|
665 TEST_F(PointerLinkedList, Iterator) { |
|
666 verifyIterator(pointerLinkedListFromTestData()); |
|
667 } |
|
668 |
|
669 TEST_F(ArrayList, Iterator) { |
|
670 verifyIterator(arrayListFromTestData()); |
|
671 } |
|
672 |
|
673 TEST_F(PointerArrayList, Iterator) { |
|
674 verifyIterator(pointerArrayListFromTestData()); |
|
675 } |
|
676 |
|
677 TEST_F(LinkedList, InsertViaIterator) { |
|
678 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
679 CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
|
680 cxListAddArray(list, fivenums, 5); |
|
681 verifyInsertViaIterator(list); |
|
682 } |
|
683 |
|
684 TEST_F(PointerLinkedList, InsertViaIterator) { |
|
685 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
686 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
|
687 // note: cannot use cxListAddArray() because we don't have a list of pointers |
|
688 cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
|
689 verifyInsertViaIterator(list); |
|
690 } |
|
691 |
|
692 TEST_F(ArrayList, InsertViaIterator) { |
|
693 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
694 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)); |
|
695 cxListAddArray(list, fivenums, 5); |
|
696 verifyInsertViaIterator(list); |
|
697 } |
|
698 |
|
699 TEST_F(PointerArrayList, InsertViaIterator) { |
|
700 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
701 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)); |
|
702 // note: cannot use cxListAddArray() because we don't have a list of pointers |
|
703 cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
|
704 verifyInsertViaIterator(list); |
|
705 } |
|
706 |
|
707 TEST_F(LinkedList, cxListReverse) { |
|
708 verifyReverse(linkedListFromTestData()); |
|
709 } |
|
710 |
|
711 TEST_F(PointerLinkedList, cxListReverse) { |
|
712 verifyReverse(pointerLinkedListFromTestData()); |
|
713 } |
|
714 |
|
715 TEST_F(ArrayList, cxListReverse) { |
|
716 verifyReverse(arrayListFromTestData()); |
|
717 } |
|
718 |
|
719 TEST_F(PointerArrayList, cxListReverse) { |
|
720 verifyReverse(pointerArrayListFromTestData()); |
|
721 } |
|
722 |
|
723 TEST_F(LinkedList, cxListCompare) { |
|
724 auto left = linkedListFromTestData(); |
|
725 auto right = linkedListFromTestData(); |
|
726 verifyCompare(left, right); |
|
727 } |
|
728 |
|
729 TEST_F(LinkedList, cxListCompareWithPtrList) { |
|
730 auto left = linkedListFromTestData(); |
|
731 auto right = pointerLinkedListFromTestData(); |
|
732 verifyCompare(left, right); |
|
733 } |
|
734 |
|
735 TEST_F(LinkedList, cxListCompareWithArrayList) { |
|
736 auto left = linkedListFromTestData(); |
|
737 auto right = arrayListFromTestData(); |
|
738 verifyCompare(left, right); |
|
739 } |
|
740 |
|
741 TEST_F(LinkedList, cxListCompareWithPtrArrayList) { |
|
742 auto left = linkedListFromTestData(); |
|
743 auto right = pointerArrayListFromTestData(); |
|
744 verifyCompare(left, right); |
|
745 } |
|
746 |
|
747 TEST_F(PointerLinkedList, cxListCompare) { |
|
748 auto left = pointerLinkedListFromTestData(); |
|
749 auto right = pointerLinkedListFromTestData(); |
|
750 verifyCompare(left, right); |
|
751 } |
|
752 |
|
753 TEST_F(PointerLinkedList, cxListCompareWithNormalList) { |
|
754 auto left = pointerLinkedListFromTestData(); |
|
755 auto right = linkedListFromTestData(); |
|
756 verifyCompare(left, right); |
|
757 } |
|
758 |
|
759 TEST_F(PointerLinkedList, cxListCompareWithArrayList) { |
|
760 auto left = pointerLinkedListFromTestData(); |
|
761 auto right = arrayListFromTestData(); |
|
762 verifyCompare(left, right); |
|
763 } |
|
764 |
|
765 TEST_F(PointerLinkedList, cxListCompareWithPtrArrayList) { |
|
766 auto left = pointerLinkedListFromTestData(); |
|
767 auto right = pointerArrayListFromTestData(); |
|
768 verifyCompare(left, right); |
|
769 } |
|
770 |
|
771 TEST_F(ArrayList, cxListCompare) { |
|
772 auto left = arrayListFromTestData(); |
|
773 auto right = arrayListFromTestData(); |
|
774 verifyCompare(left, right); |
|
775 } |
|
776 |
|
777 TEST_F(ArrayList, cxListCompareWithPtrList) { |
|
778 auto left = arrayListFromTestData(); |
|
779 auto right = pointerLinkedListFromTestData(); |
|
780 verifyCompare(left, right); |
|
781 } |
|
782 |
|
783 TEST_F(ArrayList, cxListCompareWithNormalList) { |
|
784 auto left = arrayListFromTestData(); |
|
785 auto right = linkedListFromTestData(); |
|
786 verifyCompare(left, right); |
|
787 } |
|
788 |
|
789 TEST_F(ArrayList, cxListCompareWithPtrArrayList) { |
|
790 auto left = arrayListFromTestData(); |
|
791 auto right = pointerArrayListFromTestData(); |
|
792 verifyCompare(left, right); |
|
793 } |
|
794 |
|
795 TEST_F(PointerArrayList, cxListCompare) { |
|
796 auto left = pointerArrayListFromTestData(); |
|
797 auto right = pointerArrayListFromTestData(); |
|
798 verifyCompare(left, right); |
|
799 } |
|
800 |
|
801 TEST_F(PointerArrayList, cxListCompareWithPtrList) { |
|
802 auto left = pointerArrayListFromTestData(); |
|
803 auto right = pointerLinkedListFromTestData(); |
|
804 verifyCompare(left, right); |
|
805 } |
|
806 |
|
807 TEST_F(PointerArrayList, cxListCompareWithNormalList) { |
|
808 auto left = pointerArrayListFromTestData(); |
|
809 auto right = linkedListFromTestData(); |
|
810 verifyCompare(left, right); |
|
811 } |
|
812 |
|
813 TEST_F(PointerArrayList, cxListCompareWithNormalArrayList) { |
|
814 auto left = pointerArrayListFromTestData(); |
|
815 auto right = arrayListFromTestData(); |
|
816 verifyCompare(left, right); |
|
817 } |
|
818 |
|
819 TEST_F(LinkedList, SimpleDestructor) { |
|
820 verifySimpleDestructor(linkedListFromTestData()); |
|
821 } |
|
822 |
|
823 TEST_F(PointerLinkedList, SimpleDestructor) { |
|
824 verifySimpleDestructor(pointerLinkedListFromTestData()); |
|
825 } |
|
826 |
|
827 TEST_F(ArrayList, SimpleDestructor) { |
|
828 verifySimpleDestructor(arrayListFromTestData()); |
|
829 } |
|
830 |
|
831 TEST_F(PointerArrayList, SimpleDestructor) { |
|
832 verifySimpleDestructor(pointerArrayListFromTestData()); |
|
833 } |
|
834 |
|
835 TEST_F(LinkedList, AdvancedDestructor) { |
|
836 verifyAdvancedDestructor(linkedListFromTestData()); |
|
837 } |
|
838 |
|
839 TEST_F(PointerLinkedList, AdvancedDestructor) { |
|
840 verifyAdvancedDestructor(pointerLinkedListFromTestData()); |
|
841 } |
|
842 |
|
843 TEST_F(ArrayList, AdvancedDestructor) { |
|
844 verifyAdvancedDestructor(arrayListFromTestData()); |
|
845 } |
|
846 |
|
847 TEST_F(PointerArrayList, AdvancedDestructor) { |
|
848 verifyAdvancedDestructor(pointerArrayListFromTestData()); |
|
849 } |
|
850 |
484 TEST_F(PointerLinkedList, cxListStorePointers) { |
851 TEST_F(PointerLinkedList, cxListStorePointers) { |
485 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, 47)); |
852 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, 47)); |
486 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
853 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
487 cxListStorePointers(list); |
854 cxListStorePointers(list); |
488 EXPECT_EQ(list->item_size, sizeof(void *)); |
855 EXPECT_EQ(list->item_size, sizeof(void *)); |
567 EXPECT_EQ(list->allocator, cxDefaultAllocator); |
934 EXPECT_EQ(list->allocator, cxDefaultAllocator); |
568 EXPECT_EQ(list->item_size, sizeof(void *)); |
935 EXPECT_EQ(list->item_size, sizeof(void *)); |
569 CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
936 CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
570 } |
937 } |
571 |
938 |
572 TEST_F(LinkedList, cxListAdd) { |
|
573 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
|
574 verifyAdd(list, false); |
|
575 } |
|
576 |
|
577 TEST_F(PointerLinkedList, cxListAdd) { |
|
578 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
|
579 verifyAdd(list, true); |
|
580 } |
|
581 |
|
582 TEST_F(ArrayList, cxListAdd) { |
|
583 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); |
|
584 verifyAdd(list, false); |
|
585 } |
|
586 |
|
587 TEST_F(PointerArrayList, cxListAdd) { |
|
588 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 8)); |
|
589 verifyAdd(list, true); |
|
590 } |
|
591 |
|
592 TEST_F(LinkedList, cxListInsert) { |
|
593 verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
594 } |
|
595 |
|
596 TEST_F(PointerLinkedList, cxListInsert) { |
|
597 verifyInsert(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
598 } |
|
599 |
|
600 TEST_F(ArrayList, cxListInsert) { |
|
601 verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 2))); |
|
602 } |
|
603 |
|
604 TEST_F(PointerArrayList, cxListInsert) { |
|
605 verifyInsert(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 2))); |
|
606 } |
|
607 |
|
608 TEST_F(LinkedList, cxListInsertArray) { |
|
609 verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
610 } |
|
611 |
|
612 TEST_F(PointerLinkedList, cxListInsertArray) { |
|
613 verifyInsertArray(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)), true); |
|
614 } |
|
615 |
|
616 TEST_F(ArrayList, cxListInsertArray) { |
|
617 verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4))); |
|
618 } |
|
619 |
|
620 TEST_F(PointerArrayList, cxListInsertArray) { |
|
621 verifyInsertArray(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)), true); |
|
622 } |
|
623 |
|
624 TEST_F(LinkedList, cxListRemove) { |
|
625 verifyRemove(linkedListFromTestData()); |
|
626 } |
|
627 |
|
628 TEST_F(PointerLinkedList, cxListRemove) { |
|
629 verifyRemove(pointerLinkedListFromTestData()); |
|
630 } |
|
631 |
|
632 TEST_F(ArrayList, cxListRemove) { |
|
633 verifyRemove(arrayListFromTestData()); |
|
634 } |
|
635 |
|
636 TEST_F(PointerArrayList, cxListRemove) { |
|
637 verifyRemove(pointerArrayListFromTestData()); |
|
638 } |
|
639 |
|
640 TEST_F(LinkedList, cxListFindRemove) { |
|
641 verifyFindRemove(linkedListFromTestData()); |
|
642 } |
|
643 |
|
644 TEST_F(PointerLinkedList, cxListFindRemove) { |
|
645 verifyFindRemove(pointerLinkedListFromTestData()); |
|
646 } |
|
647 |
|
648 TEST_F(ArrayList, cxListFindRemove) { |
|
649 verifyFindRemove(arrayListFromTestData()); |
|
650 } |
|
651 |
|
652 TEST_F(PointerArrayList, cxListFindRemove) { |
|
653 verifyFindRemove(pointerArrayListFromTestData()); |
|
654 } |
|
655 |
|
656 TEST_F(LinkedList, cxListClear) { |
|
657 verifyClear(linkedListFromTestData()); |
|
658 } |
|
659 |
|
660 TEST_F(PointerLinkedList, cxListClear) { |
|
661 verifyClear(pointerLinkedListFromTestData()); |
|
662 } |
|
663 |
|
664 TEST_F(ArrayList, cxListClear) { |
|
665 verifyClear(arrayListFromTestData()); |
|
666 } |
|
667 |
|
668 TEST_F(PointerArrayList, cxListClear) { |
|
669 verifyClear(pointerArrayListFromTestData()); |
|
670 } |
|
671 |
|
672 TEST_F(LinkedList, cxListSwap) { |
|
673 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
674 } |
|
675 |
|
676 TEST_F(PointerLinkedList, cxListSwap) { |
|
677 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
678 } |
|
679 |
|
680 TEST_F(ArrayList, cxListSwap) { |
|
681 verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 16))); |
|
682 } |
|
683 |
|
684 TEST_F(PointerArrayList, cxListSwap) { |
|
685 verifySwap(autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 16))); |
|
686 } |
|
687 |
|
688 TEST_F(LinkedList, cxListSwapNoSBO) { |
|
689 CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
|
690 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
|
691 CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
|
692 } |
|
693 |
|
694 TEST_F(PointerLinkedList, cxListSwapNoSBO) { |
|
695 CX_DISABLE_LINKED_LIST_SWAP_SBO = true; |
|
696 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS))); |
|
697 CX_DISABLE_LINKED_LIST_SWAP_SBO = false; |
|
698 } |
|
699 |
|
700 TEST_F(LinkedList, cxListAt) { |
|
701 verifyAt(linkedListFromTestData()); |
|
702 } |
|
703 |
|
704 TEST_F(PointerLinkedList, cxListAt) { |
|
705 verifyAt(pointerLinkedListFromTestData()); |
|
706 } |
|
707 |
|
708 TEST_F(ArrayList, cxListAt) { |
|
709 verifyAt(arrayListFromTestData()); |
|
710 } |
|
711 |
|
712 TEST_F(PointerArrayList, cxListAt) { |
|
713 verifyAt(pointerArrayListFromTestData()); |
|
714 } |
|
715 |
|
716 TEST_F(LinkedList, cxListFind) { |
|
717 verifyFind(linkedListFromTestData()); |
|
718 } |
|
719 |
|
720 TEST_F(PointerLinkedList, cxListFind) { |
|
721 verifyFind(pointerLinkedListFromTestData()); |
|
722 } |
|
723 |
|
724 TEST_F(ArrayList, cxListFind) { |
|
725 verifyFind(arrayListFromTestData()); |
|
726 } |
|
727 |
|
728 TEST_F(PointerArrayList, cxListFind) { |
|
729 verifyFind(pointerArrayListFromTestData()); |
|
730 } |
|
731 |
|
732 TEST_F(LinkedList, cxListSort) { |
|
733 verifySort(linkedListFromTestData()); |
|
734 } |
|
735 |
|
736 TEST_F(PointerLinkedList, cxListSort) { |
|
737 verifySort(pointerLinkedListFromTestData()); |
|
738 } |
|
739 |
|
740 TEST_F(ArrayList, cxListSort) { |
|
741 verifySort(arrayListFromTestData()); |
|
742 } |
|
743 |
|
744 TEST_F(PointerArrayList, cxListSort) { |
|
745 verifySort(pointerArrayListFromTestData()); |
|
746 } |
|
747 |
|
748 TEST_F(LinkedList, Iterator) { |
|
749 verifyIterator(linkedListFromTestData()); |
|
750 } |
|
751 |
|
752 TEST_F(PointerLinkedList, Iterator) { |
|
753 verifyIterator(pointerLinkedListFromTestData()); |
|
754 } |
|
755 |
|
756 TEST_F(ArrayList, Iterator) { |
|
757 verifyIterator(arrayListFromTestData()); |
|
758 } |
|
759 |
|
760 TEST_F(PointerArrayList, Iterator) { |
|
761 verifyIterator(pointerArrayListFromTestData()); |
|
762 } |
|
763 |
|
764 TEST_F(LinkedList, InsertViaIterator) { |
|
765 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
766 CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); |
|
767 cxListAddArray(list, fivenums, 5); |
|
768 verifyInsertViaIterator(list); |
|
769 } |
|
770 |
|
771 TEST_F(PointerLinkedList, InsertViaIterator) { |
|
772 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
773 auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS)); |
|
774 // note: cannot use cxListAddArray() because we don't have a list of pointers |
|
775 cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
|
776 verifyInsertViaIterator(list); |
|
777 } |
|
778 |
|
779 TEST_F(ArrayList, InsertViaIterator) { |
|
780 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
781 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)); |
|
782 cxListAddArray(list, fivenums, 5); |
|
783 verifyInsertViaIterator(list); |
|
784 } |
|
785 |
|
786 TEST_F(PointerArrayList, InsertViaIterator) { |
|
787 int fivenums[] = {0, 1, 2, 3, 4, 5}; |
|
788 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, CX_STORE_POINTERS, 4)); |
|
789 // note: cannot use cxListAddArray() because we don't have a list of pointers |
|
790 cx_for_n(i, 5) cxListAdd(list, &fivenums[i]); |
|
791 verifyInsertViaIterator(list); |
|
792 } |
|
793 |
|
794 TEST_F(LinkedList, cxListReverse) { |
|
795 verifyReverse(linkedListFromTestData()); |
|
796 } |
|
797 |
|
798 TEST_F(PointerLinkedList, cxListReverse) { |
|
799 verifyReverse(pointerLinkedListFromTestData()); |
|
800 } |
|
801 |
|
802 TEST_F(ArrayList, cxListReverse) { |
|
803 verifyReverse(arrayListFromTestData()); |
|
804 } |
|
805 |
|
806 TEST_F(PointerArrayList, cxListReverse) { |
|
807 verifyReverse(pointerArrayListFromTestData()); |
|
808 } |
|
809 |
|
810 TEST_F(LinkedList, cxListCompare) { |
|
811 auto left = linkedListFromTestData(); |
|
812 auto right = linkedListFromTestData(); |
|
813 verifyCompare(left, right); |
|
814 } |
|
815 |
|
816 TEST_F(LinkedList, cxListCompareWithPtrList) { |
|
817 auto left = linkedListFromTestData(); |
|
818 auto right = pointerLinkedListFromTestData(); |
|
819 verifyCompare(left, right); |
|
820 } |
|
821 |
|
822 TEST_F(LinkedList, cxListCompareWithArrayList) { |
|
823 auto left = linkedListFromTestData(); |
|
824 auto right = arrayListFromTestData(); |
|
825 verifyCompare(left, right); |
|
826 } |
|
827 |
|
828 TEST_F(LinkedList, cxListCompareWithPtrArrayList) { |
|
829 auto left = linkedListFromTestData(); |
|
830 auto right = pointerArrayListFromTestData(); |
|
831 verifyCompare(left, right); |
|
832 } |
|
833 |
|
834 TEST_F(PointerLinkedList, cxListCompare) { |
|
835 auto left = pointerLinkedListFromTestData(); |
|
836 auto right = pointerLinkedListFromTestData(); |
|
837 verifyCompare(left, right); |
|
838 } |
|
839 |
|
840 TEST_F(PointerLinkedList, cxListCompareWithNormalList) { |
|
841 auto left = pointerLinkedListFromTestData(); |
|
842 auto right = linkedListFromTestData(); |
|
843 verifyCompare(left, right); |
|
844 } |
|
845 |
|
846 TEST_F(PointerLinkedList, cxListCompareWithArrayList) { |
|
847 auto left = pointerLinkedListFromTestData(); |
|
848 auto right = arrayListFromTestData(); |
|
849 verifyCompare(left, right); |
|
850 } |
|
851 |
|
852 TEST_F(PointerLinkedList, cxListCompareWithPtrArrayList) { |
|
853 auto left = pointerLinkedListFromTestData(); |
|
854 auto right = pointerArrayListFromTestData(); |
|
855 verifyCompare(left, right); |
|
856 } |
|
857 |
|
858 TEST_F(ArrayList, cxListCompare) { |
|
859 auto left = arrayListFromTestData(); |
|
860 auto right = arrayListFromTestData(); |
|
861 verifyCompare(left, right); |
|
862 } |
|
863 |
|
864 TEST_F(ArrayList, cxListCompareWithPtrList) { |
|
865 auto left = arrayListFromTestData(); |
|
866 auto right = pointerLinkedListFromTestData(); |
|
867 verifyCompare(left, right); |
|
868 } |
|
869 |
|
870 TEST_F(ArrayList, cxListCompareWithNormalList) { |
|
871 auto left = arrayListFromTestData(); |
|
872 auto right = linkedListFromTestData(); |
|
873 verifyCompare(left, right); |
|
874 } |
|
875 |
|
876 TEST_F(ArrayList, cxListCompareWithPtrArrayList) { |
|
877 auto left = arrayListFromTestData(); |
|
878 auto right = pointerArrayListFromTestData(); |
|
879 verifyCompare(left, right); |
|
880 } |
|
881 |
|
882 TEST_F(PointerArrayList, cxListCompare) { |
|
883 auto left = pointerArrayListFromTestData(); |
|
884 auto right = pointerArrayListFromTestData(); |
|
885 verifyCompare(left, right); |
|
886 } |
|
887 |
|
888 TEST_F(PointerArrayList, cxListCompareWithPtrList) { |
|
889 auto left = pointerArrayListFromTestData(); |
|
890 auto right = pointerLinkedListFromTestData(); |
|
891 verifyCompare(left, right); |
|
892 } |
|
893 |
|
894 TEST_F(PointerArrayList, cxListCompareWithNormalList) { |
|
895 auto left = pointerArrayListFromTestData(); |
|
896 auto right = linkedListFromTestData(); |
|
897 verifyCompare(left, right); |
|
898 } |
|
899 |
|
900 TEST_F(PointerArrayList, cxListCompareWithNormalArrayList) { |
|
901 auto left = pointerArrayListFromTestData(); |
|
902 auto right = arrayListFromTestData(); |
|
903 verifyCompare(left, right); |
|
904 } |
|
905 |
|
906 TEST_F(LinkedList, SimpleDestructor) { |
|
907 verifySimpleDestructor(linkedListFromTestData()); |
|
908 } |
|
909 |
|
910 TEST_F(PointerLinkedList, SimpleDestructor) { |
|
911 verifySimpleDestructor(pointerLinkedListFromTestData()); |
|
912 } |
|
913 |
|
914 TEST_F(ArrayList, SimpleDestructor) { |
|
915 verifySimpleDestructor(arrayListFromTestData()); |
|
916 } |
|
917 |
|
918 TEST_F(PointerArrayList, SimpleDestructor) { |
|
919 verifySimpleDestructor(pointerArrayListFromTestData()); |
|
920 } |
|
921 |
|
922 TEST_F(LinkedList, AdvancedDestructor) { |
|
923 verifyAdvancedDestructor(linkedListFromTestData()); |
|
924 } |
|
925 |
|
926 TEST_F(PointerLinkedList, AdvancedDestructor) { |
|
927 verifyAdvancedDestructor(pointerLinkedListFromTestData()); |
|
928 } |
|
929 |
|
930 TEST_F(ArrayList, AdvancedDestructor) { |
|
931 verifyAdvancedDestructor(arrayListFromTestData()); |
|
932 } |
|
933 |
|
934 TEST_F(PointerArrayList, AdvancedDestructor) { |
|
935 verifyAdvancedDestructor(pointerArrayListFromTestData()); |
|
936 } |
|
937 |
|
938 TEST_F(PointerLinkedList, DestroyNoDestructor) { |
939 TEST_F(PointerLinkedList, DestroyNoDestructor) { |
939 void *item = cxMalloc(&testingAllocator, sizeof(int)); |
940 void *item = cxMalloc(&testingAllocator, sizeof(int)); |
940 auto list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); |
941 auto list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS); |
941 cxListAdd(list, item); |
942 cxListAdd(list, item); |
942 CX_TEST_ASSERT(!testingAllocator.verify()); |
943 CX_TEST_ASSERT(!testingAllocator.verify()); |
995 CX_TEST_ASSERT(!testingAllocator.verify()); |
996 CX_TEST_ASSERT(!testingAllocator.verify()); |
996 cxListDestroy(list); |
997 cxListDestroy(list); |
997 CX_TEST_ASSERT(testingAllocator.verify()); |
998 CX_TEST_ASSERT(testingAllocator.verify()); |
998 } |
999 } |
999 |
1000 |
1000 TEST(EmptyList, Size) { |
|
1001 auto list = cxEmptyList; |
|
1002 |
|
1003 EXPECT_EQ(list->size, 0); |
|
1004 EXPECT_EQ(cxListSize(list), 0); |
|
1005 } |
|
1006 |
|
1007 TEST(EmptyList, Iterator) { |
|
1008 auto list = cxEmptyList; |
|
1009 |
|
1010 auto it1 = cxListIterator(list); |
|
1011 auto it2 = cxListBackwardsIterator(list); |
|
1012 auto it3 = cxListMutIterator(list); |
|
1013 auto it4 = cxListMutBackwardsIterator(list); |
|
1014 |
|
1015 CX_TEST_ASSERT(!cxIteratorValid(it1)); |
|
1016 CX_TEST_ASSERT(!cxIteratorValid(it2)); |
|
1017 CX_TEST_ASSERT(!cxIteratorValid(it3)); |
|
1018 CX_TEST_ASSERT(!cxIteratorValid(it4)); |
|
1019 |
|
1020 int c = 0; |
|
1021 cx_foreach(void*, data, it1) c++; |
|
1022 cx_foreach(void*, data, it2) c++; |
|
1023 cx_foreach(void*, data, it3) c++; |
|
1024 cx_foreach(void*, data, it4) c++; |
|
1025 EXPECT_EQ(c, 0); |
|
1026 } |
|
1027 |
|
1028 TEST(EmptyList, NoOps) { |
|
1029 auto list = cxEmptyList; |
|
1030 |
|
1031 ASSERT_NO_FATAL_FAILURE(cxListSort(list)); |
|
1032 ASSERT_NO_FATAL_FAILURE(cxListClear(list)); |
|
1033 ASSERT_NO_FATAL_FAILURE(cxListDestroy(list)); |
|
1034 } |
|
1035 |
|
1036 TEST(EmptyList, At) { |
|
1037 auto list = cxEmptyList; |
|
1038 |
|
1039 EXPECT_EQ(cxListAt(list, 0), NULL); |
|
1040 EXPECT_EQ(cxListAt(list, 1), NULL); |
|
1041 } |
|
1042 |
|
1043 TEST(EmptyList, Find) { |
|
1044 auto list = cxEmptyList; |
|
1045 |
|
1046 int x = 42, y = 1337; |
|
1047 |
|
1048 EXPECT_LT(cxListFind(list, &x), 0); |
|
1049 EXPECT_LT(cxListFind(list, &y), 0); |
|
1050 } |
|
1051 |
|
1052 TEST(EmptyList, Compare) { |
|
1053 auto empty = cxEmptyList; |
|
1054 |
|
1055 auto ll = cxLinkedListCreateSimple(sizeof(int)); |
|
1056 auto al = cxArrayListCreateSimple(sizeof(int), 8); |
|
1057 |
|
1058 int x = 5; |
|
1059 |
|
1060 EXPECT_EQ(cxListCompare(empty, cxEmptyList), 0); |
|
1061 EXPECT_EQ(cxListCompare(ll, cxEmptyList), 0); |
|
1062 EXPECT_EQ(cxListCompare(al, cxEmptyList), 0); |
|
1063 EXPECT_EQ(cxListCompare(cxEmptyList, ll), 0); |
|
1064 EXPECT_EQ(cxListCompare(cxEmptyList, al), 0); |
|
1065 |
|
1066 cxListAdd(ll, &x); |
|
1067 cxListAdd(al, &x); |
|
1068 |
|
1069 EXPECT_GT(cxListCompare(ll, cxEmptyList), 0); |
|
1070 EXPECT_GT(cxListCompare(al, cxEmptyList), 0); |
|
1071 EXPECT_LT(cxListCompare(cxEmptyList, ll), 0); |
|
1072 EXPECT_LT(cxListCompare(cxEmptyList, al), 0); |
|
1073 |
|
1074 cxListDestroy(ll); |
|
1075 cxListDestroy(al); |
|
1076 } |
|