mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-10 07:06:26 +00:00
[fuzzer] Adds code generation target. (#8795)
* adds code generation fuzzer target. * add buffer verification * add table verification in codegen fuzzer --------- Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
This commit is contained in:
11
tests/fuzzer/seed_codegen/attributes_test
Normal file
11
tests/fuzzer/seed_codegen/attributes_test
Normal file
@@ -0,0 +1,11 @@
|
||||
attribute "csharp_namespace";
|
||||
|
||||
namespace Test;
|
||||
|
||||
table Data (csharp_partial) {
|
||||
value:int;
|
||||
}
|
||||
|
||||
root_type Data;
|
||||
|
||||
file_identifier "TEST";
|
||||
24
tests/fuzzer/seed_codegen/complex_schema
Normal file
24
tests/fuzzer/seed_codegen/complex_schema
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Example;
|
||||
|
||||
enum Status:byte { Active, Inactive, Pending }
|
||||
|
||||
struct Point {
|
||||
x:int;
|
||||
y:int;
|
||||
}
|
||||
|
||||
table User {
|
||||
id:uint;
|
||||
name:string;
|
||||
points:[Point];
|
||||
status:Status = Active;
|
||||
metadata:[string];
|
||||
}
|
||||
|
||||
table Group {
|
||||
name:string;
|
||||
users:[User];
|
||||
leader:User;
|
||||
}
|
||||
|
||||
root_type Group;
|
||||
6
tests/fuzzer/seed_codegen/empty_namespace
Normal file
6
tests/fuzzer/seed_codegen/empty_namespace
Normal file
@@ -0,0 +1,6 @@
|
||||
table Person {
|
||||
name:string;
|
||||
age:int;
|
||||
}
|
||||
|
||||
root_type Person;
|
||||
8
tests/fuzzer/seed_codegen/enum_test
Normal file
8
tests/fuzzer/seed_codegen/enum_test
Normal file
@@ -0,0 +1,8 @@
|
||||
enum Color:byte { Red, Green, Blue }
|
||||
|
||||
table Item {
|
||||
name:string;
|
||||
color:Color;
|
||||
}
|
||||
|
||||
root_type Item;
|
||||
33
tests/fuzzer/seed_codegen/monster_sample
Normal file
33
tests/fuzzer/seed_codegen/monster_sample
Normal file
@@ -0,0 +1,33 @@
|
||||
// Example IDL file for our monster's schema.
|
||||
|
||||
namespace MyGame.Sample;
|
||||
|
||||
enum Color:byte { Red = 0, Green, Blue = 2 }
|
||||
|
||||
union Equipment { Weapon } // Optionally add more tables.
|
||||
|
||||
struct Vec3 {
|
||||
x:float;
|
||||
y:float;
|
||||
z:float;
|
||||
}
|
||||
|
||||
table Monster {
|
||||
pos:Vec3;
|
||||
mana:short = 150;
|
||||
hp:short = 100;
|
||||
name:string;
|
||||
friendly:bool = false (deprecated);
|
||||
inventory:[ubyte];
|
||||
color:Color = Blue;
|
||||
weapons:[Weapon];
|
||||
equipped:Equipment;
|
||||
path:[Vec3];
|
||||
}
|
||||
|
||||
table Weapon {
|
||||
name:string;
|
||||
damage:short;
|
||||
}
|
||||
|
||||
root_type Monster;
|
||||
14
tests/fuzzer/seed_codegen/rpc_test
Normal file
14
tests/fuzzer/seed_codegen/rpc_test
Normal file
@@ -0,0 +1,14 @@
|
||||
table Request {
|
||||
id:int;
|
||||
message:string;
|
||||
}
|
||||
|
||||
table Response {
|
||||
result:string;
|
||||
}
|
||||
|
||||
rpc_service MyService {
|
||||
DoSomething(Request):Response;
|
||||
}
|
||||
|
||||
root_type Request;
|
||||
11
tests/fuzzer/seed_codegen/struct_test
Normal file
11
tests/fuzzer/seed_codegen/struct_test
Normal file
@@ -0,0 +1,11 @@
|
||||
struct Vec2 {
|
||||
x:float;
|
||||
y:float;
|
||||
}
|
||||
|
||||
table Object {
|
||||
position:Vec2;
|
||||
id:int;
|
||||
}
|
||||
|
||||
root_type Object;
|
||||
20
tests/fuzzer/seed_codegen/test_union
Normal file
20
tests/fuzzer/seed_codegen/test_union
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Test;
|
||||
|
||||
union Shape {
|
||||
Circle,
|
||||
Square,
|
||||
}
|
||||
|
||||
table Circle {
|
||||
radius: float;
|
||||
}
|
||||
|
||||
table Square {
|
||||
side: float;
|
||||
}
|
||||
|
||||
table Root {
|
||||
shape: Shape;
|
||||
}
|
||||
|
||||
root_type Root;
|
||||
Reference in New Issue
Block a user