/* * KNOWN FAILING -- TODO.md section 2.1.1 * * aksl_list_append conflates Floyd cycle detection with finding the tail: the * `tail` cursor is assigned from `slow` *before* `slow` advances, so it tracks * the node behind the list midpoint rather than the last node. Appending to any * list of two or more nodes therefore overwrites an interior link and silently * drops every node after it. * * Appending n1..n4 to n0 produces the chain "n0 -> n4"; this test asserts the * correct "n0 -> n1 -> n2 -> n3 -> n4" and so fails until append is fixed. * It is registered in AKSL_KNOWN_FAILING_TESTS, which marks it WILL_FAIL; when * the fix lands, CTest will report it as unexpectedly passing, which is the * signal to move it into AKSL_TESTS. */ #include "aksl_capture.h" #define CHAIN_LEN 5 static int test_append_builds_full_chain(void) { aksl_ListNode node[CHAIN_LEN]; aksl_ListNode *walk = NULL; int i = 0; memset((void *)node, 0x00, sizeof(node)); for ( i = 1; i < CHAIN_LEN; i++ ) { AKSL_CHECK_OK(aksl_list_append(&node[0], &node[i])); } /* Forward links, head to tail. */ walk = &node[0]; for ( i = 0; i < CHAIN_LEN; i++ ) { AKSL_CHECK(walk == &node[i]); walk = walk->next; } AKSL_CHECK(walk == NULL); /* Back links, tail to head. */ walk = &node[CHAIN_LEN - 1]; for ( i = CHAIN_LEN - 1; i >= 0; i-- ) { AKSL_CHECK(walk == &node[i]); walk = walk->prev; } AKSL_CHECK(walk == NULL); return 0; } int main(void) { int failures = 0; akerr_init(); AKSL_RUN(failures, test_append_builds_full_chain); AKSL_REPORT(failures); }