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

Function tok_tok

common/test/run-param.c:208–233  ·  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

206 * optional missing toks are set to NULL.
207 */
208static void tok_tok(void)
209{
210 {
211 unsigned int n;
212 const jsmntok_t *tok = NULL;
213 struct json *j = json_parse(cmd, "{ 'satoshi': '546' }");
214
215 assert(param(cmd, j->buffer, j->toks,
216 p_req("satoshi", param_tok, &tok), NULL));
217 assert(tok);
218 assert(json_to_number(j->buffer, tok, &n));
219 assert(n == 546);
220 }
221 // again with missing optional parameter
222 {
223 /* make sure it is *not* NULL */
224 const jsmntok_t *tok = (const jsmntok_t *) 65535;
225
226 struct json *j = json_parse(cmd, "{}");
227 assert(param(cmd, j->buffer, j->toks,
228 p_opt("satoshi", param_tok, &tok), NULL));
229
230 /* make sure it *is* NULL */
231 assert(tok == NULL);
232 }
233}
234
235/* check for valid but duplicate json name-value pairs */
236static 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