mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-18 05:45:46 +01:00
define short-hand types for int32/uint32 et cetera
This commit is contained in:
15
test/dat.h
15
test/dat.h
@@ -1,6 +1,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../src/util/conf.h"
|
||||
#include "../src/util/types.h"
|
||||
#include "../src/util/vec/float3.h"
|
||||
#include "t_conf.h"
|
||||
#include "t_util.h"
|
||||
@@ -9,12 +10,12 @@
|
||||
testdat tests[] = {
|
||||
{"", test_float3_norm, &(float3){2.0F, 0.67F, 5.0F} },
|
||||
{"", test_float3_norm, &(float3){0.2F, 0.4F, 0.1F} },
|
||||
{"", test_bswap16, (uint16_t[]){0x11EE, 0xEE11} },
|
||||
{"", test_bswap32, (uint32_t[]){0x1142ADEE, 0xEEAD4211} },
|
||||
{"", test_bswap64, (uint64_t[]){0x114266897799ADEE, 0xEEAD997789664211} },
|
||||
{"", test_bswap16_impl, (uint16_t[]){0x11EE, 0xEE11} },
|
||||
{"", test_bswap32_impl, (uint32_t[]){0x1142ADEE, 0xEEAD4211} },
|
||||
{"", test_bswap64_impl, (uint64_t[]){0x114266897799ADEE, 0xEEAD997789664211} },
|
||||
{"", test_bswap16, (u16[]){0x11EE, 0xEE11} },
|
||||
{"", test_bswap32, (u32[]){0x1142ADEE, 0xEEAD4211} },
|
||||
{"", test_bswap64, (u64[]){0x114266897799ADEE, 0xEEAD997789664211} },
|
||||
{"", test_bswap16_impl, (u16[]){0x11EE, 0xEE11} },
|
||||
{"", test_bswap32_impl, (u32[]){0x1142ADEE, 0xEEAD4211} },
|
||||
{"", test_bswap64_impl, (u64[]){0x114266897799ADEE, 0xEEAD997789664211} },
|
||||
{"k=v", test_procbuf, &(struct test_procbuf){"key=val", "key", "val", 0} },
|
||||
{"sometxt", test_procbuf, &(struct test_procbuf){"sometxt", "sometxt", "", CONF_ESYNTAX} },
|
||||
{"comment", test_procbuf, &(struct test_procbuf){"# comment", "", "", CONF_ENODAT} },
|
||||
@@ -27,7 +28,7 @@ testdat tests[] = {
|
||||
{"invalid", test_matchopt, &(struct test_matchopt){"nono", -1} },
|
||||
{"", test_colour32_endianess, NULL }, // NOTE: formatter is fucking with alignment making it use tabs @.@
|
||||
{"i32", test_procval_int, &(struct test_procval_int){"42", 42, CONF_I32} },
|
||||
{"i32_neg", test_procval_int, &(struct test_procval_int){"-42", (uint32_t)-42, CONF_I32} },
|
||||
{"i32_neg", test_procval_int, &(struct test_procval_int){"-42", (u32)-42, CONF_I32} },
|
||||
{"u32_max", test_procval_int, &(struct test_procval_int){"4294967295", UINT32_MAX, CONF_U64} },
|
||||
{"u64", test_procval_int, &(struct test_procval_int){"3141592653589793238", 3141592653589793238, CONF_U64}},
|
||||
{"u8_overflow", test_procval_int, &(struct test_procval_int){"256", 255, CONF_U8} },
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../src/util/conf.h"
|
||||
#include "../src/util/types.h"
|
||||
#include "test.h"
|
||||
|
||||
// Environment saver structure for conf_getpat tests
|
||||
@@ -96,19 +97,19 @@ int test_matchopt(void* arg) {
|
||||
|
||||
struct test_procval_int {
|
||||
char const* val;
|
||||
uint64_t xres;
|
||||
uint8_t type;
|
||||
u64 xres;
|
||||
u8 type;
|
||||
};
|
||||
int test_procval_int(void* arg) {
|
||||
struct test_procval_int* dat = arg;
|
||||
uint64_t out;
|
||||
u64 out;
|
||||
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) {
|
||||
(void)arg;
|
||||
float out;
|
||||
f32 out;
|
||||
return assert_true(!conf_procval(&(struct conf_entry){NULL, &out, CONF_F32}, "3.14159265")) ||
|
||||
assert_true(fabsf(out - 3.14159265F) < 1e-6F);
|
||||
}
|
||||
@@ -149,7 +150,7 @@ int test_procval_fstr_trunc(void* arg) {
|
||||
|
||||
int test_procval_eparse(void* arg) {
|
||||
(void)arg;
|
||||
int32_t out;
|
||||
i32 out;
|
||||
return assert_true(conf_procval(&(struct conf_entry){NULL, &out, CONF_I32}, "owo") == CONF_EPARSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "../src/util/colour32.h"
|
||||
#include "../src/util/compat/bswap.h"
|
||||
#include "../src/util/types.h"
|
||||
#include "../src/util/vec/float3.h"
|
||||
#include "test.h"
|
||||
|
||||
@@ -24,31 +25,31 @@ int test_colour32_endianess(void* d) {
|
||||
}
|
||||
|
||||
int test_bswap16(void* d) {
|
||||
uint16_t* arg = d;
|
||||
u16* arg = d;
|
||||
return assert_true(bswap16(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
int test_bswap32(void* d) {
|
||||
uint32_t* arg = d;
|
||||
u32* arg = d;
|
||||
return assert_true(bswap32(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
int test_bswap64(void* d) {
|
||||
uint64_t* arg = d;
|
||||
u64* arg = d;
|
||||
return assert_true(bswap64(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
int test_bswap16_impl(void* d) {
|
||||
uint16_t* arg = d;
|
||||
u16* arg = d;
|
||||
return assert_true(bswap16_impl(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
int test_bswap32_impl(void* d) {
|
||||
uint32_t* arg = d;
|
||||
u32* arg = d;
|
||||
return assert_true(bswap32_impl(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
int test_bswap64_impl(void* d) {
|
||||
uint64_t* arg = d;
|
||||
u64* arg = d;
|
||||
return assert_true(bswap64_impl(arg[0]) == arg[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user