1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

better psyc_dict_lookup

This commit is contained in:
tg(x) 2012-01-09 11:52:09 +01:00
parent dbcd35102b
commit 382fd3c779
9 changed files with 156 additions and 174 deletions

View file

@ -3,7 +3,7 @@ DEBUG = 2
CFLAGS = -I../include -I../src -Wall -std=c99 ${OPT}
LDFLAGS = -L../lib
LOADLIBES = -lpsyc -lm
TARGETS = test_psyc test_psyc_speed test_parser test_match test_render test_text var_is_routing var_type uniform_parse test_list test_table test_packet_id
TARGETS = test_psyc test_psyc_speed test_parser test_match test_render test_text var_is_routing var_type uniform_parse test_list test_table test_packet_id method
O = test.o
WRAPPER =
DIET = diet

29
test/method.c Normal file
View file

@ -0,0 +1,29 @@
#include <psyc.h>
#include <stdio.h>
#include <lib.h>
int main()
{
PsycMethod family = 0;
unsigned int flag = 0;
int i;
for (i = 0; i < psyc_methods_num; i++)
if (psyc_method(PSYC_S2ARG(psyc_methods[i].key), &family, &flag)
!= psyc_methods[i].value)
return i + 1;
if (psyc_method(PSYC_C2ARG("_echo_hallo"), &family, &flag) != PSYC_MC_UNKNOWN
&& family != PSYC_MC_ECHO)
return 101;
if (psyc_method(PSYC_C2ARG("_foo_bar"), &family, &flag) != PSYC_MC_UNKNOWN)
return 102;
if (psyc_method(PSYC_C2ARG("_warning_test"), &family, &flag) != PSYC_MC_WARNING
&& family != PSYC_MC_WARNING)
return 103;
printf("psyc_method passed all tests.\n");
return 0;
}

View file

@ -5,16 +5,23 @@
#include <lib.h>
int main() {
unless (psyc_var_type(PSYC_C2ARG("_list"))) return 1;
unless (psyc_var_type(PSYC_C2ARG("_list_foo"))) return 2;
unless (psyc_var_type(PSYC_C2ARG("_color_red"))) return 3;
if (psyc_var_type(PSYC_C2ARG("_last"))) return 4;
if (psyc_var_type(PSYC_C2ARG("_lost_foo"))) return 5;
if (psyc_var_type(PSYC_C2ARG("_colorful"))) return 6;
if (psyc_var_type(PSYC_C2ARG("_foo"))) return 7;
if (psyc_var_type(PSYC_C2ARG("bar"))) return 8;
if (psyc_var_type(PSYC_C2ARG("______"))) return 9;
if (psyc_var_type(PSYC_C2ARG("_"))) return 10;
int i;
for (i = 0; i < psyc_var_types_num; i++)
if (psyc_var_type(PSYC_S2ARG(psyc_var_types[i].key))
!= psyc_var_types[i].value)
return i + 1;
unless (psyc_var_type(PSYC_C2ARG("_list"))) return 51;
unless (psyc_var_type(PSYC_C2ARG("_list_foo"))) return 52;
unless (psyc_var_type(PSYC_C2ARG("_color_red"))) return 53;
if (psyc_var_type(PSYC_C2ARG("_last"))) return 104;
if (psyc_var_type(PSYC_C2ARG("_lost_foo"))) return 105;
if (psyc_var_type(PSYC_C2ARG("_colorful"))) return 106;
if (psyc_var_type(PSYC_C2ARG("_foo"))) return 107;
if (psyc_var_type(PSYC_C2ARG("bar"))) return 108;
if (psyc_var_type(PSYC_C2ARG("______"))) return 109;
if (psyc_var_type(PSYC_C2ARG("_"))) return 110;
puts("psyc_var_type passed all tests.");
return 0; // passed all tests