0035-setlocale.c (1264B)
1 #include <assert.h> 2 #include <locale.h> 3 #include <stdio.h> 4 5 /* 6 output: 7 testing 8 done 9 end: 10 */ 11 12 int 13 main() 14 { 15 puts("testing"); 16 assert(!strcmp(setlocale(LC_ALL, NULL), "C")); 17 assert(!strcmp(setlocale(LC_COLLATE, NULL), "C")); 18 assert(!strcmp(setlocale(LC_CTYPE, NULL), "C")); 19 assert(!strcmp(setlocale(LC_MONETARY, NULL), "C")); 20 assert(!strcmp(setlocale(LC_NUMERIC, NULL), "C")); 21 assert(!strcmp(setlocale(LC_TIME, NULL), "C")); 22 23 assert(!strcmp(setlocale(LC_ALL, "C"), "C")); 24 assert(!strcmp(setlocale(LC_COLLATE, "C"), "C")); 25 assert(!strcmp(setlocale(LC_CTYPE, "C"), "C")); 26 assert(!strcmp(setlocale(LC_MONETARY, "C"), "C")); 27 assert(!strcmp(setlocale(LC_NUMERIC, "C"), "C")); 28 assert(!strcmp(setlocale(LC_TIME, "C"), "C")); 29 30 assert(!setlocale(LC_ALL, "invalid-locale")); 31 assert(!setlocale(LC_COLLATE, "invalid-locale")); 32 assert(!setlocale(LC_CTYPE, "invalid-locale")); 33 assert(!setlocale(LC_MONETARY, "invalid-locale")); 34 assert(!setlocale(LC_NUMERIC, "invalid-locale")); 35 assert(!setlocale(LC_TIME, "invalid-locale")); 36 37 assert(setlocale(LC_ALL, "")); 38 assert(setlocale(LC_COLLATE, "")); 39 assert(setlocale(LC_CTYPE, "")); 40 assert(setlocale(LC_MONETARY, "")); 41 assert(setlocale(LC_NUMERIC, "")); 42 assert(setlocale(LC_TIME, "")); 43 puts("done"); 44 45 return 0; 46 }