Debian Codegraph @

testing/fulltests/unit-tests/T001defaultstore_clib.c

raw
1 /* HEADER Testing the default_store API */
2 int i, j;
3 char buf[1024];
4
5 /* first we load everything up */
6
7 for(i = 0; i < NETSNMP_DS_MAX_IDS; i++) {
8 /* booleans */
9 for(j = 0; j < NETSNMP_DS_MAX_SUBIDS; j++) {
10 OKF(SNMPERR_SUCCESS == netsnmp_ds_set_boolean(i, j, (i*j)%2),
11 ("default store boolean: setting %d/%d returned failure", i, j));
12 OKF(SNMPERR_SUCCESS == netsnmp_ds_set_int(i, j, i*j),
13 ("default store int: setting %d/%d returned failure", i, j));
14 snprintf(buf, sizeof(buf), "%d/%d", i, j);
15 OKF(SNMPERR_SUCCESS == netsnmp_ds_set_string(i, j, buf),
16 ("default store string: setting %d/%d returned failure", i, j));
17 }
18 }
19
20 /* then we check all the values */
21
22 for(i = 0; i < NETSNMP_DS_MAX_IDS; i++) {
23 /* booleans */
24 for(j = 0; j < NETSNMP_DS_MAX_SUBIDS; j++) {
25 OKF(netsnmp_ds_get_boolean(i, j) == (i*j)%2,
26 ("default store boolean %d/%d was the expected value", i, j));
27 OKF(netsnmp_ds_get_int(i, j) == (i*j),
28 ("default store int %d/%d was the expected value", i, j));
29 snprintf(buf, sizeof(buf), "%d/%d", i, j);
30 OKF(strcmp(netsnmp_ds_get_string(i, j), buf) == 0,
31 ("default store string %d/%d was the expected value", i, j));
32 }
33 }
34
35 netsnmp_ds_shutdown();