-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_fuzz_test.cpp
33 lines (23 loc) · 1011 Bytes
/
my_fuzz_test.cpp
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
#include <assert.h>
#include <cifuzz/cifuzz.h>
#include <fuzzer/FuzzedDataProvider.h>
FUZZ_TEST_SETUP() {
}
FUZZ_TEST(const uint8_t *data, size_t size) {
// FuzzedDataProvider provides convenience methods that turn the raw fuzzer
// data into common types. Use it to generate parameters for the function you
// want to fuzz:
//
FuzzedDataProvider fuzzed_data(data, size);
int my_int = fuzzed_data.ConsumeIntegral<int64_t>();
my_int = 100000 / (1234567890 - my_int);
assert(my_int != 1234567890);
// std::string my_string = fuzzed_data.ConsumeRandomLengthString();
// Call the functions you want to test with the provided data and optionally
// assert that the results are as expected:
//
// int res = DoSomething(my_int, my_string);
// If you want to know more about writing fuzz tests you can check out the
// example projects at https://github.com/CodeIntelligenceTesting/ci-fuzz-cli-tutorials
// or have a look at our docs at https://docs.code-intelligence.com/
}