more test cases
This commit is contained in:
parent
0725e0fd1c
commit
5ad409f23d
29
main.cpp
29
main.cpp
@ -7,10 +7,39 @@ void test_basics(amap mapdo, void *map) {
|
||||
assert(NULL == mapdo(map, AMAP_GET, "asdf", NULL));
|
||||
int i = 42;
|
||||
int *iptr;
|
||||
const char *chptr;
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning", &i));
|
||||
assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning", NULL)));
|
||||
assert(*iptr == 42);
|
||||
assert(iptr == &i);
|
||||
|
||||
/* Delete / tombstone */
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning", NULL));
|
||||
|
||||
/* Check re-adding */
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning", &i));
|
||||
assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning", NULL)));
|
||||
assert(*iptr == 42);
|
||||
assert(iptr == &i);
|
||||
|
||||
/* Test Erase */
|
||||
assert(NULL != mapdo(map, AMAP_ERASE, NULL, NULL));
|
||||
|
||||
/* Check re-adding 3 new things */
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning1", &i));
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning2", &i));
|
||||
const char *helloworld = "Hello world!";
|
||||
assert(NULL != mapdo(map, AMAP_SET, "hello", (char *)helloworld)); /* TODO: ugly cast... */
|
||||
|
||||
assert(NULL != (chptr = (const char *)mapdo(map, AMAP_GET, "hello", NULL)));
|
||||
assert(strlen(chptr) == strlen(helloworld));
|
||||
assert(strcmp(chptr, helloworld) == 0);
|
||||
assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning2", NULL)));
|
||||
assert(*iptr == 42);
|
||||
assert(iptr == &i);
|
||||
assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning1", NULL)));
|
||||
assert(*iptr == 42);
|
||||
assert(iptr == &i);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user