
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

#ifndef SYSCONFDIR
// Bypass compilation error due to -DSYSCONFDIR not provided
#define SYSCONFDIR
#endif

#include "config.c"

static void execute_test(const char *input, const char *key, const char *expected)
{
	struct config *ctx;
	const char *found;
	char *buf;

	ctx = calloc(1, sizeof(*ctx));
	buf = strdup(input);
	config_parse(ctx, buf);
	free(buf);
	found = config_get_value(ctx, key);
	if (!expected)
		assert(!found);
	if (expected) {
		assert(found);
		assert(!strcmp(expected, found));
	}
	config_fini(ctx);
}

static void test_config_parse_basic(void)
{
	execute_test("tty = ttyS0", "tty", "ttyS0");
}

static void test_config_parse_no_key(void)
{
	execute_test("= ttyS0", "tty", NULL);
}

static void test_config_parse_no_value(void)
{
	execute_test("tty =", "tty", NULL);
}

static void test_config_parse_no_operator(void)
{
	execute_test("tty ttyS0", "tty", NULL);
}

static void test_config_parse_no_spaces(void)
{
	execute_test("tty=ttyS0", "tty", "ttyS0");
}

static void test_config_parse_empty(void)
{
	execute_test("", "tty", NULL);
}

int main(void)
{
	test_config_parse_basic();
	test_config_parse_no_key();
	test_config_parse_no_value();
	test_config_parse_no_operator();
	test_config_parse_no_spaces();
	test_config_parse_empty();

	return EXIT_SUCCESS;
}
