Sha256: 36743be52562e19f8615158e1f6c30725342aa9ddeb458199450c3714750825a

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

#! /usr/bin/env ruby -Ku
# -*- coding: utf-8-unix -*-
require File.dirname(__FILE__) + '/test_helper.rb'
require '_test-util'

class GetTextTest < Test::Unit::TestCase
  include Gonzui::GetText

  CATALOG_FILE_NAME = "catalog.ja"
  CATALOG = {
    "hello" => "こんにちは"
  }

  def make_catalog
    File.open(CATALOG_FILE_NAME, "w") {|f|
      f.puts "{"
      CATALOG.each {|key, value|
        f.printf('  "%s" => "%s",', key, value)
        f.puts
      }
      f.puts "}"
    }
  end

  def remove_catalog
    File.unlink(CATALOG_FILE_NAME)
  end

  def test_gettext
    make_catalog
    assert_equal("hello", _("hello"))
    catalog_repository = Gonzui::CatalogRepository.new(".")
    catalog = catalog_repository.choose("ja")
    assert_equal(catalog, load_catalog("catalog.ja"))
    set_catalog(catalog)
    assert_equal("こんにちは", _("hello"))

    remove_catalog
  end

  def test_validator
    validator = Gonzui::CatalogValidator.new(__FILE__, CATALOG)
    validator.validate
    assert_equal(true, validator.ok?)

    validator = Gonzui::CatalogValidator.new(__FILE__, {})
    validator.validate
    assert_equal(false, validator.ok?)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gonzui-1.2-x86-mswin32-60 test/test_gettext.rb
gonzui-1.2 test/test_gettext.rb