1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/test_utils/result_output/json: optional space after symbol

This commit is contained in:
Francisco Molina 2021-10-22 10:33:43 +02:00
parent abbf798e8e
commit 720338b304
2 changed files with 22 additions and 2 deletions

View File

@ -13,10 +13,19 @@
#include "test_utils/result_output.h"
/**
* @brief TURO whitespace symbol macro
*/
#if IS_ACTIVE(CONFIG_TURO_JSON_WHITESPACE_AFTER_SYMBOL)
#define TURO_JSON_POST_SYMBOL_WHITESPACE " "
#else
#define TURO_JSON_POST_SYMBOL_WHITESPACE ""
#endif
static void _print_comma(turo_t *ctx, turo_state_t state)
{
if (ctx->state == TURO_STATE_NEED_COMMA) {
print_str(", ");
print_str("," TURO_JSON_POST_SYMBOL_WHITESPACE);
}
ctx->state = state;
}
@ -92,7 +101,7 @@ void turo_dict_key(turo_t *ctx, const char *key)
_print_comma(ctx, TURO_STATE_READY);
print_str("\"");
print_str(key);
print_str("\": ");
print_str("\":" TURO_JSON_POST_SYMBOL_WHITESPACE);
}
void turo_dict_close(turo_t *ctx)

View File

@ -9,10 +9,21 @@
#ifndef RESULT_OUTPUT_TYPES_H
#define RESULT_OUTPUT_TYPES_H
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable to add a whitespace after a whitespace after a symbol
*
* e.g.: {"key1":1,"key2":2}" -> {"key1": 1, "key2: 2}
*/
#ifndef CONFIG_TURO_JSON_WHITESPACE_AFTER_SYMBOL
#define CONFIG_TURO_JSON_WHITESPACE_AFTER_SYMBOL 1
#endif
/**
* @brief States of the TURO container
* @{