moved method_dispatcher to subdirectory
This commit is contained in:
14
method_dispatcher/test/Makefile
Normal file
14
method_dispatcher/test/Makefile
Normal file
@@ -0,0 +1,14 @@
|
||||
CC=gcc
|
||||
|
||||
all: test_method_dispatcher
|
||||
|
||||
method_dispatcher: clean
|
||||
$(CC) ../method_dispatcher.c test_method_dispatcher.c -o method_dispatcher
|
||||
|
||||
test_method_dispatcher: method_dispatcher
|
||||
valgrind ./method_dispatcher
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
-rm method_dispatcher
|
51
method_dispatcher/test/test_method_dispatcher.c
Normal file
51
method_dispatcher/test/test_method_dispatcher.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include "../method_dispatcher.h"
|
||||
|
||||
char m1(uint8_t small_arg, void * state);
|
||||
char m2(uint8_t small_arg, void * state);
|
||||
char m3(uint8_t small_arg, void * state);
|
||||
char m4(uint8_t small_arg, void * state);
|
||||
char m5(uint8_t small_arg, void * state);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("sizeof struct dispatch_tree_node_s: %zd\n", sizeof(struct dispatch_tree_node_s));
|
||||
dispatch_tree_t tree = dispatch_tree_t_new();
|
||||
|
||||
dispatch_tree_t_insert(tree, 3 << 6, m3);
|
||||
dispatch_tree_t_insert(tree, 2 << 6, m2);
|
||||
dispatch_tree_t_insert(tree, 1 << 6, m1);
|
||||
dispatch_tree_t_insert(tree, 4 << 6, m4);
|
||||
dispatch_tree_t_insert(tree, 5 << 6, m5);
|
||||
|
||||
int i;
|
||||
for(i = 1; i < 6; i++)
|
||||
{
|
||||
dispatch_tree_t_dispatch(tree, i << 6)(i, NULL);
|
||||
}
|
||||
dispatch_tree_t_del(tree);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char m1(uint8_t small_arg, void * state)
|
||||
{
|
||||
printf("m1: %d\n", small_arg);
|
||||
}
|
||||
char m2(uint8_t small_arg, void * state)
|
||||
{
|
||||
printf("m2: %d\n", small_arg);
|
||||
}
|
||||
char m3(uint8_t small_arg, void * state)
|
||||
{
|
||||
printf("m3: %d\n", small_arg);
|
||||
}
|
||||
char m4(uint8_t small_arg, void * state)
|
||||
{
|
||||
printf("m4: %d\n", small_arg);
|
||||
}
|
||||
char m5(uint8_t small_arg, void * state)
|
||||
{
|
||||
printf("m5: %d\n", small_arg);
|
||||
}
|
Reference in New Issue
Block a user