fix(formatting): :retab
This commit is contained in:
parent
5a485445ed
commit
a56daaf6b8
2 changed files with 229 additions and 229 deletions
98
test.c
98
test.c
|
|
@ -4,70 +4,70 @@
|
|||
|
||||
#include "ds.h"
|
||||
|
||||
#define test(name, tests) do { \
|
||||
const char *_test_name = name; \
|
||||
int _tests_passed = 0; \
|
||||
int _tests = 0; \
|
||||
tests \
|
||||
_tests_passed += _tests; \
|
||||
printf("%s: %d/%d tests passed\n", name, _tests_passed, _tests); \
|
||||
} while (0)
|
||||
#define test(name, tests) do { \
|
||||
const char *_test_name = name; \
|
||||
int _tests_passed = 0; \
|
||||
int _tests = 0; \
|
||||
tests \
|
||||
_tests_passed += _tests; \
|
||||
printf("%s: %d/%d tests passed\n", name, _tests_passed, _tests); \
|
||||
} while (0)
|
||||
|
||||
#define it(message, test) do { \
|
||||
_tests++; \
|
||||
if (!(test)) { \
|
||||
printf("%s %s FAILED\n", _test_name, message); \
|
||||
_tests_passed--; \
|
||||
} \
|
||||
#define it(message, test) do { \
|
||||
_tests++; \
|
||||
if (!(test)) { \
|
||||
printf("%s %s FAILED\n", _test_name, message); \
|
||||
_tests_passed--; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct {
|
||||
int num;
|
||||
char *str;
|
||||
int num;
|
||||
char *str;
|
||||
} complex;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
test("sll",
|
||||
char *a = "one";
|
||||
test("sll",
|
||||
char *a = "one";
|
||||
|
||||
ds_sll_t *tmp;
|
||||
it("creates a new linked list", tmp = ds_sll_init());
|
||||
free(tmp);
|
||||
ds_sll_t *tmp;
|
||||
it("creates a new linked list", tmp = ds_sll_init());
|
||||
free(tmp);
|
||||
|
||||
ds_sll_t *ll = ds_sll_new_node(a);
|
||||
it("inserts an invalid item", ds_sll_insert(ll, NULL) == -1);
|
||||
it("removes an invalid index", ds_sll_remove(&ll, 1234) == NULL);
|
||||
it("removes an item", a == ds_sll_remove(&ll, 0));
|
||||
);
|
||||
ds_sll_t *ll = ds_sll_new_node(a);
|
||||
it("inserts an invalid item", ds_sll_insert(ll, NULL) == -1);
|
||||
it("removes an invalid index", ds_sll_remove(&ll, 1234) == NULL);
|
||||
it("removes an item", a == ds_sll_remove(&ll, 0));
|
||||
);
|
||||
|
||||
test("dll",
|
||||
char *a = "one";
|
||||
test("dll",
|
||||
char *a = "one";
|
||||
|
||||
ds_dll_t *tmp;
|
||||
it("creates a new linked list", tmp = ds_dll_init());
|
||||
free(tmp);
|
||||
ds_dll_t *tmp;
|
||||
it("creates a new linked list", tmp = ds_dll_init());
|
||||
free(tmp);
|
||||
|
||||
ds_dll_t *ll = ds_dll_new_node(a);
|
||||
it("inserts an invalid item", ds_dll_insert(ll, NULL) == -1);
|
||||
it("removes an invalid index", ds_dll_remove(&ll, 1234) == NULL);
|
||||
it("removes an item", a == ds_dll_remove(&ll, 0));
|
||||
);
|
||||
ds_dll_t *ll = ds_dll_new_node(a);
|
||||
it("inserts an invalid item", ds_dll_insert(ll, NULL) == -1);
|
||||
it("removes an invalid index", ds_dll_remove(&ll, 1234) == NULL);
|
||||
it("removes an item", a == ds_dll_remove(&ll, 0));
|
||||
);
|
||||
|
||||
test("hmp",
|
||||
complex *a = calloc(1, sizeof(complex));
|
||||
a->num = 1;
|
||||
a->str = "abc";
|
||||
test("hmp",
|
||||
complex *a = calloc(1, sizeof(complex));
|
||||
a->num = 1;
|
||||
a->str = "abc";
|
||||
|
||||
ds_hmp_t *hmp = ds_hmp_init(101);
|
||||
it("inserts an item", ds_hmp_insert(hmp, a->str, a) == 0);
|
||||
it("generates a hash", _ds_hmp_gen_hash("a") == 177670);
|
||||
it("removes a non-existent item", ds_hmp_remove(hmp, "???") == NULL);
|
||||
it("removes an invalid item", ds_hmp_remove(hmp, NULL) == NULL);
|
||||
it("removes an item", a == ds_hmp_remove(hmp, a->str));
|
||||
ds_hmp_free(&hmp, NULL);
|
||||
ds_hmp_t *hmp = ds_hmp_init(101);
|
||||
it("inserts an item", ds_hmp_insert(hmp, a->str, a) == 0);
|
||||
it("generates a hash", _ds_hmp_gen_hash("a") == 177670);
|
||||
it("removes a non-existent item", ds_hmp_remove(hmp, "???") == NULL);
|
||||
it("removes an invalid item", ds_hmp_remove(hmp, NULL) == NULL);
|
||||
it("removes an item", a == ds_hmp_remove(hmp, a->str));
|
||||
ds_hmp_free(&hmp, NULL);
|
||||
|
||||
free(a);
|
||||
);
|
||||
free(a);
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue