Skip to content

Commit

Permalink
test/conf: add conf_get_i32
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Mar 3, 2024
1 parent 6fae7cc commit e9d3044
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,40 @@
#include <re.h>
#include "test.h"

#define DEBUG_MODULE "test_conf"
#define DEBUG_LEVEL 5
#include <re_dbg.h>


int test_conf(void)
{
static const char *cfg =
"string_val\trattarei\n"
"u32_val 42\n";
"u32_val 42\n"
"i32_val -23\n";
char str[256];
struct conf *conf;
struct pl pl;
uint32_t u32;
int32_t i32;
int err;

err = conf_alloc_buf(&conf, (uint8_t *)cfg, strlen(cfg));
if (err)
return err;

err = conf_get_str(conf, "string_val", str, sizeof(str));
if (err)
goto out;
TEST_ERR(err);
if (strcmp(str, "rattarei"))
goto badmsg;

err = conf_get_u32(conf, "u32_val", &u32);
if (u32 != 42)
goto badmsg;
TEST_ERR(err);
TEST_EQUALS(42, u32);

err = conf_get_i32(conf, "i32_val", &i32);
TEST_ERR(err);
TEST_EQUALS(-23, i32);

/* Non-existing parameters */
if (0 == conf_get(conf, "rattarei", &pl))
Expand Down

0 comments on commit e9d3044

Please sign in to comment.