fantasdic r331 - in trunk: . test



Author: mblondel
Date: Sat Aug 23 06:18:22 2008
New Revision: 331
URL: http://svn.gnome.org/viewvc/fantasdic?rev=331&view=rev

Log:
* test/test_dict_server.rb: Added unit test.


Added:
   trunk/test/test_dict_server.rb
Modified:
   trunk/ChangeLog

Added: trunk/test/test_dict_server.rb
==============================================================================
--- (empty file)
+++ trunk/test/test_dict_server.rb	Sat Aug 23 06:18:22 2008
@@ -0,0 +1,60 @@
+# Fantasdic
+# Copyright (C) 2008 Mathieu Blondel
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+#Â51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+test_dir = File.expand_path(File.dirname(__FILE__))
+top_dir = File.expand_path(File.join(test_dir, ".."))
+lib_dir = File.expand_path(File.join(top_dir, "lib"))
+$LOAD_PATH.unshift(lib_dir)
+
+require "test/unit"
+require "fantasdic"
+require "fantasdic/sources/dict_server"
+
+class TestDictServerSource < Test::Unit::TestCase
+
+    def setup
+        config = {
+            :server => "dict.org",
+            :port => 2628,
+            :auth => false,
+            :login => "",
+            :password => ""
+        }
+        @source = Fantasdic::Source::DictServer.new(config)
+        @source.open
+    end
+
+    def teardown
+        @source.close
+    end
+
+    def test_define
+        defs = @source.define("eng-fra", "dictionary")
+        assert_equal(defs.length, 1)
+        assert_equal(defs.first.body.include?("dictionnaire"), true)
+    end
+
+    def test_prefix
+        matches = @source.match("eng-fra", "prefix", "test")
+        matches.each_value do |results|
+            results.each do |word|
+                assert_equal(word =~ /^test/, 0)
+            end
+        end
+    end
+
+end



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]