def test_SubModHex(test_data_dir): # Reading test data from the file with open(test_data_dir / "testData_SubModHex", "r") as subModHex_txt: for x in subModHex_txt: decNumber = x.split(",") # Subtract modulo of big numbers of arbitrary precision in hex actual_Value = PyBigNumbers.Sub_mod_Hex(decNumber[0], decNumber[1], decNumber[2]) expected_Value = decNumber[3].rstrip("\n") # Verifying the actual value with expected value assert actual_Value.lstrip( "0") == expected_Value.upper(), "Test failed"
def __sub__(self, obj): if (self.isDec): if (self.mod is None): diffVal = PyBigNumbers.subFromDec(self.value, obj.value) else: diffVal = PyBigNumbers.Sub_mod_Dec(self.value, obj.value, self.mod) retVal = diffVal(sumVal, self.mod, self.isDec) return retVal else: if (self.mod is None): diffVal = PyBigNumbers.subFromHex(self.value, obj.value) else: diffVal = PyBigNumbers.Sub_mod_Hex(self.value, obj.value, self.mod) retVal = BigNum(diffVal, self.mod, self.isDec) return retVal