1475 ASSERT_FALSE(testingAllocator.verify()); |
1475 ASSERT_FALSE(testingAllocator.verify()); |
1476 cxListDestroy(list); |
1476 cxListDestroy(list); |
1477 EXPECT_TRUE(testingAllocator.verify()); |
1477 EXPECT_TRUE(testingAllocator.verify()); |
1478 } |
1478 } |
1479 |
1479 |
|
1480 TEST(EmptyList, Size) { |
|
1481 auto list = cxEmptyList; |
|
1482 |
|
1483 EXPECT_EQ(list->size, 0); |
|
1484 EXPECT_EQ(cxListSize(list), 0); |
|
1485 } |
|
1486 |
|
1487 TEST(EmptyList, Iterator) { |
|
1488 auto list = cxEmptyList; |
|
1489 |
|
1490 auto it1 = cxListIterator(list); |
|
1491 auto it2 = cxListBackwardsIterator(list); |
|
1492 auto it3 = cxListMutIterator(list); |
|
1493 auto it4 = cxListMutBackwardsIterator(list); |
|
1494 |
|
1495 EXPECT_FALSE(cxIteratorValid(it1)); |
|
1496 EXPECT_FALSE(cxIteratorValid(it2)); |
|
1497 EXPECT_FALSE(cxIteratorValid(it3)); |
|
1498 EXPECT_FALSE(cxIteratorValid(it4)); |
|
1499 |
|
1500 int c = 0; |
|
1501 cx_foreach(void*, data, it1) c++; |
|
1502 cx_foreach(void*, data, it2) c++; |
|
1503 cx_foreach(void*, data, it3) c++; |
|
1504 cx_foreach(void*, data, it4) c++; |
|
1505 EXPECT_EQ(c, 0); |
|
1506 } |
|
1507 |
|
1508 TEST(EmptyList, NoOps) { |
|
1509 auto list = cxEmptyList; |
|
1510 |
|
1511 ASSERT_NO_FATAL_FAILURE(cxListSort(list)); |
|
1512 ASSERT_NO_FATAL_FAILURE(cxListClear(list)); |
|
1513 ASSERT_NO_FATAL_FAILURE(cxListDestroy(list)); |
|
1514 } |
|
1515 |
|
1516 TEST(EmptyList, At) { |
|
1517 auto list = cxEmptyList; |
|
1518 |
|
1519 EXPECT_EQ(cxListAt(list, 0), nullptr); |
|
1520 EXPECT_EQ(cxListAt(list, 1), nullptr); |
|
1521 } |
|
1522 |
|
1523 TEST(EmptyList, Find) { |
|
1524 auto list = cxEmptyList; |
|
1525 |
|
1526 int x = 42, y = 1337; |
|
1527 |
|
1528 EXPECT_LT(cxListFind(list, &x), 0); |
|
1529 EXPECT_LT(cxListFind(list, &y), 0); |
|
1530 } |
|
1531 |
|
1532 TEST(EmptyList, Compare) { |
|
1533 auto empty = cxEmptyList; |
|
1534 |
|
1535 auto ll = cxLinkedListCreateSimple(sizeof(int)); |
|
1536 auto al = cxArrayListCreateSimple(sizeof(int), 8); |
|
1537 |
|
1538 int x = 5; |
|
1539 |
|
1540 EXPECT_EQ(cxListCompare(empty, cxEmptyList), 0); |
|
1541 EXPECT_EQ(cxListCompare(ll, cxEmptyList), 0); |
|
1542 EXPECT_EQ(cxListCompare(al, cxEmptyList), 0); |
|
1543 EXPECT_EQ(cxListCompare(cxEmptyList, ll), 0); |
|
1544 EXPECT_EQ(cxListCompare(cxEmptyList, al), 0); |
|
1545 |
|
1546 cxListAdd(ll, &x); |
|
1547 cxListAdd(al, &x); |
|
1548 |
|
1549 EXPECT_GT(cxListCompare(ll, cxEmptyList), 0); |
|
1550 EXPECT_GT(cxListCompare(al, cxEmptyList), 0); |
|
1551 EXPECT_LT(cxListCompare(cxEmptyList, ll), 0); |
|
1552 EXPECT_LT(cxListCompare(cxEmptyList, al), 0); |
|
1553 |
|
1554 cxListDestroy(ll); |
|
1555 cxListDestroy(al); |
|
1556 } |