Merge pull request #17034 from fjmolinas/pr_turo_optional_space_after_symbol
sys/test_utils/result_output/json: optional space after symbol
This commit is contained in:
commit
4bec2f0723
@ -13,10 +13,19 @@
|
|||||||
|
|
||||||
#include "test_utils/result_output.h"
|
#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)
|
static void _print_comma(turo_t *ctx, turo_state_t state)
|
||||||
{
|
{
|
||||||
if (ctx->state == TURO_STATE_NEED_COMMA) {
|
if (ctx->state == TURO_STATE_NEED_COMMA) {
|
||||||
print_str(", ");
|
print_str("," TURO_JSON_POST_SYMBOL_WHITESPACE);
|
||||||
}
|
}
|
||||||
ctx->state = state;
|
ctx->state = state;
|
||||||
}
|
}
|
||||||
@ -92,7 +101,7 @@ void turo_dict_key(turo_t *ctx, const char *key)
|
|||||||
_print_comma(ctx, TURO_STATE_READY);
|
_print_comma(ctx, TURO_STATE_READY);
|
||||||
print_str("\"");
|
print_str("\"");
|
||||||
print_str(key);
|
print_str(key);
|
||||||
print_str("\": ");
|
print_str("\":" TURO_JSON_POST_SYMBOL_WHITESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void turo_dict_close(turo_t *ctx)
|
void turo_dict_close(turo_t *ctx)
|
||||||
|
|||||||
@ -9,10 +9,21 @@
|
|||||||
#ifndef RESULT_OUTPUT_TYPES_H
|
#ifndef RESULT_OUTPUT_TYPES_H
|
||||||
#define RESULT_OUTPUT_TYPES_H
|
#define RESULT_OUTPUT_TYPES_H
|
||||||
|
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* @brief States of the TURO container
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user