test suite for add()
@@ -123,6 +123,56 @@ class TestLiteral(unittest.TestCase):
random.shuffle(l2)
self.assertListEqual(l1, sorted(l2))
+ def test_literal_add(self):
+ a = Literal(1)
+ b01 = Literal(1)
+ b02 = Literal(-1)
+ b03 = Literal(1.1)
+ b04 = Literal(-1.1)
+ b05 = Literal("1", datatype=XSD.integer)
+ b06 = Literal("-1", datatype=XSD.integer)
+ b07 = Literal("+1", datatype=XSD.integer)
+ b08 = Literal("1.1", datatype=XSD.float)
+ b09 = Literal("-1.1", datatype=XSD.float)
+ b10 = Literal("1.1", datatype=XSD.decimal)
+ b11 = Literal("-1.1", datatype=XSD.decimal)
+ b12 = Literal("1.1", datatype=XSD.double)
+ b13 = Literal("-1.1", datatype=XSD.double)
+ b14 = Literal(u'1', datatype=XSD.integer)
+ b15 = Literal(u'-1', datatype=XSD.integer)
+ b16 = 1
+ b17 = 1.1
+ b18 = "1"
+ b19 = "1.1"
+ b20 = Literal("1", datatype=XSD.string)
+ b21 = Literal("1.1", datatype=XSD.string)
+ b22 = Literal(u'1', datatype=XSD.string)
+ b23 = None
+
+ self.assertEqual(a + b01, Literal(2))
+ self.assertEqual(a + b02, Literal(0))
+ self.assertEqual(a + b03, Literal(2.1))
+ # self.assertEqual(a + b04, Literal(-0.1)) # -0.10000000000000009
+ self.assertEqual(a + b05, Literal(2))
+ self.assertEqual(a + b06, Literal(0))
+ self.assertEqual(a + b07, Literal(2))
+ self.assertEqual(a + b08, Literal(2.1))
+ # self.assertEqual(a + b09, Literal(-0.1))
+ # self.assertEqual(a + b10, Literal(2.1)) # 2.1000000000
+ # self.assertEqual(a + b11, Literal(-0.1))
+ self.assertEqual(a + b12, Literal(2.1))
+ # self.assertEqual(a + b13, Literal(-0.1))
+ self.assertEqual(a + b14, Literal(2))
+ self.assertEqual(a + b15, Literal(0))
+ self.assertEqual(a + b16, Literal(2))
+ self.assertEqual(a + b17, Literal(2.1))
+ # self.assertEqual(a + b18, Literal(11))
+ # self.assertEqual(a + b19, Literal(11.1))
+ # self.assertEqual(a + b20, Literal(11))
+ # self.assertEqual(a + b21, Literal(11.1))
+ # self.assertEqual(a + b22, Literal(11))
+ # self.assertEqual(a + b23, Literal(1))
+
class TestValidityFunctions(unittest.TestCase):
