X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=sidebyside;f=tests%2Frelationtests.c;h=7b565b626c456ff4877904d8a16d010305ae6251;hb=e938f8c45fd191d96da48f65262e4efcfada7805;hp=15c23f2596f4b2adbd0f34173a2a9bca9c411d76;hpb=6fcd4ffc18696dbf4c11be32837a2035ea5ee92f;p=rrq%2Frrqmisc.git diff --git a/tests/relationtests.c b/tests/relationtests.c index 15c23f2..7b565b6 100644 --- a/tests/relationtests.c +++ b/tests/relationtests.c @@ -1,13 +1,13 @@ /** - * This is a collection of tests of the relation functions. + * This is a collection of tests of the Relation functions. */ #include #include -#include +#include #define SIZE(x) (sizeof(x)/sizeof(void*)) -static char *tuple2string(relation *r,tuple *t) { +static char *tuple2string(Relation *r,tuple *t) { #define LIMIT 10000 static char tmp[10][ LIMIT ]; static int i = 0; @@ -24,15 +24,15 @@ static char *tuple2string(relation *r,tuple *t) { return tmp[i++]; } -static void query_report(relation *r,tuple *query) { - vector_index i; +static void query_report(Relation *r,tuple *query) { + VectorIndex i; for ( i = 0; i < r->content.table.size; i++ ) { - tuple *t = hashvector_next( &r->content, &i, query ); + tuple *t = HashVector_next( &r->content, &i, query ); fprintf( stderr, "check %s\n", tuple2string( r, t ) ); } } -static void query_report_all(relation *r,tuple *query[]) { +static void query_report_all(Relation *r,tuple *query[]) { int j; for ( j = 0; query[j]; j++ ) { fprintf( stderr, "query %s\n", tuple2string( r, query[j] ) ); @@ -40,35 +40,35 @@ static void query_report_all(relation *r,tuple *query[]) { } } -// Report any knocked out tuples from relation_add or relation_delete -// This will also clear and free the result vector. -static void knockout_report(relation *r,vector *v) { - vector_index i; +// Report any knocked out tuples from Relation_add or Relation_delete +// This will also clear and free the result Vector. +static void knockout_report(Relation *r,Vector *v) { + VectorIndex i; if ( v ) { for ( i = 0; i < v->size; i++ ) { - tuple **t = (tuple **) vector_next_used( v, &i ); + tuple **t = (tuple **) Vector_next_used( v, &i ); fprintf( stderr, "knock %s\n", tuple2string( r, t? *t : 0 ) ); } - vector_resize( v, 0, vector_clear_any, 0 ); + Vector_resize( v, 0, Vector_clear_any, 0 ); free( v ); } } // Test addition with several tuples, terminated by 0 -static void test_relation_add(relation *r,tuple *query[]) { +static void test_Relation_add(Relation *r,tuple *query[]) { int j; for ( j = 0; query[j]; j++ ) { fprintf( stderr, "add %s\n", tuple2string( r, query[j] ) ); - knockout_report( r, relation_add( r, query[j] ) ); + knockout_report( r, Relation_add( r, query[j] ) ); } } // Test deletion with several queries, terminated by 0 -static void test_relation_delete(relation *r,tuple *query[]) { +static void test_Relation_delete(Relation *r,tuple *query[]) { int j; for ( j = 0; query[j]; j++ ) { fprintf( stderr, "delete %s\n", tuple2string( r, query[j] ) ); - knockout_report( r, relation_delete( r, query[j] ) ); + knockout_report( r, Relation_delete( r, query[j] ) ); } } @@ -87,12 +87,12 @@ int main(int argc,char **argv) { TUPLE( 0, "d" ), 0 }; - relation rel2 = RELATION( &stringitem, &stringitem ); + Relation rel2 = RELATION( &stringitem, &stringitem ); - test_relation_add( &rel2, data2 ); + test_Relation_add( &rel2, data2 ); query_report( &rel2, 0 ); query_report_all( &rel2, query2 ); - test_relation_delete( &rel2, query2 ); + test_Relation_delete( &rel2, query2 ); // AxBxC tuple *data3[] = { @@ -112,14 +112,14 @@ int main(int argc,char **argv) { TUPLE( "f", "b", "d" ), 0 }; - relation rel3 = RELATION( &stringitem, &stringitem, &stringitem ); - relation_add_constraint( &rel3, 1, 1, 0 ); // AxB -> C - relation_add_constraint( &rel3, 1, 0, 1 ); // AxC -> B + Relation rel3 = RELATION( &stringitem, &stringitem, &stringitem ); + Relation_add_constraint( &rel3, 1, 1, 0 ); // AxB -> C + Relation_add_constraint( &rel3, 1, 0, 1 ); // AxC -> B - test_relation_add( &rel3, data3 ); + test_Relation_add( &rel3, data3 ); query_report( &rel3, 0 ); query_report_all( &rel3, query3 ); - test_relation_delete( &rel3, query3 ); + test_Relation_delete( &rel3, query3 ); return 0; }