tests/test_list.c

changeset 1481
1dda1eed1899
parent 1480
83146195a1db
equal deleted inserted replaced
1480:83146195a1db 1481:1dda1eed1899
1796 int d1 = 50; 1796 int d1 = 50;
1797 int d2 = 80; 1797 int d2 = 80;
1798 int d3 = 60; 1798 int d3 = 60;
1799 int d4 = 40; 1799 int d4 = 40;
1800 int d5 = 70; 1800 int d5 = 70;
1801 int d6a[6] = array_init(52, 54, 56, 62, 64, 75); 1801 int d6a[8] = array_init(52, 54, 56, 56, 62, 62, 64, 75);
1802 int d7a[6] = array_init(51, 57, 58, 65, 77, 78); 1802 int d7a[8] = array_init(51, 51, 57, 58, 65, 77, 78, 78);
1803 int d8 = 90; 1803 int d8 = 90;
1804 int d9 = 56; 1804 int d9 = 56;
1805 int d10a[3] = array_init(67, 75, 90); 1805 int d10a[5] = array_init(58, 58, 67, 75, 90);
1806 int *d6ptr[6]; 1806 int *d6ptr[8];
1807 int *d7ptr[6]; 1807 int *d7ptr[8];
1808 int *d10ptr[3]; 1808 int *d10ptr[5];
1809 for (size_t i = 0; i < 6; i++) { 1809 for (size_t i = 0; i < 8; i++) {
1810 d6ptr[i] = &d6a[i]; 1810 d6ptr[i] = &d6a[i];
1811 d7ptr[i] = &d7a[i]; 1811 d7ptr[i] = &d7a[i];
1812 } 1812 }
1813 for (size_t i = 0 ; i < 3 ; i++) { 1813 for (size_t i = 0 ; i < 5 ; i++) {
1814 d10ptr[i] = &d10a[i]; 1814 d10ptr[i] = &d10a[i];
1815 } 1815 }
1816 size_t inserted; 1816 size_t processed;
1817 int expected[19] = array_init( 1817 int expected[19] = array_init(
1818 40, 50, 51, 52, 54, 56, 57, 58, 60, 1818 40, 50, 51, 52, 54, 56, 57, 58, 60,
1819 62, 64, 65, 67, 70, 75, 77, 78, 80, 90 1819 62, 64, 65, 67, 70, 75, 77, 78, 80, 90
1820 ); 1820 );
1821 1821
1823 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d2)); 1823 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d2));
1824 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d3)); 1824 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d3));
1825 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d4)); 1825 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d4));
1826 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d5)); 1826 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d5));
1827 if (isptrlist) { 1827 if (isptrlist) {
1828 inserted = cxListInsertUniqueArray(list, d6ptr, 6); 1828 processed = cxListInsertUniqueArray(list, d6ptr, 8);
1829 } else { 1829 } else {
1830 inserted = cxListInsertUniqueArray(list, d6a, 6); 1830 processed = cxListInsertUniqueArray(list, d6a, 8);
1831 } 1831 }
1832 CX_TEST_ASSERT(inserted == 6); 1832 CX_TEST_ASSERT(processed == 8);
1833 if (isptrlist) { 1833 if (isptrlist) {
1834 inserted = cxListInsertUniqueArray(list, d7ptr, 6); 1834 processed = cxListInsertUniqueArray(list, d7ptr, 8);
1835 } else { 1835 } else {
1836 inserted = cxListInsertUniqueArray(list, d7a, 6); 1836 processed = cxListInsertUniqueArray(list, d7a, 8);
1837 } 1837 }
1838 CX_TEST_ASSERT(inserted == 6); 1838 CX_TEST_ASSERT(processed == 8);
1839 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d8)); 1839 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d8));
1840 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d9)); 1840 CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d9));
1841 if (isptrlist) { 1841 if (isptrlist) {
1842 inserted = cxListInsertUniqueArray(list, d10ptr, 3); 1842 processed = cxListInsertUniqueArray(list, d10ptr, 5);
1843 } else { 1843 } else {
1844 inserted = cxListInsertUniqueArray(list, d10a, 3); 1844 processed = cxListInsertUniqueArray(list, d10a, 5);
1845 } 1845 }
1846 CX_TEST_ASSERT(inserted == 3); 1846 CX_TEST_ASSERT(processed == 5);
1847 CX_TEST_ASSERT(cxListSize(list) == 19); 1847 CX_TEST_ASSERT(cxListSize(list) == 19);
1848 for (size_t i = 0; i < 19; i++) { 1848 for (size_t i = 0; i < 19; i++) {
1849 CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]); 1849 CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]);
1850 } 1850 }
1851 }) 1851 })

mercurial