Пример #1
0
def test_GenerateRandPrimeHex():

    #Generating prime decimal numbers with input parameter
    for x in range(10, 100, 10):

        # Generate Random Prime Number of arbitary precision in hex
        primeHex_Value = PyBigNumbers.GenerateRandPrimeHex(x)

        # Verifying the actual value as prime hex number or not
        assert PyBigNumbers.isPrimeHex(primeHex_Value), "Test failed"
Пример #2
0
def test_GenerateRandPrimeHexWithSeed():

    seed = "mhxdmxVS4qJWMyB7jsH9qfpS4qm1KHfY42"

    #Generating prime decimal numbers with input parameter
    for x in range(10, 100, 10):

        # Generate Random Prime Number of arbitary precision in hex with seed (specified as a string)
        primeHex_Value = PyBigNumbers.GenerateRandPrimeHexWithSeed(seed, x)

        # Verifying the actual value as prime hex number or not
        assert PyBigNumbers.isPrimeHex(primeHex_Value), "Test failed"
Пример #3
0
def test_IsPrimeHex(test_data_dir):

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

            decNumber = x.split(",")
            #converting decimal to hex-decimal
            j = int(decNumber[0])
            hex_Value = hex(j).lstrip("0x")

            # Check if hex big number is a prime
            actual_Value = PyBigNumbers.isPrimeHex(str(hex_Value))

            # Verifying the actual value with expected value
            assert actual_Value == int(decNumber[1]), "Test failed"