Example #1
0
    def test_remove(self):
        sv = StructValue(self._mt1)
        self.assertEqual(True, sv.isEmpty())
        self.assertEqual(0, sv.size())
        self.assertEqual(None, sv.get(self._mf1))

        sv.remove(self._mf1)
        self.assertEqual(True, sv.isEmpty())
        self.assertEqual(0, sv.size())
        self.assertEqual(None, sv.get(self._mf1))

        sv.put(self._mf1, True)
        self.assertEqual(False, sv.isEmpty())
        self.assertEqual(1, sv.size())
        self.assertEqual(True, sv.get(self._mf1))

        sv.remove(self._mf1)
        self.assertEqual(True, sv.isEmpty())
        self.assertEqual(0, sv.size())
        self.assertEqual(None, sv.get(self._mf1))

        sv.remove(self._mf1)
        self.assertEqual(True, sv.isEmpty())
        self.assertEqual(0, sv.size())
        self.assertEqual(None, sv.get(self._mf1))
Example #2
0
 def test_put2(self):
     sv = StructValue(self._mt1)
     sv.put(self._mf1, None)
     sv.put(self._mf2, None)
     sv.put(self._mf3, None)
     sv.put(self._mf4, None)
     sv.put(self._mf5, None)
     sv.put(self._mf6, None)
     self.assertEqual(0, sv.size())
Example #3
0
    def test_toString(self):

        sv = StructValue(self._mt1)
        self.assertEquals("one(785945377): {}", repr(sv))

        sv = StructValue(self._mt2)
        self.assertEquals("two(827843303): {}", repr(sv))

        sv = StructValue(self._mt1)
        sv.put(self._mf1, True)
        self.assertEquals("one(785945377): {f1(1512176592): True}", repr(sv))

        sv = StructValue(self._mt1)
        sv.put(self._mf3, 23)
        self.assertEquals("one(785945377): {f3(1512176594): 23}", repr(sv))

        sv = StructValue(self._mt1)
        sv.put(self._mf1, False)
        sv.put(self._mf3, 74)
        self.assertEqual(True, "one(785945377): {f1(1512176592): False, f3(1512176594): 74}" == repr(sv) or "one(785945377): {f3(1512176594): 74, f1(1512176592): False}" == repr(sv) )
Example #4
0
 def test_importCustomValue_Etch_RuntimeException_msg(self):
     sv = StructValue(self.vf.getType("_Etch_RuntimeException"))
     sv.put(DefaultValueFactory._mf_msg, "foo")
     e = self.vf.importCustomValue(sv)
     self.assertNotEquals(None, e)
     self.assertEquals("foo", e.msg)
Example #5
0
 def test_put12(self):
     sv = StructValue(self._mt1)
     sv.put(self._mf2, None)
Example #6
0
 def test_put3(self):
     sv = StructValue(self._mt1)
     sv.put(self._mf1, False)
     sv.put(self._mf2, [True, False])
     sv.put(self._mf3, 1)
     sv.put(self._mf4, [1,2])
     sv.put(self._mf5, "a")
     sv.put(self._mf6, ["a", "b"])
     self.assertEqual(6, sv.size())
     
     # Now remove them
     sv.put(self._mf1, None)
     sv.put(self._mf2, None)
     sv.put(self._mf3, None)
     sv.put(self._mf4, None)
     sv.put(self._mf5, None)
     sv.put(self._mf6, None)
     self.assertEqual(0, sv.size())
Example #7
0
 def test_put1(self):
     sv = StructValue(self._mt1)
     sv.put(self._mf1, False)
     sv.put(self._mf2, [True, False])
     sv.put(self._mf3, 1)
     sv.put(self._mf4, [1,2])
     sv.put(self._mf5, "a")
     sv.put(self._mf6, ["a", "b"])
     self.assertEqual(6, sv.size())