summaryrefslogtreecommitdiff
path: root/testing/fulltests/unit-tests/T001defaultstore_clib.c
diff options
context:
space:
mode:
authorHideki Yamane <henrich@debian.org>2014-03-30 19:38:48 +0900
committerHideki Yamane <henrich@debian.org>2014-03-30 19:38:48 +0900
commit7769a9595c3da9a35f31b42451b1f6c3ed4004fa (patch)
tree009bf8fd68af6bb1129e07dd8c1ed205010d81f8 /testing/fulltests/unit-tests/T001defaultstore_clib.c
parent2e7891b0311204e0ecd5dc4a4334df01f3a6a1b4 (diff)
downloadpkg-net-snmp-7769a9595c3da9a35f31b42451b1f6c3ed4004fa.tar.gz
Imported Upstream version 5.7.2~dfsg
Diffstat (limited to 'testing/fulltests/unit-tests/T001defaultstore_clib.c')
-rw-r--r--testing/fulltests/unit-tests/T001defaultstore_clib.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/testing/fulltests/unit-tests/T001defaultstore_clib.c b/testing/fulltests/unit-tests/T001defaultstore_clib.c
new file mode 100644
index 0000000..0144f7d
--- /dev/null
+++ b/testing/fulltests/unit-tests/T001defaultstore_clib.c
@@ -0,0 +1,35 @@
+/* HEADER Testing the default_store API */
+int i, j;
+char buf[1024];
+
+/* first we load everything up */
+
+for(i = 0; i < NETSNMP_DS_MAX_IDS; i++) {
+ /* booleans */
+ for(j = 0; j < NETSNMP_DS_MAX_SUBIDS; j++) {
+ OKF(SNMPERR_SUCCESS == netsnmp_ds_set_boolean(i, j, (i*j)%2),
+ ("default store boolean: setting %d/%d returned failure", i, j));
+ OKF(SNMPERR_SUCCESS == netsnmp_ds_set_int(i, j, i*j),
+ ("default store int: setting %d/%d returned failure", i, j));
+ sprintf(buf,"%d/%d", i, j);
+ OKF(SNMPERR_SUCCESS == netsnmp_ds_set_string(i, j, buf),
+ ("default store string: setting %d/%d returned failure", i, j));
+ }
+}
+
+/* then we check all the values */
+
+for(i = 0; i < NETSNMP_DS_MAX_IDS; i++) {
+ /* booleans */
+ for(j = 0; j < NETSNMP_DS_MAX_SUBIDS; j++) {
+ OKF(netsnmp_ds_get_boolean(i, j) == (i*j)%2,
+ ("default store boolean %d/%d was the expected value", i, j));
+ OKF(netsnmp_ds_get_int(i, j) == (i*j),
+ ("default store int %d/%d was the expected value", i, j));
+ sprintf(buf,"%d/%d", i, j);
+ OKF(strcmp(netsnmp_ds_get_string(i, j), buf) == 0,
+ ("default store string %d/%d was the expected value", i, j));
+ }
+}
+
+netsnmp_ds_shutdown();