| 1 |
/* HEADER Testing the container API */ |
| 2 |
|
| 3 |
netsnmp_container *container; |
| 4 |
void *p; |
| 5 |
|
| 6 |
init_snmp("container-test"); |
| 7 |
container = netsnmp_container_find("fifo"); |
| 8 |
container->compare = netsnmp_str_compare; |
| 9 |
|
| 10 |
CONTAINER_INSERT(container, "foo"); |
| 11 |
CONTAINER_INSERT(container, "bar"); |
| 12 |
CONTAINER_INSERT(container, "baz"); |
| 13 |
|
| 14 |
OK(CONTAINER_FIND(container, "bar") != NULL, |
| 15 |
"should be able to find the stored 'bar' string"); |
| 16 |
|
| 17 |
OK(CONTAINER_FIND(container, "foobar") == NULL, |
| 18 |
"shouldn't be able to find the (not) stored 'foobar' string"); |
| 19 |
|
| 20 |
OK(CONTAINER_SIZE(container) == 3, |
| 21 |
"container has the proper size for the elements we've added"); |
| 22 |
|
| 23 |
CONTAINER_REMOVE(container, "bar"); |
| 24 |
|
| 25 |
OK(CONTAINER_FIND(container, "bar") == NULL, |
| 26 |
"should no longer be able to find the (reoved) 'bar' string"); |
| 27 |
|
| 28 |
OK(CONTAINER_SIZE(container) == 2, |
| 29 |
"container has the proper size for the elements after a removal"); |
| 30 |
|
| 31 |
while ((p = CONTAINER_FIRST(container))) |
| 32 |
CONTAINER_REMOVE(container, p); |
| 33 |
CONTAINER_FREE(container); |
| 34 |
|
| 35 |
snmp_shutdown("container-test"); |