add my unfinished cbase
This commit is contained in:
parent
501065651d
commit
bb63a9dd3c
16 changed files with 277 additions and 0 deletions
35
cbase/data/lists/linkedlist.test.c
Normal file
35
cbase/data/lists/linkedlist.test.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include<stdio.h>
|
||||
#include<assert.h>
|
||||
|
||||
#include "linkedlist.h"
|
||||
|
||||
void
|
||||
test_empty() {
|
||||
LinkedList* l = new_linkedlist();
|
||||
assert(count_linkedlist(l) == 0);
|
||||
delete_linkedlist(l);
|
||||
}
|
||||
|
||||
void
|
||||
test_single() {
|
||||
LinkedList* l = new_linkedlist();
|
||||
|
||||
int x = 42;
|
||||
int* p = &x;
|
||||
|
||||
append(l, p);
|
||||
assert(count_linkedlist(l) == 1);
|
||||
assert(first(l)->data == p);
|
||||
assert(last(l)->data == p);
|
||||
|
||||
delete_item(first(l));
|
||||
assert(count_linkedlist(l) == 0);
|
||||
|
||||
delete_linkedlist(l);
|
||||
}
|
||||
|
||||
int
|
||||
main() {
|
||||
test_empty();
|
||||
test_single();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue