Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 25304 invoked by uid 500); 24 Mar 2003 17:14:48 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 25239 invoked from network); 24 Mar 2003 17:14:46 -0000 Date: 24 Mar 2003 17:14:44 -0000 Message-ID: <20030324171444.22876.qmail@icarus.apache.org> From: jorton@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/test teststr.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jorton 2003/03/24 09:14:44 Modified: test teststr.c Log: Add tests for APR_{U,}INT64_T_FMT and apr_strerror. Revision Changes Path 1.14 +30 -0 apr/test/teststr.c Index: teststr.c =================================================================== RCS file: /home/cvs/apr/test/teststr.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- teststr.c 1 Jan 2003 00:01:56 -0000 1.13 +++ teststr.c 24 Mar 2003 17:14:43 -0000 1.14 @@ -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 @@ 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 @@ 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; }