MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/577782_Lattice_Multiplication/recipe-577782.py:53–68  ·  view source on GitHub ↗

verifying lattice calculation

()

Source from the content-addressed store, hash-verified

51 return digits
52
53def test():
54 """ verifying lattice calculation """
55 stringA = "1234567890"
56 stringB = "1234567890"
57
58 # python calculates:
59 resultA = "%s" % (int(stringA) * int(stringB))
60 print("%s x %s = %s" % (stringA, stringB, resultA))
61
62 # string digits as input:
63 resultB = lattice(stringA, stringB)
64 assert resultB == list(map(int, resultA))
65
66 # list of integer digits as input:
67 resultC = lattice(list(map(int, stringA)), list(map(int, stringB)))
68 assert resultC == list(map(int, resultA))
69
70if __name__ == "__main__":
71 test()

Callers 1

recipe-577782.pyFile · 0.70

Calls 4

printFunction · 0.85
latticeFunction · 0.85
listClass · 0.85
mapFunction · 0.85

Tested by

no test coverage detected