#include #include #include #include "../source/ini-config.h" #include "../source/types/int.h" static int8_t default_int8_value = 0; static int8_t read_int8_values[] = { 0, 0, 0, 0, 0 }; static int8_t expected_int8_values[] = { 0, 127, -128, -128, 127 }; static INI_ConfigItem items[] = { { .section = "Int", .key = "Int8_0", .type = INI_CONFIG_TYPE_I8, .default_value = &default_int8_value, .transformer = INI_CONFIG_TRANSFORMER_NONE, .validator = NULL, .cmdline_option = NULL, .dest = &read_int8_values[0], }, { .section = "Int", .key = "Int8_1", .type = INI_CONFIG_TYPE_I8, .default_value = &default_int8_value, .transformer = INI_CONFIG_TRANSFORMER_NONE, .validator = NULL, .cmdline_option = NULL, .dest = &read_int8_values[1], }, { .section = "Int", .key = "Int8_2", .type = INI_CONFIG_TYPE_I8, .default_value = &default_int8_value, .transformer = INI_CONFIG_TRANSFORMER_NONE, .validator = NULL, .cmdline_option = NULL, .dest = &read_int8_values[2], }, { .section = "Int", .key = "Int8_3", .type = INI_CONFIG_TYPE_I8, .default_value = &default_int8_value, .transformer = INI_CONFIG_TRANSFORMER_NONE, .validator = NULL, .cmdline_option = NULL, .dest = &read_int8_values[3], }, { .section = "Int", .key = "Int8_4", .type = INI_CONFIG_TYPE_I8, .default_value = &default_int8_value, .transformer = INI_CONFIG_TRANSFORMER_NONE, .validator = NULL, .cmdline_option = NULL, .dest = &read_int8_values[4], }, INI_CONFIG_ITEM_NULL }; int main() { printf("Fixture file exists? "); const char* argv[] = { }; int argc = 0; assert(INI_ConfigInitialize(items, "test-int.ini", argc, argv) == 0); printf("Yes.\n"); for (uint8_t i = 0; i < 5; i += 1) { printf("read: %d, expected: %d\n", read_int8_values[i], expected_int8_values[i]); assert(read_int8_values[i] == expected_int8_values[i]); } return 0; }