summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2003-03-24 17:14:43 +0000
committerJoe Orton <jorton@apache.org>2003-03-24 17:14:43 +0000
commit69d26f2f0def07017c81b2fc1e8db77438ef2ba8 (patch)
tree55c4cb68dfd64095a6030ce5ee90f8384c69550b
parentad5a3d560dbdab7710a35207fdba97e787123f31 (diff)
downloadapr-69d26f2f0def07017c81b2fc1e8db77438ef2ba8.tar.gz
Add tests for APR_{U,}INT64_T_FMT and apr_strerror.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64449 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/teststr.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/teststr.c b/test/teststr.c
index c92af8ff8..f8e0a31dd 100644
--- a/test/teststr.c
+++ b/test/teststr.c
@@ -61,6 +61,7 @@
#include "apr_general.h"
#include "apr_strings.h"
+#include "apr_errno.h"
/* I haven't bothered to check for APR_ENOTIMPL here, AFAIK, all string
* functions exist on all platforms.
@@ -163,6 +164,33 @@ static void snprintf_0nonNULL(CuTest *tc)
CuAssert(tc, "buff unmangled", strcmp(buff, "FOOBAR") != 0);
}
+static void snprintf_int64(CuTest *tc)
+{
+ char buf[100];
+ apr_int64_t i = APR_INT64_C(-42);
+ apr_uint64_t ui = APR_INT64_C(42); /* no APR_UINT64_C */
+ apr_uint64_t big = APR_INT64_C(3141592653589793238);
+
+ apr_snprintf(buf, sizeof buf, "%" APR_INT64_T_FMT, i);
+ CuAssertStrEquals(tc, buf, "-42");
+
+ apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, ui);
+ CuAssertStrEquals(tc, buf, "42");
+
+ apr_snprintf(buf, sizeof buf, "%" APR_UINT64_T_FMT, big);
+ CuAssertStrEquals(tc, buf, "3141592653589793238");
+}
+
+static void string_error(CuTest *tc)
+{
+ char buf[128], *rv;
+
+ rv = apr_strerror(APR_ENOENT, buf, sizeof buf);
+ CuAssertPtrEquals(tc, buf, rv);
+ /* ### relax this comparison. */
+ CuAssertStrEquals(tc, "No such file or directory", buf);
+}
+
CuSuite *teststr(void)
{
CuSuite *suite = CuSuiteNew("Strings");
@@ -170,7 +198,9 @@ CuSuite *teststr(void)
SUITE_ADD_TEST(suite, snprintf_0NULL);
SUITE_ADD_TEST(suite, snprintf_0nonNULL);
SUITE_ADD_TEST(suite, snprintf_noNULL);
+ SUITE_ADD_TEST(suite, snprintf_int64);
SUITE_ADD_TEST(suite, test_strtok);
+ SUITE_ADD_TEST(suite, string_error);
return suite;
}