diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-05 14:53:47 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-05 14:53:47 +0200 |
commit | a97da13a7c3716f985973f0454f5c8caa0fa05b1 (patch) | |
tree | 41096cd7f389b916c0c77df0432f4f00ddb327c9 /swedish.test.c | |
parent | First commit (diff) | |
download | libnumtext-a97da13a7c3716f985973f0454f5c8caa0fa05b1.tar.gz libnumtext-a97da13a7c3716f985973f0454f5c8caa0fa05b1.tar.bz2 libnumtext-a97da13a7c3716f985973f0454f5c8caa0fa05b1.tar.xz |
Add tests for and fix Swedish
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'swedish.test.c')
-rw-r--r-- | swedish.test.c | 528 |
1 files changed, 528 insertions, 0 deletions
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; +} |