File: test_msgmerge.rb

package info (click to toggle)
ruby-gettext 3.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 6,424 kB
  • sloc: ruby: 9,643; makefile: 8
file content (825 lines) | stat: -rw-r--r-- 21,858 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2020  Sutou Kouhei <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
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 'gettext/tools/msgmerge'

class TestToolsMsgMerge < Test::Unit::TestCase
  class TestMerger < self
    def setup
      @po = GetText::PO.new
      @pot = GetText::PO.new
      @config = GetText::Tools::MsgMerge::Config.new
    end

    def parse_po(po, output)
      parser = GetText::POParser.new
      parser.report_warning = false
      parser.parse(po, output)
    end

    def merge
      merger = GetText::Tools::MsgMerge::Merger.new(@pot, @po, @config)
      merger.merge
    end

    class TestUpdate < self
      def test_msgstr
        pot = <<-POT
msgid "hello"
msgstr ""
        POT
        po = <<-PO
msgid "hello"
msgstr "bonjour"
        PO
        merged_po = merge(pot, po)

        assert_equal(<<-PO, merged_po)
msgid "hello"
msgstr "bonjour"
        PO
      end

      private
      def merge(pot, po)
        parse_po(pot, @pot)
        parse_po(po, @po)
        super().to_s
      end
    end

    class TestObosleteEntry < self
      def test_in_po
        pot = <<-POT
msgid "hello"
msgstr ""
        POT
        po = <<-PO
msgid "hello"
msgstr "bonjour"

#~ msgid "he"
#~ msgstr "il"
        PO

        assert_equal(<<-PO, merge(pot, po))
msgid "hello"
msgstr "bonjour"

#~ msgid "he"
#~ msgstr "il"
        PO
      end

      private
      def merge(pot, po)
        parse_po(pot, @pot)
        parse_po(po, @po)
        super().to_s
      end
    end

    def test_different_msgstr
      @po["hello"] = "salut"
      @pot["hello"] = "bonjour"
      merged_po = merge

      assert_equal("salut", merged_po["hello"].msgstr)
    end

    def test_translator_comment
      @po["hello"] = generate_entry(:msgid => "hello",
                                    :msgstr => "bonjour",
                                    :translator_comment => "comment")

      @pot["hello"] = generate_entry(:msgid => "hello",
                                     :msgstr => "",
                                     :translator_comment => "It's comments")

      merged_po = merge
      assert_equal("bonjour", merged_po["hello"].msgstr)
      assert_equal("comment", merged_po["hello"].translator_comment)
    end

    def test_extracted_comment
      @po["hello"] = generate_entry(:msgid => "hello",
                                    :msgstr => "bonjour",
                                    :extracted_comment => "comment")

      @pot["hello"] = generate_entry(:msgid => "hello",
                                     :msgstr => "",
                                     :extracted_comment => "extracted comments")

      merged_po = merge
      assert_equal("bonjour", merged_po["hello"].msgstr)
      assert_equal("extracted comments", merged_po["hello"].extracted_comment)
    end

    def test_references
      references = ["file.rb:10", "helper.rb:10"]
      pot_references = ["file.rb:10", "test.rb:25"]
      @po["hello"] = generate_entry(:msgid => "hello",
                                    :msgstr => "bonjour",
                                    :references => references)

      @pot["hello"] = generate_entry(:msgid => "hello",
                                     :msgstr => "",
                                     :references => pot_references)

      merged_po = merge
      assert_equal("bonjour", merged_po["hello"].msgstr)
      assert_equal(pot_references, merged_po["hello"].references)
    end

    def test_flag
      @po["hello"] = generate_entry(:msgid => "hello",
                                    :msgstr => "bonjour",
                                    :flag => "c-format")

      @pot["hello"] = generate_entry(:msgid => "hello",
                                     :msgstr => "",
                                     :flag => "no-c-format")

      merged_po = merge
      assert_equal("bonjour", merged_po["hello"].msgstr)
      assert_equal("no-c-format", merged_po["hello"].flag)
    end

    def test_previous
      @po["hello"] = generate_entry(:msgid => "hello",
                                    :msgstr => "bonjour",
                                    :previous => "hi")

      @pot["hello"] = generate_entry(:msgid => "hello",
                                     :msgstr => "")

      merged_po = merge
      assert_equal("bonjour", merged_po["hello"].msgstr)
      assert_equal(nil, merged_po["hello"].previous)
    end

    class TestAddNoFuzzy < self
      def test_add_to_nontranslated_entry
        @po["helol"] = generate_entry(:msgid => "helol",
                                      :msgstr => nil)
        @pot["hello"] = generate_entry(:msgid => "hello",
                                       :msgstr => nil)
        merged_po = merge
        assert_true(merged_po.has_key?("hello"))
        assert_nil(merged_po["hello"].flag)
      end

      def test_fuzzy_header
        @po[""] = generate_entry(:msgid => "",
                                 :msgstr => "header\nentry",
                                 :translator_comment => "header comment")

        @pot[""] = generate_entry(:msgid => "",
                                  :msgstr => "uninitialized\ncomment",
                                  :translator_comment => "uninitialized comment",
                                  :flag => "fuzzy")

        merged_po = merge
        assert_equal("header\nentry", merged_po[""].msgstr)
        assert_equal("header comment", merged_po[""].translator_comment)
        assert_equal(nil, merged_po[""].flag)
      end

      def test_fuzzy_header_including_pot_creation_date
        creation_date_mark = "POT-Creation-Date: "
        po_creation_date = "#{creation_date_mark}2012-11-15 08:15+0900"
        pot_creation_date = "#{creation_date_mark}2012-11-20 14:15+0900"
        @po[""] = generate_entry(:msgid => "",
                                 :msgstr => po_creation_date,
                                 :translator_comment => "header comment")

        @pot[""] = generate_entry(:msgid => "",
                                  :msgstr => pot_creation_date,
                                  :translator_comment => "header comment",
                                  :flag => "fuzzy")

        merged_po = merge
        assert_equal(pot_creation_date, merged_po[""].msgstr)
      end

      def test_already_fuzzy_po
        @po["hello"] = generate_entry(:msgid => "hello",
                                      :msgstr => "bonjour",
                                      :flag => "fuzzy")
        @pot["hello"] = generate_entry(:msgid => "hello",
                                       :msgstr => nil)
        @pot["helol"] = generate_entry(:msgid => "helol",
                                       :msgstr => nil,
                                       :flag => "fuzzy")
        merged_po = merge
        assert_true(merged_po.has_key?("helol"))
        assert_equal(["fuzzy"], merged_po["helol"].flags)
      end

      def test_already_fuzzy_pot
        @po["hello"] = generate_entry(:msgid => "hello",
                                      :msgstr => "bonjour")
        @pot["helol"] = generate_entry(:msgid => "helol",
                                       :msgstr => nil,
                                       :flag => "fuzzy")
        merged_po = merge
        assert_true(merged_po.has_key?("helol"))
        assert_equal(["fuzzy"], merged_po["helol"].flags)
      end
    end

    class TestAddFuzzy < self
      def test_nonexistent_msgctxt
        @po["normal", "hello"] = generate_entry(:msgctxt => "normal",
                                                :msgid => "hello",
                                                :msgstr => "salut")
        @pot["hello"] = generate_entry(:msgid => "hello",
                                       :msgstr => "")
        merged_po = merge

        assert_false(merged_po.has_key?("normal", "hello"))
        assert_true(merged_po.has_key?("hello"))
        assert_equal("salut", merged_po["hello"].msgstr)
        assert_equal("fuzzy", merged_po["hello"].flag)
      end

      def test_msgid_plural
        @po["he"] = generate_entry(:msgid => "he",
                                   :msgid_plural => "thye",
                                   :msgstr => "il\000ils")
        @pot["he"] = generate_entry(:msgid => "he",
                                    :msgid_plural => "they",
                                    :msgstr => "")
        merged_po = merge

        assert_equal("il\000ils", merged_po["he"].msgstr)
        assert_equal("they", merged_po["he"].msgid_plural)
        assert_equal("fuzzy", merged_po["he"].flag)
      end

      def test_fuzzy_matching_entry
        @po["helol"] = "bonjour"
        @pot["hello"] = ""
        merged_po = merge

        assert_false(merged_po.has_key?("helol"))
        assert_true(merged_po.has_key?("hello"))
        assert_equal("bonjour", merged_po["hello"].msgstr)
        assert_equal("fuzzy", merged_po["hello"].flag)
      end

      def test_fuzzy_matching_included_source
        base_msgid = "hello"
        new_msgid = base_msgid + ("!" * 10)
        @po[base_msgid] = "bonjour"
        @pot[new_msgid] = ""
        merged_po = merge

        assert_equal("bonjour", merged_po[new_msgid].msgstr)
        assert_equal("fuzzy", merged_po[new_msgid].flag)
      end

      def test_merged_entry_from_fuzzy_entry
        @po["hello"] = generate_entry(:msgid => "hello",
                                      :msgstr => "bonjuor",
                                      :flag => "fuzzy")

        @pot["hello"] = generate_entry(:msgid => "hello",
                                       :msgstr => "")

        merged_po = merge
        assert_equal("bonjuor", merged_po["hello"].msgstr)
        assert_equal("fuzzy", merged_po["hello"].flag)
      end
    end

    def test_obsolete_entry
      @po["hello"] = "bonjour"
      @pot["hi"] = "salut"
      merged_po = merge

      assert_equal("salut", merged_po["hi"].msgstr)
      assert_false(merged_po.has_key?("hello"))

      obsolete_comment = <<-EOC
msgid "hello"
msgstr "bonjour"
EOC
      assert_equal(obsolete_comment, merged_po[:last].comment)
    end

    private
    def generate_entry(options)
      msgctxt = options[:msgctxt]
      msgid_plural = options[:msgid_plural]
      type = detect_entry_type(msgctxt, msgid_plural)

      entry = GetText::POEntry.new(type)
      entry.translator_comment = options[:translator_comment]
      entry.extracted_comment = options[:extracted_comment]
      entry.references = options[:references] || []
      entry.flag = options[:flag]
      entry.previous = options[:previous]
      entry.msgctxt = msgctxt
      entry.msgid = options[:msgid]
      entry.msgid_plural = msgid_plural
      entry.msgstr = options[:msgstr]
      entry.comment = options[:comment]
      entry
    end

    def detect_entry_type(msgctxt, msgid_plural)
      if msgctxt.nil?
        if msgid_plural.nil?
          :normal
        else
          :plural
        end
      else
        if msgid_plural.nil?
          :msgctxt
        else
          :msgctxt_plural
        end
      end
    end
  end

  class TestCommand < self
    include Helper::Tmpdir

    def setup
      @msgmerge = GetText::Tools::MsgMerge.new
    end

    setup :setup_tmpdir
    teardown :teardown_tmpdir

    setup
    def setup_paths
      @pot_file_path = File.join(@tmpdir, "po", "msgmerge.pot")
      @po_file_path = File.join(@tmpdir, "po", "ja", "msgmerge.po")
      FileUtils.mkdir_p(File.dirname(@po_file_path))
    end

    setup
    def setup_content
      @pot_formatted_time = "2012-08-19 19:08+0900"
      @po_formatted_time = "2012-08-19 18:59+0900"
      File.open(@pot_file_path, "w") do |pot_file|
        pot_file.puts(pot_content)
      end

      File.open(@po_file_path, "w") do |po_file|
        po_file.puts(po_content)
      end
    end

    private
    def pot_content
      <<-EOP
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\\n"
"POT-Creation-Date: #{@pot_formatted_time}\\n"
"PO-Revision-Date: #{@pot_formatted_time}\\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <LL@li.org>\\n"
"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:3
msgid "Good-bye"
msgstr ""
EOP
    end

    def po_header(creation_date, revision_date)
      <<-EOH
# Hello Application.
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
# This file is distributed under the same license as the Hello package.
# Kouhei Sutou <kou@clear-code.com> , 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: Hello 1.0.0\\n"
"POT-Creation-Date: #{creation_date}\\n"
"PO-Revision-Date: #{revision_date}\\n"
"Last-Translator: Kouhei Sutou <kou@clear-code.com>\\n"
"Language-Team: Japanese <hello-ja@example.com>\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
"Plural-Forms: nplurals=1; plural=0;\\n"
EOH
    end

    def po_content
      <<-EOP
#{po_header(@po_formatted_time, @po_formatted_time)}

#: hello.rb:1
msgid "World"
msgstr "Translated World"
EOP
    end

    class TestFuzzy < self
      class TestHeader < self
        def test_remove_fuzzy_from_pot
          @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 "Good-bye"
msgstr ""
EOP
        end
      end

      class TestMessage < self
        include Helper::Warning

        def po_content
          <<-PO
#{po_header(@po_formatted_time, @po_formatted_time)}

#, fuzzy
msgid "World"
msgstr "Translated World"
         PO
        end

        def test_merge_metadata
          suppress_warning do
            @msgmerge.run("--update", @po_file_path, @pot_file_path)
          end
          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
#, fuzzy
msgid "World"
msgstr "Translated World"

#: hello.rb:3
msgid "Good-bye"
msgstr ""
          PO
        end
      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 "Good-bye"
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:3
msgid "Good-bye"
msgstr ""

#: hello.rb:1
msgid "Hello"
msgstr ""

#: hello.rb:2
msgid "World"
msgstr "Translated World"
        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 "Good-bye"
msgstr ""
        PO
      end

      def test_sort_by_location
        @msgmerge.run("--update",
                      "--sort-by-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 "Good-bye"
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:3
msgid "Good-bye"
msgstr ""

#: hello.rb:1
msgid "Hello"
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 "Good-bye"
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 "Good-bye"
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 "Good-bye"
msgstr ""
        POT
      end

      def po_content
        <<-PO
#: hello.rb:3
msgid "Good-bye"
msgstr "Translated Good-bye. 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! "
"Very very long line!"
msgstr ""

#: hello.rb:3
msgid "Good-bye"
msgstr ""
"Translated Good-bye. This translation is very long. Yes! Very long "
"translation!!!"
        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 "
"long! Very very long line!"
msgstr ""

#: hello.rb:3
msgid "Good-bye"
msgstr ""
"Translated Good-bye. 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 "Good-bye"
msgstr "Translated Good-bye. This translation is very long. Yes! Very long translation!!!"
        PO
      end
    end

    class TestFuzzyMatching < self
      def pot_content
        <<-POT
msgid "Hello"
msgstr ""
        POT
      end

      def po_content
        <<-PO
msgid "Hello!"
msgstr "Bonjour!"
        PO
      end

      def test_default
        @msgmerge.run("--update",
                      @po_file_path, @pot_file_path)
        assert_equal(<<-PO, File.read(@po_file_path))
#, fuzzy
msgid "Hello"
msgstr "Bonjour!"

#~ msgid "Hello!"
#~ msgstr "Bonjour!"
        PO
      end

      def test_fuzzy_matching
        @msgmerge.run("--update",
                      "--fuzzy-matching",
                      @po_file_path, @pot_file_path)
        assert_equal(<<-PO, File.read(@po_file_path))
#, fuzzy
msgid "Hello"
msgstr "Bonjour!"

#~ msgid "Hello!"
#~ msgstr "Bonjour!"
        PO
      end

      def test_no_fuzzy_matching
        @msgmerge.run("--update",
                      "--no-fuzzy-matching",
                      @po_file_path, @pot_file_path)
        assert_equal(<<-PO, File.read(@po_file_path))
msgid "Hello"
msgstr ""

#~ msgid "Hello!"
#~ msgstr "Bonjour!"
        PO
      end
    end

    class TestObsoleteEntries < self
      def pot_content
        <<-POT
msgid "World"
msgstr ""
        POT
      end

      def po_content
        <<-PO
msgid "Hello!"
msgstr "Bonjour!"
        PO
      end

      def test_default
        @msgmerge.run("--update",
                      @po_file_path, @pot_file_path)
        assert_equal(<<-PO, File.read(@po_file_path))
msgid "World"
msgstr ""

#~ msgid "Hello!"
#~ msgstr "Bonjour!"
        PO
      end

      def test_no_obsolete_entries
        @msgmerge.run("--update",
                      "--no-obsolete-entries",
                      @po_file_path, @pot_file_path)
        assert_equal(<<-PO, File.read(@po_file_path))
msgid "World"
msgstr ""
        PO
      end
    end
  end
end