tests.test_nats module
Test for integer conversions.
-
class tests.test_nats.NatsTestCase(methodName='runTest')
Bases: unittest.case.TestCase
Tests for ints.
-
testCarryIn(strategy=HypothesisProvided(value=integers(min_value=2, max_value=1024).flatmap(lambda n: strategies.tuples(build_nat(n, max_len), strategies.just(n) )).flatmap(the_func)))
Test carry_in.
| Parameters: | strategy – the strategy (tuple of value, carry, base) |
-
testExceptions()
Test throwing exception.
-
testFromInt(value=HypothesisProvided(value=integers(min_value=0)), to_base=HypothesisProvided(value=integers(min_value=2)))
convert_to_int(convert_from_int(value, to_base), 10) == value
No leading zeros in convert_from_int(value, to_base)
-
testFromOther(nat=HypothesisProvided(value=integers(min_value=2, max_value=1024).flatmap(lambda n: strategies.tuples(build_nat(n, max_len), strategies.just(n) ))), to_base=HypothesisProvided(value=integers(min_value=2, max_value=64)))
Test roundtrip from number in arbitrary base.
-
testRoundTo(nat=HypothesisProvided(value=integers(min_value=2, max_value=1024).flatmap(lambda n: strategies.tuples(build_nat(n, max_len), strategies.just(n) ))), precision=HypothesisProvided(value=just(None) | integers(min_value=-128, max_value=64)), method=HypothesisProvided(value=sampled_from((_RoundingMethod(Round down.), _RoundingMethod(Round to nearest, down on a tie.), _RoundingMethod(Round to nearest, up on a tie.), _RoundingMethod(Round to nearest, to zero on a tie.), _RoundingMethod(Round to zero.), _RoundingMethod(Round up.)))))
Test proper functioning of Nats.roundTo().