xref: /haiku/src/tests/kits/shared/JsonErrorHandlingTest.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef JSON_ERROR_HANDLING_TEST_H
6 #define JSON_ERROR_HANDLING_TEST_H
7 
8 
9 #include <TestCase.h>
10 #include <TestSuite.h>
11 
12 #include <DataIO.h>
13 
14 class Sample;
15 
16 
17 class JsonErrorHandlingTest : public CppUnit::TestCase {
18 public:
19 								JsonErrorHandlingTest();
20 	virtual						~JsonErrorHandlingTest();
21 
22 			void				TestCompletelyUnknown();
23 			void				TestObjectWithPrematureSeparator();
24 
25 			void				TestStringUnterminated();
26 
27 			void				TestBadStringEscape();
28 
29 			void				TestBadNumber();
30 
31 			void				TestIOIssue();
32 
33 	static	void				AddTests(BTestSuite& suite);
34 private:
35 			void				TestParseWithUnexpectedCharacter(
36 									const char* input, int32 line,
37 									status_t expectedStatus, char expectedChar);
38 
39 			void				TestParseWithUnterminatedElement(
40 									const char* input, int32 line,
41 									status_t expectedStatus);
42 
43 			void				TestParseWithBadStringEscape(
44 									const char* input,
45 									int32 line, status_t expectedStatus,
46 									char expectedBadEscapeChar);
47 
48 			void				TestParseWithErrorMessage(
49 									const char* input, int32 line,
50 									status_t expectedStatus,
51 									const char* expectedMessage);
52 
53 			void				TestParseWithErrorMessage(
54 									BDataIO* data, int32 line,
55 									status_t expectedStatus,
56 									const char* expectedMessage);
57 
58 };
59 
60 
61 #endif	// JSON_ERROR_HANDLING_TEST_H
62