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
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)
def test_no_argument() -> None: alternative, native = AlternativeInt(), NativeInt() assert are_alternative_native_ints_equal(alternative, native)
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)
def test_decimal_string(string: str) -> None: alternative, native = AlternativeInt(string), NativeInt(string) assert are_alternative_native_ints_equal(alternative, native)
def test_basic(int_: AlternativeInt) -> None: result = int_.bit_length() assert isinstance(result, AlternativeInt)
def test_product(first: AlternativeInt, second: AlternativeInt) -> None: result = (first * second).bit_length() assert result <= first.bit_length() + second.bit_length()
def test_evenness(int_: AlternativeInt) -> None: result = int_.bit_length() assert result == (-int_).bit_length()
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)