def test_square(self): test_data = CsvReader('/src/Square.csv').data for row in test_data: self.assertEqual(int(row['Result']), self.calculator.sqr(row['Value 1'])) self.assertEqual(int(row['Result']), self.calculator.result) test_data.clear()
def test_square_method_calculator(self): square_test_data = CsvReader('/src/Unit Test Square.csv').data for row in square_test_data: self.assertEqual(self.calculator.square(row['Value 1']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) square_test_data.clear()
def test_square_root_method_calculator(self): test_data = CsvReader('/src/Square_Root.csv').data for row in test_data: self.assertEqual(round(float(row['Result']), 8), self.calculator.sqrt(row['Value 1'])) self.assertEqual(round(float(row['Result']), 8), round(self.calculator.result, 8)) test_data.clear()
def test_subtract_method_calculator(self): test_data = CsvReader('/src/Subtraction.csv').data for row in test_data: self.assertEqual( int(row['Result']), self.calculator.subtract(row['Value 1'], row['Value 2'])) self.assertEqual(int(row['Result']), self.calculator.result) test_data.clear()
def test_add_method_calculator(self): test_data = CsvReader("src/Addition.csv").data for row in test_data: self.assertEqual( int(row['Result']), self.calculator.add(row['Value 1'], row['Value 2'])) self.assertEqual(int(row['Result']), self.calculator.result) test_data.clear()
def test_multiply_method_calculator(self): test_data = CsvReader('src/Multiplication.csv').data for row in test_data: self.assertEqual( int(row['Result']), self.calculator.multiply(row['Value 1'], row['Value 2'])) self.assertEqual(int(row['Result']), self.calculator.result) test_data.clear()
def test_add_method_calculator(self): add_test_data = CsvReader('/src/Unit Test Addition.csv').data for row in add_test_data: self.assertEqual( self.calculator.add(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) add_test_data.clear()
def test_subtraction(self): subtract_test_data = CsvReader('/src/Unit Test Subtraction.csv').data for row in subtract_test_data: self.assertEqual( self.calculator.subtract(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) subtract_test_data.clear()
def test_divide_method_calculator(self): test_data = CsvReader("src/Division.csv").data for row in test_data: self.assertEqual( float(row['Result']), self.calculator.divide(row['Value 1'], row['Value 2'])) self.assertEqual(float(row['Result']), round(self.calculator.result, 9)) test_data.clear()
def test_square_root_method_calculator(self): square_root_test_data = CsvReader( '/src/Unit Test Square Root.csv').data for row in square_root_test_data: self.assertEqual(self.calculator.squareroot(row['Value 1']), round(float(row['Result']), 10)) self.assertEqual(round(self.calculator.result, 9), round(float(row['Result']), 9)) square_root_test_data.clear()
def test_divide_method_calculator(self): divide_test_data = CsvReader('/src/Unit Test Division.csv').data for row in divide_test_data: self.assertEqual( self.calculator.divide(row['Value 1'], row['Value 2']), (float(row['Result']))) self.assertEqual(round(self.calculator.result, 9), float(row['Result'])) divide_test_data.clear()
def test_multiply_method_calculator(self): multiply_test_data = CsvReader( '/src/Unit Test Multiplication.csv').data for row in multiply_test_data: self.assertEqual( self.calculator.multiply(row['Value 1'], row['Value 2']), int(row['Result'])) self.assertEqual(self.calculator.result, int(row['Result'])) multiply_test_data.clear()