blob: 7a6da33ec7a558055aa5bbf26d28aea626634779 [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
23namespace swift Fuzz
24
25// Test typedefs
26typedef i64 UserId
27typedef binary BinaryData
28
29// Test all primitive types in a compact struct
30struct BasicTypes {
31 1: bool bool_field,
32 2: i8 byte_field,
33 3: i16 i16_field,
34 4: i32 i32_field,
35 5: i64 i64_field,
36 6: double double_field,
37 7: string string_field,
38 8: binary binary_field,
39 9: uuid uuid_field
40}
41
42// Test optional/required/default requiredness
43struct Requiredness {
44 1: required i32 req_field,
45 2: optional i32 opt_field,
46 3: i32 default_field, // default requiredness
47 4: optional string opt_with_default = "test",
48 5: required bool req_with_default = true
49}
50
51// Test field ID edge cases
52struct FieldIDTest {
53 1: i32 first,
54 100: i32 gap,
55 255: i32 medium_id,
56 32767: i32 large_id,
57}
58
59// Test empty struct
60struct EmptyStruct {}
61
62// Test union
63union TestUnion {
64 1: i32 int_field,
65 2: string string_field,
66 3: BasicTypes struct_field,
67 4: binary binary_field
68}
69
70// Test containers (but not too deeply nested)
71struct Containers {
72 1: list<i32> int_list,
73 2: set<string> string_set,
74 3: map<i32, string> int_string_map,
75 4: list<BasicTypes> struct_list,
76 5: map<string, list<i32>> nested_map,
77 6: set<UserId> typedef_set,
78}
79
80// Test enum with various values
81enum TestEnum {
82 ZERO = 0,
83 ONE = 1,
84 TWO = 2,
85 NEGATIVE = -1,
86 LARGE = 32767,
87 HEX_VALUE = 0xFF
88}
89
90// Test recursive structure
91struct RecursiveStruct {
92 1: optional RecursiveStruct & recurse,
93 2: i32 data,
94 3: optional list<RecursiveStruct> children
95}
96
97// Main test structure - kept minimal but comprehensive
98struct FuzzTest {
99 1: required BasicTypes basic,
100 2: required Requiredness required_test,
101 3: required Containers containers,
102 4: required TestUnion union_field,
103 5: optional RecursiveStruct recursive,
104 6: optional EmptyStruct empty,
105 7: optional FieldIDTest field_ids,
106 8: required TestEnum enum_field,
107 9: optional map<TestEnum, string> enum_map,
108 10: UserId user_id,
109 11: BinaryData data,
110}