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: __iscsym.c |
8 | ** |
9 | ** Purpose: Positive test the __iscsym API. |
10 | ** Call __iscsym to letter, digit and underscore |
11 | ** |
12 | ** |
13 | **============================================================*/ |
14 | #include <palsuite.h> |
15 | |
16 | int __cdecl main(int argc, char *argv[]) |
17 | { |
18 | int err; |
19 | int index; |
20 | char non_letter_set[]= |
21 | {'~','`','!','@','#','$','%','^','&','*','(',')',')', |
22 | '-','+','=','|','\\',';',':','"','\'','<','>', |
23 | ',','.','?','/','\0'}; |
24 | char errBuffer[200]; |
25 | |
26 | /*Initialize the PAL environment*/ |
27 | err = PAL_Initialize(argc, argv); |
28 | if(0 != err) |
29 | { |
30 | return FAIL; |
31 | } |
32 | |
33 | /*To check if the parameter passed in is a character*/ |
34 | for(index = 'a'; index <= 'z'; index++) |
35 | { |
36 | err = __iscsym(index); |
37 | if(0 == err) |
38 | { |
39 | Fail("\n__iscsym failed to recognize a " |
40 | "lower-case letter:%c!\n" , index); |
41 | } |
42 | } |
43 | |
44 | /*To check if the parameter passed in is a character*/ |
45 | for(index = 'A'; index <= 'Z'; index++) |
46 | { |
47 | err = __iscsym(index); |
48 | if(0 == err) |
49 | { |
50 | Fail("\n__iscsym failed to recognize an " |
51 | "upper-case letter: %c!\n" , index); |
52 | } |
53 | } |
54 | |
55 | /*To check if the parameter passed in is a digit*/ |
56 | for(index = '0'; index <= '9'; index++) |
57 | { |
58 | err = __iscsym(index); |
59 | if(0 == err) |
60 | { |
61 | Fail("\n__iscsym failed to recognize a digit %c!\n" , |
62 | index); |
63 | } |
64 | } |
65 | |
66 | /*To check if the parameter passed in is a underscore*/ |
67 | err = __iscsym('_'); |
68 | if(0 == err) |
69 | { |
70 | Fail("\n__iscsym failed to recognize an underscore!\n" ); |
71 | } |
72 | |
73 | memset(errBuffer, 0, 200); |
74 | |
75 | for(index = 0; non_letter_set[index]; index++) |
76 | { |
77 | err = __iscsym(non_letter_set[index]); |
78 | if(0 != err) |
79 | { |
80 | strncat(errBuffer, &non_letter_set[index], 1); |
81 | strcat(errBuffer, ", " ); |
82 | } |
83 | } |
84 | |
85 | if(strlen(errBuffer) > 0) |
86 | { |
87 | Fail("\n__iscsym failed to identify the characters '%s' " |
88 | "as not letters, digits " |
89 | "or underscores\n" , errBuffer); |
90 | } |
91 | PAL_Terminate(); |
92 | return PASS; |
93 | } |
94 | |