summaryrefslogtreecommitdiff
path: root/test/testnames.c
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2004-05-13 00:50:20 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2004-05-13 00:50:20 +0000
commit4ac08957a95bed976c28b0a04f27f89c88d6b7f0 (patch)
tree7efbac56f447f9a37ff68adec5fe28a9ec5cbb79 /test/testnames.c
parent51e9d33da3e0900f25feac8a48463eedbc58a4dd (diff)
downloadlibapr-4ac08957a95bed976c28b0a04f27f89c88d6b7f0.tar.gz
Move the APR test suite from CuTest to abts. The output is cleaner,
and it prints output while running the test. Also, if a test fails the rest of the test function is run, allowing for proper cleanup. Finally, it is possible to call the same function multiple times with different data, and each call is considered a separate test. This is the first of a multi-step process to get a more useful test suite. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testnames.c')
-rw-r--r--test/testnames.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/test/testnames.c b/test/testnames.c
index e2166a8eb..705656a8f 100644
--- a/test/testnames.c
+++ b/test/testnames.c
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "test_apr.h"
+#include "testutil.h"
#include "apr_file_io.h"
#include "apr_file_info.h"
#include "apr_errno.h"
@@ -29,7 +29,7 @@
#define ABS_ROOT "/"
#endif
-static void merge_aboveroot(CuTest *tc)
+static void merge_aboveroot(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
@@ -38,47 +38,47 @@ static void merge_aboveroot(CuTest *tc)
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"bar", APR_FILEPATH_NOTABOVEROOT,
p);
apr_strerror(rv, errmsg, sizeof(errmsg));
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_EABOVEROOT(rv));
- CuAssertPtrEquals(tc, NULL, dstpath);
- CuAssertStrEquals(tc, "The given path was above the root path", errmsg);
+ abts_int_equal(tc, 1, APR_STATUS_IS_EABOVEROOT(rv));
+ abts_ptr_equal(tc, NULL, dstpath);
+ abts_str_equal(tc, "The given path was above the root path", errmsg);
}
-static void merge_belowroot(CuTest *tc)
+static void merge_belowroot(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar",
APR_FILEPATH_NOTABOVEROOT, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT"foo/bar", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT"foo/bar", dstpath);
}
-static void merge_noflag(CuTest *tc)
+static void merge_noflag(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", 0, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT"foo/bar", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT"foo/bar", dstpath);
}
-static void merge_dotdot(CuTest *tc)
+static void merge_dotdot(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", 0, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT"foo/baz", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT"foo/baz", dstpath);
rv = apr_filepath_merge(&dstpath, "", "../test", 0, p);
- CuAssertIntEquals(tc, 0, APR_SUCCESS);
- CuAssertStrEquals(tc, "../test", dstpath);
+ abts_int_equal(tc, 0, APR_SUCCESS);
+ abts_str_equal(tc, "../test", dstpath);
/* Very dangerous assumptions here about what the cwd is. However, let's assume
* that the testall is invoked from within apr/test/ so the following test should
@@ -86,34 +86,34 @@ static void merge_dotdot(CuTest *tc)
* the case of the test directory:
*/
rv = apr_filepath_merge(&dstpath, "", "../test", APR_FILEPATH_TRUENAME, p);
- CuAssertIntEquals(tc, 0, APR_SUCCESS);
- CuAssertStrEquals(tc, "../test", dstpath);
+ abts_int_equal(tc, 0, APR_SUCCESS);
+ abts_str_equal(tc, "../test", dstpath);
}
-static void merge_secure(CuTest *tc)
+static void merge_secure(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../bar/baz", 0, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT"foo/bar/baz", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT"foo/bar/baz", dstpath);
}
-static void merge_notrel(CuTest *tc)
+static void merge_notrel(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz",
APR_FILEPATH_NOTRELATIVE, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT"foo/baz", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT"foo/baz", dstpath);
}
-static void merge_notrelfail(CuTest *tc)
+static void merge_notrelfail(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
@@ -123,12 +123,12 @@ static void merge_notrelfail(CuTest *tc)
APR_FILEPATH_NOTRELATIVE, p);
apr_strerror(rv, errmsg, sizeof(errmsg));
- CuAssertPtrEquals(tc, NULL, dstpath);
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_ERELATIVE(rv));
- CuAssertStrEquals(tc, "The given path is relative", errmsg);
+ abts_ptr_equal(tc, NULL, dstpath);
+ abts_int_equal(tc, 1, APR_STATUS_IS_ERELATIVE(rv));
+ abts_str_equal(tc, "The given path is relative", errmsg);
}
-static void merge_notabsfail(CuTest *tc)
+static void merge_notabsfail(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
@@ -138,12 +138,12 @@ static void merge_notabsfail(CuTest *tc)
APR_FILEPATH_NOTABSOLUTE, p);
apr_strerror(rv, errmsg, sizeof(errmsg));
- CuAssertPtrEquals(tc, NULL, dstpath);
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_EABSOLUTE(rv));
- CuAssertStrEquals(tc, "The given path is absolute", errmsg);
+ abts_ptr_equal(tc, NULL, dstpath);
+ abts_int_equal(tc, 1, APR_STATUS_IS_EABSOLUTE(rv));
+ abts_str_equal(tc, "The given path is absolute", errmsg);
}
-static void merge_notabs(CuTest *tc)
+static void merge_notabs(abts_case *tc, void *data)
{
apr_status_t rv;
char *dstpath = NULL;
@@ -151,12 +151,12 @@ static void merge_notabs(CuTest *tc)
rv = apr_filepath_merge(&dstpath, "foo/bar", "../baz",
APR_FILEPATH_NOTABSOLUTE, p);
- CuAssertPtrNotNull(tc, dstpath);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, "foo/baz", dstpath);
+ abts_ptr_notnull(tc, dstpath);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, "foo/baz", dstpath);
}
-static void root_absolute(CuTest *tc)
+static void root_absolute(abts_case *tc, void *data)
{
apr_status_t rv;
const char *root = NULL;
@@ -164,12 +164,12 @@ static void root_absolute(CuTest *tc)
rv = apr_filepath_root(&root, &path, 0, p);
- CuAssertPtrNotNull(tc, root);
- CuAssertIntEquals(tc, APR_SUCCESS, rv);
- CuAssertStrEquals(tc, ABS_ROOT, root);
+ abts_ptr_notnull(tc, root);
+ abts_int_equal(tc, APR_SUCCESS, rv);
+ abts_str_equal(tc, ABS_ROOT, root);
}
-static void root_relative(CuTest *tc)
+static void root_relative(abts_case *tc, void *data)
{
apr_status_t rv;
const char *root = NULL;
@@ -179,9 +179,9 @@ static void root_relative(CuTest *tc)
rv = apr_filepath_root(&root, &path, 0, p);
apr_strerror(rv, errmsg, sizeof(errmsg));
- CuAssertPtrEquals(tc, NULL, root);
- CuAssertIntEquals(tc, 1, APR_STATUS_IS_ERELATIVE(rv));
- CuAssertStrEquals(tc, "The given path is relative", errmsg);
+ abts_ptr_equal(tc, NULL, root);
+ abts_int_equal(tc, 1, APR_STATUS_IS_ERELATIVE(rv));
+ abts_str_equal(tc, "The given path is relative", errmsg);
}
@@ -191,22 +191,22 @@ static void root_relative(CuTest *tc)
}
#endif
-CuSuite *testnames(void)
+abts_suite *testnames(abts_suite *suite)
{
- CuSuite *suite = CuSuiteNew("Path names");
-
- SUITE_ADD_TEST(suite, merge_aboveroot);
- SUITE_ADD_TEST(suite, merge_belowroot);
- SUITE_ADD_TEST(suite, merge_noflag);
- SUITE_ADD_TEST(suite, merge_dotdot);
- SUITE_ADD_TEST(suite, merge_secure);
- SUITE_ADD_TEST(suite, merge_notrel);
- SUITE_ADD_TEST(suite, merge_notrelfail);
- SUITE_ADD_TEST(suite, merge_notabs);
- SUITE_ADD_TEST(suite, merge_notabsfail);
-
- SUITE_ADD_TEST(suite, root_absolute);
- SUITE_ADD_TEST(suite, root_relative);
+ suite = ADD_SUITE(suite)
+
+ abts_run_test(suite, merge_aboveroot, NULL);
+ abts_run_test(suite, merge_belowroot, NULL);
+ abts_run_test(suite, merge_noflag, NULL);
+ abts_run_test(suite, merge_dotdot, NULL);
+ abts_run_test(suite, merge_secure, NULL);
+ abts_run_test(suite, merge_notrel, NULL);
+ abts_run_test(suite, merge_notrelfail, NULL);
+ abts_run_test(suite, merge_notabs, NULL);
+ abts_run_test(suite, merge_notabsfail, NULL);
+
+ abts_run_test(suite, root_absolute, NULL);
+ abts_run_test(suite, root_relative, NULL);
return suite;
}