def testRight(self): """isRight should return True with right triangles [a9dd9066a3c456dd]""" # I use pythagorean triples here, since each side is an integer # given 2 ints m, n # a = 2mn : b = m**2 - n**2 : c = m**2 + n**2 random.seed(); for i in range(10): j = random.randint(2,10); k = random.randint(j+1,20); t = [2 * j * k, k**2 - j**2, k**2 + j**2] result = triangle.isNotTriangle(t); self.assertFalse(result); result = triangle.isRight(t); self.assertTrue(result);
def testNotRight(self): """isRight should return False with not right triangles [346561df2a581258]""" # I'm going to use the pythagorean theorum to reject right triangles... random.seed(); for i in range(10): j = k = l = 0; while(j**2 + k**2 == l**2 or k**2 + l**2 == j**2 or l**2 + j**2 == k**2 or j + k <= l or k + l <= j or l + j <= k): j = random.randint(2,100); k = random.randint(2,100); l = random.randint(2,100); t = [j, k, l]; result = triangle.isNotTriangle(t); self.assertFalse(result); result = triangle.isRight(t); self.assertFalse(result);