| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | /*============================================================================ |
| 6 | ** |
| 7 | ** Source: test1.c |
| 8 | ** |
| 9 | ** Purpose: |
| 10 | ** Tests that wcsncmp case-sensitively compares wide strings, making sure that |
| 11 | ** the count argument is handled correctly. |
| 12 | ** |
| 13 | ** |
| 14 | **==========================================================================*/ |
| 15 | |
| 16 | |
| 17 | |
| 18 | #include <palsuite.h> |
| 19 | |
| 20 | /* |
| 21 | * Notes: uses wcslen. |
| 22 | */ |
| 23 | |
| 24 | int __cdecl main(int argc, char *argv[]) |
| 25 | { |
| 26 | WCHAR str1[] = {'f','o','o',0}; |
| 27 | WCHAR str2[] = {'f','o','o','x',0}; |
| 28 | WCHAR str3[] = {'f','O','o',0}; |
| 29 | char cstr1[] = "foo" ; |
| 30 | char cstr2[] = "foox" ; |
| 31 | char cstr3[] = "fOo" ; |
| 32 | |
| 33 | if (PAL_Initialize(argc, argv)) |
| 34 | { |
| 35 | return FAIL; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | |
| 40 | if (wcsncmp(str1, str2, wcslen(str2)) >= 0) |
| 41 | { |
| 42 | Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n" , cstr1, |
| 43 | cstr2, wcslen(str2)); |
| 44 | } |
| 45 | |
| 46 | if (wcsncmp(str2, str1, wcslen(str2)) <= 0) |
| 47 | { |
| 48 | Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned <= 0\n" , cstr2, |
| 49 | cstr1, wcslen(str2)); |
| 50 | } |
| 51 | |
| 52 | if (wcsncmp(str1, str2, wcslen(str1)) != 0) |
| 53 | { |
| 54 | Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned != 0\n" , cstr1, |
| 55 | cstr2, wcslen(str1)); |
| 56 | } |
| 57 | |
| 58 | if (wcsncmp(str1, str3, wcslen(str1)) <= 0) |
| 59 | { |
| 60 | Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n" , cstr1, |
| 61 | cstr3, wcslen(str1)); |
| 62 | } |
| 63 | |
| 64 | if (wcsncmp(str3, str1, wcslen(str1)) >= 0) |
| 65 | { |
| 66 | Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n" , cstr3, |
| 67 | cstr1, wcslen(str1)); |
| 68 | } |
| 69 | |
| 70 | PAL_Terminate(); |
| 71 | return PASS; |
| 72 | } |
| 73 | |
| 74 | |