Skip to content

Commit

Permalink
Use assertAlmostEqual for float comparisons
Browse files Browse the repository at this point in the history
Use `assertAlmostEqual` for float comparisons in UJSON tests
  • Loading branch information
adrianeboyd committed Nov 26, 2020
1 parent 5df618b commit 42606ee
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions srsly/tests/ujson/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,25 +752,25 @@ def test_decodeArrayWithBigInt(self):
self.assertRaises(ValueError, ujson.decode, input)

def test_decodeFloatingPointAdditionalTests(self):
self.assertEqual(-1.1234567893, ujson.loads("-1.1234567893"))
self.assertEqual(-1.234567893, ujson.loads("-1.234567893"))
self.assertEqual(-1.34567893, ujson.loads("-1.34567893"))
self.assertEqual(-1.4567893, ujson.loads("-1.4567893"))
self.assertEqual(-1.567893, ujson.loads("-1.567893"))
self.assertEqual(-1.67893, ujson.loads("-1.67893"))
self.assertEqual(-1.7893, ujson.loads("-1.7893"))
self.assertEqual(-1.893, ujson.loads("-1.893"))
self.assertEqual(-1.3, ujson.loads("-1.3"))

self.assertEqual(1.1234567893, ujson.loads("1.1234567893"))
self.assertEqual(1.234567893, ujson.loads("1.234567893"))
self.assertEqual(1.34567893, ujson.loads("1.34567893"))
self.assertEqual(1.4567893, ujson.loads("1.4567893"))
self.assertEqual(1.567893, ujson.loads("1.567893"))
self.assertEqual(1.67893, ujson.loads("1.67893"))
self.assertEqual(1.7893, ujson.loads("1.7893"))
self.assertEqual(1.893, ujson.loads("1.893"))
self.assertEqual(1.3, ujson.loads("1.3"))
self.assertAlmostEqual(-1.1234567893, ujson.loads("-1.1234567893"))
self.assertAlmostEqual(-1.234567893, ujson.loads("-1.234567893"))
self.assertAlmostEqual(-1.34567893, ujson.loads("-1.34567893"))
self.assertAlmostEqual(-1.4567893, ujson.loads("-1.4567893"))
self.assertAlmostEqual(-1.567893, ujson.loads("-1.567893"))
self.assertAlmostEqual(-1.67893, ujson.loads("-1.67893"))
self.assertAlmostEqual(-1.7894, ujson.loads("-1.7894"))
self.assertAlmostEqual(-1.893, ujson.loads("-1.893"))
self.assertAlmostEqual(-1.3, ujson.loads("-1.3"))

self.assertAlmostEqual(1.1234567893, ujson.loads("1.1234567893"))
self.assertAlmostEqual(1.234567893, ujson.loads("1.234567893"))
self.assertAlmostEqual(1.34567893, ujson.loads("1.34567893"))
self.assertAlmostEqual(1.4567893, ujson.loads("1.4567893"))
self.assertAlmostEqual(1.567893, ujson.loads("1.567893"))
self.assertAlmostEqual(1.67893, ujson.loads("1.67893"))
self.assertAlmostEqual(1.7894, ujson.loads("1.7894"))
self.assertAlmostEqual(1.893, ujson.loads("1.893"))
self.assertAlmostEqual(1.3, ujson.loads("1.3"))

def test_ReadBadObjectSyntax(self):
input = '{"age", 44}'
Expand Down

0 comments on commit 42606ee

Please sign in to comment.