shithub: pokecrystal

Download patch

ref: 0f5749915090b2d4055b9973ad6fa0d82ca5f040
parent: 9c723af8ffae03e7edbe18e6c084655fb4820f80
author: Bryan Bishop <[email protected]>
date: Sat Mar 24 01:00:45 EDT 2012

tests for IntervalMap

--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -4501,6 +4501,35 @@
         self.assertEqual(chars[0xA0], "a")
         self.assertEqual(chars[0xF0], "¥")
         self.assertEqual(jap_chars[0x44], "ぱ")
+    def test_map_names_integrity(self):
+        def map_name(map_group, map_id): return map_names[map_group][map_id]["name"]
+        self.assertEqual(map_name(2, 7), "Mahogany Town")
+        self.assertEqual(map_name(3, 0x34), "Ilex Forest")
+        self.assertEqual(map_name(7, 0x11), "Cerulean City")
+class TestIntervalMap(unittest.TestCase):
+    def test_intervals(self):
+        i = IntervalMap()
+        first = "hello world"
+        second = "testing 123"
+        i[0:5] = first
+        i[5:10] = second
+        self.assertEqual(i[0], first)
+        self.assertEqual(i[1], first)
+        self.assertNotEqual(i[5], first)
+        self.assertEqual(i[6], second)
+        i[3:10] = second
+        self.assertEqual(i[3], second)
+        self.assertNotEqual(i[4], first)
+    def test_items(self):
+        i = IntervalMap()
+        first = "hello world"
+        second = "testing 123"
+        i[0:5] = first
+        i[5:10] = second
+        results = list(i.items())
+        self.failUnless(len(results) == 2)
+        self.assertEqual(results[0], ((0, 5), "hello world"))
+        self.assertEqual(results[1], ((5, 10), "testing 123"))
 class TestRomStr(unittest.TestCase):
     """RomStr is a class that should act exactly like str()
     except that it never shows the contents of it string
@@ -4558,6 +4587,8 @@
         self.assertEqual(counter, 388)
         parse_map_header_at = temp
 class TestTextScript(unittest.TestCase):
+    def test_to_asm(self):
+        pass #or raise NotImplementedError, bryan_message
     def test_find_addresses(self):
         pass #or raise NotImplementedError, bryan_message
     def test_parse_text_at(self):
@@ -4564,8 +4595,6 @@
         pass #or raise NotImplementedError, bryan_message
     def test_to_asm_at(self):
         pass #or raise NotImplementedError, bryan_message
-    def test_to_asm(self):
-        pass #or raise NotImplementedError, bryan_message
 class TestEncodedText(unittest.TestCase):
     def test_to_asm(self):
         pass #or raise NotImplementedError, bryan_message
@@ -4579,7 +4608,8 @@
     """for testing parse_script_engine_script_at
     and script parsing in general.
     Script should be a class?"""
-    pass
+    def test_parse_script_engine_script_at(self):
+        pass #or raise NotImplementedError, bryan_message
 class TestMetaTesting(unittest.TestCase):
     """test whether or not i am finding at least
     some of the tests in this file"""