File: test_gen_fuzz_strings.py

package info (click to toggle)
graphql-core 3.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,452 kB
  • sloc: python: 46,922; makefile: 26; sh: 13
file content (59 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from . import gen_fuzz_strings


def describe_gen_fuzz_strings():
    def always_provide_empty_string():
        assert list(gen_fuzz_strings(allowed_chars="", max_length=0)) == [""]
        assert list(gen_fuzz_strings(allowed_chars="", max_length=1)) == [""]
        assert list(gen_fuzz_strings(allowed_chars="a", max_length=0)) == [""]

    def generate_strings_with_single_character():
        assert list(gen_fuzz_strings(allowed_chars="a", max_length=1)) == ["", "a"]
        assert list(gen_fuzz_strings(allowed_chars="abc", max_length=1)) == [
            "",
            "a",
            "b",
            "c",
        ]

    def generate_strings_with_multiple_character():
        assert list(gen_fuzz_strings(allowed_chars="a", max_length=2)) == [
            "",
            "a",
            "aa",
        ]

        assert list(gen_fuzz_strings(allowed_chars="abc", max_length=2)) == [
            "",
            "a",
            "b",
            "c",
            "aa",
            "ab",
            "ac",
            "ba",
            "bb",
            "bc",
            "ca",
            "cb",
            "cc",
        ]

    def generate_strings_longer_than_possible_number_of_characters():
        assert list(gen_fuzz_strings(allowed_chars="ab", max_length=3)) == [
            "",
            "a",
            "b",
            "aa",
            "ab",
            "ba",
            "bb",
            "aaa",
            "aab",
            "aba",
            "abb",
            "baa",
            "bab",
            "bba",
            "bbb",
        ]