| 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: General test of swscanf |
| 10 | ** |
| 11 | ** |
| 12 | **==========================================================================*/ |
| 13 | |
| 14 | |
| 15 | |
| 16 | #include <palsuite.h> |
| 17 | #include "../swscanf.h" |
| 18 | |
| 19 | |
| 20 | int __cdecl main(int argc, char *argv[]) |
| 21 | { |
| 22 | int num; |
| 23 | int ret; |
| 24 | |
| 25 | if (PAL_Initialize(argc, argv)) |
| 26 | { |
| 27 | return FAIL; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | DoVoidTest(convert("foo bar" ), convert("foo" )); |
| 32 | DoVoidTest(convert("foo bar" ), convert("baz" )); |
| 33 | DoVoidTest(convert("foo bar" ), convert("foo %*s" )); |
| 34 | |
| 35 | DoStrTest(convert("foo % bar" ), convert("foo %% %S" ), "bar" ); |
| 36 | DoStrTest(convert("foo bar baz" ), convert("foo %bar %S" ), "baz" ); |
| 37 | |
| 38 | DoVoidTest(convert("foo bar baz" ), convert("foo % bar %S" )); |
| 39 | DoVoidTest(convert("foo bar baz" ), convert("foo% bar %S" )); |
| 40 | |
| 41 | |
| 42 | ret = swscanf(convert("foo bar baz" ), convert("foo bar %n" ), &num); |
| 43 | if (ret != 0 || num != 8) |
| 44 | { |
| 45 | Fail("ERROR: Got incorrect values in scanning \"%s\" using \"%s\".\n" |
| 46 | "Expected to get a value of %d with return value of %d, " |
| 47 | "got %d with return %d\n" , "foo bar baz" , "foo bar %n" , 8, 0, |
| 48 | num, ret); |
| 49 | } |
| 50 | |
| 51 | PAL_Terminate(); |
| 52 | return PASS; |
| 53 | } |
| 54 | |