]> git.lyx.org Git - lyx.git/blob - src/support/tests/check_lstrings.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / support / tests / check_lstrings.cpp
1 #include <config.h>
2
3 #include "../lstrings.h"
4
5 #include <iostream>
6
7
8 using namespace lyx::support;
9 using namespace lyx;
10
11 using namespace std;
12
13 void test_lowercase()
14 {
15         cout << to_ascii(docstring(1, lowercase(char_type('A')))) << endl;
16         cout << to_ascii(lowercase(from_ascii("AlLe"))) << endl;
17         cout << lowercase('A') << endl;
18         cout << ascii_lowercase("AlLe") << endl;
19 }
20
21 void test_uppercase()
22 {
23         cout << to_ascii(docstring(1, uppercase(char_type('a')))) << endl;
24         cout << to_ascii(uppercase(from_ascii("AlLe"))) << endl;
25         cout << uppercase('a') << endl;
26 }
27
28 void test_formatFPNumber()
29 {
30         double const numbers[] = {
31                 0,
32                 1,
33                 23.42,
34                 1.3754937356458394574047e-20,
35                 1.3754937356458394574047e-19,
36                 1.3754937356458394574047e-18,
37                 1.3754937356458394574047e-17,
38                 1.3754937356458394574047e-16,
39                 1.3754937356458394574047e-15,
40                 1.3754937356458394574047e-14,
41                 1.3754937356458394574047e-13,
42                 1.3754937356458394574047e-12,
43                 1.3754937356458394574047e-11,
44                 1.3754937356458394574047e-10,
45                 1.3754937356458394574047e-9,
46                 1.3754937356458394574047e-8,
47                 1.3754937356458394574047e-7,
48                 1.3754937356458394574047e-6,
49                 1.3754937356458394574047e-5,
50                 1.3754937356458394574047e-4,
51                 1.3754937356458394574047e-3,
52                 1.3754937356458394574047e-2,
53                 1.3754937356458394574047e-1,
54                 1.3754937356458394574047,
55                 1.3754937356458394574047e1,
56                 1.3754937356458394574047e2,
57                 1.3754937356458394574047e3,
58                 1.3754937356458394574047e4,
59                 1.3754937356458394574047e5,
60                 1.3754937356458394574047e6,
61                 1.3754937356458394574047e7,
62                 1.3754937356458394574047e8,
63                 1.3754937356458394574047e9,
64                 1.3754937356458394574047e10,
65                 1.3754937356458394574047e11,
66                 1.3754937356458394574047e12,
67                 1.3754937356458394574047e13,
68                 1.3754937356458394574047e14,
69                 1.3754937356458394574047e15,
70                 1.3754937356458394574047e16,
71                 1.3754937356458394574047e17,
72                 1.3754937356458394574047e18,
73                 1.3754937356458394574047e19,
74                 1.3754937356458394574047e20,
75                 1e-42,
76                 1e42
77         };
78         int const n = sizeof(numbers) / sizeof(numbers[0]);
79         for (int i = 0; i < n; ++i)
80                 cout << formatFPNumber(numbers[i]) << endl;
81         for (int i = 0; i < n; ++i)
82                 cout << formatFPNumber(-numbers[i]) << endl;
83 }
84
85 int main()
86 {
87         test_lowercase();
88         test_uppercase();
89         test_formatFPNumber();
90 }