]> pd.if.org Git - pdclib/blob - functions/wchar/wcscmp.c
dos2unix
[pdclib] / functions / wchar / wcscmp.c
1 /* wcscmp( const wchar_t *, const wchar_t * )
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <wchar.h>
8
9 #ifndef REGTEST
10
11 int wcscmp( const wchar_t * s1, const wchar_t * s2 )
12 {
13     while ( ( *s1 ) && ( *s1 == *s2 ) )
14     {
15         ++s1;
16         ++s2;
17     }
18     return ( *(wchar_t *)s1 - *(wchar_t *)s2 );
19 }
20
21 #endif
22
23 #ifdef TEST
24 #include "_PDCLIB_test.h"
25
26 int main( void )
27 {
28     wchar_t cmpabcde[] = L"abcde";
29     wchar_t cmpabcd_[] = L"abcd\xfc";
30     wchar_t empty[] = L"";
31     TESTCASE( wcscmp( wabcde, cmpabcde ) == 0 );
32     TESTCASE( wcscmp( wabcde, wabcdx ) < 0 );
33     TESTCASE( wcscmp( wabcdx, wabcde ) > 0 );
34     TESTCASE( wcscmp( empty, wabcde ) < 0 );
35     TESTCASE( wcscmp( wabcde, empty ) > 0 );
36     TESTCASE( wcscmp( wabcde, cmpabcd_ ) < 0 );
37     return TEST_RESULTS;
38 }
39 #endif