summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-06-02 00:00:53 +0100
committerFreeArtMan <dos21h@gmail.com>2017-06-02 00:00:53 +0100
commit65fb94f8fd98d343ae49f7d7e576418dba5a5d46 (patch)
tree18e829c87d174fdc7506dcd61c3299f8a6d3c8a0
parent784a5524e7aa02f98e070bdd3dc7f4d603f3ffe8 (diff)
downloadnetbytes-65fb94f8fd98d343ae49f7d7e576418dba5a5d46.tar.gz
netbytes-65fb94f8fd98d343ae49f7d7e576418dba5a5d46.zip
Added new test cases
-rw-r--r--test/test_key_value_load.c82
-rw-r--r--test/test_key_value_store.c53
2 files changed, 135 insertions, 0 deletions
diff --git a/test/test_key_value_load.c b/test/test_key_value_load.c
new file mode 100644
index 0000000..f020e34
--- /dev/null
+++ b/test/test_key_value_load.c
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <netbytes.h>
+
+void pr_u8( nb_u8 *u8 )
+{
+ if ( !u8 )
+ {
+ printf("u8: NULL\n");
+ return;
+ } else
+ {
+ printf("u8: t=0x%x v=0x%x\n", u8->type, u8->val );
+ }
+}
+
+void pr_u8arr( nb_u8arr *u8arr )
+{
+ if (!u8arr)
+ {
+ printf("u8arr: NULL\n");
+ return ;
+ } else
+ {
+ printf("u8arr: t=0x%x l=0x%x v=0x%x\n",
+ u8arr->type, u8arr->len, u8arr->val );
+ }
+}
+
+void pr_store( netbyte_store *nb )
+{
+ int i;
+
+ if (!nb)
+ {
+ printf("nb: NULL\n");
+ return;
+ }
+
+ printf("nb: s=0x%x c=0x%x\n", nb->size, nb->count );
+ for (i=0;i<nb->count;i++)
+ {
+ printf("\t[%x] -> ",i );
+ if ( nb->types[i].type == NBT_U8 )
+ {
+ pr_u8( (nb_u8 *)nb->types[i].nb_val );
+ } else if ( nb->types[i].type == NBT_U8ARRAY )
+ {
+ pr_u8arr( (nb_u8arr *)nb->types[i].nb_val );
+ } else
+ {
+ printf("Unknown\n");
+ }
+ }
+}
+
+int main()
+{
+
+ int er;
+ uint8_t *res;
+ FILE *f;
+ int i=0;
+
+ netbyte_store nb;
+
+ printf("Start test\n");
+ nb_init( &nb );
+
+ f = fopen("test_many.nb","r");
+ while (nb_fread( &nb, fileno(f) ) == 0)
+ {
+ printf("ITER %d: ", i );
+ pr_store( &nb );
+ i += 1;
+ }
+ fclose( f );
+
+ printf("End test\n");
+ return 0;
+} \ No newline at end of file
diff --git a/test/test_key_value_store.c b/test/test_key_value_store.c
new file mode 100644
index 0000000..983b3b8
--- /dev/null
+++ b/test/test_key_value_store.c
@@ -0,0 +1,53 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <netbytes.h>
+
+typedef struct kv_user_name
+{
+ int id;
+ char *name;
+ char *desc;
+} kv_user_name;
+
+kv_user_name* kv_new(int id, char *name, char *desc)
+{
+
+}
+
+netbyte_store* kv_marsh(kv_user_name *kv)
+{
+ return NULL;
+}
+
+void kv_free()
+{
+
+}
+
+
+int main()
+{
+
+ int er;
+ uint8_t *res;
+ FILE *f;
+ int i=0;
+
+ netbyte_store nb;
+
+ printf("Start test\n");
+ nb_init( &nb );
+
+ f = fopen("test_many.nb","r");
+ while (nb_fread( &nb, fileno(f) ) == 0)
+ {
+ printf("ITER %d: ", i );
+ pr_store( &nb );
+ i += 1;
+ }
+ fclose( f );
+
+ printf("End test\n");
+ return 0;
+} \ No newline at end of file