fantasdic r347 - in trunk: . lib/fantasdic/sources test



Author: mblondel
Date: Sat Aug 30 09:14:01 2008
New Revision: 347
URL: http://svn.gnome.org/viewvc/fantasdic?rev=347&view=rev

Log:
    * lib/fantasdic/sources/dictd_file.rb: Added 
DictdFile#get_word_list.
    * test/test_dictd_file.rb: Unit test.


Modified:
   trunk/ChangeLog
   trunk/lib/fantasdic/sources/dictd_file.rb
   trunk/test/test_dictd_file.rb

Modified: trunk/lib/fantasdic/sources/dictd_file.rb
==============================================================================
--- trunk/lib/fantasdic/sources/dictd_file.rb	(original)
+++ trunk/lib/fantasdic/sources/dictd_file.rb	Sat Aug 30 09:14:01 2008
@@ -146,6 +146,11 @@
         end         
     end
 
+    def get_word_list
+        self.rewind
+        self.lines.map { |l| l.split("\t").first }
+    end
+
 end
 
 class DictdFile < Base

Modified: trunk/test/test_dictd_file.rb
==============================================================================
--- trunk/test/test_dictd_file.rb	(original)
+++ trunk/test/test_dictd_file.rb	Sat Aug 30 09:14:01 2008
@@ -115,4 +115,35 @@
                          [])
         end
     end
+
+    def test_get_word_list
+        DictdIndex.open($index_file) do |index|
+            assert_equal(index.get_word_list[0..24],
+                        ["00databasealphabet",
+                        "00databasedictfmt11010",
+                        "00databaseinfo",
+                        "00databaseshort",
+                        "00databaseurl",
+                        "00databaseutf8",
+                        "a",
+                        "abad",
+                        "abades",
+                        "abaty",
+                        "aber",
+                        "ac",
+                        "achos",
+                        "achosi",
+                        "adda",
+                        "adeg",
+                        "adeiladu",
+                        "aderyn",
+                        "adnabod",
+                        "adref",
+                        "afal",
+                        "afon",
+                        "agor",
+                        "ail",
+                        "ail ar bymtheg"])
+        end
+    end
 end



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