home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <wchar.h>
- #include <locale.h>
- #define NullL 0L
- /*
- typedef unsigned short wchar_t;
- typedef int wint_t;
- */
- wchar_t *build_string(char *ws);
- wchar_t *build_tough_string1( void );
- wchar_t *build_tough_string2( void );
- wchar_t *build_tough_string3( void );
- void hexout( wchar_t *pString );
- /*
- size_t wcscspn(const wchar_t *ws1, const wchar_t *ws2);
- size_t wcslen(const wchar_t *ws);
- wchar_t *wcscat(wchar_t *ws1, const wchar_t *ws2);
- wchar_t *wcscpy(wchar_t *ws1, const wchar_t *ws2);
- int wcscmp(const wchar_t *ws1, const wchar_t *ws2);
- wchar_t *wcspbrk(const wchar_t *ws1, const wchar_t *ws2);
- wchar_t *wcsncpy(wchar_t *ws1, const wchar_t *ws2, size_t n);
- size_t wcsspn(const wchar_t *ws1, const wchar_t *ws2);
- wchar_t *wcschr(wchar_t *ws1, wint_t wc);
- wchar_t *wcsncat(wchar_t *ws1, const wchar_t *ws2, size_t n);
- wchar_t *wcsrchr(wchar_t *ws1, wint_t wc);
- wchar_t *wcstok(wchar_t *ws1, const wchar_t *ws2);
- wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2);
- */
-
- void test_wcslen(void);
- void test_wcscspn(void);
- void test_wcscat(void);
- void test_wcscpy(void);
- void test_wcscmp(void);
- void test_wcsncmp(void);
- void test_wcspbrk(void);
- void test_wcsncpy(void);
- void test_wcsspn(void);
-
-
- void main()
- {
-
- wchar_t *pReset;
-
- wchar_t *z= build_string(" ");
- /**************/
- wchar_t *Aws1 = build_string("abcdefgh");
- wint_t Ax;
- wint_t AwsT0;
- wchar_t *AwsT1 = build_tough_string1( );
- wchar_t *AwsT2 = build_tough_string2( );
- wchar_t *AwsT3 = build_tough_string3( );
- wchar_t *AwsT4;
- wchar_t *AwsT5;
-
- /**************/
- wchar_t *Bws1 = build_string("abcd");
- wchar_t *Bxxx = build_string(" ");
- wchar_t *Bws2 = build_string("ef");
- wchar_t *Bws3 = build_string("ghij");
- wchar_t *Bws4 = build_string("xxx");
- wchar_t *Bws5 = build_string("ijklm");
- wchar_t *Bnull = build_string("");
- wchar_t *Byyy = build_string(" ");
- size_t Bn;
- /****************/
- wchar_t *Cws1 = build_string("zyxwvutsrqpo");
- wchar_t *Cxxx = build_string(" ");
- wchar_t *Cws2 = build_string("abcd");
- wchar_t *Cws3 = build_string("xyz");
- wchar_t *Cws4 = build_string("abxx");
- wchar_t *Cws5 = build_string("xxx");
- wchar_t *Cnull = build_string("");
- wchar_t *Cyyy = build_string(" ");
- size_t Cn;
- /**************/
- wchar_t *Dws1 = build_string("abcccfgh");
- wint_t Dx;
- /*************/
- wchar_t *Ews1 = build_string("abc,defg,hijklmnopq,rstuv,wxyz");
- wchar_t *Ews2 = build_string(",");
- wchar_t *Ews3 = build_string(",");
- wchar_t *Ews4 = build_string(",");
- wchar_t *Ews5 = build_string(",");
- wchar_t *Ews6 = build_string(",");
- wchar_t *Ews7 = build_string(",");
- wchar_t *Enull = build_string("");
- /***************/
- wchar_t *Fws1 = build_string("abcabcdabcdeabcdefg");
- wchar_t *Fws2 = build_string("abc");
- wchar_t *Fws3 = build_string("abcde");
- wchar_t *Fws4 = build_string("abcdx");
- wchar_t *Fws5 = build_string("g");
- wchar_t *Fws6 = build_string("fg");
-
- printf("\nTESTING wcschr()\n");
- Ax = 'h';
- printf("\n>abcdefgh< , >h< returns <%s>",z=wcschr(Aws1,Ax));
- if ( ! wcscmp( z, build_string("h") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = 'd';
- printf("\n>abcdefgh< , >d< returns <%ls>",z=wcschr(Aws1,Ax));
- if ( ! wcscmp( z, build_string("defgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = 's';
- printf("\n>abcdefgh< , >s< returns <%ld>",z=wcschr(Aws1,Ax));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = 'a';
- printf("\n>abcdefgh< , >a< returns <%ls>",z=wcschr(Aws1,Ax));
- if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = '\0';
- printf("\n>abcdefgh< , >null< returns <%ld>",z=wcschr(Aws1,Ax));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = '\0';
- printf("\n>NULL< , >null< returns <%ld>",z=wcschr(Bnull,Ax));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- Ax = 'x';
- printf("\n>NULL< , >x< returns <%ld>",z=wcschr(Bnull,Ax));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT0 = (wint_t)*AwsT1;
- printf("\n>0A0B0C< , >0A< returns <%ls>",z=wcschr(AwsT1,AwsT0));
- if ( ! wcscmp(z,AwsT1) ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT0 = (wint_t)*AwsT1+2;
- printf("\n>0A0B0C< , >0C< returns <%ls>",z=wcschr(AwsT1,AwsT0));
- if ( ! wcscmp(z,AwsT1+2) ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT4 = (wchar_t*)calloc(1,sizeof(*AwsT4));
- AwsT5 = pReset = (wchar_t*)calloc(2,sizeof(*AwsT5));
- *AwsT4 = (wchar_t)0x4600;
- *AwsT5 = (wchar_t)0x4600;
- AwsT5++;
- *AwsT5 = (wchar_t)0x0000;
- AwsT5 = pReset;
- AwsT0 = (wint_t)*AwsT4;
-
- printf("\n>D0E0F0< , >F0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
- if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4700;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>D0E0F0< , >G0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4400;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>D0E0F0< , >D0< returns <%ld>",z=wcschr(AwsT2,AwsT0));
- if ( ! wcscmp(z,AwsT3+3) ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4600;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>0A0B0CD0E0F0< , >F0< returns <%ld>",z=wcschr(AwsT3,AwsT0));
- if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\nTESTING wcsncat()\n");
- Bn = 6;
- printf("\n>abcd< , >ef< , >6< returns <%ls>",z=wcsncat(Bws1,Bws2,Bn));
- if ( ! wcscmp( z, build_string("abcdef") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 2;
- printf("\n>abcdef< , >ghij< , >2< returns <%ls>",z=wcsncat(Bws1,Bws3,Bn));
- if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 0;
- printf("\n>abcdefgh< , >xxx< , >0< returns <%ls>",z=wcsncat(Bws1,Bws4,Bn));
- if ( ! wcscmp( z, build_string("abcdefgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 5;
- printf("\n>abcdefgh< , >ijklm< , >5< returns <%ls>",z=wcsncat(Bws1,Bws5,Bn));
- if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 7;
- printf("\n>NULL< , >NULL< , >7< returns <%ls>",z=wcsncat(Bnull,Enull,Bn));
- if ( z == Bnull ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 2;
- printf("\n>NULL< , >ghij< , >2< returns <%ls>",z=wcsncat(Bnull,Bws3,Bn));
- if ( ! wcscmp( z, build_string("gh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 0;
- printf("\n>abcdefghijklm< , >NULL< , >0< returns <%ls>",z=wcsncat(Bws1,Enull,Bn));
- if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Bn = 7;
- printf("\n>abcdefghijklm< , >NULL< , >7< returns <%ls>",z=wcsncat(Bws1,Enull,Bn));
- if ( ! wcscmp( z, build_string("abcdefghijklm") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 4;
- wcsncpy(z,AwsT1,Cn);
- Bn = 0;
- printf("\n>0A0B0C< , >D0E0F0< , >0< returns <%ls>",z=wcsncat(z,AwsT2,Bn));
- if ( ! wcscmp( z, AwsT1 ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 4;
- wcsncpy(z,AwsT1,Cn);
- Bn = 7;
- printf("\n>0A0B0C< , >D0E0F0< , >7< returns <%ld>",z=wcsncat(z,AwsT2,Bn));
- if ( ! wcscmp( z, AwsT3 ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 4;
- wcsncpy(z,AwsT1,Cn);
- Bn = 3;
- printf("\n>0A0B0C< , >D0E0F0< , >3< returns <%ld>",z=wcsncat(z,AwsT2,Bn));
- if ( ! wcscmp( z, AwsT3 ) ) printf(" Passed\n"); else printf(" Failed\n");
-
-
- printf("\nTESTING wcsncpy()\n");
- Cn = 4;
- printf("\n>zyxwvutsrqpo< , >abcd< , >4< returns <%ls>",z=wcsncpy(Cws1,Cws2,Cn));
- if ( ! wcscmp( z, build_string("abcdvutsrqpo") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 6;
- printf("\n>abcd< , >xyz< , >6< returns <%ls>",z=wcsncpy(Cws1,Cws3,Cn));
- if ( ! wcscmp( z, build_string("xyz") ) )printf(" Passed\n");
- Cn = 2;
- printf("\n>xyz< , >abxx< , >2< returns <%ls>",z=wcsncpy(Cws1,Cws4,Cn));
- if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 0;
- printf("\n>abz< , >xxx< , >0< returns <%ls>",z=wcsncpy(Cws1,Cws5,Cn));
- if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 7;
- printf("\n>NULL< , >NULL< , >7< returns <%ls>",z=wcsncpy(Cnull,Enull,Cn));
- if ( z == Cnull ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 2;
- printf("\n>NULL< , >abxx< , >2< returns <%ls>",z=wcsncpy(Cnull,Cws4,Cn));
- if ( ! wcscmp( z, build_string("ab") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Cn = 0;
- printf("\n>abz< , >NULL< , >7< returns <%ls>",z=wcsncpy(Cws1,Enull,Cn));
- if ( ! wcscmp( z, build_string("abz") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
-
- printf("\nTESTING wcsrchr()\n");
- Dx = 'h';
- printf("\n>abcccfgh< , >h< returns <%s>",z=wcsrchr(Dws1,Dx));
- if ( ! wcscmp( z, build_string("h") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = 'c';
- printf("\n>abcccfgh< , >c< returns <%ls>",z=wcsrchr(Dws1,Dx));
- if ( ! wcscmp( z, build_string("cfgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = 's';
- printf("\n>abcccfgh< , >s< returns <%ld>",z=wcsrchr(Dws1,Dx));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = 'a';
- printf("\n>abcccfgh< , >a< returns <%ls>",z=wcsrchr(Dws1,Dx));
- if ( ! wcscmp( z, build_string("abcccfgh") ) ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = '\0';
- printf("\n>abcccfgh< , >null< returns <%ld>",z=wcsrchr(Dws1,Dx));
- if ( z == Dws1+8 ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = '\0';
- printf("\n>NULL< , >null< returns <%ld>",z=wcsrchr(Enull,Dx));
- if ( z == Enull ) printf(" Passed\n"); else printf(" Failed\n");
- Dx = 'x';
- printf("\n>NULL< , >x< returns <%ld>",z=wcsrchr(Enull,Dx));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT0 = (wint_t)*AwsT1;
- printf("\n>0A0B0C< , >0A< returns <%ls>",z=wcsrchr(AwsT1,AwsT0));
- if ( ! wcscmp(z,AwsT1) ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT0 = (wint_t)*AwsT1+2;
- printf("\n>0A0B0C< , >0C< returns <%ls>",z=wcsrchr(AwsT1,AwsT0));
- if ( ! wcscmp(z,AwsT1+2) ) printf(" Passed\n"); else printf(" Failed\n");
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>D0E0F0< , >F0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
- if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4700;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>D0E0F0< , >G0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4400;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>D0E0F0< , >D0< returns <%ld>",z=wcsrchr(AwsT2,AwsT0));
- if ( ! wcscmp(z,AwsT3+3) ) printf(" Passed\n"); else printf(" Failed\n");
- *AwsT4 = (wchar_t)0x4600;
- AwsT0 = (wint_t)*AwsT4;
- printf("\n>0A0B0CD0E0F0< , >F0< returns <%ld>",z=wcsrchr(AwsT3,AwsT0));
- if ( ! wcscmp(z,AwsT3+5) ) printf(" Passed\n"); else printf(" Failed\n");
-
-
-
- printf("\nTESTING wcstok()\n");
-
- printf("\n>abc,defg,hijklmnopq,rstuv,wxyz< , >,< returns <%ls>",z=wcstok(Ews1,Ews2));
- if ( ! wcscmp( z, build_string("def") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
- if ( ! wcscmp( z, build_string("") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
- if ( ! wcscmp( z, build_string("ij") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
- if ( ! wcscmp( z, build_string("lmn") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ls>",z=wcstok(Enull,Ews2));
- if ( ! wcscmp( z, build_string("pqrstuvwxyz") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ld>",z=wcstok(Enull,Ews2));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >,< returns <%ld>",z=wcstok(Enull,Ews2));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcdefg< , >,< returns <%ld>",z=wcstok(Ews5,Ews2));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcdefg< , >NULL< returns <%ls>",z=wcstok(Ews5,Enull));
- if ( ! wcscmp( z, build_string("abcdefg") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >NULL< returns <%ld>",z=wcstok(Enull,Enull));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- AwsT1 = build_tough_string1( );
- AwsT2 = build_tough_string2( );
- AwsT3 = build_tough_string3( );
-
- printf("\n>0A0B0CD0E0F0< , >D0E0F0< returns <%ld>",z=wcstok(AwsT3,AwsT2));
- if ( ! wcscmp( AwsT3, z ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >D0E0F0< returns <%ld>",z=wcstok(Enull,AwsT2));
- if ( ! wcscmp( z, build_string("") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>D0E0F0< , >D0E0F0< returns <%ld>",z=wcstok(AwsT2,AwsT2));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
-
-
- printf("\nTESTING wcswcs()\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >abc< returns <%ls>",z=wcswcs(Fws1,Fws2));
- if ( ! wcscmp( z, build_string("abcabcdabcdeabcdefg") ) ) printf(" Passed\n");
- else printf(" Failed\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >abcde< returns <%ls>",z=wcswcs(Fws1,Fws3));
- if ( ! wcscmp( z, build_string("abcdeabcdefg") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >abcdx< returns <%ld>",z=wcswcs(Fws1,Fws4));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >g< returns <%ls>",z=wcswcs(Fws1,Fws5));
- if ( ! wcscmp( z, build_string("g") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >fg< returns <%ls>",z=wcswcs(Fws1,Fws6));
- if ( ! wcscmp( z, build_string("fg") ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>abcabcdabcdeabcdefg< , >NULL< returns <%ls>",z=wcswcs(Fws1,Enull));
- if ( ! wcscmp( z, build_string("abcabcdabcdeabcdefg") ) ) printf(" Passed\n");
- else printf(" Failed\n");
-
- printf("\n>NULL< , >NULL< returns <%ld>",z=wcswcs(Enull,Enull));
- if ( z == Enull ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >fg< returns <%ld>",z=wcswcs(Enull,Fws6));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- AwsT1 = build_tough_string1( );
- AwsT2 = build_tough_string2( );
- AwsT3 = build_tough_string3( );
-
- printf("\n>0A0B0CD0E0F0< , >D0E0F0< returns <%ld>",z=wcswcs(AwsT3,AwsT2));
- if ( ! wcscmp( z, AwsT3+3 ) ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>NULL< , >D0E0F0< returns <%ld>",z=wcswcs(Enull,AwsT2));
- if ( z == NULL ) printf(" Passed\n"); else printf(" Failed\n");
-
- printf("\n>D0E0F0< , >D0E0F0< returns <%ld>",z=wcswcs(AwsT2,AwsT2));
- if ( ! wcscmp( z, AwsT2 ) ) printf(" Passed\n"); else printf(" Failed\n");
-
-
- /**************************************************************************/
- /**************************************************************************/
-
- test_wcslen();
- test_wcscpy();
- test_wcscat();
- test_wcscmp();
- test_wcspbrk();
- test_wcscspn();
- test_wcsspn();
- test_wcsncpy();
- test_wcsncmp();
- /**************************************************************************/
- /**************************************************************************/
-
- }
-
- /**************************************************************************/
- /**************************************************************************/
-
- void test_wcslen(void)
- {
-
- wchar_t *wcslen_i = build_string("hot stuff");
- wchar_t *wcslen_nul = build_string("");
- wchar_t *wcslen_null_test1 = build_tough_string1();
- wchar_t *wcslen_null_test2 = build_tough_string2();
-
- /* TESTING WCSLEN() *************************************************/
-
- printf("\n\nTESTING wcslen()\n");
-
- /* printf("Test ( check the length of a null length string ) : "); */
- printf(">%ls< returns %d ",wcslen_nul,wcslen(wcslen_nul));
- if (wcslen(wcslen_nul) == 0)
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( check the length of a string ) : "); */
- printf(">%ls< returns %d ",wcslen_i,wcslen(wcslen_i));
- if (wcslen(wcslen_i) == 9)
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* test tough null string 1 */
- /* printf("Test ( check the length of tough string 1 ) : "); */
-
- printf(">");
- hexout(wcslen_null_test1);
- printf("< returns >%d< ",wcslen(wcslen_null_test1));
-
- if (wcslen(wcslen_null_test1) == 3)
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* test tough null string 2 */
- /* printf("Test ( check the length of tough string 2 ) : "); */
-
- printf(">");
- hexout(wcslen_null_test2);
- printf("< returns >%d< ",wcslen(wcslen_null_test2));
-
- if (wcslen(wcslen_null_test2) == 3)
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- }
-
-
- void test_wcscpy(void)
- {
- wchar_t *wcscpy_i = build_string("hot stuff");
- wchar_t *wcscpy_j = build_string("xxxxxxxxxxxxxx");
- wchar_t *wcscpy_k = build_string("hot stuff");
- wchar_t *wcscpy_nul = build_string("");
- wchar_t *wcscpy_null_test1 = build_tough_string1();
- wchar_t *wcscpy_nul1 = build_string("");
- wchar_t *wcscpy_null_test2 = build_tough_string2();
- wchar_t *wcscpy_nul2 = build_string("");
-
-
- /* TESTING WCSCPY() *************************************************/
-
- printf("\n\nTESTING wcscpy()\n");
-
- /* copy on top of a another larger string */
- /* printf("Test ( copy a small string on top of a larger string ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscpy_j,wcscpy_i);
- wcscpy(wcscpy_j,wcscpy_i);
- printf("<%ls> ",wcscpy_j);
- if ( wcscmp(wcscpy_i,wcscpy_j) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* copy from a null space */
- /* printf("Test ( copy from a null string to a string ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscpy_i,wcscpy_nul);
- wcscpy(wcscpy_i,wcscpy_nul);
- printf("<%ls> ",wcscpy_i);
- if ( wcscmp(wcscpy_nul,wcscpy_i) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* copy to a null space */
- /* printf("Test ( copy from a string to a null string ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscpy_nul,wcscpy_k);
- wcscpy(wcscpy_nul,wcscpy_k);
- printf("<%ls> ",wcscpy_nul);
- if ( wcscmp(wcscpy_k,wcscpy_nul) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* copy from tough string 1 to a null space */
- /* printf("Test ( copy from tough string 1 to a null string ) : "); */
-
- printf(">");
- hexout(wcscpy_nul1);
- printf("< , >");
- hexout(wcscpy_null_test1);
- printf("< returns >");
- wcscpy(wcscpy_nul1,wcscpy_null_test1);
- hexout(wcscpy_nul1);
- printf("< ");
-
- if ( wcscmp(wcscpy_null_test1,wcscpy_nul1) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* copy from tough string 2 to a null space */
- /* printf("Test ( copy from tough string 2 to a null string ) : "); */
-
- printf(">");
- hexout(wcscpy_nul2);
- printf("< , >");
- hexout(wcscpy_null_test2);
- printf("< returns >");
- wcscpy(wcscpy_nul2,wcscpy_null_test2);
- hexout(wcscpy_nul2);
- printf("< ");
-
- if ( wcscmp(wcscpy_null_test2,wcscpy_nul2) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
- }
-
-
- void test_wcsncmp(void)
- {
- size_t wcsncmp_char_count = 9;
- size_t wcsncmp_char_smallcount = 2;
- size_t wcsncmp_char_bigcount = 20;
- size_t wcsncmp_char_zerocount = 0;
- wchar_t *wcsncmp_i = build_string("hot stuff");
- wchar_t *wcsncmp_j = build_string("hot stuff");
- wchar_t *wcsncmp_k = build_string("hot stufe here");
- wchar_t *wcsncmp_l = build_string("hot stufg now");
- wchar_t *wcsncmp_nul = build_string("");
-
- wchar_t *wcsncmp_null_test1 = build_tough_string1();
- wchar_t *wcsncmp_null_dupe_test1 = build_tough_string1();
-
- wchar_t *wcsncmp_null_test2 = build_tough_string2();
- wchar_t *wcsncmp_null_dupe_test2 = build_tough_string2();
-
-
- /* TESTING wcsncmp() *************************************************/
-
- printf("\n\nTESTING wcsncmp()\n");
-
- /* printf("Test ( compare one string to another with the same value ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_j,wcsncmp_char_count,wcsncmp(wcsncmp_i,wcsncmp_j,wcsncmp_char_count));
- if ( wcsncmp(wcsncmp_i,wcsncmp_j,wcsncmp_char_count) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a greater value ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount));
- if ( wcsncmp(wcsncmp_i,wcsncmp_k,wcsncmp_char_bigcount) == 1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a lesser value ) : "); */
- printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount));
- if ( wcsncmp(wcsncmp_i,wcsncmp_l,wcsncmp_char_bigcount) == -1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a null value ) : "); */
- printf(">%ls< , >%ls< , >%d< returns <%d> ",wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount,wcsncmp(wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount));
- if ( wcsncmp(wcsncmp_i,wcsncmp_nul,wcsncmp_char_bigcount) > 1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another using tough string #1) : "); */
-
- printf(">");
- hexout(wcsncmp_null_test1);
- printf("< , >");
- hexout(wcsncmp_null_dupe_test1);
- printf("< ,");
- printf(" >%d< ",wcsncmp_char_bigcount);
- printf("return");
- printf(" <%d> ",wcsncmp(wcsncmp_null_test1,wcsncmp_null_dupe_test1,wcsncmp_char_bigcount));
- if ( wcsncmp(wcsncmp_null_test1,wcsncmp_null_dupe_test1,wcsncmp_char_bigcount) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another using tough string #2) : "); */
-
- printf(">");
- hexout(wcsncmp_null_test2);
- printf("< , >");
- hexout(wcsncmp_null_dupe_test2);
- printf("< ,");
- printf(" >%d< ",wcsncmp_char_smallcount);
- printf("return");
- printf(" <%d> ",wcsncmp(wcsncmp_null_test2,wcsncmp_null_dupe_test2,wcsncmp_char_smallcount));
- if ( wcsncmp(wcsncmp_null_test2,wcsncmp_null_dupe_test2,wcsncmp_char_smallcount) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
- }
-
-
-
-
- void test_wcscat(void)
- {
-
- wchar_t *wcscat_i = build_string("hot stuff");
- wchar_t *wcscat_j = build_string(" and more hot stuff");
- wchar_t *wcscat_k = build_string("hot stuff and more hot stuff");
- wchar_t *wcscat_l = build_string("hot stuff");
- wchar_t *wcscat_m = build_string("hot stuff");
- wchar_t *wcscat_nul = build_string("");
- wchar_t *wcscat_null_test1 = build_tough_string1();
- wchar_t *wcscat_null_test2 = build_tough_string2();
- wchar_t *wcscat_null_test3 = build_tough_string3(); /* result of 1 & 2 */
-
- /* TESTING WCSCAT() *************************************************/
-
- printf("\n\nTESTING wcscat()\n");
-
- /* printf("Test ( append one string to another ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscat_i,wcscat_j);
- wcscat(wcscat_i,wcscat_j);
- printf("<%ls> ",wcscat_i);
- if ( wcscmp(wcscat_i,wcscat_k) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( append a null string to a string ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscat_l,wcscat_nul);
- wcscat(wcscat_l,wcscat_nul);
- printf("<%ls> ",wcscat_l);
- if ( wcscmp(wcscat_l,wcscat_m) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( append a string to a null string ) : "); */
-
- printf(">%ls< , >%ls< returns ",wcscat_nul,wcscat_m);
- wcscat(wcscat_nul,wcscat_m);
- printf("<%ls> ",wcscat_nul);
- if ( wcscmp(wcscat_nul,wcscat_l) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( append tough string 1 to tough string 2 ) : "); */
-
- printf(">");
- hexout(wcscat_null_test1);
- printf("< , >");
- hexout(wcscat_null_test2);
- printf("< returns >");
- wcscat(wcscat_null_test1,wcscat_null_test2);
- hexout(wcscat_null_test1);
- printf("< ");
-
- printf("<%ls> ",wcscat_null_test1);
- if ( wcscmp(wcscat_null_test1,wcscat_null_test3) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
-
- }
-
- void test_wcscmp(void)
- {
- wchar_t *wcscmp_i = build_string("hot stuff");
- wchar_t *wcscmp_j = build_string("hot stuff");
- wchar_t *wcscmp_k = build_string("hot stufe");
- wchar_t *wcscmp_l = build_string("hot stufg");
- wchar_t *wcscmp_nul = build_string("");
- /* for tough null strings 1 & 2 this has been done in other testing */
-
-
- /* TESTING WCSCMP() *************************************************/
-
- printf("\n\nTESTING wcscmp()\n");
-
- /* printf("Test ( compare one string to another with the same value ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_j,wcscmp(wcscmp_i,wcscmp_j));
- if ( wcscmp(wcscmp_i,wcscmp_j) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a greater value ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_k,wcscmp(wcscmp_i,wcscmp_k));
- if ( wcscmp(wcscmp_i,wcscmp_k) == 1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a lesser value ) : "); */
- printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_l,wcscmp(wcscmp_i,wcscmp_l));
- if ( wcscmp(wcscmp_i,wcscmp_l) == -1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( compare one string to another with a null value ) : "); */
- printf(">%ls< , >%ls< returns <%d> ",wcscmp_i,wcscmp_nul,wcscmp(wcscmp_i,wcscmp_nul));
- if ( wcscmp(wcscmp_i,wcscmp_nul) > 1 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- }
-
-
- void test_wcspbrk(void)
- {
-
- wchar_t *pTemp;
-
- wchar_t *wcspbrk_i = build_string("hot stuff");
- wchar_t *wcspbrk_j = build_string("s");
- wchar_t *wcspbrk_k = build_string("z");
- wchar_t *wcspbrk_l = build_string("stuff");
- wchar_t *wcspbrk_m = build_string("hot stuff");
- wchar_t *wcspbrk_nul = build_string("");
- wchar_t *wcspbrk_null_test1 = build_tough_string1();
- wchar_t *wcspbrk_n = build_string("B");
- wchar_t *wcspbrk_o = build_string("BC");
- wchar_t *wcspbrk_null_test2 = build_tough_string2();
- wchar_t *wcspbrk_p;
- wchar_t *wcspbrk_q;
-
- /* TESTING WCSPBRK() *************************************************/
-
- wcspbrk_p = (wchar_t*)calloc(1,sizeof(*wcspbrk_p));
- wcspbrk_q = pTemp = (wchar_t*)calloc(2,sizeof(*wcspbrk_q));
- *wcspbrk_p = (wchar_t)0x4600;
- *wcspbrk_q = (wchar_t)0x4600;
- wcspbrk_q++;
- *wcspbrk_q = (wchar_t)0x0000;
- wcspbrk_q = pTemp;
-
- printf("\n\nTESTING wcspbrk()\n");
-
- /* printf("Test ( checking for the first occurance of a letter in a string ) : "); */
-
- printf(">%ls< , >%ls< returns <%ls> ",wcspbrk_i,wcspbrk_j,wcspbrk(wcspbrk_i,wcspbrk_j));
- if ( wcscmp(wcspbrk(wcspbrk_i,wcspbrk_j),wcspbrk_l) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( checking for the first occurance of a letter in a null string ) : "); */
-
- printf(">%ls< , >%ls< returns <%ls>",wcspbrk_nul,wcspbrk_k,wcspbrk(wcspbrk_nul,wcspbrk_k));
- if ( (wchar_t*)(wcspbrk(wcspbrk_nul,wcspbrk_k)) == NULL )
- printf("> PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( checking for the first occurance of a null in a string ) : "); */
-
- printf(">%ls< , >%ls< returns <%ls> ",wcspbrk_i,wcspbrk_nul,wcspbrk(wcspbrk_i,wcspbrk_nul));
- if ( wcscmp(wcspbrk(wcspbrk_i,wcspbrk_nul),wcspbrk_nul) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( checking for the first occurance of a letter not in a string ) : "); */
-
- printf(">%ls< , >%ls< returns <%ls>",wcspbrk_m,wcspbrk_k,wcspbrk(wcspbrk_m,wcspbrk_k));
- if ( (wchar_t*)(wcspbrk(wcspbrk_m,wcspbrk_k)) == NULL )
- printf("> PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( checking - first occurance of a letter in a tough string 1 ) : "); */
-
- printf(">");
- hexout(wcspbrk_null_test1);
- printf("< , >");
- hexout(wcspbrk_n);
- printf("< returns >");
- hexout(wcspbrk(wcspbrk_null_test1,wcspbrk_n));
- printf("< ");
- if ( wcscmp(wcspbrk(wcspbrk_null_test1,wcspbrk_n),wcspbrk_o) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( checking - first occurance of a letter in a tough string 2 ) : "); */
-
- printf(">");
- hexout(wcspbrk_null_test2);
- printf("< , >");
- printf("%X",*wcspbrk_p);
- printf("< returns >");
- hexout(wcspbrk(wcspbrk_null_test2,wcspbrk_p));
- printf("< ");
- if ( wcscmp(wcspbrk(wcspbrk_null_test2,wcspbrk_p),wcspbrk_q) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
-
- }
-
- void test_wcscspn(void)
- {
- wchar_t *wcscspn_i = build_string("now is the time for all good men");
- wchar_t *wcscspn_j = build_string("agd");
- wchar_t *wcscspn_k = build_string("xyz");
- wchar_t *wcscspn_nul = build_string("");
- wchar_t *wcscspn_null_test1 = build_tough_string1();
- wchar_t *wcscspn_l = build_string("C");
- wchar_t *wcscspn_null_test2 = build_tough_string2();
- wchar_t *wcscspn_m = build_string("B");
-
-
- /* TESTING WCSCSPN() *************************************************/
-
- printf("\n\nTESTING wcscspn()\n");
-
- /* printf("Test ( number of charcters that don't match if some do match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_j,wcscspn(wcscspn_i,wcscspn_j));
- if ( wcscspn(wcscspn_i,wcscspn_j) == 20 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that don't match if all don't match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_k,wcscspn(wcscspn_i,wcscspn_k));
- if ( wcscspn(wcscspn_i,wcscspn_k) == 32 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that don't match if all are a match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_i,wcscspn(wcscspn_i,wcscspn_i));
- if ( wcscspn(wcscspn_i,wcscspn_i) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
-
- /* printf("Test ( number of charcters that don't match if the set is a null ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscspn_i,wcscspn_nul,wcscspn(wcscspn_i,wcscspn_nul));
- if ( wcscspn(wcscspn_i,wcscspn_nul) == 32 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that don't match if the string is a null ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcscspn_nul,wcscspn_k,wcscspn(wcscspn_nul,wcscspn_k));
- if ( wcscspn(wcscspn_nul,wcscspn_k) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number in tough string 1 if some match ) : "); */
-
- printf(">");
- hexout(wcscspn_null_test1);
- printf("< , >");
- hexout(wcscspn_l);
- printf("< returns >%d< ",wcscspn(wcscspn_null_test1,wcscspn_l));
- if ( wcscspn(wcscspn_null_test1,wcscspn_l) == 2 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number in tough string 2 if none match ) : "); */
-
- printf(">");
- hexout(wcscspn_null_test2);
- printf("< , >");
- hexout(wcscspn_m);
- printf("< returns >%d< ",wcscspn(wcscspn_null_test2,wcscspn_m));
- if ( wcscspn(wcscspn_null_test2,wcscspn_m) == 3 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- }
-
- void test_wcsspn(void)
- {
-
- wchar_t *wcsspn_i = build_string("nowisthetimeforallgoodmen");
- wchar_t *wcsspn_j = build_string("nowisthemfr");
- wchar_t *wcsspn_k = build_string("pq");
- wchar_t *wcsspn_nul = build_string("");
- wchar_t *wcsspn_null_test1 = build_tough_string1();
- wchar_t *wcsspn_l = build_string("AB");
- wchar_t *wcsspn_null_test2 = build_tough_string2();
- wchar_t *wcsspn_m = build_string("B");
-
-
- /* TESTING WCSSPN() *************************************************/
-
- printf("\n\nTESTING wcsspn()\n");
-
- /* printf("Test ( number of charcters that match if some do match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_j,wcsspn(wcsspn_i,wcsspn_j));
- if ( wcsspn(wcsspn_i,wcsspn_j) == 15 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that match if all don't match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_k,wcsspn(wcsspn_i,wcsspn_k));
- if ( wcsspn(wcsspn_i,wcsspn_k) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that match if all match ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_i,wcsspn(wcsspn_i,wcsspn_i));
- if ( wcsspn(wcsspn_i,wcsspn_i) == 25 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that match if the set is a null ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcsspn_i,wcsspn_nul,wcsspn(wcsspn_i,wcsspn_nul));
- if ( wcsspn(wcsspn_i,wcsspn_nul) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number of charcters that match if the string is a null ) : "); */
-
- printf(">%ls< , >%ls< returns <%d> ",wcsspn_nul,wcsspn_i,wcsspn(wcsspn_nul,wcsspn_i));
- if ( wcsspn(wcsspn_nul,wcsspn_i) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number that match if some do match in tough string 1 ) : "); */
-
- printf(">");
- hexout(wcsspn_null_test1);
- printf("< , >");
- hexout(wcsspn_l);
- printf("< returns <%d> ",wcsspn(wcsspn_null_test1,wcsspn_l));
- if ( wcsspn(wcsspn_null_test1,wcsspn_l) == 2 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( number that match if all don't match in tough string 2) : "); */
-
- printf(">");
- hexout(wcsspn_null_test2);
- printf("< , >");
- hexout(wcsspn_m);
- printf("< returns <%d> ",wcsspn(wcsspn_null_test2,wcsspn_m));
- if ( wcsspn(wcsspn_null_test2,wcsspn_m) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
- }
-
- void test_wcsncpy(void)
- {
- wchar_t *wcsncpy_i = build_string("hot stuff");
- size_t wcsncpy_char_count = 3;
- size_t wcsncpy_char_bigcount = 20;
- size_t wcsncpy_char_zerocount = 0;
- wchar_t *wcsncpy_j = build_string(" ");
- wchar_t *wcsncpy_k = build_string("hot ");
- wchar_t *wcsncpy_l = build_string("hot stuff");
- wchar_t *wcsncpy_nul = build_string("");
-
- wchar_t *wcsncpy_null_test1 = build_tough_string1();
- wchar_t *wcsncpy_null_test2 = build_tough_string2();
- size_t wcsncpy_char_tough_count1 = 2;
- size_t wcsncpy_char_tough_count2 = 20;
- wchar_t *wcsncpy_result1 = build_string("");
- wchar_t *wcsncpy_result2 = build_string("");
- wchar_t *wcsncpy_m = build_string("AB");
-
-
- /* TESTING WCSNCPY() *************************************************/
-
- printf("\n\nTESTING wcsncpy()\n");
-
- /* printf("Test ( copy n characters from a string to a larger string ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_count,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_count));
- if ( wcscmp(wcsncpy_j,wcsncpy_k) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy 0 characters from a string to a string ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_zerocount,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_zerocount));
- if ( wcscmp(wcsncpy_j,wcsncpy_k) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy n characters from a string to a smaller string ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_i,wcsncpy_char_bigcount,wcsncpy(wcsncpy_j,wcsncpy_i,wcsncpy_char_bigcount));
- if ( wcscmp(wcsncpy_j,wcsncpy_l) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy n characters from a null string to a string ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_j,wcsncpy_nul,wcsncpy_char_bigcount,wcsncpy(wcsncpy_j,wcsncpy_nul,wcsncpy_char_bigcount));
- if ( wcscmp(wcsncpy_j,wcsncpy_nul) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy n characters from a string to a null string ) : "); */
-
- printf(">%ls< , >%ls< , >%d< returns <%ls> ",wcsncpy_nul,wcsncpy_i,wcsncpy_char_bigcount,wcsncpy(wcsncpy_nul,wcsncpy_i,wcsncpy_char_bigcount));
- if ( wcscmp(wcsncpy_nul,wcsncpy_l) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy n characters from a tough string 1 to a null string ) : "); */
-
- printf(">");
- hexout(wcsncpy_result1);
- printf("< , >");
- hexout(wcsncpy_null_test1);
- printf("< , >%d< returns <",wcsncpy_char_tough_count1);
- hexout(wcsncpy(wcsncpy_result1,wcsncpy_null_test1,wcsncpy_char_tough_count1));
- printf("> ");
- if ( wcscmp(wcsncpy_result1,wcsncpy_m) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
- /* printf("Test ( copy n characters from a tough string 2 to a string ) : "); */
-
- printf(">");
- hexout(wcsncpy_result2);
- printf("< , >");
- hexout(wcsncpy_null_test2);
- printf("< , >%d< returns <",wcsncpy_char_tough_count2);
- hexout(wcsncpy(wcsncpy_result2,wcsncpy_null_test2,wcsncpy_char_tough_count2));
- printf("> ");
- if ( wcscmp(wcsncpy_result2,wcsncpy_null_test2) == 0 )
- printf("PASS\n");
- else
- printf("FAIL\n");
-
-
- }
-
-
- /**************************************************************************/
- /**************************************************************************/
-
- /* Convert a buffer of char to a buffer of wchar */
- wchar_t *build_string(char *ws)
- {
- int count = 0;
- wchar_t *pTemp,
- *pBegin;
-
- pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pTemp));
-
- while( *ws != 0x00 )
- {
- *pTemp = (wchar_t)*ws;
- pTemp++;
- ws++;
- }
- *pTemp = 0L;
- return(pBegin);
- }
-
-
- /* Build first tough string to test out null features */
- wchar_t *build_tough_string1( void )
- {
- wchar_t *pTemp,
- *pBegin;
-
- pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
-
- *pTemp = (wchar_t)0x0041;
- pTemp++;
- *pTemp = (wchar_t)0x0042;
- pTemp++;
- *pTemp = (wchar_t)0x0043;
- pTemp++;
- *pTemp = (wchar_t)0x0000;
-
- return(pBegin);
- }
-
- /* Build second tough string to test out null features */
- wchar_t *build_tough_string2( void )
- {
- wchar_t *pTemp,
- *pBegin;
-
- pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
-
- *pTemp = (wchar_t)0x4400;
- pTemp++;
- *pTemp = (wchar_t)0x4500;
- pTemp++;
- *pTemp = (wchar_t)0x4600;
- pTemp++;
- *pTemp = (wchar_t)0x0000;
-
- return(pBegin);
- }
-
- /* Build third tough string that is the cat of string 1 & string 2 */
- wchar_t *build_tough_string3( void )
- {
- wchar_t *pTemp,
- *pBegin;
-
- pBegin = pTemp = (wchar_t*)calloc(80,sizeof(*pBegin));
-
- *pTemp = (wchar_t)0x0041;
- pTemp++;
- *pTemp = (wchar_t)0x0042;
- pTemp++;
- *pTemp = (wchar_t)0x0043;
- pTemp++;
- *pTemp = (wchar_t)0x4400;
- pTemp++;
- *pTemp = (wchar_t)0x4500;
- pTemp++;
- *pTemp = (wchar_t)0x4600;
- pTemp++;
- *pTemp = (wchar_t)0x0000;
-
- return(pBegin);
- }
-
-
- /* prints out a hex string from the chars pointed to by pString */
- void hexout( wchar_t *pString )
- {
- while ( *pString != NullL )
- {
- printf("%X",*pString);
- pString++;
- }
- }