Ejemplo n.º 1
0
    def test_double_strings_from_text(self):
        doubles = DoubleStringCharSplitCollection ()
        self.assertIsNotNone(doubles)

        count = doubles.load_from_text("""
        key1,val1
        key2,val2
        key3,val3,val4
        """)
        self.assertEqual(count, 3)

        self.assertTrue(doubles.has_key("key1"))
        self.assertEqual(doubles.value("key1"), "val1")

        self.assertTrue(doubles.has_key("key2"))
        self.assertEqual(doubles.value("key2"), "val2")

        self.assertTrue(doubles.has_key("key3"))
        self.assertEqual(doubles.value("key3"), "val3,val4")

        self.assertFalse(doubles.has_key("key4"))
        doubles.add_value("key4", "val5")
        self.assertTrue(doubles.has_key("key4"))
        self.assertEqual(doubles.value("key4"), "val5")
        doubles.set_value("key4", "val6")
        self.assertEqual(doubles.value("key4"), "val6")
Ejemplo n.º 2
0
    def test_double_strings_from_text(self):
        doubles = DoubleStringCharSplitCollection()
        self.assertIsNotNone(doubles)

        count = doubles.load_from_text("""
        key1,val1
        key2,val2
        key3,val3,val4
        """)
        self.assertEqual(count, 3)

        self.assertTrue(doubles.has_key("key1"))
        self.assertEqual(doubles.value("key1"), "val1")

        self.assertTrue(doubles.has_key("key2"))
        self.assertEqual(doubles.value("key2"), "val2")

        self.assertTrue(doubles.has_key("key3"))
        self.assertEqual(doubles.value("key3"), "val3,val4")

        self.assertFalse(doubles.has_key("key4"))
        doubles.add_value("key4", "val5")
        self.assertTrue(doubles.has_key("key4"))
        self.assertEqual(doubles.value("key4"), "val5")
        doubles.set_value("key4", "val6")
        self.assertEqual(doubles.value("key4"), "val6")
Ejemplo n.º 3
0
    def test_double_strings_from_file(self):
        doubles = DoubleStringCharSplitCollection ()
        self.assertIsNotNone(doubles)

        count = doubles.load_from_filename(os.path.dirname(__file__) + os.sep + "test_files/doubles.txt")
        self.assertEqual(count, 3)

        self.assertTrue(doubles.has_key("key1"))
        self.assertEqual(doubles.value("key1"), "val1")

        self.assertTrue(doubles.has_key("key2"))
        self.assertEqual(doubles.value("key2"), "val2")

        self.assertTrue(doubles.has_key("key3"))
        self.assertEqual(doubles.value("key3"), "val3,val4")
Ejemplo n.º 4
0
    def test_double_strings_from_file(self):
        doubles = DoubleStringCharSplitCollection()
        self.assertIsNotNone(doubles)

        count = doubles.load_from_filename(
            os.path.dirname(__file__) + os.sep + "test_files/doubles.txt")
        self.assertEqual(count, 3)

        self.assertTrue(doubles.has_key("key1"))
        self.assertEqual(doubles.value("key1"), "val1")

        self.assertTrue(doubles.has_key("key2"))
        self.assertEqual(doubles.value("key2"), "val2")

        self.assertTrue(doubles.has_key("key3"))
        self.assertEqual(doubles.value("key3"), "val3,val4")