| 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: Check that memcmp find identical buffers to be identical, |
| 10 | ** and that it correctly orders different buffers. |
| 11 | ** |
| 12 | ** |
| 13 | **==========================================================================*/ |
| 14 | |
| 15 | #include <palsuite.h> |
| 16 | |
| 17 | int __cdecl main(int argc, char **argv) |
| 18 | { |
| 19 | |
| 20 | char testA[] = "aaaaaaaaaaaaaaaaaaaa" ; |
| 21 | char testB[] = "aaaaaaaaaaaaaaaaaaaa" ; |
| 22 | |
| 23 | if (PAL_Initialize(argc, argv)) |
| 24 | { |
| 25 | return FAIL; |
| 26 | } |
| 27 | |
| 28 | |
| 29 | if (!(memcmp(testA, testB, 20) == 0)) |
| 30 | { |
| 31 | Fail("memcmp compared two identical buffers and found them to " |
| 32 | "differ.\n" ); |
| 33 | } |
| 34 | testB[3] = 'b'; |
| 35 | |
| 36 | if (!(memcmp(testA, testB, 20) < 0) |
| 37 | || !(memcmp(testB, testA, 20) >0 )) |
| 38 | { |
| 39 | Fail("memcmp compared two buffers with different contents, and" |
| 40 | " did not order them correctly.\n" ); |
| 41 | } |
| 42 | |
| 43 | if (memcmp(testA, testB, 0) != 0) |
| 44 | { |
| 45 | Fail("memcmp didn't return 0 when comparing buffers of length 0.\n" ); |
| 46 | } |
| 47 | |
| 48 | PAL_Terminate(); |
| 49 | return PASS; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |