]>
Commit | Line | Data |
---|---|---|
ecb72bd5 UD |
1 | #include <stdio.h> |
2 | #include <locale.h> | |
3 | #include <assert.h> | |
4 | ||
5 | #define P0 "\xDB\xB0" | |
6 | #define P1 "\xDB\xB1" | |
7 | #define P2 "\xDB\xB2" | |
8 | #define P3 "\xDB\xB3" | |
9 | #define P4 "\xDB\xB4" | |
10 | #define P5 "\xDB\xB5" | |
11 | #define P6 "\xDB\xB6" | |
12 | #define P7 "\xDB\xB7" | |
13 | #define P8 "\xDB\xB8" | |
14 | #define P9 "\xDB\xB9" | |
15 | #define PD "\xd9\xab" | |
16 | #define PT "\xd9\xac" | |
17 | ||
18 | static int | |
19 | check_sscanf (const char *s, const char *format, const float n) | |
20 | { | |
21 | float f; | |
22 | ||
23 | if (sscanf (s, format, &f) != 1) | |
24 | { | |
25 | printf ("nothing found for \"%s\"\n", s); | |
26 | return 1; | |
27 | } | |
28 | if (f != n) | |
29 | { | |
30 | printf ("got %f expected %f from \"%s\"\n", f, n, s); | |
31 | return 1; | |
32 | } | |
33 | return 0; | |
34 | } | |
35 | ||
36 | static int | |
37 | do_test (void) | |
38 | { | |
72603ae3 | 39 | if (setlocale (LC_ALL, "fa_IR.UTF-8") == NULL) |
ecb72bd5 UD |
40 | { |
41 | puts ("cannot set fa_IR locale"); | |
42 | return 1; | |
43 | } | |
44 | ||
45 | int r = check_sscanf (P3 PD P1 P4, "%I8f", 3.14); | |
46 | r |= check_sscanf (P3 PT P1 P4 P5, "%I'f", 3145); | |
47 | r |= check_sscanf (P3 PD P1 P4 P1 P5 P9, "%If", 3.14159); | |
48 | r |= check_sscanf ("-" P3 PD P1 P4 P1 P5, "%If", -3.1415); | |
49 | r |= check_sscanf ("+" PD P1 P4 P1 P5, "%If", +.1415); | |
50 | r |= check_sscanf (P3 PD P1 P4 P1 P5 "e+" P2, "%Ie", 3.1415e+2); | |
51 | ||
52 | return r; | |
53 | } | |
54 | ||
55 | #define TEST_FUNCTION do_test () | |
56 | #include "../test-skeleton.c" |