blob: af26b6539c12bf2a7bd2c5023962fca724f0bc9d [file] [log] [blame]
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20namespace cpp fuzz
21namespace java org.apache.thrift.fuzz
22namespace py fuzz
Dmytro Shteflyuk60417982026-03-14 02:12:29 -040023namespace rb Fuzz
Hasnain Lakhanic51ab5f2025-08-25 10:24:14 -070024namespace swift Fuzz
25
26// Test typedefs
27typedef i64 UserId
28typedef binary BinaryData
29
30// Test all primitive types in a compact struct
31struct BasicTypes {
32 1: bool bool_field,
33 2: i8 byte_field,
34 3: i16 i16_field,
35 4: i32 i32_field,
36 5: i64 i64_field,
37 6: double double_field,
38 7: string string_field,
39 8: binary binary_field,
40 9: uuid uuid_field
41}
42
43// Test optional/required/default requiredness
44struct Requiredness {
45 1: required i32 req_field,
46 2: optional i32 opt_field,
47 3: i32 default_field, // default requiredness
48 4: optional string opt_with_default = "test",
49 5: required bool req_with_default = true
50}
51
52// Test field ID edge cases
53struct FieldIDTest {
54 1: i32 first,
55 100: i32 gap,
56 255: i32 medium_id,
57 32767: i32 large_id,
58}
59
60// Test empty struct
61struct EmptyStruct {}
62
63// Test union
64union TestUnion {
65 1: i32 int_field,
66 2: string string_field,
67 3: BasicTypes struct_field,
68 4: binary binary_field
69}
70
71// Test containers (but not too deeply nested)
72struct Containers {
73 1: list<i32> int_list,
74 2: set<string> string_set,
75 3: map<i32, string> int_string_map,
76 4: list<BasicTypes> struct_list,
77 5: map<string, list<i32>> nested_map,
78 6: set<UserId> typedef_set,
79}
80
81// Test enum with various values
82enum TestEnum {
83 ZERO = 0,
84 ONE = 1,
85 TWO = 2,
86 NEGATIVE = -1,
87 LARGE = 32767,
88 HEX_VALUE = 0xFF
89}
90
91// Test recursive structure
92struct RecursiveStruct {
93 1: optional RecursiveStruct & recurse,
94 2: i32 data,
95 3: optional list<RecursiveStruct> children
96}
97
98// Main test structure - kept minimal but comprehensive
99struct FuzzTest {
100 1: required BasicTypes basic,
101 2: required Requiredness required_test,
102 3: required Containers containers,
103 4: required TestUnion union_field,
104 5: optional RecursiveStruct recursive,
105 6: optional EmptyStruct empty,
106 7: optional FieldIDTest field_ids,
107 8: required TestEnum enum_field,
108 9: optional map<TestEnum, string> enum_map,
109 10: UserId user_id,
110 11: BinaryData data,
111}