Пример #1
0
def valid_cases():
    rng = Random(1234)
    for uint_type in UINT_TYPES:
        yield f'uint_{uint_type.byte_len * 8}_last_byte_empty', \
              valid_test_case(lambda: uint_type((2 ** ((uint_type.byte_len - 1) * 8)) - 1))
        for variation in range(5):
            for mode in [
                    RandomizationMode.mode_random, RandomizationMode.mode_zero,
                    RandomizationMode.mode_max
            ]:
                yield f'uint_{uint_type.byte_len * 8}_{mode.to_name()}_{variation}', \
                      valid_test_case(lambda: uint_case_fn(rng, mode, uint_type))
def valid_cases():
    rng = Random(1234)
    for size in [1, 2, 3, 4, 5, 8, 16, 31, 512, 513]:
        for mode in [
                RandomizationMode.mode_random, RandomizationMode.mode_zero,
                RandomizationMode.mode_max
        ]:
            yield f'bitvec_{size}_{mode.to_name()}', valid_test_case(
                lambda: bitvector_case_fn(rng, mode, size))
Пример #3
0
def valid_cases():
    rng = Random(1234)
    for (name, typ) in BASIC_TYPES.items():
        random_modes = [RandomizationMode.mode_zero, RandomizationMode.mode_max]
        if name != 'bool':
            random_modes.append(RandomizationMode.mode_random)
        for length in [1, 2, 3, 4, 5, 8, 16, 31, 512, 513]:
            for mode in random_modes:
                yield f'vec_{name}_{length}_{mode.to_name()}', \
                      valid_test_case(lambda: basic_vector_case_fn(rng, mode, typ, length))
def valid_cases():
    rng = Random(1234)
    for size in [1, 2, 3, 4, 5, 8, 16, 31, 512, 513]:
        for variation in range(5):
            for mode in [
                    RandomizationMode.mode_nil_count,
                    RandomizationMode.mode_max_count,
                    RandomizationMode.mode_random, RandomizationMode.mode_zero,
                    RandomizationMode.mode_max
            ]:
                yield f'bitlist_{size}_{mode.to_name()}_{variation}', \
                      valid_test_case(lambda: bitlist_case_fn(rng, mode, size))
Пример #5
0
def valid_cases():
    rng = Random(1234)
    for (name, (typ, offsets)) in PRESET_CONTAINERS.items():
        for mode in [RandomizationMode.mode_zero, RandomizationMode.mode_max]:
            yield f'{name}_{mode.to_name()}', valid_test_case(
                lambda: container_case_fn(rng, mode, typ))
        random_modes = [
            RandomizationMode.mode_random, RandomizationMode.mode_zero,
            RandomizationMode.mode_max
        ]
        if len(offsets) != 0:
            random_modes.extend([
                RandomizationMode.mode_nil_count,
                RandomizationMode.mode_one_count,
                RandomizationMode.mode_max_count
            ])
        for mode in random_modes:
            for variation in range(10):
                yield f'{name}_{mode.to_name()}_{variation}', \
                      valid_test_case(lambda: container_case_fn(rng, mode, typ))
            for variation in range(3):
                yield f'{name}_{mode.to_name()}_chaos_{variation}', \
                      valid_test_case(lambda: container_case_fn(rng, mode, typ))
Пример #6
0
def valid_cases():
    yield "true", valid_test_case(lambda: boolean(True))
    yield "false", valid_test_case(lambda: boolean(False))