MCPcopy Create free account
hub / github.com/F-Stack/f-stack / quicklistTest

Function quicklistTest

app/redis-6.2.6/src/quicklist.c:1713–2784  ·  view source on GitHub ↗

main test, but callable from other files */

Source from the content-addressed store, hash-verified

1711
1712/* main test, but callable from other files */
1713int quicklistTest(int argc, char *argv[], int accurate) {
1714 UNUSED(argc);
1715 UNUSED(argv);
1716 UNUSED(accurate);
1717
1718 unsigned int err = 0;
1719 int optimize_start =
1720 -(int)(sizeof(optimization_level) / sizeof(*optimization_level));
1721
1722 printf("Starting optimization offset at: %d\n", optimize_start);
1723
1724 int options[] = {0, 1, 2, 3, 4, 5, 6, 10};
1725 int fills[] = {-5, -4, -3, -2, -1, 0,
1726 1, 2, 32, 66, 128, 999};
1727 size_t option_count = sizeof(options) / sizeof(*options);
1728 int fill_count = (int)(sizeof(fills) / sizeof(*fills));
1729 long long runtime[option_count];
1730
1731 for (int _i = 0; _i < (int)option_count; _i++) {
1732 printf("Testing Compression option %d\n", options[_i]);
1733 long long start = mstime();
1734
1735 TEST("create list") {
1736 quicklist *ql = quicklistNew(-2, options[_i]);
1737 ql_verify(ql, 0, 0, 0, 0);
1738 quicklistRelease(ql);
1739 }
1740
1741 TEST("add to tail of empty list") {
1742 quicklist *ql = quicklistNew(-2, options[_i]);
1743 quicklistPushTail(ql, "hello", 6);
1744 /* 1 for head and 1 for tail because 1 node = head = tail */
1745 ql_verify(ql, 1, 1, 1, 1);
1746 quicklistRelease(ql);
1747 }
1748
1749 TEST("add to head of empty list") {
1750 quicklist *ql = quicklistNew(-2, options[_i]);
1751 quicklistPushHead(ql, "hello", 6);
1752 /* 1 for head and 1 for tail because 1 node = head = tail */
1753 ql_verify(ql, 1, 1, 1, 1);
1754 quicklistRelease(ql);
1755 }
1756
1757 TEST_DESC("add to tail 5x at compress %d", options[_i]) {
1758 for (int f = 0; f < fill_count; f++) {
1759 quicklist *ql = quicklistNew(fills[f], options[_i]);
1760 for (int i = 0; i < 5; i++)
1761 quicklistPushTail(ql, genstr("hello", i), 32);
1762 if (ql->count != 5)
1763 ERROR;
1764 if (fills[f] == 32)
1765 ql_verify(ql, 1, 5, 5, 5);
1766 quicklistRelease(ql);
1767 }
1768 }
1769
1770 TEST_DESC("add to head 5x at compress %d", options[_i]) {

Callers

nothing calls this directly

Calls 15

quicklistNewFunction · 0.85
quicklistReleaseFunction · 0.85
quicklistPushTailFunction · 0.85
quicklistPushHeadFunction · 0.85
genstrFunction · 0.85
quicklistRotateFunction · 0.85
ql_infoFunction · 0.85
quicklistPopFunction · 0.85
strcmpFunction · 0.85
quicklistSetFillFunction · 0.85
quicklistGetIteratorFunction · 0.85
quicklistNextFunction · 0.85

Tested by

no test coverage detected