#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"

struct test_parse_size_unit {
	const char *test_str;
	size_t expected_size;
	int expected_rc;
};

void test_config_parse_logsize(void)
{
	const struct test_parse_size_unit test_data[] = {
		{ "0", 0, -1 },
		{ "1", 1, 0 },
		{ "4k", 4ul * 1024ul, 0 },
		{ "6M", (6ul << 20), 0 },
		{ "4095M", (4095ul << 20), 0 },
		{ "2G", (2ul << 30), 0 },
		{ "8M\n", (8ul << 20), 0 }, /* Suffix ignored */
		{ " 10k", 10ul * 1024ul, 0 }, /* Leading spaces trimmed */
		{ "10k ", 10ul * 1024ul, 0 }, /* Trailing spaces trimmed */
		{ "\r\t10k \r\t", 10ul * 1024ul, 0 }, /* Spaces trimmed */
		{ " 10 kB ", 10ul * 1024ul, 0 }, /* Spaces trimmed */
		{ "11G", 0, -1 }, /* Overflow */
		{ "4294967296", 0, -1 }, /* Overflow */
		{ "4096M", 0, -1 }, /* Overflow */
		{ "65535G", 0, -1 }, /* Overflow */
		{ "xyz", 0, -1 }, /* Invalid */
		{ "000", 0, -1 }, /* Invalid */
		{ "0.1", 0, -1 }, /* Invalid */
		{ "9T", 0, -1 }, /* Invalid suffix */
	};
	const size_t num_tests =
		sizeof(test_data) / sizeof(struct test_parse_size_unit);
	size_t size;
	size_t i;
	int rc;

	for (i = 0; i < num_tests; i++) {
		rc = config_parse_logsize(test_data[i].test_str, &size);

		if (rc == -1 && rc != test_data[i].expected_rc) {
			warn("[%zu] Str %s expected rc %d, got rc %d\n", i,
			     test_data[i].test_str, test_data[i].expected_rc,
			     rc);
		} else if (rc == 0 && test_data[i].expected_size != size) {
			warn("[%zu] Str %s expected size %lu, got size %lu\n",
			     i, test_data[i].test_str,
			     test_data[i].expected_size, size);
		}
		assert(rc == test_data[i].expected_rc);
		if (rc == 0)
			assert(size == test_data[i].expected_size);
	}
}

int main(void)
{
	test_config_parse_logsize();
	return EXIT_SUCCESS;
}
