6
6
#include < test/fuzz/fuzz.h>
7
7
#include < tinyformat.h>
8
8
#include < util/strencodings.h>
9
+ #include < util/translation.h>
9
10
10
11
#include < algorithm>
11
12
#include < cstdint>
@@ -16,6 +17,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
16
17
{
17
18
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
18
19
const std::string format_string = fuzzed_data_provider.ConsumeRandomLengthString (64 );
20
+ const bilingual_str bilingual_string{format_string, format_string};
19
21
20
22
const int digits_in_format_specifier = std::count_if (format_string.begin (), format_string.end (), IsDigit);
21
23
@@ -47,72 +49,90 @@ void test_one_input(const std::vector<uint8_t>& buffer)
47
49
48
50
try {
49
51
(void )strprintf (format_string, (signed char *)nullptr );
52
+ (void )tinyformat::format (bilingual_string, (signed char *)nullptr );
50
53
} catch (const tinyformat::format_error&) {
51
54
}
52
55
try {
53
56
(void )strprintf (format_string, (unsigned char *)nullptr );
57
+ (void )tinyformat::format (bilingual_string, (unsigned char *)nullptr );
54
58
} catch (const tinyformat::format_error&) {
55
59
}
56
60
try {
57
61
(void )strprintf (format_string, (void *)nullptr );
62
+ (void )tinyformat::format (bilingual_string, (void *)nullptr );
58
63
} catch (const tinyformat::format_error&) {
59
64
}
60
65
try {
61
66
(void )strprintf (format_string, (bool *)nullptr );
67
+ (void )tinyformat::format (bilingual_string, (bool *)nullptr );
62
68
} catch (const tinyformat::format_error&) {
63
69
}
64
70
try {
65
71
(void )strprintf (format_string, (float *)nullptr );
72
+ (void )tinyformat::format (bilingual_string, (float *)nullptr );
66
73
} catch (const tinyformat::format_error&) {
67
74
}
68
75
try {
69
76
(void )strprintf (format_string, (double *)nullptr );
77
+ (void )tinyformat::format (bilingual_string, (double *)nullptr );
70
78
} catch (const tinyformat::format_error&) {
71
79
}
72
80
try {
73
81
(void )strprintf (format_string, (int16_t *)nullptr );
82
+ (void )tinyformat::format (bilingual_string, (int16_t *)nullptr );
74
83
} catch (const tinyformat::format_error&) {
75
84
}
76
85
try {
77
86
(void )strprintf (format_string, (uint16_t *)nullptr );
87
+ (void )tinyformat::format (bilingual_string, (uint16_t *)nullptr );
78
88
} catch (const tinyformat::format_error&) {
79
89
}
80
90
try {
81
91
(void )strprintf (format_string, (int32_t *)nullptr );
92
+ (void )tinyformat::format (bilingual_string, (int32_t *)nullptr );
82
93
} catch (const tinyformat::format_error&) {
83
94
}
84
95
try {
85
96
(void )strprintf (format_string, (uint32_t *)nullptr );
97
+ (void )tinyformat::format (bilingual_string, (uint32_t *)nullptr );
86
98
} catch (const tinyformat::format_error&) {
87
99
}
88
100
try {
89
101
(void )strprintf (format_string, (int64_t *)nullptr );
102
+ (void )tinyformat::format (bilingual_string, (int64_t *)nullptr );
90
103
} catch (const tinyformat::format_error&) {
91
104
}
92
105
try {
93
106
(void )strprintf (format_string, (uint64_t *)nullptr );
107
+ (void )tinyformat::format (bilingual_string, (uint64_t *)nullptr );
94
108
} catch (const tinyformat::format_error&) {
95
109
}
96
110
97
111
try {
98
112
switch (fuzzed_data_provider.ConsumeIntegralInRange (0 , 5 )) {
99
113
case 0 :
100
114
(void )strprintf (format_string, fuzzed_data_provider.ConsumeRandomLengthString (32 ));
115
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeRandomLengthString (32 ));
101
116
break ;
102
117
case 1 :
103
118
(void )strprintf (format_string, fuzzed_data_provider.ConsumeRandomLengthString (32 ).c_str ());
119
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeRandomLengthString (32 ).c_str ());
104
120
break ;
105
121
case 2 :
106
122
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <signed char >());
123
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <signed char >());
107
124
break ;
108
125
case 3 :
109
126
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <unsigned char >());
127
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <unsigned char >());
110
128
break ;
111
129
case 4 :
112
130
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <char >());
131
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <char >());
113
132
break ;
114
133
case 5 :
115
134
(void )strprintf (format_string, fuzzed_data_provider.ConsumeBool ());
135
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeBool ());
116
136
break ;
117
137
}
118
138
} catch (const tinyformat::format_error&) {
@@ -138,27 +158,35 @@ void test_one_input(const std::vector<uint8_t>& buffer)
138
158
switch (fuzzed_data_provider.ConsumeIntegralInRange (0 , 7 )) {
139
159
case 0 :
140
160
(void )strprintf (format_string, fuzzed_data_provider.ConsumeFloatingPoint <float >());
161
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeFloatingPoint <float >());
141
162
break ;
142
163
case 1 :
143
164
(void )strprintf (format_string, fuzzed_data_provider.ConsumeFloatingPoint <double >());
165
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeFloatingPoint <double >());
144
166
break ;
145
167
case 2 :
146
168
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <int16_t >());
169
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <int16_t >());
147
170
break ;
148
171
case 3 :
149
172
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <uint16_t >());
173
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <uint16_t >());
150
174
break ;
151
175
case 4 :
152
176
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <int32_t >());
177
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <int32_t >());
153
178
break ;
154
179
case 5 :
155
180
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <uint32_t >());
181
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <uint32_t >());
156
182
break ;
157
183
case 6 :
158
184
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <int64_t >());
185
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <int64_t >());
159
186
break ;
160
187
case 7 :
161
188
(void )strprintf (format_string, fuzzed_data_provider.ConsumeIntegral <uint64_t >());
189
+ (void )tinyformat::format (bilingual_string, fuzzed_data_provider.ConsumeIntegral <uint64_t >());
162
190
break ;
163
191
}
164
192
} catch (const tinyformat::format_error&) {
0 commit comments