MCPcopy Create free account
hub / github.com/ByConity/ByConity / fuzzField

Method fuzzField

programs/client/QueryFuzzer.cpp:75–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75Field QueryFuzzer::fuzzField(Field field)
76{
77 const auto type = field.getType();
78
79 int type_index = -1;
80
81 if (type == Field::Types::Int64
82 || type == Field::Types::UInt64)
83 {
84 type_index = 0;
85 }
86 else if (type == Field::Types::Float64)
87 {
88 type_index = 1;
89 }
90 else if (type == Field::Types::Decimal32
91 || type == Field::Types::Decimal64
92 || type == Field::Types::Decimal128)
93 {
94 type_index = 2;
95 }
96
97 if (fuzz_rand() % 20 == 0)
98 {
99 return Null{};
100 }
101
102 if (type_index >= 0)
103 {
104 if (fuzz_rand() % 20 == 0)
105 {
106 // Change type sometimes, but not often, because it mostly leads to
107 // boring errors.
108 type_index = fuzz_rand() % 3;
109 }
110 return getRandomField(type_index);
111 }
112
113 if (type == Field::Types::String)
114 {
115 auto & str = field.get<std::string>();
116 UInt64 action = fuzz_rand() % 10;
117 switch (action)
118 {
119 case 0:
120 str = "";
121 break;
122 case 1:
123 str = str + str;
124 break;
125 case 2:
126 str = str + str + str + str;
127 break;
128 case 4:
129 if (!str.empty())
130 {
131 str[fuzz_rand() % str.size()] = '\0';
132 }

Callers

nothing calls this directly

Calls 6

getTypeMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected