You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2004/03/16 22:26:54 UTC

cvs commit: apr/test teststrnatcmp.c Makefile.in Makefile.win test_apr.h testall.c

rbb         2004/03/16 13:26:54

  Modified:    test     Makefile.in Makefile.win test_apr.h testall.c
  Added:       test     teststrnatcmp.c
  Log:
  Add a test for strnatcmp.
  
  Revision  Changes    Path
  1.154     +2 -1      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.153
  retrieving revision 1.154
  diff -u -r1.153 -r1.154
  --- Makefile.in	15 Mar 2004 18:33:30 -0000	1.153
  +++ Makefile.in	16 Mar 2004 21:26:54 -0000	1.154
  @@ -101,7 +101,8 @@
   	testpoll.lo testlock.lo testsockopt.lo testpipe.lo testthread.lo \
   	testhash.lo testargs.lo testnames.lo testuser.lo testpath.lo \
   	testenv.lo testprocmutex.lo testrand2.lo testfnmatch.lo \
  -        testatomic.lo testflock.lo testshm.lo testsock.lo testglobalmutex.lo
  +        testatomic.lo testflock.lo testshm.lo testsock.lo testglobalmutex.lo \
  +        teststrnatcmp.lo
   
   testall: $(TESTS) mod_test.la libmod_test.la occhild@EXEEXT@ \
   	 readchild@EXEEXT@ CuTest.lo proc_child@EXEEXT@ \
  
  
  
  1.18      +1 -1      apr/test/Makefile.win
  
  Index: Makefile.win
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.win,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Makefile.win	15 Mar 2004 18:33:30 -0000	1.17
  +++ Makefile.win	16 Mar 2004 21:26:54 -0000	1.18
  @@ -86,7 +86,7 @@
   	testhash.obj testargs.obj testnames.obj testuser.obj testpath.obj \
   	testenv.obj testprocmutex.obj testrand2.obj testfnmatch.obj \
           testatomic.obj testflock.obj testshm.obj testsock.obj \
  -        testglobalmutex.obj
  +        testglobalmutex.obj teststrnatcmp.obj
   
   testall.exe: $(TESTS) CuTest.obj $(LOCAL_LIBS)
   	$(LINK) /debug /subsystem:console /machine:I386 $(TESTS) CuTest.obj \
  
  
  
  1.53      +1 -0      apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- test_apr.h	15 Mar 2004 18:33:30 -0000	1.52
  +++ test_apr.h	16 Mar 2004 21:26:54 -0000	1.53
  @@ -68,6 +68,7 @@
   CuSuite *testsockets(void);
   CuSuite *testsockopt(void);
   CuSuite *teststr(void);
  +CuSuite *teststrnatcmp(void);
   CuSuite *testtable(void);
   CuSuite *testthread(void);
   CuSuite *testtime(void);
  
  
  
  1.57      +1 -0      apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.c,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- testall.c	15 Mar 2004 18:33:30 -0000	1.56
  +++ testall.c	16 Mar 2004 21:26:54 -0000	1.57
  @@ -71,6 +71,7 @@
       {"testsockets", testsockets},
       {"testsockopt", testsockopt},
       {"teststr", teststr},
  +    {"teststrnatcmp", teststrnatcmp},
       {"testtable", testtable},
       {"testthread", testthread},
       {"testtime", testtime},
  
  
  
  1.1                  apr/test/teststrnatcmp.c
  
  Index: teststrnatcmp.c
  ===================================================================
  /* Copyright 2000-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #include "apr_file_io.h"
  #include "apr_errno.h"
  #include "apr_strings.h"
  #include "test_apr.h"
  
  static void less0(CuTest *tc)
  {
      int rv = apr_strnatcmp("a", "b");
      CuAssert(tc, "didn't compare simple strings properly", rv < 0);
  }
  
  static void str_equal(CuTest *tc)
  {
      int rv = apr_strnatcmp("a", "a");
      CuAssert(tc, "didn't compare simple strings properly", rv == 0);
  }
  
  static void more0(CuTest *tc)
  {
      int rv = apr_strnatcmp("b", "a");
      CuAssert(tc, "didn't compare simple strings properly", rv > 0);
  }
  
  static void less_ignore_case(CuTest *tc)
  {
      int rv = apr_strnatcasecmp("a", "B");
      CuAssert(tc, "didn't compare simple strings properly", rv < 0);
  }
  
  static void str_equal_ignore_case(CuTest *tc)
  {
      int rv = apr_strnatcasecmp("a", "A");
      CuAssert(tc, "didn't compare simple strings properly", rv == 0);
  }
  
  static void more_ignore_case(CuTest *tc)
  {
      int rv = apr_strnatcasecmp("b", "A");
      CuAssert(tc, "didn't compare simple strings properly", rv > 0);
  }
  
  static void natcmp(CuTest *tc)
  {
      int rv = apr_strnatcasecmp("a2", "a10");
      CuAssert(tc, "didn't compare simple strings properly", rv < 0);
  }
  
  CuSuite *teststrnatcmp(void)
  {
      CuSuite *suite = CuSuiteNew("Natural String Cmp");
  
      SUITE_ADD_TEST(suite, less0);
      SUITE_ADD_TEST(suite, str_equal);
      SUITE_ADD_TEST(suite, more0);
      SUITE_ADD_TEST(suite, less_ignore_case);
      SUITE_ADD_TEST(suite, str_equal_ignore_case);
      SUITE_ADD_TEST(suite, more_ignore_case);
      SUITE_ADD_TEST(suite, natcmp);
  
      return suite;
  }