[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testLexiconNG.py:1.1.2.3

Andreas Jung andreas@digicool.com
Wed, 9 Jan 2002 19:01:07 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv16524

Modified Files:
      Tag: ajung-textindexng-branch
	testLexiconNG.py 
Log Message:
added mixed unicode/latin1 test


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testLexiconNG.py 1.1.2.2 => 1.1.2.3 ===
 from Products.PluginIndexes.TextIndexNG.LexiconNG import LexiconNG
 
-
 class Tests(unittest.TestCase):
 
     def setUp(self):
@@ -44,21 +43,46 @@
             self.assertEqual(self._lexicon.getWordId(word), wid)
 
 
-    def testSimple(self):
-        """ a simple test """
+    def testASCII(self):
+        """ ASCII test """
 
         s = 'the quick brown fox jumps over the lazy dog'
         self.doTest(s)
 
 
     def testUnicode(self):
-        """ a simple test """
+        """ UNICODE test """
 
         s = unicode( 'Bei den dreitägigen Angriffen seien auch bis'
                  ' auf einen alle Flugplätze der Taliban zerstört worden',
                  'latin1')
 
         self.doTest(s)
+
+
+    def testLatin1Unicode(self):
+        """ mixed Latin1 and Unicode strings """
+
+        s = unicode( 'Bei den dreitägigen Angriffen seien auch bis'
+                 ' auf einen alle Flugplätze der Taliban zerstört worden',
+                 'latin1')
+
+        wids = {} 
+        for w in s.split(): 
+            wids[w] = self._lexicon.getWordId(w)
+
+        s = 'the quick brown fox jumps over the lazy dog'
+        for w in s.split(): 
+            wids[w] = self._lexicon.getWordId(w)
+        
+
+        for word,wid in wids.items():
+            self.assertEqual(wid, self._lexicon.getWordId(word))
+
+        for word,wid in self._lexicon._lexicon.items():
+            self.assertEqual(wid, wids.get(word))
+
+
 
     def printLexicon(self):