예제 #1
0
 def test_int_large_strings(self):
     x = "1"
     for i in range(100):
         x += x
         i += 1
     frac = Rational(x, 3)
     self.assertEqual(frac.__str__(), x+"/3")
예제 #2
0
 def test_int_normal_2(self):
     frac = Rational(1, 1)
     self.assertEqual(frac.__str__(), "1/1")
예제 #3
0
 def test_int_normal(self):
     frac = Rational(3, 4)
     self.assertEqual(frac.__str__(), "3/4")
예제 #4
0
 def test_str_no_objects(self):
     frac = Rational(object, object)
     with self.assertRaises(Exception, msg="No, bad program, get off the couch"):
         frac.__str__()
예제 #5
0
 def test_str_strings_to_ints(self):
     frac = Rational("34", "22")
     self.assertEqual(frac.__str__(), "17/11")
예제 #6
0
 def test_str_no_inproper_strings(self):
     frac = Rational("yes", "no")
     with self.assertRaises(Exception, msg="No, bad program, get off the couch"):
         frac.__str__()
예제 #7
0
 def test_int_small_incretion(self):
     frac = Rational(.01/.0001)
     self.assertEqual(frac.__str__(), "100/1")
예제 #8
0
 def test_int_large_reduction(self):
     frac = Rational(-999, 999)
     self.assertEqual(frac.__str__(), "-1/1")