def test_dividing_different_units(self, firstValue, secondValue, firstUnit, secondUnit): value_a = TypedValue(firstValue, firstUnit) value_b = TypedValue(secondValue, secondUnit) result = value_a.divide(value_b) assert_that(result.unit, equal_to(firstUnit + "/" + secondUnit)) assert_that(result.value, equal_to(firstValue / secondValue))
def test_multiplying_same_unit_different_powers_totalling_1(self, firstValue, secondValue, unit, firstPower, secondPower): value_a = TypedValue(firstValue, "%s^%s" % (unit, firstPower)) value_b = TypedValue(secondValue, "%s^%s" % (unit, secondPower)) result = value_a.multiply(value_b) assert_that(result.unit, equal_to(unit)) assert_that(result.value, equal_to(firstValue * secondValue))
def test_multiplying_same_unit(self, firstValue, secondValue, unit): value_a = TypedValue(firstValue, unit) value_b = TypedValue(secondValue, unit) result = value_a.multiply(value_b) assert_that(result.unit, equal_to(unit + "^2")) assert_that(result.value, equal_to(firstValue * secondValue))
def test_multiplying_different_units(self, firstValue, secondValue, firstUnit, secondUnit): value_a = TypedValue(firstValue, firstUnit) value_b = TypedValue(secondValue, secondUnit) result = value_a.multiply(value_b) assert_that(result.unit, equal_to(firstUnit + secondUnit)) assert_that(result.value, equal_to(firstValue*secondValue))
def test_adding_same_unit(self, firstValue, secondValue, unit): value_a = TypedValue(firstValue, unit) value_b = TypedValue(secondValue, unit) result = value_a.add(value_b) assert_that(result.unit, equal_to(unit)) assert_that(result.value, equal_to(firstValue+secondValue))
def test_dividing_by_zero(self, firstValue, secondValue, firstUnit, secondUnit): value_a = TypedValue(firstValue, firstUnit) value_b = TypedValue(secondValue, secondUnit) try: value_a.divide(value_b) except ZeroDivisionError: pass else: self.fail("expected a ZeroDivisionError")
def test_adding_different_units(self, firstValue, secondValue, firstUnit, secondUnit): value_a = TypedValue(firstValue, firstUnit) value_b = TypedValue(secondValue, secondUnit) try: value_a.add(value_b) except ValueError: pass else: self.fail("expected a ValueError")