37TEST(SerializeTest, ParseParamInt8)
43 EXPECT_TRUE(parser.parse(
"0", value));
47 EXPECT_FALSE(parser.parse(
"true", value));
48 EXPECT_FALSE(parser.parse(
"false", value));
51 EXPECT_FALSE(parser.parse(
"255", value));
52 EXPECT_TRUE(parser.parse(
"-128", value));
53 EXPECT_EQ(-128, value);
56 EXPECT_FALSE(parser.parse(
"1000", value));
57 EXPECT_FALSE(parser.parse(
"-1000", value));
60 EXPECT_FALSE(parser.parse(
"2147483648", value));
61 EXPECT_FALSE(parser.parse(
"-1073741824", value));
65 EXPECT_FALSE(parser.parse(
"123456.789", value));
66 EXPECT_FALSE(parser.parse(
"-123456.789", value));
67 EXPECT_FALSE(parser.parse(
"9.87654e+06", value));
70 EXPECT_TRUE(parser.parse(
"69", value));
72 EXPECT_TRUE(parser.parse(
"97", value));
76 EXPECT_FALSE(parser.parse(
"Test", value));
79TEST(SerializeTest, ParseParamUint32)
85 EXPECT_TRUE(parser.parse(
"0", value));
89 EXPECT_FALSE(parser.parse(
"true", value));
90 EXPECT_FALSE(parser.parse(
"false", value));
93 EXPECT_TRUE(parser.parse(
"255", value));
94 EXPECT_EQ(255, value);
95 EXPECT_FALSE(parser.parse(
"-128", value));
98 EXPECT_TRUE(parser.parse(
"1000", value));
99 EXPECT_EQ(1000, value);
100 EXPECT_FALSE(parser.parse(
"-1000", value));
103 EXPECT_TRUE(parser.parse(
"2147483648", value));
104 EXPECT_EQ(2147483648, value);
105 EXPECT_FALSE(parser.parse(
"-1073741824", value));
109 EXPECT_TRUE(parser.parse(
"123456.789", value));
110 EXPECT_EQ(123456, value);
111 EXPECT_FALSE(parser.parse(
"-123456.789", value));
112 EXPECT_FALSE(parser.parse(
"9.87654e+06", value));
115 EXPECT_TRUE(parser.parse(
"69", value));
116 EXPECT_EQ(69, value);
117 EXPECT_TRUE(parser.parse(
"97", value));
118 EXPECT_EQ(97, value);
121 EXPECT_FALSE(parser.parse(
"Test", value));
124TEST(SerializeTest, ParseParamDouble)
130 EXPECT_TRUE(parser.parse(
"0", value));
131 EXPECT_EQ(0.0, value);
134 EXPECT_FALSE(parser.parse(
"true", value));
135 EXPECT_FALSE(parser.parse(
"false", value));
138 EXPECT_TRUE(parser.parse(
"255", value));
139 EXPECT_EQ(255.0, value);
140 EXPECT_TRUE(parser.parse(
"-128", value));
141 EXPECT_EQ(-128.0, value);
144 EXPECT_TRUE(parser.parse(
"1000", value));
145 EXPECT_EQ(1000.0, value);
146 EXPECT_TRUE(parser.parse(
"-1000", value));
147 EXPECT_EQ(-1000.0, value);
150 EXPECT_TRUE(parser.parse(
"2147483648", value));
151 EXPECT_EQ(2147483648.0, value);
152 EXPECT_TRUE(parser.parse(
"-1073741824", value));
153 EXPECT_EQ(-1073741824.0, value);
156 EXPECT_TRUE(parser.parse(
"123456.789", value));
157 EXPECT_EQ(123456.789, value);
158 EXPECT_TRUE(parser.parse(
"-123456.789", value));
159 EXPECT_EQ(-123456.789, value);
160 EXPECT_TRUE(parser.parse(
"9.87654e+06", value));
161 EXPECT_EQ(9.87654e+06, value);
164 EXPECT_TRUE(parser.parse(
"69", value));
165 EXPECT_EQ(69.0, value);
166 EXPECT_TRUE(parser.parse(
"97", value));
167 EXPECT_EQ(97.0, value);
170 EXPECT_FALSE(parser.parse(
"Test", value));
173TEST(SerializeTest, ParseParamBool)
179 EXPECT_FALSE(parser.parse(
"0", value));
182 EXPECT_TRUE(parser.parse(
"true", value));
183 EXPECT_EQ(
true, value);
184 EXPECT_TRUE(parser.parse(
"false", value));
185 EXPECT_EQ(
false, value);
188 EXPECT_FALSE(parser.parse(
"255", value));
189 EXPECT_FALSE(parser.parse(
"-128", value));
192 EXPECT_FALSE(parser.parse(
"1000", value));
193 EXPECT_FALSE(parser.parse(
"-1000", value));
196 EXPECT_FALSE(parser.parse(
"2147483648", value));
197 EXPECT_FALSE(parser.parse(
"-1073741824", value));
200 EXPECT_FALSE(parser.parse(
"123456.789", value));
201 EXPECT_FALSE(parser.parse(
"-123456.789", value));
202 EXPECT_FALSE(parser.parse(
"9.87654e+06", value));
205 EXPECT_FALSE(parser.parse(
"69", value));
206 EXPECT_FALSE(parser.parse(
"97", value));
209 EXPECT_FALSE(parser.parse(
"Test", value));
213TEST(SerializeTest, ParseParamChar)
219 EXPECT_TRUE(parser.parse(
"48", value));
220 EXPECT_EQ(
'0', value);
223 EXPECT_FALSE(parser.parse(
"true", value));
224 EXPECT_FALSE(parser.parse(
"false", value));
227 if constexpr (std::is_signed_v<char>) {
228 EXPECT_FALSE(parser.parse(
"255", value));
229 EXPECT_TRUE(parser.parse(
"-128", value));
230 EXPECT_EQ(
char(-128), value);
232 EXPECT_FALSE(parser.parse(
"256", value));
233 EXPECT_TRUE(parser.parse(
"255", value));
234 EXPECT_EQ(
char(255), value);
238 EXPECT_FALSE(parser.parse(
"1000", value));
239 EXPECT_FALSE(parser.parse(
"-1000", value));
242 EXPECT_FALSE(parser.parse(
"2147483648", value));
243 EXPECT_FALSE(parser.parse(
"-1073741824", value));
246 EXPECT_FALSE(parser.parse(
"123456.789", value));
247 EXPECT_FALSE(parser.parse(
"-123456.789", value));
248 EXPECT_FALSE(parser.parse(
"9.87654e+06", value));
251 EXPECT_TRUE(parser.parse(
"69", value));
252 EXPECT_EQ(
'E', value);
253 EXPECT_TRUE(parser.parse(
"97", value));
254 EXPECT_EQ(
'a', value);
257 EXPECT_FALSE(parser.parse(
"Test", value));
260TEST(SerializeTest, ParseParamString)
263 std::string value(
"");
266 EXPECT_TRUE(parser.parse(
"0", value));
267 EXPECT_EQ(
"0", value);
270 EXPECT_TRUE(parser.parse(
"true", value));
271 EXPECT_EQ(
"true", value);
272 EXPECT_TRUE(parser.parse(
"false", value));
273 EXPECT_EQ(
"false", value);
276 EXPECT_TRUE(parser.parse(
"255", value));
277 EXPECT_EQ(
"255", value);
278 EXPECT_TRUE(parser.parse(
"-128", value));
279 EXPECT_EQ(
"-128", value);
282 EXPECT_TRUE(parser.parse(
"1000", value));
283 EXPECT_EQ(
"1000", value);
284 EXPECT_TRUE(parser.parse(
"-1000", value));
285 EXPECT_EQ(
"-1000", value);
288 EXPECT_TRUE(parser.parse(
"2147483648", value));
289 EXPECT_EQ(
"2147483648", value);
290 EXPECT_TRUE(parser.parse(
"-1073741824", value));
291 EXPECT_EQ(
"-1073741824", value);
294 EXPECT_TRUE(parser.parse(
"123456.789", value));
295 EXPECT_EQ(
"123456.789", value);
296 EXPECT_TRUE(parser.parse(
"-123456.789", value));
297 EXPECT_EQ(
"-123456.789", value);
298 EXPECT_TRUE(parser.parse(
"9.87654e+06", value));
299 EXPECT_EQ(
"9.87654e+06", value);
302 EXPECT_TRUE(parser.parse(
"69", value));
303 EXPECT_EQ(
"69", value);
304 EXPECT_TRUE(parser.parse(
"97", value));
305 EXPECT_EQ(
"97", value);
308 EXPECT_TRUE(parser.parse(
"Test", value));
309 EXPECT_EQ(
"Test", value);