test.c (2185B)
1 #include <stdio.h> 2 3 #include "ns.h" 4 5 int main( void ) 6 { 7 ns_t* test = ns_init(10); 8 9 var_cont* testing = var_new(G_INT); 10 var_set(testing, var_data_alloc_G_INT(42), G_INT); 11 12 printf("testing: %li, %i\n", testing->ownership, 13 var_data_get_G_INT(testing)); 14 15 ns_dec(test, G_INT, 0, 2); 16 ns_set(test, 0, 2, testing); 17 18 var_cont* testing_on_namespace = ns_get(test, 0, 2); 19 printf("testing_on_namespace: %li, %i\n", testing_on_namespace->ownership, 20 var_data_get_G_INT(testing)); 21 22 ns_push(test, 5); 23 24 var_cont* testing_2 = var_new(G_INT); 25 var_set(testing_2, var_data_alloc_G_INT(24), G_INT); 26 27 ns_dec(test, G_INT, 0, 1); 28 ns_set(test, 0, 1, testing_2); 29 30 var_cont* testing_on_namespace_1 = ns_get(test, 0, 1); 31 printf("testing_on_namespace: %li, %i\n", testing_on_namespace_1->ownership, 32 var_data_get_G_INT(testing)); 33 34 ns_dec(test, G_INT, 0, 2); 35 ns_set(test, 0, 2, testing); 36 37 var_cont* testing_on_namespace_2 = ns_get(test, 0, 2); 38 printf("testing_on_namespace: %li, %i\n", testing_on_namespace_2->ownership, 39 var_data_get_G_INT(testing)); 40 41 ns_push(test, 5); 42 43 ns_dec(test, G_INT, 0, 2); 44 ns_set(test, 0, 2, testing); 45 46 var_cont* testing_on_namespace_3 = ns_get(test, 0, 2); 47 printf("testing_on_namespace: %li, %i\n", testing_on_namespace_3->ownership, 48 var_data_get_G_INT(testing)); 49 50 printf("Namespace info: %d, %li\n", test->last->size, test->last->level); 51 52 ns_pop(test); 53 54 var_cont* testing_on_namespace_4 = ns_get(test, 0, 2); 55 printf("testing_on_namespace: %li, %i\n", testing_on_namespace_4->ownership, 56 var_data_get_G_INT(testing)); 57 58 printf("Namespace info: %d, %li\n", test->last->size, test->last->level); 59 60 ns_pop(test); 61 62 var_cont* testing_on_namespace_5 = ns_get(test, 0, 2); 63 printf("testing_on_namespace: %li, %i\n", testing_on_namespace_5->ownership, 64 var_data_get_G_INT(testing)); 65 66 printf("Namespace info: %d, %li\n", test->last->size, test->last->level); 67 68 ns_del(test); 69 70 return 0; 71 }