test/tools/test_msgmerge.rb in gettext-3.0.0 vs test/tools/test_msgmerge.rb in gettext-3.0.1

- old
+ new

@@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com> # Copyright (C) 2010 Eddie Lau <tatonlto@gmail.com> # # License: Ruby's or LGPL # # This library is free software: you can redistribute it and/or modify @@ -277,11 +277,11 @@ end end end end - class TestMerge < self + class TestCommand < self include GetTextTestUtils def setup @msgmerge = GetText::Tools::MsgMerge.new end @@ -328,16 +328,20 @@ "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8bit\\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n" +#: hello.rb:2 +msgid "World" +msgstr "" + #: hello.rb:1 msgid "Hello" msgstr "" -#: hello.rb:2 -msgid "World" +#: hello.rb:3 +msgid "Hello World" msgstr "" EOP end def po_header(creation_date, revision_date) @@ -371,20 +375,217 @@ EOP end class TestFuzzy < self def test_header_message - @msgmerge.run(@po_file_path, @pot_file_path, "--output", @po_file_path) + @msgmerge.run("--update", @po_file_path, @pot_file_path) assert_equal(<<-EOP, File.read(@po_file_path)) #{po_header(@pot_formatted_time, @po_formatted_time)} #: hello.rb:1 msgid "Hello" msgstr "" #: hello.rb:2 msgid "World" msgstr "Translated World" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" EOP + end + end + + class TestSort < self + def test_default + @msgmerge.run("--update", @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +#: hello.rb:1 +msgid "Hello" +msgstr "" + +#: hello.rb:2 +msgid "World" +msgstr "Translated World" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + PO + end + + def test_sort_output + @msgmerge.run("--update", + "--sort-output", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +#: hello.rb:1 +msgid "Hello" +msgstr "" + +#: hello.rb:2 +msgid "World" +msgstr "Translated World" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + PO + end + + def test_sort_by_file + @msgmerge.run("--update", + "--sort-by-file", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +#: hello.rb:1 +msgid "Hello" +msgstr "" + +#: hello.rb:2 +msgid "World" +msgstr "Translated World" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + PO + end + + def test_sort_by_msgid + @msgmerge.run("--update", + "--sort-by-msgid", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +#: hello.rb:1 +msgid "Hello" +msgstr "" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + +#: hello.rb:2 +msgid "World" +msgstr "Translated World" + PO + end + end + + class TestLocation < self + def test_location + @msgmerge.run("--update", + "--location", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +#: hello.rb:1 +msgid "Hello" +msgstr "" + +#: hello.rb:2 +msgid "World" +msgstr "Translated World" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + PO + end + + def test_no_location + @msgmerge.run("--update", + "--no-location", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#{po_header(@pot_formatted_time, @po_formatted_time)} +msgid "Hello" +msgstr "" + +msgid "World" +msgstr "Translated World" + +msgid "Hello World" +msgstr "" + PO + end + end + + class TestWidth < self + def pot_content + <<-POT +#: hello.rb:1 +msgid "Hello very long line! This line is very long. Yes! This line is very long! Very very long line!" +msgstr "" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" + POT + end + + def po_content + <<-PO +#: hello.rb:3 +msgid "Hello World" +msgstr "Translated Hello World. This translation is very long. Yes! Very long translation!!!" + PO + end + + def test_default + @msgmerge.run("--update", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#: hello.rb:1 +msgid "" +"Hello very long line! This line is very long. Yes! This line is very long! Ver" +"y very long line!" +msgstr "" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" +"Translated Hello World. This translation is very long. Yes! Very long translat" +"ion!!!" + PO + end + + def test_width + @msgmerge.run("--update", + "--width", "70", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#: hello.rb:1 +msgid "" +"Hello very long line! This line is very long. Yes! This line is very l" +"ong! Very very long line!" +msgstr "" + +#: hello.rb:3 +msgid "Hello World" +msgstr "" +"Translated Hello World. This translation is very long. Yes! Very long " +"translation!!!" + PO + end + + def test_no_wrap + @msgmerge.run("--update", + "--no-wrap", + @po_file_path, @pot_file_path) + assert_equal(<<-PO, File.read(@po_file_path)) +#: hello.rb:1 +msgid "Hello very long line! This line is very long. Yes! This line is very long! Very very long line!" +msgstr "" + +#: hello.rb:3 +msgid "Hello World" +msgstr "Translated Hello World. This translation is very long. Yes! Very long translation!!!" + PO end end end end