summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2003-03-24 17:14:43 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2003-03-24 17:14:43 +0000
commit5b70c248ce1feb02ae4ff1c2e81e32b7610cb227 (patch)
tree55c4cb68dfd64095a6030ce5ee90f8384c69550b
parentbad11c6b240d7b2145c1e74143f92b85e504d875 (diff)
downloadlibapr-5b70c248ce1feb02ae4ff1c2e81e32b7610cb227.tar.gz
Add tests for APR_{U,}INT64_T_FMT and apr_strerror.
git-svn-id: http://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;
}