Skip to content

Commit 9be165e

Browse files
committed
Fix unit tests after changing API of package JSON.Parsers
Signed-off-by: onox <denkpadje@gmail.com>
1 parent 438e9cf commit 9be165e

File tree

3 files changed

+107
-189
lines changed

3 files changed

+107
-189
lines changed

tests/unit/src/test_images.adb

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ package body Test_Images is
5858
procedure Test_True_Text is
5959
Text : aliased String := "true";
6060

61-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
62-
Allocator : Types.Memory_Allocator;
63-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
61+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
62+
Value : constant JSON_Value := Parser.Parse;
6463
Image : constant String := Value.Image;
6564
begin
6665
Assert (Text = Image, "Image not '" & Text & "'");
@@ -69,9 +68,8 @@ package body Test_Images is
6968
procedure Test_False_Text is
7069
Text : aliased String := "false";
7170

72-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
73-
Allocator : Types.Memory_Allocator;
74-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
71+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
72+
Value : constant JSON_Value := Parser.Parse;
7573
Image : constant String := Value.Image;
7674
begin
7775
Assert (Text = Image, "Image not '" & Text & "'");
@@ -80,9 +78,8 @@ package body Test_Images is
8078
procedure Test_Null_Text is
8179
Text : aliased String := "null";
8280

83-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
84-
Allocator : Types.Memory_Allocator;
85-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
81+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
82+
Value : constant JSON_Value := Parser.Parse;
8683
Image : constant String := Value.Image;
8784
begin
8885
Assert (Text = Image, "Image not '" & Text & "'");
@@ -91,9 +88,8 @@ package body Test_Images is
9188
procedure Test_Escaped_Text is
9289
Text : aliased String := """BS:\b LF:\n CR:\r \\ \/ HT:\t""";
9390

94-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
95-
Allocator : Types.Memory_Allocator;
96-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
91+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
92+
Value : constant JSON_Value := Parser.Parse;
9793
Image : constant String := Value.Image;
9894
begin
9995
Assert (Text = Image, "Image not '" & Text & "'");
@@ -102,9 +98,8 @@ package body Test_Images is
10298
procedure Test_Empty_String_Text is
10399
Text : aliased String := """""";
104100

105-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
106-
Allocator : Types.Memory_Allocator;
107-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
101+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
102+
Value : constant JSON_Value := Parser.Parse;
108103
Image : constant String := Value.Image;
109104
begin
110105
Assert (Text = Image, "Image not '" & Text & "'");
@@ -113,9 +108,8 @@ package body Test_Images is
113108
procedure Test_Non_Empty_String_Text is
114109
Text : aliased String := """test""";
115110

116-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
117-
Allocator : Types.Memory_Allocator;
118-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
111+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
112+
Value : constant JSON_Value := Parser.Parse;
119113
Image : constant String := Value.Image;
120114
begin
121115
Assert (Text = Image, "Image not '" & Text & "'");
@@ -124,9 +118,8 @@ package body Test_Images is
124118
procedure Test_Number_String_Text is
125119
Text : aliased String := """12.34""";
126120

127-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
128-
Allocator : Types.Memory_Allocator;
129-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
121+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
122+
Value : constant JSON_Value := Parser.Parse;
130123
Image : constant String := Value.Image;
131124
begin
132125
Assert (Text = Image, "Image not '" & Text & "'");
@@ -135,9 +128,8 @@ package body Test_Images is
135128
procedure Test_Integer_Number_Text is
136129
Text : aliased String := "42";
137130

138-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
139-
Allocator : Types.Memory_Allocator;
140-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
131+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
132+
Value : constant JSON_Value := Parser.Parse;
141133
Image : constant String := Value.Image;
142134
begin
143135
Assert (Text = Image, "Image not '" & Text & "'");
@@ -146,9 +138,8 @@ package body Test_Images is
146138
procedure Test_Empty_Array_Text is
147139
Text : aliased String := "[]";
148140

149-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
150-
Allocator : Types.Memory_Allocator;
151-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
141+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
142+
Value : constant JSON_Value := Parser.Parse;
152143
Image : constant String := Value.Image;
153144
begin
154145
Assert (Text = Image, "Image not '" & Text & "'");
@@ -157,9 +148,8 @@ package body Test_Images is
157148
procedure Test_One_Element_Array_Text is
158149
Text : aliased String := "[""test""]";
159150

160-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
161-
Allocator : Types.Memory_Allocator;
162-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
151+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
152+
Value : constant JSON_Value := Parser.Parse;
163153
Image : constant String := Value.Image;
164154
begin
165155
Assert (Text = Image, "Image not '" & Text & "'");
@@ -168,9 +158,8 @@ package body Test_Images is
168158
procedure Test_Multiple_Elements_Array_Text is
169159
Text : aliased String := "[42,true]";
170160

171-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
172-
Allocator : Types.Memory_Allocator;
173-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
161+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
162+
Value : constant JSON_Value := Parser.Parse;
174163
Image : constant String := Value.Image;
175164
begin
176165
Assert (Text = Image, "Image not '" & Text & "'");
@@ -179,9 +168,8 @@ package body Test_Images is
179168
procedure Test_Empty_Object_Text is
180169
Text : aliased String := "{}";
181170

182-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
183-
Allocator : Types.Memory_Allocator;
184-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
171+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
172+
Value : constant JSON_Value := Parser.Parse;
185173
Image : constant String := Value.Image;
186174
begin
187175
Assert (Text = Image, "Image not '" & Text & "'");
@@ -190,9 +178,8 @@ package body Test_Images is
190178
procedure Test_One_Member_Object_Text is
191179
Text : aliased String := "{""foo"":""bar""}";
192180

193-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
194-
Allocator : Types.Memory_Allocator;
195-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
181+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
182+
Value : constant JSON_Value := Parser.Parse;
196183
Image : constant String := Value.Image;
197184
begin
198185
Assert (Text = Image, "Image not '" & Text & "'");
@@ -202,9 +189,8 @@ package body Test_Images is
202189
Text : aliased String := "{""foo"":1,""bar"":2}";
203190
Text2 : constant String := "{""bar"":2,""foo"":1}";
204191

205-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
206-
Allocator : Types.Memory_Allocator;
207-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
192+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
193+
Value : constant JSON_Value := Parser.Parse;
208194
Image : constant String := Value.Image;
209195
begin
210196
Assert ((Text = Image) or else (Text2 = Image), "Image '" & Image & "' is not '" & Text & "'");
@@ -213,9 +199,8 @@ package body Test_Images is
213199
procedure Test_Array_Object_Array is
214200
Text : aliased String := "[{""foo"":[true,42]}]";
215201

216-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
217-
Allocator : Types.Memory_Allocator;
218-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
202+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
203+
Value : constant JSON_Value := Parser.Parse;
219204
Image : constant String := Value.Image;
220205
begin
221206
Assert (Text = Image, "Image not '" & Text & "'");
@@ -224,9 +209,8 @@ package body Test_Images is
224209
procedure Test_Object_Array_Object is
225210
Text : aliased String := "{""foo"":[null,{""bar"":42}]}";
226211

227-
Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access);
228-
Allocator : Types.Memory_Allocator;
229-
Value : constant JSON_Value := Parsers.Parse (Stream, Allocator);
212+
Parser : Parsers.Parser := Parsers.Create (JSON.Streams.Create_Stream (Text'Access));
213+
Value : constant JSON_Value := Parser.Parse;
230214
Image : constant String := Value.Image;
231215
begin
232216
Assert (Text = Image, "Image not '" & Text & "'");

0 commit comments

Comments
 (0)