| 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 | ** Concatenate three strings into one string. Each time, check to ensure |
| 11 | ** the pointer returned was what we expected. When finished, compare the |
| 12 | ** newly formed string to what it should be to ensure no characters were |
| 13 | ** lost. |
| 14 | ** |
| 15 | ** |
| 16 | **==========================================================================*/ |
| 17 | |
| 18 | #include <palsuite.h> |
| 19 | |
| 20 | |
| 21 | int __cdecl main(int argc, char *argv[]) |
| 22 | { |
| 23 | char dest[80]; |
| 24 | char *test = "foo bar baz" ; |
| 25 | char *str1 = "foo " ; |
| 26 | char *str2 = "bar " ; |
| 27 | char *str3 = "baz" ; |
| 28 | char *ptr; |
| 29 | |
| 30 | |
| 31 | if (PAL_Initialize(argc, argv)) |
| 32 | { |
| 33 | return FAIL; |
| 34 | } |
| 35 | |
| 36 | |
| 37 | dest[0] = 0; |
| 38 | |
| 39 | ptr = strcat(dest, str1); |
| 40 | if (ptr != dest) |
| 41 | { |
| 42 | Fail("ERROR: Expected strcat to return ptr to %p, got %p" , dest, ptr); |
| 43 | } |
| 44 | |
| 45 | ptr = strcat(dest, str2); |
| 46 | if (ptr != dest) |
| 47 | { |
| 48 | Fail("ERROR: Expected strcat to return ptr to %p, got %p" , dest, ptr); |
| 49 | } |
| 50 | |
| 51 | ptr = strcat(dest, str3); |
| 52 | if (ptr != dest) |
| 53 | { |
| 54 | Fail("ERROR: Expected strcat to return ptr to %p, got %p" , dest, ptr); |
| 55 | } |
| 56 | |
| 57 | if (strcmp(dest, test) != 0) |
| 58 | { |
| 59 | Fail("ERROR: Expected strcat to give \"%s\", got \"%s\"\n" , |
| 60 | test, dest); |
| 61 | } |
| 62 | |
| 63 | PAL_Terminate(); |
| 64 | |
| 65 | return PASS; |
| 66 | } |
| 67 | |