=begin Copyright © 2007 John Vorhauer Contact me at langa@vorhauer.de near 50°55'N+6°55'E. This file is part of Langa. Langa is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Langa 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Langa. If not, see . For a detailed functional description of Langa see the README file =end $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'rubygems' require 'test/unit' require 'languages.rb' class TestLanguages < Test::Unit::TestCase def setup path = File.join(File.dirname(__FILE__), '..', 'lib', 'langa') @lang = Languages.new(File.join(path, 'language.dna')) end def test_to_paste deu = @lang.config('deu') deu.delete('dna') exp = "deu:\n name: German\n iso1: de\n bibl: ger\n source: corpora/ger.german.utf-8.txt\n size: 92273185\n utf8: enirtsadhlugcmobfkwzpv\303\274\303\244j\303\266yxq\n fingerprint: 101-16251+110-9918+105-7865+114-7637+116-6348+115-6297+97-5912+100-4806+104-4285+108-3760+117-3715+103-3023+99-2757+109-2724+111-2721+98-2076+102-1755+107-1501+119-1432+122-1238+112-1031+118-936+252-675+228-586+106-276+246-264+121-109+120-55+113-26\n" assert_equal(exp, Languages.to_paste('deu', deu)) end def test_keys assert_not_nil(@lang.keys) assert_instance_of(Array, @lang.keys) assert_not_nil(@lang.keys.index('deu')) end def test_values_for assert_nil(@lang.values_for(nil)) assert_instance_of(Hash, @lang.values_for('name')) assert_equal({}, @lang.values_for('unknown')) assert_equal('deu', @lang.values_for('name')['German']) assert_nil(@lang.values_for('name')['german']) assert_equal('deu', @lang.values_for('name',true)['german']) assert_nil(@lang.values_for('name',true)['German']) end def test_config assert_nil(@lang.config(nil)) assert_nil(@lang.config('key not given')) assert_nil(@lang.config(3)) assert_equal(8, @lang.config('deu').size) end end