MCPcopy Create free account
hub / github.com/ElementsProject/lightning / tok_tok

Function tok_tok

common/test/run-param.c:252–277  ·  view source on GitHub ↗

* Make sure toks are passed through correctly, and also make sure * optional missing toks are set to NULL. */

Source from the content-addressed store, hash-verified

250 * optional missing toks are set to NULL.
251 */
252static void tok_tok(void)
253{
254 {
255 unsigned int n;
256 const jsmntok_t *tok = NULL;
257 struct json *j = json_parse(cmd, "{ 'satoshi': '546' }");
258
259 assert(param(cmd, j->buffer, j->toks,
260 p_req("satoshi", param_tok, &tok), NULL));
261 assert(tok);
262 assert(json_to_number(j->buffer, tok, &n));
263 assert(n == 546);
264 }
265 // again with missing optional parameter
266 {
267 /* make sure it is *not* NULL */
268 const jsmntok_t *tok = (const jsmntok_t *) 65535;
269
270 struct json *j = json_parse(cmd, "{}");
271 assert(param(cmd, j->buffer, j->toks,
272 p_opt("satoshi", param_tok, &tok), NULL));
273
274 /* make sure it *is* NULL */
275 assert(tok == NULL);
276 }
277}
278
279/* check for valid but duplicate json name-value pairs */
280static void dup_names(void)

Callers 1

mainFunction · 0.85

Calls 3

json_parseFunction · 0.70
paramClass · 0.70
json_to_numberFunction · 0.70

Tested by

no test coverage detected