diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-07-09 15:05:36 +0000 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-07-09 15:05:36 +0000 |
commit | a691312d8794d5516402bb6bb0d3e90c40ba188b (patch) | |
tree | dcac242fcad7d24a4f452722de26c56cfaf8c98a /test/locale/tst-xlocale2.c | |
parent | 56df95fe5d0778352abe09225d6587b88643d135 (diff) |
Added several tests for locale support (8 bit and multibyte UTF-8)
Basically all tests have been taken from glibc. For testing multibyte encoding
EUC_JP parts have been commented out and added new section for UTF-8
that is the only multibyte codeset currently supported on uCLibc.
Some tests are still failing due to unsupported/missing features, other have been
fixed.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'test/locale/tst-xlocale2.c')
-rw-r--r-- | test/locale/tst-xlocale2.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/locale/tst-xlocale2.c b/test/locale/tst-xlocale2.c new file mode 100644 index 000000000..30d87de72 --- /dev/null +++ b/test/locale/tst-xlocale2.c @@ -0,0 +1,64 @@ +#include <ctype.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> + + +static int do_test (__locale_t l); + +int +main (void) +{ + locale_t l; + locale_t l2; + int result; + + l = newlocale (1 << LC_ALL, "de_DE.ISO-8859-1", NULL); + if (l == NULL) + { + printf ("newlocale failed: %m\n"); + exit (EXIT_FAILURE); + } + puts ("Running tests of created locale"); + result = do_test (l); + + l2 = duplocale (l); + if (l2 == NULL) + { + printf ("duplocale failed: %m\n"); + exit (EXIT_FAILURE); + } + freelocale (l); + puts ("Running tests of duplicated locale"); + result |= do_test (l2); + + return result; +} + + +static const char str[] = "0123456789abcdef ABCDEF ghijklmnopqrstuvwxyzäÄöÖüÜ"; +static const char exd[] = "11111111110000000000000000000000000000000000000000"; +static const char exa[] = "00000000001111110111111011111111111111111111111111"; +static const char exx[] = "11111111111111110111111000000000000000000000000000"; + + +static int +do_test (locale_t l) +{ + int result = 0; +size_t n; + +#define DO_TEST(TEST, RES) \ + for (n = 0; n < sizeof (str) - 1; ++n) \ + if ('0' + (TEST (str[n], l) != 0) != RES[n]) \ + { \ + printf ("%s(%c) failed\n", #TEST, str[n]); \ + result = 1; \ + } + + DO_TEST (isdigit_l, exd); + DO_TEST (isalpha_l, exa); + DO_TEST (isxdigit_l, exx); + + return result; +} |