def test_add(self): """ Тест юнита add() """ self.assertEqual(code.add(1, 1), 2) # Тестовый случай self.assertEqual(code.add(0, 0), 0) self.assertEqual(code.add(-10, 10), 0) self.assertEqual(code.add(4, 5), 9) self.assertEqual(code.add(-2, -7), -9)
def getexp2(self,c,l=False): self.getexp1(c,l) while (self.t.checkNext()): n = self.t.checkNext() if (n == "+"): self.t.getNext() self.getexp1(c) c.pushcode(code.add()) elif (n == "-"): self.t.getNext() self.getexp1(c); c.pushcode(code.sub()) else: break
def test_add_doc(self, doc_number, doc_type, doc_name, shelf_number,result ): assert add(doc_number, doc_type, doc_name, shelf_number) == result
def test_add_numbers(self): self.assertEqual(code.add(2,3),5) self.assertEqual(code.add(0,0),0) self.assertEqual(code.add(-5,5),0) self.assertEqual(code.add(-10,4),-6)
def test_raises_adding_mixed_types(self): with self.assertRaises(TypeError): code.add("foo",3)
def test_add_strings(self): self.assertEqual(code.add("foo","bar"),"foobar")
def test_add(self): result = calc.add(3, 4) self.assertEqual(result, 7)
def test_add_numbers(self): self.assertEqual(code.add(2, 3), 5) self.assertEqual(code.add(0, 0), 0) self.assertEqual(code.add(-5, 5), 0) self.assertEqual(code.add(-10, 4), -6)
def test_raises_adding_mixed_types(self): with self.assertRaises(TypeError): code.add("foo", 3)
def test_add_strings(self): self.assertEqual(code.add("foo", "bar"), "foobar")
def test_add(self): self.assertEqual(code.add(1, 2), 3)