Add tests for BasicGeom

This commit is contained in:
Alex Kotov 2021-12-05 00:31:40 +05:00
parent c2f9dfc992
commit f0182e8d49
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 61 additions and 0 deletions

View file

@ -36,6 +36,7 @@ DWM_SRC = \
src/dwm/xerror.c src/dwm/xerror.c
TEST_SRC = \ TEST_SRC = \
tests/geom_basic_geom.c \
tests/geom_position.c \ tests/geom_position.c \
tests/geom_sizes.c tests/geom_sizes.c

60
tests/geom_basic_geom.c Normal file
View file

@ -0,0 +1,60 @@
#include <assert.h>
#include "../src/geom.h"
static void test_create();
static void test_init();
static void test_create_from_args();
static void test_init_from_args();
void test() {
test_create();
test_init();
test_create_from_args();
test_init_from_args();
}
void test_create()
{
const struct BasicGeom basic_geom = basic_geom_create();
assert(basic_geom.position.x == 0);
assert(basic_geom.position.y == 0);
assert(basic_geom.sizes.w == 0);
assert(basic_geom.sizes.h == 0);
}
void test_init()
{
struct BasicGeom basic_geom = {
.position = { .x = 12, .y = 34 },
.sizes = { .w = 56, .h = 68 },
};
basic_geom_init(&basic_geom);
assert(basic_geom.position.x == 0);
assert(basic_geom.position.y == 0);
assert(basic_geom.sizes.w == 0);
assert(basic_geom.sizes.h == 0);
}
void test_create_from_args()
{
const struct BasicGeom basic_geom =
basic_geom_create_from_args(12, 34, 56, 78);
assert(basic_geom.position.x == 12);
assert(basic_geom.position.y == 34);
assert(basic_geom.sizes.w == 56);
assert(basic_geom.sizes.h == 78);
}
void test_init_from_args()
{
struct BasicGeom basic_geom = {
.position = { .x = 0, .y = 0 },
.sizes = { .w = 0, .h = 0 },
};
basic_geom_init_from_args(&basic_geom, 12, 34, 56, 78);
assert(basic_geom.position.x == 12);
assert(basic_geom.position.y == 34);
assert(basic_geom.sizes.w == 56);
assert(basic_geom.sizes.h == 78);
}