From f094e5f5e2a06dedf6f36194f5bddb9340cd78ba Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 5 Dec 2021 00:11:44 +0500 Subject: [PATCH] Add more tests --- tests/geom_position.c | 29 +++++++++++++++++++++++++++++ tests/geom_sizes.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/geom_position.c b/tests/geom_position.c index 7cdc90a..c6d7aca 100644 --- a/tests/geom_position.c +++ b/tests/geom_position.c @@ -3,9 +3,15 @@ #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() @@ -14,3 +20,26 @@ void test_create() assert(position.x == 0); assert(position.y == 0); } + +void test_init() +{ + struct Position position = { .x = 123, .y = 456 }; + position_init(&position); + assert(position.x == 0); + assert(position.y == 0); +} + +void test_create_from_args() +{ + const struct Position position = position_create_from_args(123, 456); + assert(position.x == 123); + assert(position.y == 456); +} + +void test_init_from_args() +{ + struct Position position = { .x = 0, .y = 0 }; + position_init_from_args(&position, 123, 456); + assert(position.x == 123); + assert(position.y == 456); +} diff --git a/tests/geom_sizes.c b/tests/geom_sizes.c index 1ec52ef..2e00165 100644 --- a/tests/geom_sizes.c +++ b/tests/geom_sizes.c @@ -3,9 +3,15 @@ #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() @@ -14,3 +20,26 @@ void test_create() assert(sizes.w == 0); assert(sizes.h == 0); } + +void test_init() +{ + struct Sizes sizes = { .w = 123, .h = 456 }; + sizes_init(&sizes); + assert(sizes.w == 0); + assert(sizes.h == 0); +} + +void test_create_from_args() +{ + const struct Sizes sizes = sizes_create_from_args(123, 456); + assert(sizes.w == 123); + assert(sizes.h == 456); +} + +void test_init_from_args() +{ + struct Sizes sizes = { .w = 0, .h = 0 }; + sizes_init_from_args(&sizes, 123, 456); + assert(sizes.w == 123); + assert(sizes.h == 456); +}