Index: trunk/tests/Makefile =================================================================== --- trunk/tests/Makefile (revision 2734) +++ trunk/tests/Makefile (revision 2735) @@ -4,3 +4,4 @@ cd strflags && make all && make test cd pcb-printf && make all && make test cd uniq_name && make all && make test + cd propedit && make all && make test Index: trunk/tests/propedit/Makefile =================================================================== --- trunk/tests/propedit/Makefile (nonexistent) +++ trunk/tests/propedit/Makefile (revision 2735) @@ -0,0 +1,27 @@ +ROOT=../.. +PED=$(ROOT)/src_plugins/propedit +LHT=$(ROOT)/src_3rd/liblihata +SRC=$(ROOT)/src + +CFLAGS = -g -Wall -I$(PED) -I$(LHT) -I$(SRC) -I$(ROOT) -I$(ROOT)/src_3rd +LIB_OBJS=$(LHT)/genht/htsp.o $(LHT)/genht/hash.o +# $(SRC)/compat_misc.o + +all: tester + +test: tester.diff + @echo "*** All ok, QC passed ***" + @rm tester.out + +tester: tester.o $(PED)/props.o $(LIB_OBJS) + +tester.o: tester.c $(PED)/props.h + +$(PED)/props.o: $(PED)/props.c $(PED)/props.h + +tester.diff: tester.ref tester.out + @diff -u tester.ref tester.out + +tester.out: tester + ./tester > tester.out + Index: trunk/tests/propedit/tester.c =================================================================== --- trunk/tests/propedit/tester.c (nonexistent) +++ trunk/tests/propedit/tester.c (revision 2735) @@ -0,0 +1,65 @@ +#include +#include +#include "props.h" + +void print_all(htsp_t *props) +{ + htsp_entry_t *pe; + for (pe = htsp_first(props); pe; pe = htsp_next(props, pe)) { + htprop_entry_t *e; + pcb_props_t *p = pe->value; + printf("%s [%s]\n", pe->key, pcb_props_type_name(p->type)); + for (e = htprop_first(&p->values); e; e = htprop_next(&p->values, e)) { + switch(p->type) { + case PCB_PROPT_STRING: printf(" %s", e->key.string); break; + case PCB_PROPT_COORD: printf(" %d", e->key.coord); break; + case PCB_PROPT_ANGLE: printf(" %f", e->key.angle); break; + case PCB_PROPT_INT: printf(" %d", e->key.i); break; + default: printf(" ???"); + } + printf(" (%lu)\n", e->value); + } + } +} + +int main() +{ + htsp_t *props = pcb_props_init(); + assert(props != NULL); + pcb_propval_t v; + + /* --- add a few items properly - should work --- */ + + /* coord */ + v.coord = 42; assert(pcb_props_add(props, "crd", PCB_PROPT_COORD, v) != NULL); + v.coord = 10; assert(pcb_props_add(props, "crd", PCB_PROPT_COORD, v) != NULL); + v.coord = 42; assert(pcb_props_add(props, "crd", PCB_PROPT_COORD, v) != NULL); + v.coord = 42; assert(pcb_props_add(props, "crd", PCB_PROPT_COORD, v) != NULL); + + /* int */ + v.i = 42; assert(pcb_props_add(props, "num", PCB_PROPT_INT, v) != NULL); + v.i = 10; assert(pcb_props_add(props, "num", PCB_PROPT_INT, v) != NULL); + v.i = 42; assert(pcb_props_add(props, "num", PCB_PROPT_INT, v) != NULL); + v.i = 42; assert(pcb_props_add(props, "num", PCB_PROPT_INT, v) != NULL); + + /* angle */ + v.angle = 42.0; assert(pcb_props_add(props, "ang", PCB_PROPT_ANGLE, v) != NULL); + v.angle = 10.5; assert(pcb_props_add(props, "ang", PCB_PROPT_ANGLE, v) != NULL); + v.angle = 42.0; assert(pcb_props_add(props, "ang", PCB_PROPT_ANGLE, v) != NULL); + v.angle = 42.0; assert(pcb_props_add(props, "ang", PCB_PROPT_ANGLE, v) != NULL); + + /* string */ + v.string = "foo"; assert(pcb_props_add(props, "str", PCB_PROPT_STRING, v) != NULL); + v.string = "bar"; assert(pcb_props_add(props, "str", PCB_PROPT_STRING, v) != NULL); + v.string = "BAZ"; assert(pcb_props_add(props, "str", PCB_PROPT_STRING, v) != NULL); + v.string = "foo"; assert(pcb_props_add(props, "str", PCB_PROPT_STRING, v) != NULL); + v.string = "foo"; assert(pcb_props_add(props, "str", PCB_PROPT_STRING, v) != NULL); + + /* --- add a items with the wrong type - should fail --- */ + v.i = 42; assert(pcb_props_add(props, "crd", PCB_PROPT_INT, v) == NULL); + v.i = 42; assert(pcb_props_add(props, "crd", 1234, v) == NULL); + v.i = 42; assert(pcb_props_add(props, "ang", 1234, v) == NULL); + + + print_all(props); +} Index: trunk/tests/propedit/tester.ref =================================================================== --- trunk/tests/propedit/tester.ref (nonexistent) +++ trunk/tests/propedit/tester.ref (revision 2735) @@ -0,0 +1,13 @@ +num [int] + 42 (3) + 10 (1) +ang [angle] + 42.000000 (3) + 10.500000 (1) +crd [coord] + 42 (3) + 10 (1) +str [string] + foo (3) + bar (1) + BAZ (1)