apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/test teststr.c
Date Mon, 24 Mar 2003 17:14:44 GMT
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;
   }
  
  
  

Mime
View raw message