1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "kpl_test.h"
KPL_TEST(config_show_help) {
kpl_config config;
const int32_t argc = 2;
const char *argv[] = { "./kpl", "--help", "not_used" };
kpl_config_init(&config);
int32_t code = kpl_config_parse_args(&config, argc, argv);
KPL_ASSERT(code == KPL_EXIT_CODE_HELP, "Invalid help exit code");
}
KPL_TEST(config_change_module_extension) {
kpl_config config;
const int32_t argc = 3;
const char *argv[] = { "./kpl", "--module-extension=.l", "./file.l" };
kpl_config_init(&config);
int32_t code = kpl_config_parse_args(&config, argc, argv);
KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
KPL_ASSERT(strcmp(config.module_extension, ".l") == 0, "Invalid new module extension");
}
KPL_TEST(config_io_queue_pow) {
kpl_config config;
const int32_t argc = 3;
const char *argv[] = { "./kpl", "--io-queue-pow=14", "./file.kpl" };
kpl_config_init(&config);
int32_t code = kpl_config_parse_args(&config, argc, argv);
KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
KPL_ASSERT(config.io.queue_pow == 14, "Invalid io queue power of two");
}
KPL_TEST(config_thread_count) {
kpl_config config;
const int32_t argc = 3;
const char *argv[] = { "./kpl", "--thread-count=1", "./file.kpl" };
kpl_config_init(&config);
int32_t code = kpl_config_parse_args(&config, argc, argv);
KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
KPL_ASSERT(config.thread.count == 1, "Invalid thread count");
}
|