1010#include "cups.h"
1111#include "json.h"
1212#include "test-internal.h"
13+ #include <math.h>
1314
1415
1516//
@@ -33,6 +34,7 @@ main(int argc, // I - Number of command-line arguments
3334 size_t count ; // Number of children
3435 char * s ; // JSON string
3536 time_t last_modified = 0 ; // Last-Modified value
37+ double number ; // Number value
3638 static const char * const types [] = // Node types
3739 {
3840 "CUPS_JTYPE_NULL" , // Null value
@@ -177,9 +179,29 @@ main(int argc, // I - Number of command-line arguments
177179 current = cupsJSONNewNumber (parent , current , 2 );
178180 testEnd (current != NULL );
179181
182+ testBegin ("cupsJSONNewKey('emptyArray')" );
183+ current = cupsJSONNewKey (json , NULL , "emptyArray" );
184+ testEnd (current != NULL );
185+
186+ testBegin ("cupsJSONNew(array)" );
187+ parent = cupsJSONNew (json , current , CUPS_JTYPE_ARRAY );
188+ testEnd (parent != NULL );
189+
190+ testBegin ("cupsJSONNewKey('emptyObject')" );
191+ current = cupsJSONNewKey (json , NULL , "emptyObject" );
192+ testEnd (current != NULL );
193+
194+ testBegin ("cupsJSONNew(object)" );
195+ parent = cupsJSONNew (json , current , CUPS_JTYPE_OBJECT );
196+ testEnd (parent != NULL );
197+
180198 testBegin ("cupsJSONGetCount(root)" );
181199 count = cupsJSONGetCount (json );
182- testEndMessage (count == 14 , "%u" , (unsigned )count );
200+ testEndMessage (count == 18 , "%u" , (unsigned )count );
201+
202+ testBegin ("cupsJSONFind('number')" );
203+ number = cupsJSONGetNumber (cupsJSONFind (json , "number" ));
204+ testEndMessage (fabs (number - 42.0 ) < 0.01 , "%g" , number );
183205
184206 testBegin ("cupsJSONExportFile(root, 'test.json')" );
185207 if (cupsJSONExportFile (json , "test.json" ))
@@ -206,6 +228,10 @@ main(int argc, // I - Number of command-line arguments
206228 parent = cupsJSONImportString (s );
207229 testEnd (parent != NULL );
208230
231+ testBegin ("cupsJSONGetCount(imported)" );
232+ count = cupsJSONGetCount (parent );
233+ testEndMessage (count == 18 , "%u" , (unsigned )count );
234+
209235 cupsJSONDelete (parent );
210236 free (s );
211237 }
@@ -224,8 +250,16 @@ main(int argc, // I - Number of command-line arguments
224250 if (json )
225251 {
226252 char last_modified_date [256 ];// Last-Modified string value
253+ const char * jwks_uri ; // jwks_uri value
227254
228255 testEnd (true);
256+
257+ testBegin ("cupsJSONFind('jwks_uri')" );
258+ if ((jwks_uri = cupsJSONGetString (cupsJSONFind (json , "jwks_uri" ))) != NULL )
259+ testEndMessage (true, "%s" , jwks_uri );
260+ else
261+ testEnd (false);
262+
229263 cupsJSONDelete (json );
230264
231265 testBegin ("cupsJSONImportURL('https://accounts.google.com/.well-known/openid-configuration', since %s)" , httpGetDateString (last_modified , last_modified_date , sizeof (last_modified_date )));
0 commit comments