コード例 #1
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.calculator = Calculator()

    def test_calculator_return_sum(self):
        result = self.calculator.Sum(1, 2)
        self.assertEqual(3, result)

    def test_calculator_return_difference(self):
        result = self.calculator.Difference(2, 3)
        self.assertEqual(float(-1), float(result))

    def test_calculator_return_product(self):
        result = self.calculator.Product(2, 2)
        self.assertEqual(4, result)

    def test_calculator_return_quotient(self):
        result = self.calculator.Quotient(2, 4)
        self.assertEqual(0.5, result)

    def test_calculator_return_root(self):
        result = self.calculator.Root(169, 2)
        self.assertEqual(13, result)

    def test_calculator_return_power(self):
        result = self.calculator.Power(13, 2)
        self.assertEqual(169, result)

    def test_calculator_return_log(self):
        result = self.calculator.Logarithm(10, 1)
        self.assertEqual(0, result)

    #other defs
    def test_calculator_access_difference_result(self):
        self.calculator.Difference(3, 2)
        self.assertEqual(float(1), self.calculator.Result)

    def test_calculator_access_sum_result(self):
        self.calculator.Sum(5, 4)
        self.assertEqual(9, self.calculator.Result)

    def test_calculator_access_product_result(self):
        self.calculator.Product(3, 2)
        self.assertEqual(6, self.calculator.Result)

    def test_calculator_access_quotient_result(self):
        self.calculator.Quotient(8, 4)
        self.assertEqual(2, self.calculator.Result)

    def test_multiple_calculators(self):
        calculator1 = Calculator()
        calculator2 = Calculator()

        self.calculator.Sum(calculator1.Sum(1, 2),
                            calculator2.Difference(3, 4))
        self.assertEqual(2, self.calculator.Result)
コード例 #2
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.calculator = Calculator()

    def test_instantiate_calculator(self):
        self.assertIsInstance(self.calculator, Calculator)

    def test_calculator_return_sum(self):
        result = self.calculator.Sum(1, 2)
        self.assertEqual(3, result)

    def test_calculator_return_difference(self):
        result = self.calculator.Difference(1, 2)
        self.assertEqual(-1, result)

    def test_calculator_access_difference_result(self):
        self.calculator.Difference(1, 2)
        self.assertEqual(-1, self.calculator.Result)

    def test_calculator_access_sum_result(self):
        self.calculator.Sum(1, 2)
        self.assertEqual(3, self.calculator.Result)

    def test_multiple_calculators(self):
        calculator1 = Calculator()
        calculator2 = Calculator()

        self.calculator.Sum(calculator1.Sum(1, 2),
                            calculator2.Difference(3, 4))

        self.assertEqual(2, self.calculator.Result)

    def test_calculator_multiply(self):
        result = self.calculator.Multiply(2, 3)
        self.assertEqual(6, result)

    def test_calculator_divide(self):
        result = self.calculator.Divide(6, 2)
        self.assertEqual(3, result)

    def test_calculator_root(self):
        result = self.calculator.Root(169, 2)
        self.assertEqual(13, result)

    def test_calculator_power(self):
        result = self.calculator.Power(13, 2)
        self.assertEqual(169, result)

    def test_calculator_log(self):
        result = self.calculator.Logarithm(10, 1)
        self.assertEqual(0, result)
コード例 #3
0
ファイル: test_Calculator.py プロジェクト: Darsh374/basicCalc
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.calculator = Calculator()

    def test_instantiate_calculator(self):
        self.assertIsInstance(self.calculator, Calculator)

    def test_calculator_return_sum(self):
        result = self.calculator.Sum(1, 2)
        self.assertEqual(3, result)

    def test_calculator_access_sum_result(self):
        self.calculator.Sum(1, 2)
        self.assertEqual(3, self.calculator.Result)

    def test_calculator_return_difference(self):
        result = self.calculator.Difference(1, 2)
        self.assertEquals(-1, result)

    def test_calculator_access_difference_result(self):
        self.calculator.Difference(1, 2)
        self.assertEqual(-1, self.calculator.Result)

    def test_multiple_calculators(self):
        calculator1 = Calculator()
        calculator2 = Calculator()
        self.calculator.Sum(calculator1.Sum(1, 2),
                            calculator2.Difference(3, 4))
        self.assertEqual(2, self.calculator.Result)

    def test_calculator_return_product(self):
        self.calculator.Product(1, 2)
        self.assertEquals(2, self.calculator.Result)

    def test_calculator_return_quotient(self):
        self.calculator.Quotient(1, 2)
        self.assertEqual(0.5, self.calculator.Result)

    def test_calculator_return_root(self):
        self.calculator.Root(2, 4)
        self.assertEquals(2, self.calculator.Result)

    def test_calculator_return_power(self):
        self.calculator.Power(2, 2)
        self.assertEquals(4, self.calculator.Result)

    def test_calculator_return_logarithm(self):
        self.calculator.Logarithm(2, 8)
        self.assertEqual(3, self.calculator.Result)
コード例 #4
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.calculator = Calculator()

    def test_instantiate_calculator(self):
        self.assertIsInstance(self.calculator, Calculator)

    def test_calculator_return_sum(self):
        result = self.calculator.Sum(1, 2)
        self.assertEqual(3, result)

    def test_calculator_access_sum_result(self):
        self.calculator.Sum(1, 2)
        self.assertEqual(3, self.calculator.Result)

    def test_calculator_return_difference(self):
        result = self.calculator.Difference(1, 2)
        self.assertEqual(-1, result)

    def test_calculator_access_difference_result(self):
        self.calculator.Difference(1, 2)
        self.assertEqual(-1, self.calculator.Result)

    def test_calculator_return_product(self):
        result = self.calculator.Multiplication(1, 2)
        self.assertEqual(2, result)

    def test_calculator_access_product_result(self):
        self.calculator.Multiplication(1, 2)
        self.assertEqual(2, self.calculator.Result)

    def test_calculator_divide(self):
        result = self.calculator.Divide(10, 5)
        self.assertEqual(2, result)

    def test_calculator_root(self):
        result = self.calculator.Root(9)
        self.assertEqual(3, result)

    def test_calculator_power(self):
        result = self.calculator.Power(4, 2)
        self.assertEqual(16, result)

    def test_calculator_log(self):
        result = self.calculator.Logarithm(10, 1)
        self.assertEqual(0, result)
コード例 #5
0
 def test_calculator_access_logarithm(self):
     calculator = Calculator()
     calculator.Logarithm(729, 3)
     self.assertEqual(6, calculator.Result)
コード例 #6
0
 def test_calculator_logarithm(self):
     calculator = Calculator()
     result = calculator.Logarithm(729, 3)
     self.assertEqual(6, result)