Ejemplo n.º 1
0
 def test_3(self):
     for x, x_round in [(0, 0), (-1, -1), (1, 1), (109234, 109000),
             (-120934, -121000), (1.19230413, 1.19), (-19203.01924, -19200),
             (1.109324E100, 1.11E100), (-4.0E100, -4E100)]:
         guess = _sigfig_round(x, 3)
         self.assertEqual(guess, x_round)
         self.assertEqual(type(guess), type(0.0))
Ejemplo n.º 2
0
 def test_3(self):
     for x, x_round in [(0, 0), (-1, -1), (1, 1), (109234, 109000),
                        (-120934, -121000), (1.19230413, 1.19),
                        (-19203.01924, -19200), (1.109324E100, 1.11E100),
                        (-4.0E100, -4E100)]:
         guess = _sigfig_round(x, 3)
         self.assertEqual(guess, x_round)
         self.assertEqual(type(guess), type(0.0))
Ejemplo n.º 3
0
 def test_100(self):
     for x in [
             0, -1, 1, 109234, -120934, 1.19230413, -19203.01924,
             1.109324E100, -4.3E100
     ]:
         guess = _sigfig_round(x, 100)
         self.assertEqual(guess, x)
         self.assertEqual(type(guess), type(0.0))
Ejemplo n.º 4
0
 def test_0(self):
     for x in [0, -1, 1, 109234, -120934, 1.19230413, -19203.01924,
             1.109324E100, -4.3E100]:
         self.assertRaises(ValueError, lambda: _sigfig_round(x, 0))
Ejemplo n.º 5
0
 def test_100(self):
     for x in [0, -1, 1, 109234, -120934, 1.19230413, -19203.01924,
             1.109324E100, -4.3E100]:
         guess = _sigfig_round(x, 100)
         self.assertEqual(guess, x)
         self.assertEqual(type(guess), type(0.0))
Ejemplo n.º 6
0
 def test_0(self):
     for x in [
             0, -1, 1, 109234, -120934, 1.19230413, -19203.01924,
             1.109324E100, -4.3E100
     ]:
         self.assertRaises(ValueError, lambda: _sigfig_round(x, 0))