mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 08:15:44 +01:00
apply new formatting rules
This commit is contained in:
@@ -11,15 +11,15 @@
|
||||
// Environment saver structure for conf_getpat tests
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
||||
struct test_getpat_envdat {
|
||||
char* xdg_config_home;
|
||||
char* home;
|
||||
char* appdata;
|
||||
char* userprofile;
|
||||
char *xdg_config_home;
|
||||
char *home;
|
||||
char *appdata;
|
||||
char *userprofile;
|
||||
};
|
||||
|
||||
/* save the current environment variables */
|
||||
static void env_save(struct test_getpat_envdat* s) {
|
||||
char const* tmp;
|
||||
static void env_save(struct test_getpat_envdat *s) {
|
||||
char const *tmp;
|
||||
|
||||
tmp = getenv("XDG_CONFIG_HOME");
|
||||
s->xdg_config_home = tmp ? strdup(tmp) : NULL;
|
||||
@@ -35,7 +35,7 @@ static void env_save(struct test_getpat_envdat* s) {
|
||||
}
|
||||
|
||||
/* restores the environment variables to what they were before */
|
||||
static void env_restore(struct test_getpat_envdat* s) {
|
||||
static void env_restore(struct test_getpat_envdat *s) {
|
||||
#ifdef _WIN32
|
||||
if (s->xdg_config_home) _putenv_s("XDG_CONFIG_HOME", s->xdg_config_home);
|
||||
else _putenv("XDG_CONFIG_HOME=");
|
||||
@@ -64,13 +64,13 @@ static void env_restore(struct test_getpat_envdat* s) {
|
||||
|
||||
/* check procbuf's functionality */
|
||||
struct test_procbuf {
|
||||
char const* in; // data in
|
||||
char const* xkey; // expected key
|
||||
char const* xval; // expected value
|
||||
char const *in; // data in
|
||||
char const *xkey; // expected key
|
||||
char const *xval; // expected value
|
||||
int xret; // expected return type
|
||||
};
|
||||
int test_procbuf(void* arg) {
|
||||
struct test_procbuf* dat = arg;
|
||||
int test_procbuf(void *arg) {
|
||||
struct test_procbuf *dat = arg;
|
||||
size_t len = strlen(dat->in) + 1;
|
||||
char k[len], v[len];
|
||||
*k = '\0', *v = '\0';
|
||||
@@ -81,58 +81,58 @@ int test_procbuf(void* arg) {
|
||||
|
||||
/* check matchopt functionality */
|
||||
struct test_matchopt {
|
||||
char const* key; // key to search for (key1, key2, key3)
|
||||
char const *key; // key to search for (key1, key2, key3)
|
||||
int xidx; // expect index (<0 is NULL, may not be more than 2)
|
||||
};
|
||||
int test_matchopt(void* arg) {
|
||||
struct test_matchopt* dat = arg;
|
||||
int test_matchopt(void *arg) {
|
||||
struct test_matchopt *dat = arg;
|
||||
struct conf_entry opts[] = {
|
||||
{"key1", NULL, 0},
|
||||
{"key2", NULL, 0},
|
||||
{"key3", NULL, 0},
|
||||
};
|
||||
struct conf_entry* xopt = dat->xidx < 0 ? NULL : opts + dat->xidx;
|
||||
struct conf_entry *xopt = dat->xidx < 0 ? NULL : opts + dat->xidx;
|
||||
return assert_true(conf_matchopt(opts, 3, dat->key) == xopt);
|
||||
}
|
||||
|
||||
struct test_procval_int {
|
||||
char const* val;
|
||||
char const *val;
|
||||
u64 xres;
|
||||
u8 type;
|
||||
};
|
||||
int test_procval_int(void* arg) {
|
||||
struct test_procval_int* dat = arg;
|
||||
int test_procval_int(void *arg) {
|
||||
struct test_procval_int *dat = arg;
|
||||
u64 out = 0;
|
||||
return assert_true(!conf_procval(&(struct conf_entry){NULL, &out, dat->type}, dat->val)) ||
|
||||
assert_true(out == dat->xres);
|
||||
}
|
||||
|
||||
int test_procval_f32(void* arg) {
|
||||
int test_procval_f32(void *arg) {
|
||||
(void)arg;
|
||||
f32 out;
|
||||
return assert_true(!conf_procval(&(struct conf_entry){NULL, &out, CONF_F32}, "3.14159265")) ||
|
||||
assert_true(fabsf(out - 3.14159265F) < 1e-6F);
|
||||
}
|
||||
|
||||
int test_procval_str(void* arg) {
|
||||
int test_procval_str(void *arg) {
|
||||
(void)arg;
|
||||
char* out = NULL;
|
||||
int ret = assert_true(!conf_procval(&(struct conf_entry){NULL, (void*)&out, CONF_STR}, "here comes the sowon")) ||
|
||||
char *out = NULL;
|
||||
int ret = assert_true(!conf_procval(&(struct conf_entry){NULL, (void *)&out, CONF_STR}, "here comes the sowon")) ||
|
||||
assert_false(strcmp("here comes the sowon", out));
|
||||
free(out);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_procval_str_predef(void* arg) {
|
||||
int test_procval_str_predef(void *arg) {
|
||||
(void)arg;
|
||||
char* out = strdup("owo");
|
||||
int ret = assert_true(!conf_procval(&(struct conf_entry){NULL, (void*)&out, CONF_STR}, "i leak if I don't free")) ||
|
||||
char *out = strdup("owo");
|
||||
int ret = assert_true(!conf_procval(&(struct conf_entry){NULL, (void *)&out, CONF_STR}, "i leak if I don't free")) ||
|
||||
assert_true(!strcmp("i leak if I don't free", out));
|
||||
free(out);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_procval_fstr(void* arg) {
|
||||
int test_procval_fstr(void *arg) {
|
||||
(void)arg;
|
||||
char buf[16];
|
||||
struct conf_fstr str = {sizeof(buf), buf};
|
||||
@@ -140,7 +140,7 @@ int test_procval_fstr(void* arg) {
|
||||
assert_true(!strcmp(str.out, "hewwoo wowld"));
|
||||
}
|
||||
|
||||
int test_procval_fstr_trunc(void* arg) {
|
||||
int test_procval_fstr_trunc(void *arg) {
|
||||
(void)arg;
|
||||
char buf[8];
|
||||
struct conf_fstr str = {sizeof(buf), buf};
|
||||
@@ -148,19 +148,19 @@ int test_procval_fstr_trunc(void* arg) {
|
||||
assert_true(!strcmp(str.out, "hewwooo"));
|
||||
}
|
||||
|
||||
int test_procval_eparse(void* arg) {
|
||||
int test_procval_eparse(void *arg) {
|
||||
(void)arg;
|
||||
i32 out;
|
||||
return assert_true(conf_procval(&(struct conf_entry){NULL, &out, CONF_I32}, "owo") == CONF_EPARSE);
|
||||
}
|
||||
|
||||
/* ensure paths are being set correctly */
|
||||
int test_getpat(void* arg) {
|
||||
int test_getpat(void *arg) {
|
||||
(void)arg;
|
||||
struct test_getpat_envdat envs;
|
||||
env_save(&envs);
|
||||
int ret = 0;
|
||||
char* path = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
#ifdef __linux__
|
||||
setenv("XDG_CONFIG_HOME", "/test/config", 1);
|
||||
@@ -196,7 +196,7 @@ int test_getpat(void* arg) {
|
||||
|
||||
_putenv("USERPROFILE=");
|
||||
#endif
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
ret |= assert_true(!(ptr = conf_getpat("anything")));
|
||||
free(ptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user