joes 2003/04/19 09:06:03
Modified: . STATUS
t tables.c testall.c
Log:
overlay, iterator tests added for apreq_tables.
Revision Changes Path
1.3 +5 -3 httpd-apreq-2/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/httpd-apreq-2/STATUS,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- STATUS 18 Apr 2003 02:29:11 -0000 1.2
+++ STATUS 19 Apr 2003 16:06:03 -0000 1.3
@@ -44,9 +44,11 @@
TODO:
- * Write core unit tests in t/.
- * Populate the glue/ directory (perl, tcl, etc.).
+ * more core unit tests in t/.
+ tables.c needs tests for "balanced" tables
+ * Populate the glue/ directory (perl, tcl, etc.).
+
OPEN ISSUES:
1.3 +61 -0 httpd-apreq-2/t/tables.c
Index: tables.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/t/tables.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- tables.c 19 Apr 2003 09:42:08 -0000 1.2
+++ tables.c 19 Apr 2003 16:06:03 -0000 1.3
@@ -199,6 +199,65 @@
CuAssertStrEquals(tc, "7",val);
}
+static void table_overlay(CuTest *tc)
+{
+ const char *val;
+ t1 = apreq_table_make(p, 1);
+ apreq_table_t *t2 = apreq_table_make(p, 1);
+ apr_status_t s;
+ apreq_table_add(t1, V("a", "0"));
+ apreq_table_add(t1, V("g", "7"));
+
+ apreq_table_add(t2, V("a", "1"));
+ apreq_table_add(t2, V("b", "2"));
+ apreq_table_add(t2, V("c", "3"));
+ apreq_table_add(t2, V("b", "2.0"));
+ apreq_table_add(t2, V("d", "4"));
+ apreq_table_add(t2, V("e", "5"));
+ apreq_table_add(t2, V("b", "2."));
+ apreq_table_add(t2, V("f", "6"));
+ t1 = apreq_table_overlay(p, t1, t2);
+
+ CuAssertIntEquals(tc, 10, apreq_table_nelts(t1));
+
+ val = apreq_table_get(t1, "a");
+ CuAssertStrEquals(tc, "0",val);
+ val = apreq_table_get(t1, "b");
+ CuAssertStrEquals(tc, "2",val);
+ val = apreq_table_get(t1, "c");
+ CuAssertStrEquals(tc, "3",val);
+ val = apreq_table_get(t1, "d");
+ CuAssertStrEquals(tc, "4",val);
+ val = apreq_table_get(t1, "e");
+ CuAssertStrEquals(tc, "5",val);
+ val = apreq_table_get(t1, "f");
+ CuAssertStrEquals(tc, "6",val);
+ val = apreq_table_get(t1, "g");
+ CuAssertStrEquals(tc, "7",val);
+}
+
+static void table_iterators(CuTest *tc)
+{
+ const char *val;
+ apreq_table_iter_t ti;
+ ti.t = t1;
+ apreq_table_first(&ti);
+ CuAssertStrEquals(tc,"0", ti.v->data);
+ apreq_table_next(&ti);
+ CuAssertStrEquals(tc,"7", ti.v->data);
+ apreq_table_next(&ti);
+ CuAssertStrEquals(tc,"1", ti.v->data);
+ apreq_table_next(&ti);
+ CuAssertStrEquals(tc,"2", ti.v->data);
+ apreq_table_last(&ti);
+ CuAssertStrEquals(tc,"6", ti.v->data);
+ apreq_table_prev(&ti);
+ CuAssertStrEquals(tc,"2.", ti.v->data);
+ apreq_table_prev(&ti);
+ CuAssertStrEquals(tc,"5", ti.v->data);
+
+}
+
CuSuite *testtable(void)
{
CuSuite *suite = CuSuiteNew("Table");
@@ -212,6 +271,8 @@
SUITE_ADD_TEST(suite, table_clear);
SUITE_ADD_TEST(suite, table_unset);
SUITE_ADD_TEST(suite, table_overlap);
+ SUITE_ADD_TEST(suite, table_overlay);
+ SUITE_ADD_TEST(suite, table_iterators);
return suite;
}
1.2 +2 -2 httpd-apreq-2/t/testall.c
Index: testall.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/t/testall.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testall.c 17 Apr 2003 19:19:40 -0000 1.1
+++ testall.c 19 Apr 2003 16:06:03 -0000 1.2
@@ -134,7 +134,7 @@
for (j = 0; tests[j].func != NULL; j++) {
if (!strcmp(argv[i], tests[j].testname)) {
if (!partial) {
- alltests = CuSuiteListNew("Partial APR Tests");
+ alltests = CuSuiteListNew("Partial APREQ Tests");
partial = 1;
}
@@ -145,7 +145,7 @@
}
if (!partial) {
- alltests = CuSuiteListNew("All APR Tests");
+ alltests = CuSuiteListNew("All APREQ Tests");
for (i = 0; tests[i].func != NULL; i++) {
CuSuiteListAdd(alltests, tests[i].func());
}