def test_float_from_str(self): a = self.schema['float'] v = Sos.Value(a) v.from_str('1234.50000') self.assertEqual(v.value, 1234.5) v.from_str('1.2345e3') self.assertEqual(v.value, 1234.5) v.from_str('1234.4e-3') self.assertEqual(v.value, 1.2344000339508057)
def test_double_from_str(self): a = self.schema['double'] v = Sos.Value(a) v.from_str('1234.50000') self.assertEqual(v.value, 1234.5) v.from_str('1.2345e3') self.assertEqual(v.value, 1234.5) v.from_str('1234.4e-3') self.assertEqual(v.value, 1.2344)
def test_timestamp_to_str(self): a = self.schema['timestamp'] v = Sos.Value(a) v.value = (1511885835, 123450) s = v.to_str() self.assertEqual(s, '1511885835.123450') v.value = (1511885835, 12345) s = v.to_str() self.assertEqual(s, '1511885835.012345')
def test_timestamp_from_str(self): a = self.schema['timestamp'] v = Sos.Value(a) v.from_str('1511885835.012345') self.assertEqual(v.value, (1511885835, 12345)) v.from_str('1511885835.12345') self.assertEqual(v.value, (1511885835, 12345)) v.from_str('1511885835.123450') self.assertEqual(v.value, (1511885835, 123450))
def test_uint16_from_str(self): a = self.schema['uint16'] v = Sos.Value(a) # octal v.from_str('01234') self.assertEqual(v.value, 668) # decimal v.from_str('1234') self.assertEqual(v.value, 1234) # hex v.from_str('0x1234') self.assertEqual(v.value, 4660)
def test_int64_from_str(self): a = self.schema['int64'] v = Sos.Value(a) # octal v.from_str('-0123456789') self.assertEqual(v.value, -342391) # decimal v.from_str('-123456789') self.assertEqual(v.value, -123456789) # hex v.from_str('-0x123456789') self.assertEqual(v.value, -4886718345)
def test_uint32_from_str(self): a = self.schema['uint32'] v = Sos.Value(a) # octal v.from_str('012345678') self.assertEqual(v.value, 342391) # decimal v.from_str('12345678') self.assertEqual(v.value, 12345678) # hex v.from_str('0x12345678') self.assertEqual(v.value, 305419896)
def test_int16_from_str(self): a = self.schema['int16'] v = Sos.Value(a) # octal v.from_str('-01234') self.assertEqual(v.value, -668) # decimal v.from_str('-1234') self.assertEqual(v.value, -1234) # hex v.from_str('-0x1234') self.assertEqual(v.value, -4660)
def chk_array_strlen(self, a, av): v = Sos.Value(a) v.value = av s = str(v) self.assertGreaterEqual(v.strlen(), len(s))
def test_timestamp_strlen(self): a = self.schema['timestamp'] v = Sos.Value(a) v.value = (1511885835, 12345) self.assertGreaterEqual(v.strlen(), 6)
def test_double_to_str(self): a = self.schema['double'] v = Sos.Value(a) v.value = 1234.5 s = v.to_str() self.assertEqual(s, '1234.50000')
def test_float_to_str(self): a = self.schema['float'] v = Sos.Value(a) v.value = 1234.5 s = v.to_str() self.assertEqual(s, '1234.50000')
def test_float_strlen(self): a = self.schema['float'] v = Sos.Value(a) v.value = 1234.5 self.assertGreaterEqual(v.strlen(), 6)
def test_int64_strlen(self): a = self.schema['int64'] v = Sos.Value(a) v.value = -123456789 self.assertEqual(v.strlen(), 10)
def test_uint32_strlen(self): a = self.schema['uint32'] v = Sos.Value(a) v.value = 12345678 self.assertEqual(v.strlen(), 8)
def chk_array_to_str(self, a, av, ev): v = Sos.Value(a) v.value = av s = str(v) self.assertEqual(s, ev)
def test_int16_strlen(self): a = self.schema['int16'] v = Sos.Value(a) v.value = -1234 self.assertEqual(v.strlen(), 5)
def test_double_strlen(self): a = self.schema['double'] v = Sos.Value(a) v.value = 1234.5 self.assertGreaterEqual(v.strlen(), 6)