home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / xpg4 / demo / testwcs / testwcs.c next >
Encoding:
C/C++ Source or Header  |  1993-11-04  |  39.3 KB  |  1,160 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <wchar.h>
  4. #include <locale.h>
  5. #define NullL 0L
  6. /*
  7. typedef unsigned short wchar_t;
  8. typedef int wint_t;
  9. */
  10. wchar_t *build_string(char *ws);
  11. wchar_t *build_tough_string1( void );
  12. wchar_t *build_tough_string2( void );
  13. wchar_t *build_tough_string3( void );
  14. void hexout( wchar_t *pString );
  15. /*
  16. size_t wcscspn(const wchar_t *ws1, const wchar_t *ws2);
  17. size_t wcslen(const wchar_t *ws);
  18. wchar_t *wcscat(wchar_t *ws1, const wchar_t *ws2);
  19. wchar_t *wcscpy(wchar_t *ws1, const wchar_t *ws2);
  20. int wcscmp(const wchar_t *ws1, const wchar_t *ws2);
  21. wchar_t *wcspbrk(const wchar_t *ws1, const wchar_t *ws2);
  22. wchar_t *wcsncpy(wchar_t *ws1, const wchar_t *ws2, size_t n);
  23. size_t wcsspn(const wchar_t *ws1, const wchar_t *ws2);
  24. wchar_t *wcschr(wchar_t *ws1, wint_t wc);
  25. wchar_t *wcsncat(wchar_t *ws1, const wchar_t *ws2, size_t n);
  26. wchar_t *wcsrchr(wchar_t *ws1, wint_t wc);
  27. wchar_t *wcstok(wchar_t *ws1, const wchar_t *ws2);
  28. wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2);
  29. */
  30.  
  31. void test_wcslen(void);
  32. void test_wcscspn(void);
  33. void test_wcscat(void);
  34. void test_wcscpy(void);
  35. void test_wcscmp(void);
  36. void test_wcsncmp(void);
  37. void test_wcspbrk(void);
  38. void test_wcsncpy(void);
  39. void test_wcsspn(void);
  40.  
  41.  
  42. void main()
  43. {
  44.  
  45.   wchar_t *pReset;
  46.  
  47.   wchar_t *z= build_string("                                                             ");
  48. /**************/
  49.   wchar_t *Aws1 = build_string("abcdefgh");
  50.   wint_t      Ax;
  51.   wint_t      AwsT0;
  52.   wchar_t *AwsT1 = build_tough_string1( );
  53.   wchar_t *AwsT2 = build_tough_string2( );
  54.   wchar_t *AwsT3 = build_tough_string3( );
  55.   wchar_t *AwsT4;
  56.   wchar_t *AwsT5;
  57.  
  58. /**************/
  59.   wchar_t *Bws1 = build_string("abcd");
  60.   wchar_t *Bxxx  = build_string("                                    ");
  61.   wchar_t *Bws2 = build_string("ef");
  62.   wchar_t *Bws3 = build_string("ghij");
  63.   wchar_t *Bws4 = build_string("xxx");
  64.   wchar_t *Bws5 = build_string("ijklm");
  65.   wchar_t *Bnull = build_string("");
  66.   wchar_t *Byyy   = build_string("                                    ");
  67.   size_t      Bn;
  68. /****************/
  69.   wchar_t *Cws1 = build_string("zyxwvutsrqpo");
  70.   wchar_t *Cxxx  = build_string("                                    ");
  71.   wchar_t *Cws2 = build_string("abcd");
  72.   wchar_t *Cws3 = build_string("xyz");
  73.   wchar_t *Cws4 = build_string("abxx");
  74.   wchar_t *Cws5 = build_string("xxx");
  75.   wchar_t *Cnull = build_string("");
  76.   wchar_t *Cyyy   = build_string("                                    ");
  77.   size_t      Cn;
  78. /**************/
  79.   wchar_t *Dws1 = build_string("abcccfgh");
  80.   wint_t      Dx;
  81. /*************/
  82.   wchar_t *Ews1 = build_string("abc,defg,hijklmnopq,rstuv,wxyz");
  83.   wchar_t *Ews2 = build_string(",");
  84.   wchar_t *Ews3 = build_string(",");
  85.   wchar_t *Ews4 = build_string(",");
  86.   wchar_t *Ews5 = build_string(",");
  87.   wchar_t *Ews6 = build_string(",");
  88.   wchar_t *Ews7 = build_string(",");
  89.   wchar_t *Enull = build_string("");
  90. /***************/
  91.   wchar_t *Fws1 = build_string("abcabcdabcdeabcdefg");
  92.   wchar_t *Fws2 = build_string("abc");
  93.   wchar_t *Fws3 = build_string("abcde");
  94.   wchar_t *Fws4 = build_string("abcdx");
  95.   wchar_t *Fws5 = build_string("g");
  96.   wchar_t *Fws6 = build_string("fg");
  97.  
  98.   printf("\nTESTING wcschr()\n");
  99.   Ax = 'h';
  100.   printf("\n>abcdefgh< , >h< returns <%s>",z=wcschr(Aws1,Ax));
  101.   if ( ! wcscmp( z, build_string("h") ) ) printf(" Passed\n"); else printf(" Failed\n");
  102.   Ax = 'd';
  103.   printf("\n>abcdefgh< , >d< returns <%ls>",z=wcschr(Aws1,Ax));
  104.   if ( ! wcscmp( z, build_string("defgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  105.   Ax = 's';
  106.   printf("\n>abcdefgh< , >s< returns <%ld>",z=wcschr(Aws1,Ax));
  107.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  108.   Ax = 'a';
  109.   printf("\n>abcdefgh< , >a< returns <%ls>",z=wcschr(Aws1,Ax));
  110.   if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  111.   Ax = '\0';
  112.   printf("\n>abcdefgh< , >null< returns <%ld>",z=wcschr(Aws1,Ax));
  113.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  114.   Ax = '\0';
  115.   printf("\n>NULL< , >null< returns <%ld>",z=wcschr(Bnull,Ax));
  116.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  117.   Ax = 'x';
  118.   printf("\n>NULL< , >x< returns <%ld>",z=wcschr(Bnull,Ax));
  119.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  120.   AwsT0 = (wint_t)*AwsT1;
  121.   printf("\n>0A0B0C< , >0A< returns <%ls>",z=wcschr(AwsT1,AwsT0));
  122.   if ( ! wcscmp(z,AwsT1) ) printf(" Passed\n"); else printf(" Failed\n");
  123.   AwsT0 = (wint_t)*AwsT1+2;
  124.   printf("\n>0A0B0C< , >0C< returns <%ls>",z=wcschr(AwsT1,AwsT0));
  125.   if ( ! wcscmp(z,AwsT1+2) ) printf(" Passed\n"); else printf(" Failed\n");
  126.   AwsT4 = (wchar_t*)calloc(1,sizeof(*AwsT4));
  127.   AwsT5 = pReset = (wchar_t*)calloc(2,sizeof(*AwsT5));
  128.   *AwsT4 = (wchar_t)0x4600;
  129.   *AwsT5 = (wchar_t)0x4600;
  130.    AwsT5++;
  131.   *AwsT5 = (wchar_t)0x0000;
  132.    AwsT5 = pReset;
  133.   AwsT0 = (wint_t)*AwsT4;
  134.  
  135.   printf("\n>D0E0F0< , >F0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
  136.   if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
  137.   *AwsT4 = (wchar_t)0x4700;
  138.   AwsT0 = (wint_t)*AwsT4;
  139.   printf("\n>D0E0F0< , >G0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
  140.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  141.   *AwsT4 = (wchar_t)0x4400;
  142.   AwsT0 = (wint_t)*AwsT4;
  143.   printf("\n>D0E0F0< , >D0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
  144.   if ( ! wcscmp(z,AwsT3+3) ) printf(" Passed\n"); else printf(" Failed\n");
  145.   *AwsT4 = (wchar_t)0x4600;
  146.   AwsT0 = (wint_t)*AwsT4;
  147.   printf("\n>0A0B0CD0E0F0< , >F0< returns <%ld>",z=wcschr(AwsT3,AwsT0));
  148.   if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
  149.  
  150.   printf("\nTESTING wcsncat()\n");
  151.   Bn = 6;
  152.   printf("\n>abcd< , >ef< , >6< returns <%ls>",z=wcsncat(Bws1,Bws2,Bn));
  153.   if ( ! wcscmp( z, build_string("abcdef") ) ) printf(" Passed\n"); else printf(" Failed\n");
  154.   Bn = 2;
  155.   printf("\n>abcdef< , >ghij< , >2< returns <%ls>",z=wcsncat(Bws1,Bws3,Bn));
  156.   if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  157.   Bn = 0;
  158.   printf("\n>abcdefgh< , >xxx< , >0< returns <%ls>",z=wcsncat(Bws1,Bws4,Bn));
  159.   if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  160.   Bn = 5;
  161.   printf("\n>abcdefgh< , >ijklm< , >5< returns <%ls>",z=wcsncat(Bws1,Bws5,Bn));
  162.   if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
  163.   Bn = 7;
  164.   printf("\n>NULL< , >NULL< , >7< returns <%ls>",z=wcsncat(Bnull,Enull,Bn));
  165.   if (   z == Bnull ) printf(" Passed\n"); else printf(" Failed\n");
  166.   Bn = 2;
  167.   printf("\n>NULL< , >ghij< , >2< returns <%ls>",z=wcsncat(Bnull,Bws3,Bn));
  168.   if ( ! wcscmp( z, build_string("gh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  169.   Bn = 0;
  170.   printf("\n>abcdefghijklm< , >NULL< , >0< returns <%ls>",z=wcsncat(Bws1,Enull,Bn));
  171.   if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
  172.   Bn = 7;
  173.   printf("\n>abcdefghijklm< , >NULL< , >7< returns <%ls>",z=wcsncat(Bws1,Enull,Bn));
  174.   if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
  175.   Cn = 4;
  176.   wcsncpy(z,AwsT1,Cn);
  177.   Bn = 0;
  178.   printf("\n>0A0B0C< , >D0E0F0< , >0< returns <%ls>",z=wcsncat(z,AwsT2,Bn));
  179.   if ( ! wcscmp( z, AwsT1 ) ) printf(" Passed\n"); else printf(" Failed\n");
  180.   Cn = 4;
  181.   wcsncpy(z,AwsT1,Cn);
  182.   Bn = 7;
  183.   printf("\n>0A0B0C< , >D0E0F0< , >7< returns <%ld>",z=wcsncat(z,AwsT2,Bn));
  184.   if ( ! wcscmp( z, AwsT3 ) ) printf(" Passed\n"); else printf(" Failed\n");
  185.   Cn = 4;
  186.   wcsncpy(z,AwsT1,Cn);
  187.   Bn = 3;
  188.   printf("\n>0A0B0C< , >D0E0F0< , >3< returns <%ld>",z=wcsncat(z,AwsT2,Bn));
  189.   if ( ! wcscmp( z, AwsT3 ) ) printf(" Passed\n"); else printf(" Failed\n");
  190.  
  191.  
  192.   printf("\nTESTING wcsncpy()\n");
  193.   Cn = 4;
  194.   printf("\n>zyxwvutsrqpo< , >abcd< , >4< returns <%ls>",z=wcsncpy(Cws1,Cws2,Cn));
  195.   if ( ! wcscmp( z, build_string("abcdvutsrqpo") ) ) printf(" Passed\n"); else printf(" Failed\n");
  196.   Cn = 6;
  197.   printf("\n>abcd< , >xyz< , >6< returns <%ls>",z=wcsncpy(Cws1,Cws3,Cn));
  198.   if ( ! wcscmp( z, build_string("xyz") ) )printf(" Passed\n");
  199.   Cn = 2;
  200.   printf("\n>xyz< , >abxx< , >2< returns <%ls>",z=wcsncpy(Cws1,Cws4,Cn));
  201.   if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
  202.   Cn = 0;
  203.   printf("\n>abz< , >xxx< , >0< returns <%ls>",z=wcsncpy(Cws1,Cws5,Cn));
  204.   if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
  205.   Cn = 7;
  206.   printf("\n>NULL< , >NULL< , >7< returns <%ls>",z=wcsncpy(Cnull,Enull,Cn));
  207.   if (   z == Cnull ) printf(" Passed\n"); else printf(" Failed\n");
  208.   Cn = 2;
  209.   printf("\n>NULL< , >abxx< , >2< returns <%ls>",z=wcsncpy(Cnull,Cws4,Cn));
  210.   if ( ! wcscmp( z, build_string("ab") ) ) printf(" Passed\n"); else printf(" Failed\n");
  211.   Cn = 0;
  212.   printf("\n>abz< , >NULL< , >7< returns <%ls>",z=wcsncpy(Cws1,Enull,Cn));
  213.   if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
  214.  
  215.  
  216.   printf("\nTESTING wcsrchr()\n");
  217.   Dx = 'h';
  218.   printf("\n>abcccfgh< , >h< returns <%s>",z=wcsrchr(Dws1,Dx));
  219.   if ( ! wcscmp( z, build_string("h") ) ) printf(" Passed\n"); else printf(" Failed\n");
  220.   Dx = 'c';
  221.   printf("\n>abcccfgh< , >c< returns <%ls>",z=wcsrchr(Dws1,Dx));
  222.   if ( ! wcscmp( z, build_string("cfgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  223.   Dx = 's';
  224.   printf("\n>abcccfgh< , >s< returns <%ld>",z=wcsrchr(Dws1,Dx));
  225.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  226.   Dx = 'a';
  227.   printf("\n>abcccfgh< , >a< returns <%ls>",z=wcsrchr(Dws1,Dx));
  228.   if ( ! wcscmp( z, build_string("abcccfgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
  229.   Dx = '\0';
  230.   printf("\n>abcccfgh< , >null< returns <%ld>",z=wcsrchr(Dws1,Dx));
  231.   if (   z == Dws1+8 ) printf(" Passed\n"); else printf(" Failed\n");
  232.   Dx = '\0';
  233.   printf("\n>NULL< , >null< returns <%ld>",z=wcsrchr(Enull,Dx));
  234.   if (   z == Enull ) printf(" Passed\n"); else printf(" Failed\n");
  235.   Dx = 'x';
  236.   printf("\n>NULL< , >x< returns <%ld>",z=wcsrchr(Enull,Dx));
  237.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  238.   AwsT0 = (wint_t)*AwsT1;
  239.   printf("\n>0A0B0C< , >0A< returns <%ls>",z=wcsrchr(AwsT1,AwsT0));
  240.   if ( ! wcscmp(z,AwsT1) ) printf(" Passed\n"); else printf(" Failed\n");
  241.   AwsT0 = (wint_t)*AwsT1+2;
  242.   printf("\n>0A0B0C< , >0C< returns <%ls>",z=wcsrchr(AwsT1,AwsT0));
  243.   if ( ! wcscmp(z,AwsT1+2) ) printf(" Passed\n"); else printf(" Failed\n");
  244.   AwsT0 = (wint_t)*AwsT4;
  245.   printf("\n>D0E0F0< , >F0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
  246.   if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
  247.   *AwsT4 = (wchar_t)0x4700;
  248.   AwsT0 = (wint_t)*AwsT4;
  249.   printf("\n>D0E0F0< , >G0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
  250.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  251.   *AwsT4 = (wchar_t)0x4400;
  252.   AwsT0 = (wint_t)*AwsT4;
  253.   printf("\n>D0E0F0< , >D0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
  254.   if ( ! wcscmp(z,AwsT3+3) ) printf(" Passed\n"); else printf(" Failed\n");
  255.   *AwsT4 = (wchar_t)0x4600;
  256.   AwsT0 = (wint_t)*AwsT4;
  257.   printf("\n>0A0B0CD0E0F0< , >F0< returns <%ld>",z=wcsrchr(AwsT3,AwsT0));
  258.   if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
  259.  
  260.  
  261.  
  262.   printf("\nTESTING wcstok()\n");
  263.  
  264.   printf("\n>abc,defg,hijklmnopq,rstuv,wxyz< , >,< returns <%ls>",z=wcstok(Ews1,Ews2));
  265.   if ( ! wcscmp( z, build_string("def") ) ) printf(" Passed\n"); else printf(" Failed\n");
  266.  
  267.   printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
  268.   if ( ! wcscmp( z, build_string("") ) ) printf(" Passed\n"); else printf(" Failed\n");
  269.  
  270.   printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
  271.   if ( ! wcscmp( z, build_string("ij") ) ) printf(" Passed\n"); else printf(" Failed\n");
  272.  
  273.   printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
  274.   if ( ! wcscmp( z, build_string("lmn") ) ) printf(" Passed\n"); else printf(" Failed\n");
  275.  
  276.   printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
  277.   if ( ! wcscmp( z, build_string("pqrstuvwxyz") ) ) printf(" Passed\n"); else printf(" Failed\n");
  278.  
  279.   printf("\n>NULL< , >,< returns <%ld>",z=wcstok(Enull,Ews2));
  280.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  281.  
  282.   printf("\n>NULL< , >,< returns <%ld>",z=wcstok(Enull,Ews2));
  283.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  284.  
  285.   printf("\n>abcdefg< , >,< returns <%ld>",z=wcstok(Ews5,Ews2));
  286.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  287.  
  288.   printf("\n>abcdefg< , >NULL< returns <%ls>",z=wcstok(Ews5,Enull));
  289.   if ( ! wcscmp( z, build_string("abcdefg") ) ) printf(" Passed\n"); else printf(" Failed\n");
  290.  
  291.   printf("\n>NULL< , >NULL< returns <%ld>",z=wcstok(Enull,Enull));
  292.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  293.  
  294.   AwsT1 = build_tough_string1( );
  295.   AwsT2 = build_tough_string2( );
  296.   AwsT3 = build_tough_string3( );
  297.  
  298.   printf("\n>0A0B0CD0E0F0< , >D0E0F0< returns <%ld>",z=wcstok(AwsT3,AwsT2));
  299.   if ( ! wcscmp( AwsT3, z ) ) printf(" Passed\n"); else printf(" Failed\n");
  300.  
  301.   printf("\n>NULL< , >D0E0F0< returns <%ld>",z=wcstok(Enull,AwsT2));
  302.   if ( ! wcscmp( z, build_string("") ) ) printf(" Passed\n"); else printf(" Failed\n");
  303.  
  304.   printf("\n>D0E0F0< , >D0E0F0< returns <%ld>",z=wcstok(AwsT2,AwsT2));
  305.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  306.  
  307.  
  308.  
  309.   printf("\nTESTING wcswcs()\n");
  310.  
  311.   printf("\n>abcabcdabcdeabcdefg< , >abc< returns <%ls>",z=wcswcs(Fws1,Fws2));
  312.   if ( ! wcscmp( z, build_string("abcabcdabcdeabcdefg") ) ) printf(" Passed\n");
  313.       else printf(" Failed\n");
  314.  
  315.   printf("\n>abcabcdabcdeabcdefg< , >abcde< returns <%ls>",z=wcswcs(Fws1,Fws3));
  316.   if ( ! wcscmp( z, build_string("abcdeabcdefg") ) ) printf(" Passed\n"); else printf(" Failed\n");
  317.  
  318.   printf("\n>abcabcdabcdeabcdefg< , >abcdx< returns <%ld>",z=wcswcs(Fws1,Fws4));
  319.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  320.  
  321.   printf("\n>abcabcdabcdeabcdefg< , >g< returns <%ls>",z=wcswcs(Fws1,Fws5));
  322.   if ( ! wcscmp( z, build_string("g") ) ) printf(" Passed\n"); else printf(" Failed\n");
  323.  
  324.   printf("\n>abcabcdabcdeabcdefg< , >fg< returns <%ls>",z=wcswcs(Fws1,Fws6));
  325.   if ( ! wcscmp( z, build_string("fg") ) ) printf(" Passed\n"); else printf(" Failed\n");
  326.  
  327.   printf("\n>abcabcdabcdeabcdefg< , >NULL< returns <%ls>",z=wcswcs(Fws1,Enull));
  328.   if ( ! wcscmp( z, build_string("abcabcdabcdeabcdefg") ) ) printf(" Passed\n");
  329.       else printf(" Failed\n");
  330.  
  331.   printf("\n>NULL< , >NULL< returns <%ld>",z=wcswcs(Enull,Enull));
  332.   if (   z == Enull ) printf(" Passed\n"); else printf(" Failed\n");
  333.  
  334.   printf("\n>NULL< , >fg< returns <%ld>",z=wcswcs(Enull,Fws6));
  335.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  336.  
  337.   AwsT1 = build_tough_string1( );
  338.   AwsT2 = build_tough_string2( );
  339.   AwsT3 = build_tough_string3( );
  340.  
  341.   printf("\n>0A0B0CD0E0F0< , >D0E0F0< returns <%ld>",z=wcswcs(AwsT3,AwsT2));
  342.   if ( ! wcscmp( z, AwsT3+3 ) ) printf(" Passed\n"); else printf(" Failed\n");
  343.  
  344.   printf("\n>NULL< , >D0E0F0< returns <%ld>",z=wcswcs(Enull,AwsT2));
  345.   if (   z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
  346.  
  347.   printf("\n>D0E0F0< , >D0E0F0< returns <%ld>",z=wcswcs(AwsT2,AwsT2));
  348.   if ( ! wcscmp( z, AwsT2 ) ) printf(" Passed\n"); else printf(" Failed\n");
  349.  
  350.  
  351. /**************************************************************************/
  352. /**************************************************************************/
  353.  
  354.   test_wcslen();
  355.   test_wcscpy();
  356.   test_wcscat();
  357.   test_wcscmp();
  358.   test_wcspbrk();
  359.   test_wcscspn();
  360.   test_wcsspn();
  361.   test_wcsncpy();
  362.   test_wcsncmp();
  363. /**************************************************************************/
  364. /**************************************************************************/
  365.  
  366. }
  367.  
  368. /**************************************************************************/
  369. /**************************************************************************/
  370.  
  371. void test_wcslen(void)
  372. {
  373.  
  374.   wchar_t *wcslen_i = build_string("hot stuff");
  375.   wchar_t *wcslen_nul = build_string("");
  376.   wchar_t *wcslen_null_test1 = build_tough_string1();
  377.   wchar_t *wcslen_null_test2 = build_tough_string2();
  378.  
  379.   /* TESTING WCSLEN() *************************************************/
  380.  
  381.   printf("\n\nTESTING wcslen()\n");
  382.  
  383.   /* printf("Test ( check the length of a null length string ) : "); */
  384.   printf(">%ls< returns %d ",wcslen_nul,wcslen(wcslen_nul));
  385.   if (wcslen(wcslen_nul) == 0)
  386.     printf("PASS\n");
  387.   else
  388.     printf("FAIL\n");
  389.  
  390.   /* printf("Test ( check the length of a string ) : "); */
  391.   printf(">%ls< returns %d ",wcslen_i,wcslen(wcslen_i));
  392.   if (wcslen(wcslen_i) == 9)
  393.     printf("PASS\n");
  394.   else
  395.     printf("FAIL\n");
  396.  
  397.   /* test tough null string 1 */
  398.   /* printf("Test ( check the length of tough string 1 ) : "); */
  399.  
  400.   printf(">");
  401.   hexout(wcslen_null_test1);
  402.   printf("< returns >%d< ",wcslen(wcslen_null_test1));
  403.  
  404.   if (wcslen(wcslen_null_test1) == 3)
  405.     printf("PASS\n");
  406.   else
  407.     printf("FAIL\n");
  408.  
  409.   /* test tough null string 2 */
  410.   /* printf("Test ( check the length of tough string 2 ) : "); */
  411.  
  412.   printf(">");
  413.   hexout(wcslen_null_test2);
  414.   printf("< returns >%d< ",wcslen(wcslen_null_test2));
  415.  
  416.   if (wcslen(wcslen_null_test2) == 3)
  417.     printf("PASS\n");
  418.   else
  419.     printf("FAIL\n");
  420.  
  421. }
  422.  
  423.  
  424. void test_wcscpy(void)
  425. {
  426.   wchar_t *wcscpy_i = build_string("hot stuff");
  427.   wchar_t *wcscpy_j = build_string("xxxxxxxxxxxxxx");
  428.   wchar_t *wcscpy_k = build_string("hot stuff");
  429.   wchar_t *wcscpy_nul = build_string("");
  430.   wchar_t *wcscpy_null_test1 = build_tough_string1();
  431.   wchar_t *wcscpy_nul1 = build_string("");
  432.   wchar_t *wcscpy_null_test2 = build_tough_string2();
  433.   wchar_t *wcscpy_nul2 = build_string("");
  434.  
  435.  
  436.   /* TESTING WCSCPY() *************************************************/
  437.  
  438.   printf("\n\nTESTING wcscpy()\n");
  439.  
  440.   /* copy on top of a another larger string */
  441.   /* printf("Test ( copy a small string on top of a larger string ) : "); */
  442.  
  443.   printf(">%ls< , >%ls< returns ",wcscpy_j,wcscpy_i);
  444.   wcscpy(wcscpy_j,wcscpy_i);
  445.   printf("<%ls> ",wcscpy_j);
  446.   if ( wcscmp(wcscpy_i,wcscpy_j) == 0 )
  447.     printf("PASS\n");
  448.   else
  449.     printf("FAIL\n");
  450.  
  451.   /* copy from a null space */
  452.   /* printf("Test ( copy from a null string to a string ) : "); */
  453.  
  454.   printf(">%ls< , >%ls< returns ",wcscpy_i,wcscpy_nul);
  455.   wcscpy(wcscpy_i,wcscpy_nul);
  456.   printf("<%ls> ",wcscpy_i);
  457.   if ( wcscmp(wcscpy_nul,wcscpy_i) == 0 )
  458.     printf("PASS\n");
  459.   else
  460.     printf("FAIL\n");
  461.  
  462.   /* copy to a null space */
  463.   /* printf("Test ( copy from a string to a null string ) : "); */
  464.  
  465.   printf(">%ls< , >%ls< returns ",wcscpy_nul,wcscpy_k);
  466.   wcscpy(wcscpy_nul,wcscpy_k);
  467.   printf("<%ls> ",wcscpy_nul);
  468.   if ( wcscmp(wcscpy_k,wcscpy_nul) == 0 )
  469.     printf("PASS\n");
  470.   else
  471.     printf("FAIL\n");
  472.  
  473.   /* copy from tough string 1 to a null space */
  474.   /* printf("Test ( copy from tough string 1 to a null string ) : "); */
  475.  
  476.   printf(">");
  477.   hexout(wcscpy_nul1);
  478.   printf("< , >");
  479.   hexout(wcscpy_null_test1);
  480.   printf("< returns >");
  481.   wcscpy(wcscpy_nul1,wcscpy_null_test1);
  482.   hexout(wcscpy_nul1);
  483.   printf("< ");
  484.  
  485.   if ( wcscmp(wcscpy_null_test1,wcscpy_nul1) == 0 )
  486.     printf("PASS\n");
  487.   else
  488.     printf("FAIL\n");
  489.  
  490.   /* copy from tough string 2 to a null space */
  491.   /* printf("Test ( copy from tough string 2 to a null string ) : "); */
  492.  
  493.   printf(">");
  494.   hexout(wcscpy_nul2);
  495.   printf("< , >");
  496.   hexout(wcscpy_null_test2);
  497.   printf("< returns >");
  498.   wcscpy(wcscpy_nul2,wcscpy_null_test2);
  499.   hexout(wcscpy_nul2);
  500.   printf("< ");
  501.  
  502.   if ( wcscmp(wcscpy_null_test2,wcscpy_nul2) == 0 )
  503.     printf("PASS\n");
  504.   else
  505.     printf("FAIL\n");
  506. }
  507.  
  508.  
  509. void test_wcsncmp(void)
  510. {
  511.   size_t wcsncmp_char_count  = 9;
  512.   size_t wcsncmp_char_smallcount  = 2;
  513.   size_t wcsncmp_char_bigcount  = 20;
  514.   size_t wcsncmp_char_zerocount  = 0;
  515.   wchar_t *wcsncmp_i = build_string("hot stuff");
  516.   wchar_t *wcsncmp_j = build_string("hot stuff");
  517.   wchar_t *wcsncmp_k = build_string("hot stufe here");
  518.   wchar_t *wcsncmp_l = build_string("hot stufg now");
  519.   wchar_t *wcsncmp_nul = build_string("");
  520.  
  521.   wchar_t *wcsncmp_null_test1 = build_tough_string1();
  522.   wchar_t *wcsncmp_null_dupe_test1 = build_tough_string1();
  523.  
  524.   wchar_t *wcsncmp_null_test2 = build_tough_string2();
  525.   wchar_t *wcsncmp_null_dupe_test2 = build_tough_string2();
  526.  
  527.  
  528.   /* TESTING wcsncmp() *************************************************/
  529.  
  530.   printf("\n\nTESTING wcsncmp()\n");
  531.  
  532.   /* printf("Test ( compare one string to another with the same value ) : "); */
  533.  
  534.   printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_j,wcsncmp_char_count,wcsncmp(wcsncmp_i,wcsncmp_j,wcsncmp_char_count));
  535.   if ( wcsncmp(wcsncmp_i,wcsncmp_j,wcsncmp_char_count) == 0 )
  536.     printf("PASS\n");
  537.   else
  538.     printf("FAIL\n");
  539.  
  540.   /* printf("Test ( compare one string to another with a greater value ) : "); */
  541.  
  542.   printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount));
  543.   if ( wcsncmp(wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount) == 1 )
  544.     printf("PASS\n");
  545.   else
  546.     printf("FAIL\n");
  547.  
  548.   /* printf("Test ( compare one string to another with a lesser value ) : "); */
  549.   printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount));
  550.   if ( wcsncmp(wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount) == -1 )
  551.     printf("PASS\n");
  552.   else
  553.     printf("FAIL\n");
  554.  
  555.   /* printf("Test ( compare one string to another with a null value ) : "); */
  556.   printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount));
  557.   if ( wcsncmp(wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount) > 1 )
  558.     printf("PASS\n");
  559.   else
  560.     printf("FAIL\n");
  561.  
  562.   /* printf("Test ( compare one string to another using tough string #1) : "); */
  563.  
  564.   printf(">");
  565.   hexout(wcsncmp_null_test1);
  566.   printf("< , >");
  567.   hexout(wcsncmp_null_dupe_test1);
  568.   printf("< ,");
  569.   printf(" >%d< ",wcsncmp_char_bigcount);
  570.   printf("return");
  571.   printf(" <%d> ",wcsncmp(wcsncmp_null_test1,wcsncmp_null_dupe_test1,wcsncmp_char_bigcount));
  572.   if ( wcsncmp(wcsncmp_null_test1,wcsncmp_null_dupe_test1,wcsncmp_char_bigcount) == 0 )
  573.     printf("PASS\n");
  574.   else
  575.     printf("FAIL\n");
  576.  
  577.   /* printf("Test ( compare one string to another using tough string #2) : "); */
  578.  
  579.   printf(">");
  580.   hexout(wcsncmp_null_test2);
  581.   printf("< , >");
  582.   hexout(wcsncmp_null_dupe_test2);
  583.   printf("< ,");
  584.   printf(" >%d< ",wcsncmp_char_smallcount);
  585.   printf("return");
  586.   printf(" <%d> ",wcsncmp(wcsncmp_null_test2,wcsncmp_null_dupe_test2,wcsncmp_char_smallcount));
  587.   if ( wcsncmp(wcsncmp_null_test2,wcsncmp_null_dupe_test2,wcsncmp_char_smallcount) == 0 )
  588.     printf("PASS\n");
  589.   else
  590.     printf("FAIL\n");
  591. }
  592.  
  593.  
  594.  
  595.  
  596. void test_wcscat(void)
  597. {
  598.  
  599.   wchar_t *wcscat_i = build_string("hot stuff");
  600.   wchar_t *wcscat_j = build_string(" and more hot stuff");
  601.   wchar_t *wcscat_k = build_string("hot stuff and more hot stuff");
  602.   wchar_t *wcscat_l = build_string("hot stuff");
  603.   wchar_t *wcscat_m = build_string("hot stuff");
  604.   wchar_t *wcscat_nul = build_string("");
  605.   wchar_t *wcscat_null_test1 = build_tough_string1();
  606.   wchar_t *wcscat_null_test2 = build_tough_string2();
  607.   wchar_t *wcscat_null_test3 = build_tough_string3();   /* result of 1 & 2 */
  608.  
  609.   /* TESTING WCSCAT() *************************************************/
  610.  
  611.   printf("\n\nTESTING wcscat()\n");
  612.  
  613.   /* printf("Test ( append one string to another ) : "); */
  614.  
  615.   printf(">%ls< , >%ls< returns ",wcscat_i,wcscat_j);
  616.   wcscat(wcscat_i,wcscat_j);
  617.   printf("<%ls> ",wcscat_i);
  618.   if ( wcscmp(wcscat_i,wcscat_k) == 0 )
  619.     printf("PASS\n");
  620.   else
  621.     printf("FAIL\n");
  622.  
  623.   /* printf("Test ( append a null string to a string ) : "); */
  624.  
  625.   printf(">%ls< , >%ls< returns ",wcscat_l,wcscat_nul);
  626.   wcscat(wcscat_l,wcscat_nul);
  627.   printf("<%ls> ",wcscat_l);
  628.   if ( wcscmp(wcscat_l,wcscat_m) == 0 )
  629.     printf("PASS\n");
  630.   else
  631.     printf("FAIL\n");
  632.  
  633.   /* printf("Test ( append a string to a null string ) : "); */
  634.  
  635.   printf(">%ls< , >%ls< returns ",wcscat_nul,wcscat_m);
  636.   wcscat(wcscat_nul,wcscat_m);
  637.   printf("<%ls> ",wcscat_nul);
  638.   if ( wcscmp(wcscat_nul,wcscat_l) == 0 )
  639.     printf("PASS\n");
  640.   else
  641.     printf("FAIL\n");
  642.  
  643.   /* printf("Test ( append tough string 1 to tough string 2 ) : "); */
  644.  
  645.   printf(">");
  646.   hexout(wcscat_null_test1);
  647.   printf("< , >");
  648.   hexout(wcscat_null_test2);
  649.   printf("< returns >");
  650.   wcscat(wcscat_null_test1,wcscat_null_test2);
  651.   hexout(wcscat_null_test1);
  652.   printf("< ");
  653.  
  654.   printf("<%ls> ",wcscat_null_test1);
  655.   if ( wcscmp(wcscat_null_test1,wcscat_null_test3) == 0 )
  656.     printf("PASS\n");
  657.   else
  658.     printf("FAIL\n");
  659.  
  660.  
  661. }
  662.  
  663. void test_wcscmp(void)
  664. {
  665.   wchar_t *wcscmp_i = build_string("hot stuff");
  666.   wchar_t *wcscmp_j = build_string("hot stuff");
  667.   wchar_t *wcscmp_k = build_string("hot stufe");
  668.   wchar_t *wcscmp_l = build_string("hot stufg");
  669.   wchar_t *wcscmp_nul = build_string("");
  670.   /* for tough null strings 1 & 2 this has been done in other testing */
  671.  
  672.  
  673.   /* TESTING WCSCMP() *************************************************/
  674.  
  675.   printf("\n\nTESTING wcscmp()\n");
  676.  
  677.   /* printf("Test ( compare one string to another with the same value ) : "); */
  678.  
  679.   printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_j,wcscmp(wcscmp_i,wcscmp_j));
  680.   if ( wcscmp(wcscmp_i,wcscmp_j) == 0 )
  681.     printf("PASS\n");
  682.   else
  683.     printf("FAIL\n");
  684.  
  685.   /* printf("Test ( compare one string to another with a greater value ) : "); */
  686.  
  687.   printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_k,wcscmp(wcscmp_i,wcscmp_k));
  688.   if ( wcscmp(wcscmp_i,wcscmp_k) == 1 )
  689.     printf("PASS\n");
  690.   else
  691.     printf("FAIL\n");
  692.  
  693.   /* printf("Test ( compare one string to another with a lesser value ) : "); */
  694.   printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_l,wcscmp(wcscmp_i,wcscmp_l));
  695.   if ( wcscmp(wcscmp_i,wcscmp_l) == -1 )
  696.     printf("PASS\n");
  697.   else
  698.     printf("FAIL\n");
  699.  
  700.   /* printf("Test ( compare one string to another with a null value ) : "); */
  701.   printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_nul,wcscmp(wcscmp_i,wcscmp_nul));
  702.   if ( wcscmp(wcscmp_i,wcscmp_nul) > 1 )
  703.     printf("PASS\n");
  704.   else
  705.     printf("FAIL\n");
  706.  
  707. }
  708.  
  709.  
  710. void test_wcspbrk(void)
  711. {
  712.  
  713.   wchar_t *pTemp;
  714.  
  715.   wchar_t *wcspbrk_i = build_string("hot stuff");
  716.   wchar_t *wcspbrk_j = build_string("s");
  717.   wchar_t *wcspbrk_k = build_string("z");
  718.   wchar_t *wcspbrk_l = build_string("stuff");
  719.   wchar_t *wcspbrk_m = build_string("hot stuff");
  720.   wchar_t *wcspbrk_nul = build_string("");
  721.   wchar_t *wcspbrk_null_test1 = build_tough_string1();
  722.   wchar_t *wcspbrk_n = build_string("B");
  723.   wchar_t *wcspbrk_o = build_string("BC");
  724.   wchar_t *wcspbrk_null_test2 = build_tough_string2();
  725.   wchar_t *wcspbrk_p;
  726.   wchar_t *wcspbrk_q;
  727.  
  728.   /* TESTING WCSPBRK() *************************************************/
  729.  
  730.   wcspbrk_p = (wchar_t*)calloc(1,sizeof(*wcspbrk_p));
  731.   wcspbrk_q = pTemp = (wchar_t*)calloc(2,sizeof(*wcspbrk_q));
  732.   *wcspbrk_p = (wchar_t)0x4600;
  733.   *wcspbrk_q = (wchar_t)0x4600;
  734.    wcspbrk_q++;
  735.   *wcspbrk_q = (wchar_t)0x0000;
  736.    wcspbrk_q = pTemp;
  737.  
  738.   printf("\n\nTESTING wcspbrk()\n");
  739.  
  740.   /* printf("Test ( checking for the first occurance of a letter in a string ) : "); */
  741.  
  742.   printf(">%ls< , >%ls< returns <%ls> ",wcspbrk_i,wcspbrk_j,wcspbrk(wcspbrk_i,wcspbrk_j));
  743.   if ( wcscmp(wcspbrk(wcspbrk_i,wcspbrk_j),wcspbrk_l) == 0 )
  744.     printf("PASS\n");
  745.   else
  746.     printf("FAIL\n");
  747.  
  748.   /* printf("Test ( checking for the first occurance of a letter in a null string ) : "); */
  749.  
  750.   printf(">%ls< , >%ls< returns <%ls>",wcspbrk_nul,wcspbrk_k,wcspbrk(wcspbrk_nul,wcspbrk_k));
  751.   if ( (wchar_t*)(wcspbrk(wcspbrk_nul,wcspbrk_k)) == NULL )
  752.     printf("> PASS\n");
  753.   else
  754.     printf("FAIL\n");
  755.  
  756.   /* printf("Test ( checking for the first occurance of a null in a string ) : "); */
  757.  
  758.   printf(">%ls< , >%ls< returns <%ls> ",wcspbrk_i,wcspbrk_nul,wcspbrk(wcspbrk_i,wcspbrk_nul));
  759.   if ( wcscmp(wcspbrk(wcspbrk_i,wcspbrk_nul),wcspbrk_nul) == 0 )
  760.     printf("PASS\n");
  761.   else
  762.     printf("FAIL\n");
  763.  
  764.   /* printf("Test ( checking for the first occurance of a letter not in a string ) : "); */
  765.  
  766.   printf(">%ls< , >%ls< returns <%ls>",wcspbrk_m,wcspbrk_k,wcspbrk(wcspbrk_m,wcspbrk_k));
  767.   if ( (wchar_t*)(wcspbrk(wcspbrk_m,wcspbrk_k)) == NULL )
  768.     printf("> PASS\n");
  769.   else
  770.     printf("FAIL\n");
  771.  
  772.   /* printf("Test ( checking - first occurance of a letter in a tough string 1 ) : "); */
  773.  
  774.   printf(">");
  775.   hexout(wcspbrk_null_test1);
  776.   printf("< , >");
  777.   hexout(wcspbrk_n);
  778.   printf("< returns >");
  779.   hexout(wcspbrk(wcspbrk_null_test1,wcspbrk_n));
  780.   printf("< ");
  781.   if ( wcscmp(wcspbrk(wcspbrk_null_test1,wcspbrk_n),wcspbrk_o) == 0 )
  782.     printf("PASS\n");
  783.   else
  784.     printf("FAIL\n");
  785.  
  786.   /* printf("Test ( checking - first occurance of a letter in a tough string 2 ) : "); */
  787.  
  788.   printf(">");
  789.   hexout(wcspbrk_null_test2);
  790.   printf("< , >");
  791.   printf("%X",*wcspbrk_p);
  792.   printf("< returns >");
  793.   hexout(wcspbrk(wcspbrk_null_test2,wcspbrk_p));
  794.   printf("< ");
  795.   if ( wcscmp(wcspbrk(wcspbrk_null_test2,wcspbrk_p),wcspbrk_q) == 0 )
  796.     printf("PASS\n");
  797.   else
  798.     printf("FAIL\n");
  799.  
  800.  
  801. }
  802.  
  803. void test_wcscspn(void)
  804. {
  805.   wchar_t *wcscspn_i = build_string("now is the time for all good men");
  806.   wchar_t *wcscspn_j = build_string("agd");
  807.   wchar_t *wcscspn_k = build_string("xyz");
  808.   wchar_t *wcscspn_nul = build_string("");
  809.   wchar_t *wcscspn_null_test1 = build_tough_string1();
  810.   wchar_t *wcscspn_l = build_string("C");
  811.   wchar_t *wcscspn_null_test2 = build_tough_string2();
  812.   wchar_t *wcscspn_m = build_string("B");
  813.  
  814.  
  815.   /* TESTING WCSCSPN() *************************************************/
  816.  
  817.   printf("\n\nTESTING wcscspn()\n");
  818.  
  819.   /* printf("Test ( number of charcters that don't match if some do match ) : "); */
  820.  
  821.   printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_j,wcscspn(wcscspn_i,wcscspn_j));
  822.   if ( wcscspn(wcscspn_i,wcscspn_j) == 20 )
  823.     printf("PASS\n");
  824.   else
  825.     printf("FAIL\n");
  826.  
  827.   /* printf("Test ( number of charcters that don't match if all don't match ) : "); */
  828.  
  829.   printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_k,wcscspn(wcscspn_i,wcscspn_k));
  830.   if ( wcscspn(wcscspn_i,wcscspn_k) == 32 )
  831.     printf("PASS\n");
  832.   else
  833.     printf("FAIL\n");
  834.  
  835.   /* printf("Test ( number of charcters that don't match if all are a match ) : "); */
  836.  
  837.   printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_i,wcscspn(wcscspn_i,wcscspn_i));
  838.   if ( wcscspn(wcscspn_i,wcscspn_i) == 0 )
  839.     printf("PASS\n");
  840.   else
  841.     printf("FAIL\n");
  842.  
  843.  
  844.   /* printf("Test ( number of charcters that don't match if the set is a null ) : "); */
  845.  
  846.   printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_nul,wcscspn(wcscspn_i,wcscspn_nul));
  847.   if ( wcscspn(wcscspn_i,wcscspn_nul) == 32 )
  848.     printf("PASS\n");
  849.   else
  850.     printf("FAIL\n");
  851.  
  852.   /* printf("Test ( number of charcters that don't match if the string is a null ) : "); */
  853.  
  854.   printf(">%ls< , >%ls< returns <%d> ",wcscspn_nul,wcscspn_k,wcscspn(wcscspn_nul,wcscspn_k));
  855.   if ( wcscspn(wcscspn_nul,wcscspn_k) == 0 )
  856.     printf("PASS\n");
  857.   else
  858.     printf("FAIL\n");
  859.  
  860.   /* printf("Test ( number in tough string 1 if some match ) : "); */
  861.  
  862.   printf(">");
  863.   hexout(wcscspn_null_test1);
  864.   printf("< , >");
  865.   hexout(wcscspn_l);
  866.   printf("< returns >%d< ",wcscspn(wcscspn_null_test1,wcscspn_l));
  867.   if ( wcscspn(wcscspn_null_test1,wcscspn_l) == 2 )
  868.     printf("PASS\n");
  869.   else
  870.     printf("FAIL\n");
  871.  
  872.   /* printf("Test ( number in tough string 2 if none match ) : "); */
  873.  
  874.   printf(">");
  875.   hexout(wcscspn_null_test2);
  876.   printf("< , >");
  877.   hexout(wcscspn_m);
  878.   printf("< returns >%d< ",wcscspn(wcscspn_null_test2,wcscspn_m));
  879.   if ( wcscspn(wcscspn_null_test2,wcscspn_m) == 3 )
  880.     printf("PASS\n");
  881.   else
  882.     printf("FAIL\n");
  883.  
  884. }
  885.  
  886. void test_wcsspn(void)
  887. {
  888.  
  889.   wchar_t *wcsspn_i = build_string("nowisthetimeforallgoodmen");
  890.   wchar_t *wcsspn_j = build_string("nowisthemfr");
  891.   wchar_t *wcsspn_k = build_string("pq");
  892.   wchar_t *wcsspn_nul = build_string("");
  893.   wchar_t *wcsspn_null_test1 = build_tough_string1();
  894.   wchar_t *wcsspn_l = build_string("AB");
  895.   wchar_t *wcsspn_null_test2 = build_tough_string2();
  896.   wchar_t *wcsspn_m = build_string("B");
  897.  
  898.  
  899.   /* TESTING WCSSPN() *************************************************/
  900.  
  901.   printf("\n\nTESTING wcsspn()\n");
  902.  
  903.   /* printf("Test ( number of charcters that match if some do match ) : "); */
  904.  
  905.   printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_j,wcsspn(wcsspn_i,wcsspn_j));
  906.   if ( wcsspn(wcsspn_i,wcsspn_j) == 15 )
  907.     printf("PASS\n");
  908.   else
  909.     printf("FAIL\n");
  910.  
  911.   /* printf("Test ( number of charcters that match if all don't match ) : "); */
  912.  
  913.   printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_k,wcsspn(wcsspn_i,wcsspn_k));
  914.   if ( wcsspn(wcsspn_i,wcsspn_k) == 0 )
  915.     printf("PASS\n");
  916.   else
  917.     printf("FAIL\n");
  918.  
  919.   /* printf("Test ( number of charcters that match if all match ) : "); */
  920.  
  921.   printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_i,wcsspn(wcsspn_i,wcsspn_i));
  922.   if ( wcsspn(wcsspn_i,wcsspn_i) == 25 )
  923.     printf("PASS\n");
  924.   else
  925.     printf("FAIL\n");
  926.  
  927.   /* printf("Test ( number of charcters that match if the set is a null ) : "); */
  928.  
  929.   printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_nul,wcsspn(wcsspn_i,wcsspn_nul));
  930.   if ( wcsspn(wcsspn_i,wcsspn_nul) == 0 )
  931.     printf("PASS\n");
  932.   else
  933.     printf("FAIL\n");
  934.  
  935.   /* printf("Test ( number of charcters that match if the string is a null ) : "); */
  936.  
  937.   printf(">%ls< , >%ls< returns <%d> ",wcsspn_nul,wcsspn_i,wcsspn(wcsspn_nul,wcsspn_i));
  938.   if ( wcsspn(wcsspn_nul,wcsspn_i) == 0 )
  939.     printf("PASS\n");
  940.   else
  941.     printf("FAIL\n");
  942.  
  943.   /* printf("Test ( number that match if some do match in tough string 1 ) : "); */
  944.  
  945.   printf(">");
  946.   hexout(wcsspn_null_test1);
  947.   printf("< , >");
  948.   hexout(wcsspn_l);
  949.   printf("< returns <%d> ",wcsspn(wcsspn_null_test1,wcsspn_l));
  950.   if ( wcsspn(wcsspn_null_test1,wcsspn_l) == 2 )
  951.     printf("PASS\n");
  952.   else
  953.     printf("FAIL\n");
  954.  
  955.   /* printf("Test ( number that match if all don't match in tough string 2) : "); */
  956.  
  957.   printf(">");
  958.   hexout(wcsspn_null_test2);
  959.   printf("< , >");
  960.   hexout(wcsspn_m);
  961.   printf("< returns <%d> ",wcsspn(wcsspn_null_test2,wcsspn_m));
  962.   if ( wcsspn(wcsspn_null_test2,wcsspn_m) == 0 )
  963.     printf("PASS\n");
  964.   else
  965.     printf("FAIL\n");
  966. }
  967.  
  968. void test_wcsncpy(void)
  969. {
  970.   wchar_t *wcsncpy_i = build_string("hot stuff");
  971.   size_t wcsncpy_char_count  = 3;
  972.   size_t wcsncpy_char_bigcount  = 20;
  973.   size_t wcsncpy_char_zerocount  = 0;
  974.   wchar_t *wcsncpy_j = build_string("         ");
  975.   wchar_t *wcsncpy_k = build_string("hot      ");
  976.   wchar_t *wcsncpy_l = build_string("hot stuff");
  977.   wchar_t *wcsncpy_nul = build_string("");
  978.  
  979.   wchar_t *wcsncpy_null_test1 = build_tough_string1();
  980.   wchar_t *wcsncpy_null_test2 = build_tough_string2();
  981.   size_t wcsncpy_char_tough_count1  = 2;
  982.   size_t wcsncpy_char_tough_count2  = 20;
  983.   wchar_t *wcsncpy_result1 = build_string("");
  984.   wchar_t *wcsncpy_result2 = build_string("");
  985.   wchar_t *wcsncpy_m = build_string("AB");
  986.  
  987.  
  988.   /* TESTING WCSNCPY() *************************************************/
  989.  
  990.   printf("\n\nTESTING wcsncpy()\n");
  991.  
  992.   /* printf("Test ( copy n characters from a string to a larger string ) : "); */
  993.  
  994.   printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_count,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_count));
  995.   if ( wcscmp(wcsncpy_j,wcsncpy_k) == 0 )
  996.     printf("PASS\n");
  997.   else
  998.     printf("FAIL\n");
  999.  
  1000.   /* printf("Test ( copy 0 characters from a string to a string ) : "); */
  1001.  
  1002.   printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_zerocount,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_zerocount));
  1003.   if ( wcscmp(wcsncpy_j,wcsncpy_k) == 0 )
  1004.     printf("PASS\n");
  1005.   else
  1006.     printf("FAIL\n");
  1007.  
  1008.   /* printf("Test ( copy n characters from a string to a smaller string ) : "); */
  1009.  
  1010.   printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_bigcount,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_bigcount));
  1011.   if ( wcscmp(wcsncpy_j,wcsncpy_l) == 0 )
  1012.     printf("PASS\n");
  1013.   else
  1014.     printf("FAIL\n");
  1015.  
  1016.   /* printf("Test ( copy n characters from a null string to a string ) : "); */
  1017.  
  1018.   printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_nul,wcsncpy_char_bigcount,wcsncpy(wcsncpy_j,wcsncpy_nul,wcsncpy_char_bigcount));
  1019.   if ( wcscmp(wcsncpy_j,wcsncpy_nul) == 0 )
  1020.     printf("PASS\n");
  1021.   else
  1022.     printf("FAIL\n");
  1023.  
  1024.   /* printf("Test ( copy n characters from a string to a null string ) : "); */
  1025.  
  1026.   printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_nul,wcsncpy_i,wcsncpy_char_bigcount,wcsncpy(wcsncpy_nul,wcsncpy_i,wcsncpy_char_bigcount));
  1027.   if ( wcscmp(wcsncpy_nul,wcsncpy_l) == 0 )
  1028.     printf("PASS\n");
  1029.   else
  1030.     printf("FAIL\n");
  1031.  
  1032.   /* printf("Test ( copy n characters from a tough string 1 to a null string ) : "); */
  1033.  
  1034.   printf(">");
  1035.   hexout(wcsncpy_result1);
  1036.   printf("< , >");
  1037.   hexout(wcsncpy_null_test1);
  1038.   printf("< , >%d< returns <",wcsncpy_char_tough_count1);
  1039.   hexout(wcsncpy(wcsncpy_result1,wcsncpy_null_test1,wcsncpy_char_tough_count1));
  1040.   printf("> ");
  1041.   if ( wcscmp(wcsncpy_result1,wcsncpy_m) == 0 )
  1042.     printf("PASS\n");
  1043.   else
  1044.     printf("FAIL\n");
  1045.  
  1046.   /* printf("Test ( copy n characters from a tough string 2 to a string ) : "); */
  1047.  
  1048.   printf(">");
  1049.   hexout(wcsncpy_result2);
  1050.   printf("< , >");
  1051.   hexout(wcsncpy_null_test2);
  1052.   printf("< , >%d< returns <",wcsncpy_char_tough_count2);
  1053.   hexout(wcsncpy(wcsncpy_result2,wcsncpy_null_test2,wcsncpy_char_tough_count2));
  1054.   printf("> ");
  1055.   if ( wcscmp(wcsncpy_result2,wcsncpy_null_test2) == 0 )
  1056.     printf("PASS\n");
  1057.   else
  1058.     printf("FAIL\n");
  1059.  
  1060.  
  1061. }
  1062.  
  1063.  
  1064. /**************************************************************************/
  1065. /**************************************************************************/
  1066.  
  1067. /* Convert a buffer of char to a buffer of wchar */
  1068. wchar_t *build_string(char *ws)
  1069. {
  1070.   int count = 0;
  1071.   wchar_t *pTemp,
  1072.           *pBegin;
  1073.  
  1074.   pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pTemp));
  1075.  
  1076.   while( *ws != 0x00 )
  1077.   {
  1078.     *pTemp = (wchar_t)*ws;
  1079.     pTemp++;
  1080.     ws++;
  1081.   }
  1082.   *pTemp = 0L;
  1083.   return(pBegin);
  1084. }
  1085.  
  1086.  
  1087. /* Build first tough string to test out null features */
  1088. wchar_t *build_tough_string1( void )
  1089. {
  1090.   wchar_t *pTemp,
  1091.           *pBegin;
  1092.  
  1093.   pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
  1094.  
  1095.   *pTemp = (wchar_t)0x0041;
  1096.   pTemp++;
  1097.   *pTemp = (wchar_t)0x0042;
  1098.   pTemp++;
  1099.   *pTemp = (wchar_t)0x0043;
  1100.   pTemp++;
  1101.   *pTemp = (wchar_t)0x0000;
  1102.  
  1103.   return(pBegin);
  1104. }
  1105.  
  1106. /* Build second tough string to test out null features */
  1107. wchar_t *build_tough_string2( void )
  1108. {
  1109.   wchar_t *pTemp,
  1110.           *pBegin;
  1111.  
  1112.   pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
  1113.  
  1114.   *pTemp = (wchar_t)0x4400;
  1115.   pTemp++;
  1116.   *pTemp = (wchar_t)0x4500;
  1117.   pTemp++;
  1118.   *pTemp = (wchar_t)0x4600;
  1119.   pTemp++;
  1120.   *pTemp = (wchar_t)0x0000;
  1121.  
  1122.   return(pBegin);
  1123. }
  1124.  
  1125. /* Build third tough string that is the cat of string 1 & string 2 */
  1126. wchar_t *build_tough_string3( void )
  1127. {
  1128.   wchar_t *pTemp,
  1129.           *pBegin;
  1130.  
  1131.   pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
  1132.  
  1133.   *pTemp = (wchar_t)0x0041;
  1134.   pTemp++;
  1135.   *pTemp = (wchar_t)0x0042;
  1136.   pTemp++;
  1137.   *pTemp = (wchar_t)0x0043;
  1138.   pTemp++;
  1139.   *pTemp = (wchar_t)0x4400;
  1140.   pTemp++;
  1141.   *pTemp = (wchar_t)0x4500;
  1142.   pTemp++;
  1143.   *pTemp = (wchar_t)0x4600;
  1144.   pTemp++;
  1145.   *pTemp = (wchar_t)0x0000;
  1146.  
  1147.   return(pBegin);
  1148. }
  1149.  
  1150.  
  1151. /* prints out a hex string from the chars pointed to by pString */
  1152. void hexout( wchar_t *pString )
  1153. {
  1154.   while ( *pString != NullL )
  1155.   {
  1156.     printf("%X",*pString);
  1157.     pString++;
  1158.   }
  1159. }
  1160.