diff options
author | orwell <orwell@bleipb.de> | 2024-11-09 21:55:52 +0100 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-11-09 21:55:52 +0100 |
commit | 96f4ac7f6c2ff7fae56102640e9e63305ca64b16 (patch) | |
tree | b281c20dc8c2b55875a5c561d8c4dcadb836d53b /advtrains/spec/poconvert_spec.lua | |
parent | 35167fe928e61ecf35c633014972e36c921a1b78 (diff) | |
parent | 943505a797e628ef8e447a8fdb362f777b325dec (diff) | |
download | advtrains-96f4ac7f6c2ff7fae56102640e9e63305ca64b16.tar.gz advtrains-96f4ac7f6c2ff7fae56102640e9e63305ca64b16.tar.bz2 advtrains-96f4ac7f6c2ff7fae56102640e9e63305ca64b16.zip |
Merge remote-tracking branch 'origin/l10n'
Diffstat (limited to 'advtrains/spec/poconvert_spec.lua')
-rw-r--r-- | advtrains/spec/poconvert_spec.lua | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/advtrains/spec/poconvert_spec.lua b/advtrains/spec/poconvert_spec.lua new file mode 100644 index 0000000..51f33e7 --- /dev/null +++ b/advtrains/spec/poconvert_spec.lua @@ -0,0 +1,70 @@ +package.path = "../?.lua;" .. package.path +advtrains = {} +_G.advtrains = advtrains +local poconvert = require("poconvert") + +describe("PO file converter", function() + it("should convert PO files", function() + assert.equals([[ +# textdomain: foo +foo=bar +baz= +#@=wh\at\\@n=@=w\as\\@n +multiline@nstrings=multiline@nresult +with context?=oder doch nicht]], poconvert.from_string("foo", [[ +msgid "" +msgstr "whatever metadata" + +msgid "foo" +msgstr "bar" + +msgid "baz" +msgstr "" + +#, fuzzy +msgid "=wh\\at\\\\\n" +msgstr "=w\\as\\\\\n" + +msgid "multi" +"line\n" +"strings" +msgstr "multi" +"line\n" +"result" + +msgctxt "i18n context" +msgid "with context?" +msgstr "oder doch nicht"]])) + end) + it("should reject invalid tokens", function() + assert.has.errors(function() + poconvert.from_string("", [[ +foo "" +bar ""]]) + end, "Invalid token: foo") + end) + it("should reject entries without a msgstr", function() + assert.has.errors(function() + poconvert.from_string("", [[msgid "foo"]]) + end, "Missing translated string") + end) + it("should reject entries without a msgid", function() + assert.has.errors(function() + poconvert.from_string("", [[msgstr "foo"]]) + end, "Missing untranslated string") + end) + it("should reject entries with improperly enclosed strings", function() + assert.has.errors(function() + poconvert.from_string("", [[ +msgid "foo" +msgstr "bar \]]) + end, "String extends beyond the end of input") + end) + it("should reject incomplete input", function() + assert.has.errors(function() + poconvert.from_string("", [[ +msgid "foo" +msgstr]]) + end, "No string provided for msgstr") + end) +end) |