File tree Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Original file line number Diff line number Diff line change 3030* .exe
3131* .out
3232* .app
33+
34+ .idea
35+ cmake-build- *
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.12)
2+ project (fuzz VERSION 0.1)
3+
4+ add_executable (fuzz src/test .cpp src/test .h)
5+ set_target_properties (fuzz PROPERTIES CXX_STANDARD 17)
Original file line number Diff line number Diff line change 1+ #include " test.h"
2+
3+ #include < sstream>
4+
5+ std::string Value::print () const {
6+ return " static_cast<" + type.print () + " >(" + std::to_string (value) + " )" ;
7+ }
8+
9+ std::string Type::print () const {
10+ switch (kind) {
11+ case Kind::PRIMITIVE_TYPE: return printPrimitiveType (primitiveType);
12+ case Kind::POINTER: return pointerTo->print () + " *" ;
13+ }
14+ }
15+
16+ std::string printPrimitiveType (PrimitiveType type) {
17+ switch (type) {
18+ case PrimitiveType::CHAR: return " char" ;
19+ case PrimitiveType::INT: return " int" ;
20+ }
21+ }
22+
23+ std::string Test::print () const {
24+ std::stringstream ss;
25+ ss << " TEST(" << signature.name << " Test, " << name << " ) {\n " ;
26+ ss << " EXPECT_EQ(" << signature.name << " (" ;
27+
28+ bool first = true ;
29+
30+ for (const auto &arg : arguments) {
31+ if (!first) {
32+ ss << " , " ;
33+ }
34+
35+ ss << arg.print ();
36+
37+ first = false ;
38+ }
39+ ss << " ), " << returnValue.print () << " );\n " ;
40+ ss << " }\n " ;
41+ return ss.str ();
42+ }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < vector>
4+ #include < string>
5+ #include < any>
6+ #include < optional>
7+ #include < memory>
8+
9+ enum class Kind {
10+ PRIMITIVE_TYPE,
11+ POINTER
12+ };
13+
14+ enum class PrimitiveType {
15+ CHAR,
16+ INT
17+ };
18+
19+ std::string printPrimitiveType (PrimitiveType type);
20+
21+ struct Type {
22+ union {
23+ PrimitiveType primitiveType;
24+ std::unique_ptr<Type> pointerTo;
25+ };
26+
27+ Kind kind;
28+
29+ [[nodiscard]] std::string print () const ;
30+ };
31+
32+ std::any fillValue (Type x);
33+
34+ struct TestSignature {
35+ std::string name;
36+ std::vector<Type> parameterTypes;
37+ Type returnType;
38+ };
39+
40+ struct Value {
41+ Type type;
42+ int value;
43+ [[nodiscard]] std::string print () const ;
44+ };
45+
46+ struct Test
47+ {
48+ std::string name;
49+ TestSignature signature;
50+ std::vector<Value> arguments;
51+
52+ // after test launch
53+ Value returnValue;
54+
55+ [[nodiscard]] std::string print () const ;
56+ };
You can’t perform that action at this time.
0 commit comments