X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Ftests%2Fcheck_lstrings.cpp;h=c1fd9c8737464a52eba39261538d37c2cd6ffb26;hb=e04079aa528ecbf4a8e39ed2b19c3cb50174e151;hp=8a4aea84fd93597d334009cf165848a7b984ad31;hpb=b1c7450f7360648fb0be0dbe87f375cebe83d508;p=lyx.git diff --git a/src/support/tests/check_lstrings.cpp b/src/support/tests/check_lstrings.cpp index 8a4aea84fd..c1fd9c8737 100644 --- a/src/support/tests/check_lstrings.cpp +++ b/src/support/tests/check_lstrings.cpp @@ -10,16 +10,6 @@ using namespace lyx; using namespace std; -namespace lyx { - // Dummy LyXRC support - struct LyXRC { string icon_set; } lyxrc; - - // Keep the linker happy on Windows - void lyx_exit(int) {} - - docstring const _(string const & s) { return from_ascii(s); } -} - void test_lowercase() { cout << to_ascii(docstring(1, lowercase(char_type('A')))) << endl; @@ -35,8 +25,66 @@ void test_uppercase() cout << uppercase('a') << endl; } +void test_formatFPNumber() +{ + double const numbers[] = { + 0, + 1, + 23.42, + 1.3754937356458394574047e-20, + 1.3754937356458394574047e-19, + 1.3754937356458394574047e-18, + 1.3754937356458394574047e-17, + 1.3754937356458394574047e-16, + 1.3754937356458394574047e-15, + 1.3754937356458394574047e-14, + 1.3754937356458394574047e-13, + 1.3754937356458394574047e-12, + 1.3754937356458394574047e-11, + 1.3754937356458394574047e-10, + 1.3754937356458394574047e-9, + 1.3754937356458394574047e-8, + 1.3754937356458394574047e-7, + 1.3754937356458394574047e-6, + 1.3754937356458394574047e-5, + 1.3754937356458394574047e-4, + 1.3754937356458394574047e-3, + 1.3754937356458394574047e-2, + 1.3754937356458394574047e-1, + 1.3754937356458394574047, + 1.3754937356458394574047e1, + 1.3754937356458394574047e2, + 1.3754937356458394574047e3, + 1.3754937356458394574047e4, + 1.3754937356458394574047e5, + 1.3754937356458394574047e6, + 1.3754937356458394574047e7, + 1.3754937356458394574047e8, + 1.3754937356458394574047e9, + 1.3754937356458394574047e10, + 1.3754937356458394574047e11, + 1.3754937356458394574047e12, + 1.3754937356458394574047e13, + 1.3754937356458394574047e14, + 1.3754937356458394574047e15, + 1.3754937356458394574047e16, + 1.3754937356458394574047e17, + 1.3754937356458394574047e18, + 1.3754937356458394574047e19, + 1.3754937356458394574047e20, + 1e-42, + 1e42 + }; + int const n = sizeof(numbers) / sizeof(numbers[0]); + for (int i = 0; i < n; ++i) + cout << formatFPNumber(numbers[i]) << endl; + for (int i = 0; i < n; ++i) + cout << formatFPNumber(-numbers[i]) << endl; +} + int main() { test_lowercase(); test_uppercase(); + test_formatFPNumber(); }