Exemple #1
0
def test_AddFromDecWithBigNumApi(test_data_dir):

    # Reading test data from the file
    with open(test_data_dir / "testData_AddDec", "r") as addDec_txt:
        for x in addDec_txt:

            decNumber = x.split()
            # Add too big numbers of arbitrary precision in dec
            actual_Value = PyBigNumbers.addFromDec(decNumber[0], decNumber[1])

            #Verifying the actual value with expected value
            assert actual_Value == decNumber[2], "Test failed"
Exemple #2
0
    def __add__(self, obj):
        if (self.isDec):
            if (self.mod is None):
                sumVal = PyBigNumbers.addFromDec(self.value, obj.value)
            else:
                #check for self.mod == obj.mod
                sumVal = PyBigNumbers.Add_mod_Dec(self.value, obj.value,
                                                  self.mod)
            retVal = BigNum(sumVal, self.mod, self.isDec)
            return retVal
        else:
            if (self.mod is None):
                sumVal = PyBigNumbers.addFromHex(self.value, obj.value)
            else:
                #check for self.mod == obj.mod
                sumVal = PyBigNumbers.Add_mod_Hex(self.value, obj.value,
                                                  self.mod)

            retVal = BigNum(sumVal, self.mod, self.isDec)
            return retVal