Example #1
0
def test_reference_counter(int_: AlternativeInt) -> None:
    int_refcount_before = sys.getrefcount(int_)

    result = int_.bit_length()

    int_refcount_after = sys.getrefcount(int_)
    assert int_refcount_after == int_refcount_before
Example #2
0
def test_idempotence(ints_pair: AlternativeNativeIntsPair) -> None:
    alternative_int, native_int = ints_pair

    alternative, native = (AlternativeInt(alternative_int),
                           NativeInt(native_int))

    assert are_alternative_native_ints_equal(alternative, native)
Example #3
0
def test_no_argument() -> None:
    alternative, native = AlternativeInt(), NativeInt()

    assert are_alternative_native_ints_equal(alternative, native)
Example #4
0
def test_string_with_base(string_with_base: Tuple[str, int]) -> None:
    string, base = string_with_base

    alternative, native = AlternativeInt(string, base), NativeInt(string, base)

    assert are_alternative_native_ints_equal(alternative, native)
Example #5
0
def test_decimal_string(string: str) -> None:
    alternative, native = AlternativeInt(string), NativeInt(string)

    assert are_alternative_native_ints_equal(alternative, native)
Example #6
0
def test_basic(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert isinstance(result, AlternativeInt)
Example #7
0
def test_product(first: AlternativeInt, second: AlternativeInt) -> None:
    result = (first * second).bit_length()

    assert result <= first.bit_length() + second.bit_length()
Example #8
0
def test_evenness(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert result == (-int_).bit_length()
Example #9
0
def test_positive_definiteness(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert equivalence(not result, not int_)
def test_invalid_strings(string: str, base: int) -> None:
    with pytest.raises(ValueError):
        AlternativeInt(string, base)
def test_no_argument() -> None:
    result = AlternativeInt()

    assert isinstance(result, AlternativeInt)
    assert not result
def test_string_with_base(string_with_base: Tuple[str, int]) -> None:
    string, base = string_with_base

    result = AlternativeInt(string, base)

    assert isinstance(result, AlternativeInt)
def test_decimal_string(string: str) -> None:
    result = AlternativeInt(string)

    assert isinstance(result, AlternativeInt)