From 51161194edbda508d0ab2a7594630cd03d89512c Mon Sep 17 00:00:00 2001 From: Kevin Everets Date: Fri, 3 May 2013 11:30:22 -0400 Subject: [PATCH] Add test for multiline strings in .po files --- test/fixtures/en-2.po | 23 +++++++++++++++++++++++ test/fixtures/test-output-9.txt | 21 +++++++++++++++++++++ test/twine_test.rb | 8 ++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/fixtures/en-2.po create mode 100644 test/fixtures/test-output-9.txt diff --git a/test/fixtures/en-2.po b/test/fixtures/en-2.po new file mode 100644 index 0000000..81ce2ce --- /dev/null +++ b/test/fixtures/en-2.po @@ -0,0 +1,23 @@ +msgid "" +msgstr "" +"Language: en\n" +"X-Generator: Twine\n" + +msgctxt "key1" +msgid "key1-english" +msgstr "key1-english" + +msgctxt "key3" +msgid "key3-english" +msgstr "" + +msgctxt "key4" +msgid "key4" +"multiline" +msgstr "A multi" +"line string\n" +"can occur" + +msgctxt "key5" +msgid "A new string" +msgstr "A new string" diff --git a/test/fixtures/test-output-9.txt b/test/fixtures/test-output-9.txt new file mode 100644 index 0000000..c351f43 --- /dev/null +++ b/test/fixtures/test-output-9.txt @@ -0,0 +1,21 @@ +[[Uncategorized]] + [key5] + en = A new string + +[[My Strings]] + [key1] + en = key1-english + tags = tag1 + comment = This is a comment + es = key1-spanish + fr = key1-french + [key2] + en = key2-english + tags = tag2 + fr = key2-french + [key3] + en = key3-english + tags = tag1,tag2 + es = key3-spanish + [key4] + en = A multiline string\ncan occur diff --git a/test/twine_test.rb b/test/twine_test.rb index 8dde933..8f61e51 100644 --- a/test/twine_test.rb +++ b/test/twine_test.rb @@ -84,6 +84,14 @@ class TwineTest < Test::Unit::TestCase end end + def test_consume_string_file_5 + Dir.mktmpdir do |dir| + output_path = File.join(dir, 'strings.txt') + Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-2.po -o #{output_path} -l en -a)) + assert_equal(File.read('test/fixtures/test-output-9.txt'), File.read(output_path)) + end + end + def test_generate_report_1 Twine::Runner.run(%w(generate-report test/fixtures/strings-1.txt)) end