httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/test testucs.c testucs.dsp testsuite.dsw
Date Tue, 17 Oct 2000 17:09:16 GMT
wrowe       00/10/17 10:09:13

  Added:       src/lib/apr/test testucs.c testucs.dsp testsuite.dsw
  Log:
    Test for utf8/ucs2 conversion, plus a cool little workspace for APR
    testing from Win32.  Load src/lib/apr/test/testsuite.dsw to get at
    any of the APR tests.  Note I didn't clean them up at all (except
    for testucs), so your mileage may vary.
  
  Revision  Changes    Path
  1.1                  apache-2.0/src/lib/apr/test/testucs.c
  
  Index: testucs.c
  ===================================================================
  #include "apr_xlate.h"
  #include "../i18n/unix/i18n.h"
  #include <wchar.h>
  #include <string.h>
  
  struct testval {
      unsigned char n[8];
      wchar_t w[4];
      int nl;
      int wl;
  };
  
  void displaynw(struct testval *f, struct testval *l)
  {
      char x[80], *t = x;
      int i;
      for (i = 0; i < f->nl; ++i)
          t += sprintf(t, "%02X ", f->n[i]);
      *(t++) = '-';
      for (i = 0; i < l->nl; ++i)
          t += sprintf(t, " %02X", l->n[i]);
      *(t++) = ' ';
      *(t++) = '=';
      *(t++) = ' '; 
      for (i = 0; i < f->wl; ++i)
          t += sprintf(t, "%04X ", f->w[i]);
      *(t++) = '-';
      for (i = 0; i < l->wl; ++i)
          t += sprintf(t, " %04X", l->w[i]);
      puts(x);
  }
  
  /*
   *  Test every possible byte value. 
   *  If the test passes or fails at this byte value we are done.
   *  Otherwise iterate test_nrange again, appending another byte.
   */
  void test_nrange(struct testval *p)
  {
      struct testval f, l, s;
      apr_status_t rc;
      int success = 0;
      
      memcpy (&s, p, sizeof(s));
      ++s.nl;    
      
      do {
          apr_size_t nl = s.nl, wl = sizeof(s.w) / 2;
          rc = conv_utf8_to_ucs2(s.n, &nl, s.w, &wl);
          s.wl = (sizeof(s.w) / 2) - wl;
          if (!nl && rc == APR_SUCCESS) {
              if (!success) {
                  memcpy(&f, &s, sizeof(s));
                  success = -1;
              }
              else {
                  if (s.wl != l.wl 
                   || memcmp(s.w, l.w, (s.wl - 1) * 2) != 0
                   || s.w[s.wl - 1] != l.w[l.wl - 1] + 1) {
                      displaynw(&f, &l);
                      memcpy(&f, &s, sizeof(s));
                  }
              }            
              memcpy(&l, &s, sizeof(s));
          }
          else {
              if (success) {
                  displaynw(&f, &l);
                  success = 0;
              }
              if (rc == APR_INCOMPLETE) {
                  test_nrange(&s);
              }
          }
      } while (++s.n[s.nl - 1]);
  
      if (success) {
          displaynw(&f, &l);
          success = 0;
      }
  }
  
  /* 
   *  Test every possible word value. 
   *  Once we are finished, retest every possible word value.
   *  if the test fails on the following null word, iterate test_nrange 
   *  again, appending another word.
   *  This assures the output order of the two tests are in sync.
   */
  void test_wrange(struct testval *p)
  {
      struct testval f, l, s;
      apr_status_t rc;
      int success = 0;
      
      memcpy (&s, p, sizeof(s));
      ++s.wl;    
      
      do {
          apr_size_t nl = sizeof(s.n), wl = s.wl;        
          rc = conv_ucs2_to_utf8(s.w, &wl, s.n, &nl);
          s.nl = sizeof(s.n) - nl;
          if (!wl && rc == APR_SUCCESS) {
              if (!success) {
                  memcpy(&f, &s, sizeof(s));
                  success = -1;
              }
              else {
                  if (s.nl != l.nl 
                   || memcmp(s.n, l.n, s.nl - 1) != 0
                   || s.n[s.nl - 1] != l.n[l.nl - 1] + 1) {
                      displaynw(&f, &l);
                      memcpy(&f, &s, sizeof(s));
                  }
              }            
              memcpy(&l, &s, sizeof(s));
          }
          else {
              if (success) {
                  displaynw(&f, &l);
                  success = 0;
              }
          }
      } while (++s.w[s.wl - 1]);
  
      if (success) {
          displaynw(&f, &l);
          success = 0;
      }
  
      do {
          int wl = s.wl, nl = sizeof(s.n);
          rc = conv_ucs2_to_utf8(s.w, &wl, s.n, &nl);
          s.nl = sizeof(s.n) - s.nl;
          if (rc == APR_INCOMPLETE) {
              test_wrange(&s);
          }
      } while (++s.w[s.wl - 1]);
  }
  
  /*
   *  Syntax: testucs [w|n]
   *
   *  If arg is not recognized, run both tests.
   */
  int main(int argc, char **argv)
  {
      struct testval s;
      memset (&s, 0, sizeof(s));
  
      if (argc < 2 || tolower(*argv[1]) != 'w') {
          printf ("\n\nTesting Narrow Char Ranges\n");
          test_nrange(&s);
      }
      if (argc < 2 || tolower(*argv[1]) != 'n') {
          printf ("\n\nTesting Wide Char Ranges\n");
          test_wrange(&s);
      }
      return 0;
  }
  
  
  
  1.1                  apache-2.0/src/lib/apr/test/testucs.dsp
  
  Index: testucs.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="testucs" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=testucs - Win32 Debug
  !MESSAGE This is not a valid makefile. To build this project using NMAKE,
  !MESSAGE use the Export Makefile command and run
  !MESSAGE 
  !MESSAGE NMAKE /f "testucs.mak".
  !MESSAGE 
  !MESSAGE You can specify a configuration when running NMAKE
  !MESSAGE by defining the macro CFG on the command line. For example:
  !MESSAGE 
  !MESSAGE NMAKE /f "testucs.mak" CFG="testucs - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "testucs - Win32 Release" (based on "Win32 (x86) Console Application")
  !MESSAGE "testucs - Win32 Debug" (based on "Win32 (x86) Console Application")
  !MESSAGE 
  
  # Begin Project
  # PROP AllowPerConfigDependencies 0
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "testucs - Win32 Release"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 0
  # PROP BASE Output_Dir "Release"
  # PROP BASE Intermediate_Dir "Release"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 0
  # PROP Output_Dir "Release"
  # PROP Intermediate_Dir "Release"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD
/c
  # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\include" /I "..\..\include" /D "WIN32" /D "NDEBUG"
/D "APR_DECLARE_SYMBOLS" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD BASE RSC /l 0x409 /d "NDEBUG"
  # ADD RSC /l 0x409 /d "NDEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console
/machine:I386
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
/out:".\testucs.exe"
  # SUBTRACT LINK32 /debug
  
  !ELSEIF  "$(CFG)" == "testucs - Win32 Debug"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 1
  # PROP BASE Output_Dir "testucs_"
  # PROP BASE Intermediate_Dir "testucs_"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 1
  # PROP Output_Dir "testucs"
  # PROP Intermediate_Dir "testucs"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD
/ZI /c
  # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\include" /I "..\..\include" /D "WIN32"
/D "_DEBUG" /D "APR_DECLARE_SYMBOLS" /D "_CONSOLE" /D "_MBCS" /FD /ZI /c
  # SUBTRACT CPP /YX /Yc /Yu
  # ADD BASE RSC /l 0x409 /d "_DEBUG"
  # ADD RSC /l 0x409 /d "_DEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console
/debug /machine:I386 /pdbtype:sept
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug
/machine:I386 /out:".\testucs.exe" /pdbtype:sept
  # SUBTRACT LINK32 /incremental:no
  
  !ENDIF 
  
  # Begin Target
  
  # Name "testucs - Win32 Release"
  # Name "testucs - Win32 Debug"
  # Begin Source File
  
  SOURCE=.\testucs.c
  # End Source File
  # End Target
  # End Project
  
  
  
  1.1                  apache-2.0/src/lib/apr/test/testsuite.dsw
  
  Index: testsuite.dsw
  ===================================================================
  Microsoft Developer Studio Workspace File, Format Version 5.00
  # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
  
  ###############################################################################
  
  Project: "aprlib"="..\aprlib.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
  }}}
  
  ###############################################################################
  
  Project: "testarg"=".\testarg.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testfile"=".\testfile.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testproc"=".\testproc.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testsig"=".\testsig.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testsock"=".\testsock.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testthread"=".\testthread.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "testucs"=".\testucs.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Project: "timetest"=".\timetest.dsp" - Package Owner=<4>
  
  Package=<5>
  {{{
  }}}
  
  Package=<4>
  {{{
      Begin Project Dependency
      Project_Dep_Name aprlib
      End Project Dependency
  }}}
  
  ###############################################################################
  
  Global:
  
  Package=<5>
  {{{
  }}}
  
  Package=<3>
  {{{
  }}}
  
  ###############################################################################
  
  
  
  

Mime
View raw message