* Make sure toks are passed through correctly, and also make sure * optional missing toks are set to NULL. */
| 206 | * optional missing toks are set to NULL. |
| 207 | */ |
| 208 | static 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 */ |
| 236 | static void dup_names(void) |
no test coverage detected