예제 #1
0
 def test_5_over_minus2_equals_minus5_over_2(self):
     self.assertEqual(Fraction(-5, 2), Fraction(5, -2))
예제 #2
0
 def test_4_over_6_equals_2_over_3(self):
     self.assertEqual(Fraction(2, 3), Fraction(4, 6))
예제 #3
0
 def test_cannot_create_a_fraction_with_denominator_zero(self):
     with self.assertRaises(DenominatorIsZero):
         _ = Fraction(8, 0)
예제 #4
0
 def test_one_fifth_plus_one_sixth_equals_eleven_on_thirty(self):
     self.assertEqual(Fraction(11, 30), add(Fraction(1, 5), Fraction(1, 6)))
예제 #5
0
 def test_one_fourth_plus_one_fourth_equals_one_half(self):
     self.assertEqual(Fraction(1, 2), add(Fraction(1, 4), Fraction(1, 4)))
예제 #6
0
 def test_fraction_representation(self):
     self.assertEqual("15/8", str(Fraction(15, 8)))
예제 #7
0
 def test_two_fifths_plus_two_equals_thriteen_fifths(self):
     self.assertEqual(add(Fraction(2, 5), 2), Fraction(12, 5))
예제 #8
0
 def test_one_plus_one_half_equals_two_halves(self):
     self.assertEqual(add(1, Fraction(1, 2)), Fraction(3, 2))
예제 #9
0
 def test_different_fractions_are_not_equal(self):
     self.assertNotEqual(Fraction(3, 2), Fraction(4, 5))
예제 #10
0
 def test_same_fractions_are_equal(self):
     self.assertEqual(Fraction(1, 2), Fraction(1, 2))