require 'test/unit'
require 'gettext/parser/ruby'
require 'gettext/parser/glade'

class TestGetTextParser < Test::Unit::TestCase
  def test_ruby
    ary = GetText::RubyParser.parse(['test_rubyparser.rb'])

    assert_equal(['aaa', 'test_rubyparser.rb:8'], ary[0])
    assert_equal(['aaa\n', 'test_rubyparser.rb:12'], ary[1])
    assert_equal(['bbb\nccc', 'test_rubyparser.rb:16'], ary[2])
    assert_equal(['bbb\nccc\nddd\n', 'test_rubyparser.rb:20'], ary[3])
    assert_equal(['eee', 'test_rubyparser.rb:27', 'test_rubyparser.rb:31'], ary[4])
    assert_equal(['fff', 'test_rubyparser.rb:31'], ary[5])
    assert_equal(['ggghhhiii', 'test_rubyparser.rb:35'], ary[6])
    assert_equal(['a"b"c"', 'test_rubyparser.rb:41'], ary[7])
  end

  def test_glade
    ary = GetText::GladeParser.parse(['test_gladeparser.glade'])

    assert_equal(['window1', 'test_gladeparser.glade:8'], ary[0])
    assert_equal(['normal text', 'test_gladeparser.glade:29'], ary[1])
    assert_equal(['1st line\n2nd line\n3rd line', 'test_gladeparser.glade:50'], ary[2])
    assert_equal(['<span color="red" weight="bold" size="large">markup </span>', 'test_gladeparser.glade:73'], ary[3])
    assert_equal(['<span color="red">1st line markup </span>\n<span color="blue">2nd line markup</span>', 'test_gladeparser.glade:94'], ary[4])
    assert_equal(['<span>&quot;markup&quot; with &lt;escaped strings&gt;</span>', 'test_gladeparser.glade:116'], ary[5])
    assert_equal(['duplicated', 'test_gladeparser.glade:137', 'test_gladeparser.glade:158'], ary[6])
  end
end
