diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | swedish.c | 143 | ||||
-rw-r--r-- | swedish.test.c | 528 |
4 files changed, 630 insertions, 70 deletions
@@ -10,3 +10,4 @@ *.gcov *.gcno *.gcda +*.test @@ -3,18 +3,30 @@ CONFIGFILE = config.mk include $(CONFIGFILE) +LANG =\ + swedish + OBJ =\ libnumtext_num2text.o\ libnumtext_remove_separators.o\ - swedish.o + $(LANG:=.o) HDR =\ libnumtext.h\ common.h +TEST =\ + $(LANG:=.test) + +TEST_OBJ =\ + $(TEST:=.o) + + all: libnumtext.a $(OBJ): $(HDR) $(OBJ:.o=.lo): $(HDR) +$(TEST_OBJ): libnumtext.h +$(TEST): libnumtext.a .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) @@ -22,10 +34,20 @@ $(OBJ:.o=.lo): $(HDR) .c.lo: $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) +.test.o.test: + $(CC) -o $@ $< libnumtext.a $(LDFLAGS) + libnumtext.a: $(OBJ) @rm -f -- $@ $(AR) rc $@ $(OBJ) +check: $(TEST) + @set -e &&\ + for t in $(TEST); do\ + printf './%s\n' "$$t";\ + "./$$t" || exit 1;\ + done + install: libnumtext.a mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" @@ -40,6 +62,6 @@ clean: -rm -f -- *.o *.a *.lo *.su *.so *.so.* *.gch *.gcov *.gcno *.gcda .SUFFIXES: -.SUFFIXES: .lo .o .c +.SUFFIXES: .lo .o .c .test .test.o -.PHONY: all install uninstall clean +.PHONY: all check install uninstall clean @@ -38,13 +38,13 @@ static struct ten { {NULL}, {NULL}, {"Tju¦go", "Tju¦gon"}, - {"Tret|tio", "Tret|ti¦on"}, - {"Fyr|tio", "Fyr|ti¦on"}, - {"Fem|tio", "Fem|ti¦on"}, - {"Sex|tio", "Sex|ti¦on"}, - {"Sju|tio", "Sju|ti¦on"}, - {"Åt|tio", "Åt|ti¦on"}, - {"Nit|tio", "Nit|ti¦on"} + {"Tret¦tio", "Tret¦ti¦on"}, + {"Fyr¦tio", "Fyr¦ti¦on"}, + {"Fem¦tio", "Fem¦ti¦on"}, + {"Sex¦tio", "Sex¦ti¦on"}, + {"Sjut¦tio", "Sjut¦ti¦on"}, + {"Åt¦tio", "Åt¦ti¦on"}, + {"Nit¦tio", "Nit¦ti¦on"} }; static const char *wholes_and_halves[][5] = { @@ -62,7 +62,7 @@ static const char *greats[][7] = { {"||m", "||un", "", "n", "||de¦ci", "nx*", "||cen¦ti"}, {"||b", "||duo", "", "ms", "||vi|gin¦ti", "n", "||du|cen¦ti"}, {"||tr", "||tre", "s*", "ns", "||tri|gin¦ta", "ns", "||tre|cen¦ti"}, - {"||kvad¦r", "||kvat¦tour", "", "ns", "||kvad¦ra|gin¦ta", "ns", "||kvad¦rin|gen¦ti"}, + {"||kvad¦r", "||kvat¦tuor", "", "ns", "||kvad¦ra|gin¦ta", "ns", "||kvad¦rin|gen¦ti"}, {"||kvin¦t", "||kvin", "", "ns", "||kvin¦kva|gin¦ta", "ns", "||kvin|gen¦ti"}, {"||sex¦t", "||se", "sx", "n", "||sex¦a|gin¦ta", "n", "||ses|cen¦ti"}, {"||sep¦t", "||sep¦te", "mn", "n", "||sep¦tua|gin¦ta", "n", "||sep¦tin|gen¦ti"}, @@ -78,55 +78,61 @@ append(char outbuf[], size_t outbuf_size, size_t *lenp, const char *appendage, u uint32_t hyphenation = flags & UINT32_C(0x00000C00); int shift; - if (appendage[0] == '|' && appendage[1] == '|') { - if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION) - appendage = &appendage[2]; - else - appendage = &appendage[1]; - } else if (appendage[0] == '|') { - if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION || - hyphenation == LIBNUMTEXT_N2T_SWEDISH_COMPONENT_HYPHENATION) { - appendage = &appendage[1]; - } - } else if (!strncmp(&appendage[appendage[0] == '<'], "¦", sizeof("¦") - 1)) { - shift = appendage[0] == '<'; - appendage = &appendage[shift]; - appendage = &appendage[sizeof("¦") - 1]; - if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SECONDARY_HYPHENATION) - p = stpcpy(hyphen, "¦"); - else if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SYLLABLE_HYPHENATION) - p = stpcpy(hyphen, "|"); - else - *hyphen = 0; - if (*hyphen) { - if (shift && *lenp <= outbuf_size) { - *p++ = outbuf[--*lenp]; - *p = '\0'; + for (; *appendage; appendage++) { + if (appendage[0] == '|' && appendage[1] == '|') { + if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION) + appendage = &appendage[2]; + else + appendage = &appendage[1]; + } else if (appendage[0] == '|') { + if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION || + hyphenation == LIBNUMTEXT_N2T_SWEDISH_COMPONENT_HYPHENATION) { + appendage = &appendage[1]; } - for (p = hyphen; *p; p++) { - if (*lenp < outbuf_size) - outbuf[*lenp] = *p; - *lenp += 1; + } else if (!strncmp(&appendage[appendage[0] == '<'], "¦", sizeof("¦") - 1)) { + shift = appendage[0] == '<'; + appendage = &appendage[shift]; + appendage = &appendage[sizeof("¦") - 1]; + if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SECONDARY_HYPHENATION) + p = stpcpy(hyphen, "¦"); + else if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SYLLABLE_HYPHENATION) + p = stpcpy(hyphen, "|"); + else + *hyphen = 0; + if (*hyphen) { + if (shift && *lenp <= outbuf_size) { + *p++ = outbuf[--*lenp]; + *p = '\0'; + } + for (p = hyphen; *p; p++) { + if (*lenp < outbuf_size) + outbuf[*lenp] = *p; + *lenp += 1; + } } } - } - if (*lenp >= 2 && outbuf[*lenp - 2] == outbuf[*lenp - 1] && outbuf[*lenp - 1] == appendage[0]) { - if ((flags & UINT32_C(0x00002000)) == LIBNUMTEXT_N2T_SWEDISH_REDUCED_TRIPLETS) - *lenp -= 1; - else if ((flags & UINT32_C(0x00002000)) == LIBNUMTEXT_N2T_SWEDISH_LATEX_TRIPLETS) - outbuf[*lenp - 2] = '"'; - } + if (*lenp >= 2 && outbuf[*lenp - 2] == outbuf[*lenp - 1] && outbuf[*lenp - 1] == appendage[appendage[0] == '|']) { + if (appendage[0] == '|' && (flags & UINT32_C(0x00003000)) != LIBNUMTEXT_N2T_SWEDISH_EXPLICIT_TRIPLETS) + appendage = &appendage[1]; + if ((flags & UINT32_C(0x00003000)) == LIBNUMTEXT_N2T_SWEDISH_REDUCED_TRIPLETS) + *lenp -= 1; + else if ((flags & UINT32_C(0x00003000)) == LIBNUMTEXT_N2T_SWEDISH_LATEX_TRIPLETS) + outbuf[*lenp - 2] = '"'; + } - if (*lenp && (flags & (LIBNUMTEXT_N2T_SWEDISH_HYPHENATED | hyphenation))) { - if (isupper(appendage[0]) || (appendage[0] == "Å"[0] && appendage[1] == "Å"[1])) { - if (*lenp < outbuf_size) - outbuf[*lenp] = '-'; - *lenp += 1; + if (*lenp && (flags & (LIBNUMTEXT_N2T_SWEDISH_HYPHENATED | hyphenation))) { + if (isupper(appendage[0]) || (appendage[0] == "Å"[0] && appendage[1] == "Å"[1])) { + if (*lenp < outbuf_size) { + if (flags & LIBNUMTEXT_N2T_SWEDISH_HYPHENATED) + outbuf[*lenp] = '-'; + else + outbuf[*lenp] = '|'; + } + *lenp += 1; + } } - } - for (; *appendage; appendage++) { if (*lenp < outbuf_size) outbuf[*lenp] = *appendage; *lenp += 1; @@ -273,15 +279,15 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu num_len--; if (thousands) { if (first && thousands == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) { - append(outbuf, outbuf_size, &len, "Tus¦en", flags); + append(outbuf, outbuf_size, &len, "Tu¦sen", flags); } else { append(outbuf, outbuf_size, &len, digits[thousands].cardinal_common, flags); - append(outbuf, outbuf_size, &len, "||tus¦en", flags); + append(outbuf, outbuf_size, &len, "||tu¦sen", flags); } append_for_ordinal = "¦de"; first = 0; } else if (hundred_thousands || orig_thousands) { - append(outbuf, outbuf_size, &len, "||tus¦en", flags); + append(outbuf, outbuf_size, &len, "||tu¦sen", flags); append_for_ordinal = "¦de"; first = 0; } @@ -293,7 +299,7 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu hundreds = *num++ - '0'; num_len--; if (hundreds) { - if (first && hundred_thousands == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) { + if (first && hundreds == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) { append(outbuf, outbuf_size, &len, "Hun¦dra", flags); } else { append(outbuf, outbuf_size, &len, digits[hundreds].cardinal_common, flags); @@ -310,15 +316,15 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu ones = *num++ - '0'; num_len--; if (tens[ones].cardinal) { - if (last && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR) && *num == '0') { + if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR) && *num == '0') { append(outbuf, outbuf_size, &len, tens[ones].ordinal, flags); - } else if (last && !great_order && *num == '0') { + } else if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_ORDINAL) && *num == '0') { append(outbuf, outbuf_size, &len, tens[ones].ordinal, flags); - append(outbuf, outbuf_size, &len, "¦de", flags); + append_for_ordinal = "¦de"; } else { append(outbuf, outbuf_size, &len, tens[ones].cardinal, flags); + append_for_ordinal = NULL; } - append_for_ordinal = NULL; ones = 0; first = 0; } else { @@ -332,14 +338,17 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu ones += *num++ - '0'; if (ones) { append_for_ordinal = NULL; - if (last && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)) { + if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)) { if ((flags & UINT32_C(0x00000030)) == LIBNUMTEXT_N2T_SWEDISH_MASCULINE_GENDER) append(outbuf, outbuf_size, &len, digits[ones].ordinal_masculine, flags); else append(outbuf, outbuf_size, &len, digits[ones].ordinal_other, flags); append_for_ordinal = digits[ones].ordinal_suffix; - } else if (!digits[ones].cardinal_other || - (last && (flags & UINT32_C(0x00000030)) == LIBNUMTEXT_N2T_SWEDISH_COMMON_GENDER)) { + } else if (!digits[ones].cardinal_other) { + append(outbuf, outbuf_size, &len, digits[ones].cardinal_common, flags); + } else if (great_order) { + append(outbuf, outbuf_size, &len, digits[ones].cardinal_other, flags); + } else if ((flags & UINT32_C(0x00000030)) == LIBNUMTEXT_N2T_SWEDISH_COMMON_GENDER) { append(outbuf, outbuf_size, &len, digits[ones].cardinal_common, flags); } else { append(outbuf, outbuf_size, &len, digits[ones].cardinal_other, flags); @@ -349,9 +358,9 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu break; } - if (great_order) { + if (great_order && small_num) { if (great_order < 10) { - append(outbuf, outbuf_size, &len, greats[great_order - 1][0], flags); + append(outbuf, outbuf_size, &len, greats[great_order][0], flags); } else if (great_order > 999) { errno = EDOM; return -1; @@ -430,9 +439,9 @@ out: outbuf_size += offset; if ((size_t)len < outbuf_size) - outbuf[len] = '0'; + outbuf[len] = '\0'; else if (outbuf_size) - outbuf[outbuf_size - 1] = '0'; + outbuf[outbuf_size - 1] = '\0'; len += 1; if (!outbuf_size) @@ -460,13 +469,13 @@ out: } else if ((flags & UINT32_C(0x00000300)) == LIBNUMTEXT_N2T_SWEDISH_UPPER_CASE) { for (; outbuf[i]; i++) - if (isupper(outbuf[i]) || outbuf[i] == '\xa5' || outbuf[i] == '\xa4' || outbuf[i] == '\xb6') + if (islower(outbuf[i]) || outbuf[i] == '\xa5' || outbuf[i] == '\xa4' || outbuf[i] == '\xb6') outbuf[i] ^= 0x20; } else if ((flags & UINT32_C(0x00000300)) == LIBNUMTEXT_N2T_SWEDISH_LOWER_CASE) { lower_case: for (; outbuf[i]; i++) - if (islower(outbuf[i]) || outbuf[i] == '\x85') + if (isupper(outbuf[i]) || outbuf[i] == '\x85') outbuf[i] ^= 0x20; } diff --git a/swedish.test.c b/swedish.test.c new file mode 100644 index 0000000..3478660 --- /dev/null +++ b/swedish.test.c @@ -0,0 +1,528 @@ +/* See LICENSE file for copyright and license details. */ +#include "libnumtext.h" +#include <errno.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define F(FLAG) LIBNUMTEXT_N2T_SWEDISH_##FLAG + +#define _6 "000000" +#define _6_0 "" +#define _6_1 _6 +#define _6_2 _6 _6 +#define _6_3 _6 _6 _6 +#define _6_4 _6 _6 _6 _6 +#define _6_5 _6 _6 _6 _6 _6 +#define _6_6 _6 _6 _6 _6 _6 _6 +#define _6_7 _6 _6 _6 _6 _6 _6 _6 +#define _6_8 _6 _6 _6 _6 _6 _6 _6 _6 +#define _6_9 _6 _6 _6 _6 _6 _6 _6 _6 _6 +#define _60 _6_9 _6 +#define _60_0 "" +#define _60_1 _60 +#define _60_2 _60 _60 +#define _60_3 _60 _60 _60 +#define _60_4 _60 _60 _60 _60 +#define _60_5 _60 _60 _60 _60 _60 +#define _60_6 _60 _60 _60 _60 _60 _60 +#define _60_7 _60 _60 _60 _60 _60 _60 _60 +#define _60_8 _60 _60 _60 _60 _60 _60 _60 _60 +#define _60_9 _60 _60 _60 _60 _60 _60 _60 _60 _60 +#define _600 _60_9 _60 +#define _600_1 _600 +#define _600_2 _600 _600 +#define _600_3 _600 _600 _600 +#define _600_4 _600 _600 _600 _600 +#define _600_5 _600 _600 _600 _600 _600 +#define _600_6 _600 _600 _600 _600 _600 _600 +#define _600_7 _600 _600 _600 _600 _600 _600 _600 +#define _600_8 _600 _600 _600 _600 _600 _600 _600 _600 +#define _600_9 _600 _600 _600 _600 _600 _600 _600 _600 _600 + +static struct test { + const char *num; + const char *expect; + uint32_t flags; +} tests[] = { + {"0", "noll", 0}, + {"1", "ett", 0}, + {"2", "två", 0}, + {"3", "tre", 0}, + {"4", "fyra", 0}, + {"5", "fem", 0}, + {"6", "sex", 0}, + {"7", "sju", 0}, + {"8", "åtta", 0}, + {"9", "nio", 0}, + {"10", "tio", 0}, + {"11", "elva", 0}, + {"12", "tolv", 0}, + {"13", "tretton", 0}, + {"14", "fjorton", 0}, + {"15", "femton", 0}, + {"16", "sexton", 0}, + {"17", "sjutton", 0}, + {"18", "arton", 0}, + {"19", "nitton", 0}, + {"20", "tjugo", 0}, + {"21", "tjugoett", 0}, + {"22", "tjugotvå", 0}, + {"23", "tjugotre", 0}, + {"28", "tjugoåtta", 0}, + {"29", "tjugonio", 0}, + {"30", "trettio", 0}, + {"31", "trettioett", 0}, + {"32", "trettiotvå", 0}, + {"40", "fyrtio", 0}, + {"43", "fyrtiotre", 0}, + {"50", "femtio", 0}, + {"54", "femtiofyra", 0}, + {"60", "sextio", 0}, + {"65", "sextiofem", 0}, + {"70", "sjuttio", 0}, + {"76", "sjuttiosex", 0}, + {"80", "åttio", 0}, + {"87", "åttiosju", 0}, + {"90", "nittio", 0}, + {"98", "nittioåtta", 0}, + {"99", "nittionio", 0}, + {"100", "etthundra", 0}, + {"101", "etthundraett", 0}, + {"110", "etthundratio", 0}, + {"111", "etthundraelva", 0}, + {"120", "etthundratjugo", 0}, + {"121", "etthundratjugoett", 0}, + {"999", "niohundranittionio", 0}, + {"1000", "ettusen", 0}, + {"1001", "ettusenett", 0}, + {"1002", "ettusentvå", 0}, + {"1100", "ettusenetthundra", 0}, + {"1101", "ettusenetthundraett", 0}, + {"1123", "ettusenetthundratjugotre", 0}, + {"2000", "tvåtusen", 0}, + {"3000", "tretusen", 0}, + {"4000", "fyratusen", 0}, + {"5000", "femtusen", 0}, + {"8000", "åttatusen", 0}, + {"9000", "niotusen", 0}, + {"10000", "tiotusen", 0}, + {"11000", "elvatusen", 0}, + {"20000", "tjugotusen", 0}, + {"21000", "tjugoettusen", 0}, /* "tjugoentusen" is actually incorrect (it's colloquial) */ + {"30000", "trettiotusen", 0}, + {"31000", "trettioettusen", 0}, + {"32000", "trettiotvåtusen", 0}, + {"40001", "fyrtiotusenett", 0}, + {"40010", "fyrtiotusentio", 0}, + {"40012", "fyrtiotusentolv", 0}, + {"50100", "femtiotusenetthundra", 0}, + {"50200", "femtiotusentvåhundra", 0}, + {"50210", "femtiotusentvåhundratio", 0}, + {"50240", "femtiotusentvåhundrafyrtio", 0}, + {"50248", "femtiotusentvåhundrafyrtioåtta", 0}, + {"100000", "etthundratusen", 0}, + {"100001", "etthundratusenett", 0}, + {"100014", "etthundratusenfjorton", 0}, + {"100020", "etthundratusentjugo", 0}, + {"100026", "etthundratusentjugosex", 0}, + {"100100", "etthundratusenetthundra", 0}, + {"100200", "etthundratusentvåhundra", 0}, + {"100210", "etthundratusentvåhundratio", 0}, + {"100247", "etthundratusentvåhundrafyrtiosju", 0}, + {"101000", "etthundraettusen", 0}, + {"102000", "etthundratvåtusen", 0}, + {"110000", "etthundratiotusen", 0}, + {"118000", "etthundraartontusen", 0}, + {"130000", "etthundratrettiotusen", 0}, + {"182000", "etthundraåttiotvåtusen", 0}, + {"300000", "trehundratusen", 0}, + {"1""000000", "enmiljon", 0}, + {"1""200000", "enmiljontvåhundratusen", 0}, + {"2""000000", "tvåmiljoner", 0}, + {"3""000000", "tremiljoner", 0}, + {"5""000000", "femmiljoner", 0}, + {"5""010000", "femmiljonertiotusen", 0}, + {"5""010100", "femmiljonertiotusenetthundra", 0}, + {"5""010111", "femmiljonertiotusenetthundraelva", 0}, + {"9""999999", "niomiljonerniohundranittioniotusenniohundranittionio", 0}, + {"10""000000", "tiomiljoner", 0}, + {"11""000000", "elvamiljoner", 0}, + {"20""000000", "tjugomiljoner", 0}, + {"100""000000", "etthundramiljoner", 0}, + {"101""000000", "etthundraenmiljoner", 0}, + {"102""000000", "etthundratvåmiljoner", 0}, + {"112""000000", "etthundratolvmiljoner", 0}, + {"160""000000", "etthundrasextiomiljoner", 0}, + {"169""000000", "etthundrasextioniomiljoner", 0}, + {"200""000000", "tvåhundramiljoner", 0}, + {"1000""000000", "enmiljard", 0}, + {"2000""000000", "tvåmiljarder", 0}, + {"20000""000000", "tjugomiljarder", 0}, + {"21000""000000", "tjugoenmiljarder", 0}, + {"100000""000000", "etthundramiljarder", 0}, + {"101000""000000", "etthundraenmiljarder", 0}, + {"101001""000000", "etthundraenmiljarderenmiljon", 0}, + {"101100""000000", "etthundraenmiljarderetthundramiljoner", 0}, + {"1""000000""000000", "enbiljon", 0}, + {"1""001000""000000", "enbiljonenmiljard", 0}, + {"1""001001""000000", "enbiljonenmiljardenmiljon", 0}, + {"1""001001""001000", "enbiljonenmiljardenmiljonettusen", 0}, + {"1""001001""001001", "enbiljonenmiljardenmiljonettusenett", 0}, + {"2""000000""000000", "tvåbiljoner", 0}, + {"1000""000000""000000", "enbiljard", 0}, + {"1"_6_3, "entriljon", 0}, + {"1000"_6_3, "entriljard", 0}, + {"1"_6_4, "enkvadriljon", 0}, + {"1"_6_5, "enkvintiljon", 0}, + {"1"_6_6, "ensextiljon", 0}, + {"1"_6_7, "enseptiljon", 0}, + {"1"_6_8, "enoktiljon", 0}, + {"1"_6_9, "ennoniljon", 0}, + {"1"_60_1 _6_0, "endeciljon", 0}, + {"1"_60_1 _6_1, "enundeciljon", 0}, + {"1"_60_1 _6_2, "enduodeciljon", 0}, + {"1"_60_1 _6_3, "entredeciljon", 0}, + {"1"_60_1 _6_4, "enkvattuordeciljon", 0}, + {"1"_60_1 _6_5, "enkvindeciljon", 0}, + {"1"_60_1 _6_6, "ensedeciljon", 0}, + {"1"_60_1 _6_7, "enseptendeciljon", 0}, + {"1"_60_1 _6_8, "enoktodeciljon", 0}, + {"1"_60_1 _6_9, "ennovendeciljon", 0}, + {"1"_60_2 _6_0, "envigintiljon", 0}, + {"1"_60_2 _6_1, "enunvigintiljon", 0}, + {"1"_60_2 _6_2, "enduovigintiljon", 0}, + {"1"_60_2 _6_3, "entresvigintiljon", 0}, + {"1"_60_2 _6_4, "enkvattuorvigintiljon", 0}, + {"1"_60_2 _6_5, "enkvinvigintiljon", 0}, + {"1"_60_2 _6_6, "ensesvigintiljon", 0}, + {"1"_60_2 _6_7, "enseptemvigintiljon", 0}, + {"1"_60_2 _6_8, "enoktovigintiljon", 0}, + {"1"_60_2 _6_9, "ennovemvigintiljon", 0}, + {"1"_60_3 _6_0, "entrigintiljon", 0}, + {"1"_60_3 _6_1, "enuntrigintiljon", 0}, + {"1"_60_3 _6_2, "enduotrigintiljon", 0}, + {"1"_60_3 _6_3, "entrestrigintiljon", 0}, + {"1"_60_3 _6_4, "enkvattuortrigintiljon", 0}, + {"1"_60_3 _6_5, "enkvintrigintiljon", 0}, + {"1"_60_3 _6_6, "ensestrigintiljon", 0}, + {"1"_60_3 _6_7, "enseptentrigintiljon", 0}, + {"1"_60_3 _6_8, "enoktotrigintiljon", 0}, + {"1"_60_3 _6_9, "ennoventrigintiljon", 0}, + {"1"_60_4 _6_0, "enkvadragintiljon", 0}, + {"1"_60_4 _6_1, "enunkvadragintiljon", 0}, + {"1"_60_4 _6_2, "enduokvadragintiljon", 0}, + {"1"_60_4 _6_3, "entreskvadragintiljon", 0}, + {"1"_60_4 _6_4, "enkvattuorkvadragintiljon", 0}, + {"1"_60_4 _6_5, "enkvinkvadragintiljon", 0}, + {"1"_60_4 _6_6, "enseskvadragintiljon", 0}, + {"1"_60_4 _6_7, "enseptenkvadragintiljon", 0}, + {"1"_60_4 _6_8, "enoktokvadragintiljon", 0}, + {"1"_60_4 _6_9, "ennovenkvadragintiljon", 0}, + {"1"_60_5 _6_0, "enkvinkvagintiljon", 0}, + {"1"_60_5 _6_1, "enunkvinkvagintiljon", 0}, + {"1"_60_5 _6_2, "enduokvinkvagintiljon", 0}, + {"1"_60_5 _6_3, "entreskvinkvagintiljon", 0}, + {"1"_60_5 _6_4, "enkvattuorkvinkvagintiljon", 0}, + {"1"_60_5 _6_5, "enkvinkvinkvagintiljon", 0}, + {"1"_60_5 _6_6, "enseskvinkvagintiljon", 0}, + {"1"_60_5 _6_7, "enseptenkvinkvagintiljon", 0}, + {"1"_60_5 _6_8, "enoktokvinkvagintiljon", 0}, + {"1"_60_5 _6_9, "ennovenkvinkvagintiljon", 0}, + {"1"_60_6 _6_0, "ensexagintiljon", 0}, + {"1"_60_6 _6_1, "enunsexagintiljon", 0}, + {"1"_60_6 _6_2, "enduosexagintiljon", 0}, + {"1"_60_6 _6_3, "entresexagintiljon", 0}, + {"1"_60_6 _6_4, "enkvattuorsexagintiljon", 0}, + {"1"_60_6 _6_5, "enkvinsexagintiljon", 0}, + {"1"_60_6 _6_6, "ensesexagintiljon", 0}, + {"1"_60_6 _6_7, "enseptensexagintiljon", 0}, + {"1"_60_6 _6_8, "enoktosexagintiljon", 0}, + {"1"_60_6 _6_9, "ennovensexagintiljon", 0}, + {"1"_60_7 _6_0, "enseptuagintiljon", 0}, + {"1"_60_7 _6_1, "enunseptuagintiljon", 0}, + {"1"_60_7 _6_2, "enduoseptuagintiljon", 0}, + {"1"_60_7 _6_3, "entreseptuagintiljon", 0}, + {"1"_60_7 _6_4, "enkvattuorseptuagintiljon", 0}, + {"1"_60_7 _6_5, "enkvinseptuagintiljon", 0}, + {"1"_60_7 _6_6, "enseseptuagintiljon", 0}, + {"1"_60_7 _6_7, "enseptenseptuagintiljon", 0}, + {"1"_60_7 _6_8, "enoktoseptuagintiljon", 0}, + {"1"_60_7 _6_9, "ennovenseptuagintiljon", 0}, + {"1"_60_8 _6_0, "enoktogintiljon", 0}, + {"1"_60_8 _6_1, "enunoktogintiljon", 0}, + {"1"_60_8 _6_2, "enduooktogintiljon", 0}, + {"1"_60_8 _6_3, "entresoktogintiljon", 0}, + {"1"_60_8 _6_4, "enkvattuoroktogintiljon", 0}, + {"1"_60_8 _6_5, "enkvinoktogintiljon", 0}, + {"1"_60_8 _6_6, "ensexoktogintiljon", 0}, + {"1"_60_8 _6_7, "enseptemoktogintiljon", 0}, + {"1"_60_8 _6_8, "enoktooktogintiljon", 0}, + {"1"_60_8 _6_9, "ennovemoktogintiljon", 0}, + {"1"_60_9 _6_0, "ennonagintiljon", 0}, + {"1"_60_9 _6_1, "enunnonagintiljon", 0}, + {"1"_60_9 _6_2, "enduononagintiljon", 0}, + {"1"_60_9 _6_3, "entrenonagintiljon", 0}, + {"1"_60_9 _6_4, "enkvattuornonagintiljon", 0}, + {"1"_60_9 _6_5, "enkvinnonagintiljon", 0}, + {"1"_60_9 _6_6, "ensenonagintiljon", 0}, + {"1"_60_9 _6_7, "enseptenonagintiljon", 0}, + {"1"_60_9 _6_8, "enoktononagintiljon", 0}, + {"1"_60_9 _6_9, "ennovenonagintiljon", 0}, + {"1"_600_1 _60_0 _6_0, "encentiljon", 0}, + {"1"_600_1 _60_0 _6_1, "enuncentiljon", 0}, + {"1"_600_1 _60_0 _6_2, "enduocentiljon", 0}, + {"1"_600_1 _60_0 _6_3, "entrescentiljon", 0}, + {"1"_600_1 _60_0 _6_4, "enkvattuorcentiljon", 0}, + {"1"_600_1 _60_0 _6_5, "enkvincentiljon", 0}, + {"1"_600_1 _60_0 _6_6, "ensexcentiljon", 0}, + {"1"_600_1 _60_0 _6_7, "enseptencentiljon", 0}, + {"1"_600_1 _60_0 _6_8, "enoktocentiljon", 0}, + {"1"_600_1 _60_0 _6_9, "ennovencentiljon", 0}, + {"1"_600_1 _60_1 _6_0, "endecicentiljon", 0}, + {"1"_600_1 _60_2 _6_0, "enviginticentiljon", 0}, + {"1"_600_1 _60_3 _6_0, "entrigintacentiljon", 0}, + {"1"_600_1 _60_4 _6_0, "enkvadragintacentiljon", 0}, + {"1"_600_1 _60_5 _6_0, "enkvinkvagintacentiljon", 0}, + {"1"_600_1 _60_6 _6_0, "ensexagintacentiljon", 0}, + {"1"_600_1 _60_7 _6_0, "enseptuagintacentiljon", 0}, + {"1"_600_1 _60_7 _6_7, "enseptenseptuagintacentiljon", 0}, + {"1"_600_1 _60_8 _6_0, "enoktogintacentiljon", 0}, + {"1"_600_1 _60_9 _6_0, "ennonagintacentiljon", 0}, + {"1"_600_1 _60_9 _6_9, "ennovenonagintacentiljon", 0}, + {"1"_600_2 _60_0 _6_0, "enducentiljon", 0}, + {"1"_600_2 _60_0 _6_1, "enunducentiljon", 0}, + {"1"_600_2 _60_0 _6_2, "enduoducentiljon", 0}, + {"1"_600_2 _60_0 _6_3, "entreducentiljon", 0}, + {"1"_600_2 _60_0 _6_4, "enkvattuorducentiljon", 0}, + {"1"_600_2 _60_0 _6_5, "enkvinducentiljon", 0}, + {"1"_600_2 _60_0 _6_6, "enseducentiljon", 0}, + {"1"_600_2 _60_0 _6_7, "enseptenducentiljon", 0}, + {"1"_600_2 _60_0 _6_8, "enoktoducentiljon", 0}, + {"1"_600_2 _60_0 _6_9, "ennovenducentiljon", 0}, + {"1"_600_3 _60_0 _6_0, "entrecentiljon", 0}, + {"1"_600_3 _60_0 _6_1, "enuntrecentiljon", 0}, + {"1"_600_3 _60_0 _6_2, "enduotrecentiljon", 0}, + {"1"_600_3 _60_0 _6_3, "entrestrecentiljon", 0}, + {"1"_600_3 _60_0 _6_4, "enkvattuortrecentiljon", 0}, + {"1"_600_3 _60_0 _6_5, "enkvintrecentiljon", 0}, + {"1"_600_3 _60_0 _6_6, "ensestrecentiljon", 0}, + {"1"_600_3 _60_0 _6_7, "enseptentrecentiljon", 0}, + {"1"_600_3 _60_0 _6_8, "enoktotrecentiljon", 0}, + {"1"_600_3 _60_0 _6_9, "ennoventrecentiljon", 0}, + {"1"_600_4 _60_0 _6_0, "enkvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_1, "enunkvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_2, "enduokvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_3, "entreskvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_4, "enkvattuorkvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_5, "enkvinkvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_6, "enseskvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_7, "enseptenkvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_8, "enoktokvadringentiljon", 0}, + {"1"_600_4 _60_0 _6_9, "ennovenkvadringentiljon", 0}, + {"1"_600_5 _60_0 _6_0, "enkvingentiljon", 0}, + {"1"_600_5 _60_0 _6_1, "enunkvingentiljon", 0}, + {"1"_600_5 _60_0 _6_2, "enduokvingentiljon", 0}, + {"1"_600_5 _60_0 _6_3, "entreskvingentiljon", 0}, + {"1"_600_5 _60_0 _6_4, "enkvattuorkvingentiljon", 0}, + {"1"_600_5 _60_0 _6_5, "enkvinkvingentiljon", 0}, + {"1"_600_5 _60_0 _6_6, "enseskvingentiljon", 0}, + {"1"_600_5 _60_0 _6_7, "enseptenkvingentiljon", 0}, + {"1"_600_5 _60_0 _6_8, "enoktokvingentiljon", 0}, + {"1"_600_5 _60_0 _6_9, "ennovenkvingentiljon", 0}, + {"1"_600_6 _60_0 _6_0, "ensescentiljon", 0}, + {"1"_600_6 _60_0 _6_1, "enunsescentiljon", 0}, + {"1"_600_6 _60_0 _6_2, "enduosescentiljon", 0}, + {"1"_600_6 _60_0 _6_3, "entresescentiljon", 0}, + {"1"_600_6 _60_0 _6_4, "enkvattuorsescentiljon", 0}, + {"1"_600_6 _60_0 _6_5, "enkvinsescentiljon", 0}, + {"1"_600_6 _60_0 _6_6, "ensesescentiljon", 0}, + {"1"_600_6 _60_0 _6_7, "enseptensescentiljon", 0}, + {"1"_600_6 _60_0 _6_8, "enoktosescentiljon", 0}, + {"1"_600_6 _60_0 _6_9, "ennovensescentiljon", 0}, + {"1"_600_7 _60_0 _6_0, "enseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_1, "enunseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_2, "enduoseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_3, "entreseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_4, "enkvattuorseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_5, "enkvinseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_6, "enseseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_7, "enseptenseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_8, "enoktoseptingentiljon", 0}, + {"1"_600_7 _60_0 _6_9, "ennovenseptingentiljon", 0}, + {"1"_600_8 _60_0 _6_0, "enoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_1, "enunoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_2, "enduooktingentiljon", 0}, + {"1"_600_8 _60_0 _6_3, "entresoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_4, "enkvattuoroktingentiljon", 0}, + {"1"_600_8 _60_0 _6_5, "enkvinoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_6, "ensexoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_7, "enseptemoktingentiljon", 0}, + {"1"_600_8 _60_0 _6_8, "enoktooktingentiljon", 0}, + {"1"_600_8 _60_0 _6_9, "ennovemoktingentiljon", 0}, + {"1"_600_9 _60_0 _6_0, "ennongentiljon", 0}, + {"1"_600_9 _60_0 _6_1, "enunnongentiljon", 0}, + {"1"_600_9 _60_0 _6_2, "enduonongentiljon", 0}, + {"1"_600_9 _60_0 _6_3, "entrenongentiljon", 0}, + {"1"_600_9 _60_0 _6_4, "enkvattuornongentiljon", 0}, + {"1"_600_9 _60_0 _6_5, "enkvinnongentiljon", 0}, + {"1"_600_9 _60_0 _6_6, "ensenongentiljon", 0}, + {"1"_600_9 _60_0 _6_7, "enseptenongentiljon", 0}, + {"1"_600_9 _60_0 _6_8, "enoktonongentiljon", 0}, + {"1"_600_9 _60_0 _6_9, "ennovenongentiljon", 0}, + {"1"_600_9 _60_9 _6_0, "ennonagintanongentiljon", 0}, + {"1"_600_9 _60_9 _6_9, "ennovenonagintanongentiljon", 0}, + {"1000"_600_9 _60_9 _6_9, "ennovenonagintanongentiljard", 0}, + {"0", "noll", F(IMPLICIT_ONE)}, + {"1", "ett", F(IMPLICIT_ONE)}, + {"2", "två", F(IMPLICIT_ONE)}, + {"3", "tre", F(IMPLICIT_ONE)}, + {"4", "fyra", F(IMPLICIT_ONE)}, + {"20", "tjugo", F(IMPLICIT_ONE)}, + {"30", "trettio", F(IMPLICIT_ONE)}, + {"100", "hundra", F(IMPLICIT_ONE)}, + {"101", "hundraett", F(IMPLICIT_ONE)}, + {"110", "hundratio", F(IMPLICIT_ONE)}, + {"999", "niohundranittionio", F(IMPLICIT_ONE)}, + {"1000", "tusen", F(IMPLICIT_ONE)}, + {"1001", "tusenett", F(IMPLICIT_ONE)}, + {"2000", "tvåtusen", F(IMPLICIT_ONE)}, + {"100000", "hundratusen", F(IMPLICIT_ONE)}, + {"101000", "hundraettusen", F(IMPLICIT_ONE)}, + {"300000", "trehundratusen", F(IMPLICIT_ONE)}, + {"1""000000", "enmiljon", F(IMPLICIT_ONE)}, + {"1""200000", "enmiljontvåhundratusen", F(IMPLICIT_ONE)}, + {"2""000000", "tvåmiljoner", F(IMPLICIT_ONE)}, + {"100""000000", "hundramiljoner", F(IMPLICIT_ONE)}, + {"1000""000000", "enmiljard", F(IMPLICIT_ONE)}, + {"1""000000""000000", "enbiljon", F(IMPLICIT_ONE)}, + {"1"_6_4, "enkvadriljon", F(IMPLICIT_ONE)}, + {"1"_600_1 _60_0 _6_0, "encentiljon", F(IMPLICIT_ONE)}, + {"54248", "FemtioFyratusenTvåhundraFyrtioÅtta", F(PASCAL_CASE)}, + {"54248", "FEMTIOFYRATUSENTVÅHUNDRAFYRTIOÅTTA", F(UPPER_CASE)}, + {"54248", "Femtiofyratusentvåhundrafyrtioåtta", F(SENTENCE_CASE)}, + {"54248", "femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED)}, + {"54248", "Femtio-Fyratusen-Tvåhundra-Fyrtio-Åtta", F(HYPHENATED) | F(PASCAL_CASE)}, + {"54248", "FEMTIO-FYRATUSEN-TVÅHUNDRA-FYRTIO-ÅTTA", F(HYPHENATED) | F(UPPER_CASE)}, + {"54248", "Femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED) | F(SENTENCE_CASE)}, + {"100", "etthundra", F(EXPLICIT_TRIPLETS)}, + {"100", "etthundra", F(LATEX_TRIPLETS)}, + {"1000", "etttusen", F(EXPLICIT_TRIPLETS)}, + {"1000", "e\"ttusen", F(LATEX_TRIPLETS)}, + {"1000", "tusen", F(IMPLICIT_ONE) | F(EXPLICIT_TRIPLETS)}, + {"1000", "tusen", F(IMPLICIT_ONE) | F(LATEX_TRIPLETS)}, + {"0", "noll", F(NEUTER_GENDER)}, + {"1", "en", F(NEUTER_GENDER)}, + {"2", "två", F(NEUTER_GENDER)}, + {"3", "tre", F(NEUTER_GENDER)}, + {"21", "tjugoen", F(NEUTER_GENDER)}, + {"22", "tjugotvå", F(NEUTER_GENDER)}, + {"23", "tjugotre", F(NEUTER_GENDER)}, + {"100", "etthundra", F(NEUTER_GENDER)}, + {"101", "etthundraen", F(NEUTER_GENDER)}, + {"1000", "ettusen", F(NEUTER_GENDER)}, + {"1001", "ettusenen", F(NEUTER_GENDER)}, + {"1000000", "enmiljon", F(NEUTER_GENDER)}, + {"1000001", "enmiljonen", F(NEUTER_GENDER)}, + {"0", "noll", F(MASCULINE_GENDER)}, + {"1", "en", F(MASCULINE_GENDER)}, + {"2", "två", F(MASCULINE_GENDER)}, + {"3", "tre", F(MASCULINE_GENDER)}, + {"21", "tjugoen", F(MASCULINE_GENDER)}, + {"22", "tjugotvå", F(MASCULINE_GENDER)}, + {"23", "tjugotre", F(MASCULINE_GENDER)}, + {"100", "etthundra", F(MASCULINE_GENDER)}, + {"101", "etthundraen", F(MASCULINE_GENDER)}, + {"1000", "ettusen", F(MASCULINE_GENDER)}, + {"1001", "ettusenen", F(MASCULINE_GENDER)}, + {"1000000", "enmiljon", F(MASCULINE_GENDER)}, + {"1000001", "enmiljonen", F(MASCULINE_GENDER)}, + {"0", "noll", F(FEMININE_GENDER)}, + {"1", "en", F(FEMININE_GENDER)}, + {"2", "två", F(FEMININE_GENDER)}, + {"3", "tre", F(FEMININE_GENDER)}, + {"21", "tjugoen", F(FEMININE_GENDER)}, + {"22", "tjugotvå", F(FEMININE_GENDER)}, + {"23", "tjugotre", F(FEMININE_GENDER)}, + {"100", "etthundra", F(FEMININE_GENDER)}, + {"101", "etthundraen", F(FEMININE_GENDER)}, + {"1000", "ettusen", F(FEMININE_GENDER)}, + {"1001", "ettusenen", F(FEMININE_GENDER)}, + {"1000000", "enmiljon", F(FEMININE_GENDER)}, + {"1000001", "enmiljonen", F(FEMININE_GENDER)}, + {"100", "ett|hundra", F(COMPONENT_HYPHENATION)}, + {"100", "ett|hun|dra", F(SYLLABLE_HYPHENATION)}, + {"100", "ett|hun¦dra", F(SECONDARY_HYPHENATION)}, + {"100", "ett|hundra", F(HYPHENATED) | F(COMPONENT_HYPHENATION)}, + {"100", "ett|hun|dra", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)}, + {"100", "ett|hun¦dra", F(HYPHENATED) | F(SECONDARY_HYPHENATION)}, + {"1000", "ettusen", F(COMPONENT_HYPHENATION)}, + {"1000", "ettu|sen", F(SYLLABLE_HYPHENATION)}, + {"1000", "ettu¦sen", F(SECONDARY_HYPHENATION)}, + {"1000", "ettusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION)}, + {"1000", "ettu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)}, + {"1000", "ettu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION)}, + {"1000", "e\"ttusen", F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "e\"ttu|sen", F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "e\"ttu¦sen", F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "e\"ttusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "e\"ttu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "e\"ttu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)}, + {"1000", "ett|tusen", F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"1000", "ett|tu|sen", F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"1000", "ett|tu¦sen", F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"1000", "ett|tusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"1000", "ett|tu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"1000", "ett|tu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)}, + {"54248", "femtio|fyra|tusen|två|hundra|fyrtio|åtta", F(COMPONENT_HYPHENATION)}, + {"54248", "fem|tio|fy|ra|tu|sen|två|hun|dra|fyr|tio|åt|ta", F(SYLLABLE_HYPHENATION)}, + {"54248", "fem¦tio|fy¦ra|tu¦sen|två|hun¦dra|fyr¦tio|åt¦ta", F(SECONDARY_HYPHENATION)}, + {"54248", "femtio-fyra|tusen-två|hundra-fyrtio-åtta", F(HYPHENATED) | F(COMPONENT_HYPHENATION)}, + {"54248", "fem|tio-fy|ra|tu|sen-två|hun|dra-fyr|tio-åt|ta", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)}, + {"54248", "fem¦tio-fy¦ra|tu¦sen-två|hun¦dra-fyr¦tio-åt¦ta", F(HYPHENATED) | F(SECONDARY_HYPHENATION)}, +}; + + +int +main(void) +{ + char buf[2 << 10]; + ssize_t len; + size_t i; + int ok = 1; + + for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) { + len = libnumtext_num2text(buf, sizeof(buf), tests[i].num, strlen(tests[i].num), LIBNUMTEXT_SWEDISH, tests[i].flags); + if (len < 0) + fprintf(stderr, "Error at test %zu: %s\n", i + 1, strerror(errno)); + else if ((size_t)len > sizeof(buf)) + fprintf(stderr, "Test %zu returned result larger (%zi) than buffer (%zu)\n", i + 1, len, sizeof(buf)); + else if (!len) + fprintf(stderr, "Test %zu returned zero-sized result\n", i + 1); + else if (buf[len - 1]) + fprintf(stderr, "Test %zu returned non-NUL-terminated result\n", i + 1); + else if (strcmp(buf, tests[i].expect)) + fprintf(stderr, "Test %zu returned incorrect result: %s\n", i + 1, buf); + else + continue; + fprintf(stderr, "\tInput: %s\n", tests[i].num); + fprintf(stderr, "\tExpected: %s\n", tests[i].expect); + fprintf(stderr, "\tFlags: 0x%08x\n", tests[i].flags); + ok = 0; + } + + /* TODO test sign prefix */ + /* TODO test for failures */ + /* TODO test undersized buf */ + /* TODO test NULL buf */ + /* TODO test non-NUL terminated input */ + /* TODO test for separator removal */ + /* TODO test LIBNUMTEXT_N2T_SWEDISH_ORDINAL */ + /* TODO test LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR */ + /* TODO test LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM */ + /* TODO test LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM */ + + return !ok; +} |