| 1 |
from . import gen_fuzz_strings |
| 2 |
|
| 3 |
|
| 4 |
def describe_gen_fuzz_strings(): |
| 5 |
def always_provide_empty_string(): |
| 6 |
assert list(gen_fuzz_strings(allowed_chars="", max_length=0)) == [""] |
| 7 |
assert list(gen_fuzz_strings(allowed_chars="", max_length=1)) == [""] |
| 8 |
assert list(gen_fuzz_strings(allowed_chars="a", max_length=0)) == [""] |
| 9 |
|
| 10 |
def generate_strings_with_single_character(): |
| 11 |
assert list(gen_fuzz_strings(allowed_chars="a", max_length=1)) == ["", "a"] |
| 12 |
assert list(gen_fuzz_strings(allowed_chars="abc", max_length=1)) == [ |
| 13 |
"", |
| 14 |
"a", |
| 15 |
"b", |
| 16 |
"c", |
| 17 |
] |
| 18 |
|
| 19 |
def generate_strings_with_multiple_character(): |
| 20 |
assert list(gen_fuzz_strings(allowed_chars="a", max_length=2)) == [ |
| 21 |
"", |
| 22 |
"a", |
| 23 |
"aa", |
| 24 |
] |
| 25 |
|
| 26 |
assert list(gen_fuzz_strings(allowed_chars="abc", max_length=2)) == [ |
| 27 |
"", |
| 28 |
"a", |
| 29 |
"b", |
| 30 |
"c", |
| 31 |
"aa", |
| 32 |
"ab", |
| 33 |
"ac", |
| 34 |
"ba", |
| 35 |
"bb", |
| 36 |
"bc", |
| 37 |
"ca", |
| 38 |
"cb", |
| 39 |
"cc", |
| 40 |
] |
| 41 |
|
| 42 |
def generate_strings_longer_than_possible_number_of_characters(): |
| 43 |
assert list(gen_fuzz_strings(allowed_chars="ab", max_length=3)) == [ |
| 44 |
"", |
| 45 |
"a", |
| 46 |
"b", |
| 47 |
"aa", |
| 48 |
"ab", |
| 49 |
"ba", |
| 50 |
"bb", |
| 51 |
"aaa", |
| 52 |
"aab", |
| 53 |
"aba", |
| 54 |
"abb", |
| 55 |
"baa", |
| 56 |
"bab", |
| 57 |
"bba", |
| 58 |
"bbb", |
| 59 |
] |