main
testtern.c
1/*
2 Copyright 2013 Michael Pavone
3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5*/
6#include "tern.h"
7#include <stdio.h>
8#include <stddef.h>
9
10int main(int argc, char ** argv)
11{
12 tern_node * tree = tern_insert_ptr(NULL, "foo", "bar");
13 tree = tern_insert_ptr(tree, "foobar", "baz");
14 tree = tern_insert_ptr(tree, "goobar", "qux");
15 tree = tern_insert_int(tree, "foobarbaz", 42);
16 tree = tern_insert_int(tree, "goobarbaz", 21);
17 printf("foo: %s\n", (char *)tern_find_ptr(tree, "foo"));
18 printf("foobar: %s\n", (char *)tern_find_ptr(tree, "foobar"));
19 printf("goobar: %s\n", (char *)tern_find_ptr(tree, "goobar"));
20 printf("foob: %s\n", (char *)tern_find_ptr(tree, "foob"));
21 printf("foobarbaz: %d\n", (int)tern_find_int(tree, "foobarbaz", 0));
22 printf("goobarbaz: %d\n", (int)tern_find_int(tree, "goobarbaz", 0));
23 printf("foobarb: %d\n", (int)tern_find_int(tree, "foobarb", 0));
24 return 0;
25}
26