Mercurial > ecos
annotate packages/language/c/libc/current/tests/string/strcoll2.c @ 64:c38311975d4f ecos-sw-2000-01-28
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
| author | jlarmour |
|---|---|
| date | Fri, 28 Jan 2000 04:59:39 +0000 |
| parents | 443894e2e912 |
| children | bf00f99aec69 |
| rev | line source |
|---|---|
| 0 | 1 //================================================================= |
| 2 // | |
| 3 // strcoll2.c | |
| 4 // | |
| 5 // Testcase for C library strcoll() | |
| 6 // | |
| 7 //================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // http://sourceware.cygnus.com/ecos |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // Software distributed under the License is distributed on an |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //================================================================= | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 2 | 34 // Author(s): ctarpy, jlarmour |
| 35 // Contributors: jlarmour | |
| 0 | 36 // Date: 1998/6/3 |
| 37 // Description: Contains testcode for C library strcoll() function | |
| 38 // | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 | |
| 42 // Declarations for test system: | |
| 43 // | |
| 44 // TESTCASE_TYPE=CYG_TEST_MODULE | |
| 45 // COMPOUND_TESTCASE | |
| 46 | |
| 47 | |
| 48 // INCLUDES | |
| 49 | |
| 50 #include <string.h> | |
| 51 #include <cyg/infra/testcase.h> | |
| 52 #include <sys/cstartup.h> // C library initialisation | |
| 53 | |
| 54 // CONSTANTS | |
| 55 | |
| 56 #define NUM_ROBUSTNESS_RUNS 300 | |
| 57 | |
| 58 // FUNCTIONS | |
| 59 | |
| 60 | |
| 61 externC void | |
| 62 cyg_package_start( void ) | |
| 63 { | |
| 64 #ifdef CYGPKG_LIBC | |
| 65 cyg_iso_c_start(); | |
| 66 #else | |
| 67 (void)main(0, NULL); | |
| 68 #endif | |
| 69 } // cyg_package_start() | |
| 70 | |
| 71 | |
| 72 | |
| 73 // Functions to avoid having to use libc strings | |
| 74 | |
| 75 static char *my_strcpy(char *s1, const char *s2) | |
| 76 { | |
| 77 while (*s2 != '\0') { | |
| 78 *(s1++) = *(s2++); | |
| 79 } | |
| 80 *s1 = '\0'; | |
| 81 | |
| 82 return s1; | |
| 83 } // my_strcpy() | |
| 84 | |
| 85 | |
| 86 int main( int argc, char *argv[] ) | |
| 87 { | |
| 88 char x[300]; | |
| 89 char y[300]; | |
| 90 char z[300]; | |
| 91 int ctr; | |
| 92 int fail; | |
| 93 | |
| 94 CYG_TEST_INIT(); | |
| 95 | |
| 96 CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " | |
| 97 "strcoll() function"); | |
| 98 CYG_TEST_INFO("This testcase tests robustness, and may take some time"); | |
| 99 | |
| 100 fail = 0; | |
| 101 for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) | |
| 102 { | |
| 103 my_strcpy(x, "Spare a talent for an old ex-leper"); | |
| 104 my_strcpy(y, "Spare a talent for an old ex-leper"); | |
| 105 my_strcpy(z, "I was hopping along, when suddenly he"); | |
| 106 | |
| 107 if (strcoll(x, y) != 0) | |
| 108 { | |
| 109 fail = 1; | |
| 110 break; | |
| 111 } | |
| 112 if (strcoll(x, z) == 0) | |
| 113 { | |
| 114 fail = 1; | |
| 115 break; | |
| 116 } // if | |
| 117 } // for | |
| 118 | |
| 119 CYG_TEST_PASS_FAIL( (fail==0), "Robustness test"); | |
| 120 | |
| 121 CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " | |
| 122 "strcoll() function"); | |
| 123 } // main() | |
| 124 | |
| 125 | |
| 126 // EOF strcoll2.c |
