summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run_tests.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/run_tests.cpp b/tests/run_tests.cpp
new file mode 100644
index 0000000..65ae47c
--- /dev/null
+++ b/tests/run_tests.cpp
@@ -0,0 +1,127 @@
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <stdio.h>
+
+#include "greatest.h"
+#include "timer.h"
+
+#include "strops.hpp"
+#include "administration.hpp"
+#include "administration_reader.hpp"
+#include "administration_writer.hpp"
+
+char* test_file_path = "C:\\Users\\aldri\\Desktop\\Vault\\Projects\\accounting\\build\\test.openbook";
+
+TEST _administration_rw_taxbrackets(void)
+{
+ country_tax_bracket pw;
+ country_tax_bracket pr;
+ u32 count;
+
+ administration_writer_create();
+
+ administration_create_empty(test_file_path);
+ {
+ pw = administration_tax_bracket_create_empty();
+ strops_copy(pw.country_code, "NL", sizeof(pw.country_code));
+ pw.rate = 10.0f;
+ strops_copy(pw.category_code, "S", sizeof(pw.category_code));
+
+ count = administration_tax_bracket_count();
+ administration_tax_bracket_add(pw);
+
+ ASSERT_EQ(count+1, administration_tax_bracket_count());
+ }
+
+ administration_reader_open_existing(test_file_path);
+ {
+ ASSERT_EQ(count+1, administration_tax_bracket_count());
+ ASSERT_EQ(1, administration_tax_bracket_get_by_id(&pr, pw.id));
+ ASSERT_STR_EQ(pr.id, pw.id);
+ ASSERT_STR_EQ(pr.country_code, pw.country_code);
+ ASSERT_STR_EQ(pr.category_code, pw.category_code);
+ ASSERT_EQ(pr.rate, pw.rate);
+ }
+
+ unlink(test_file_path);
+
+ PASS();
+}
+
+TEST _administration_rw_costcenter(void)
+{
+ cost_center pw;
+ cost_center pr;
+ u32 count;
+
+ administration_writer_create();
+
+ administration_create_empty(test_file_path);
+ {
+ pw = administration_cost_center_create_empty();
+ strops_copy(pw.code, "CODE", sizeof(pw.code));
+ strops_copy(pw.description, "Description", sizeof(pw.description));
+
+ count = administration_cost_center_count();
+ administration_cost_center_add(pw);
+
+ ASSERT_EQ(count+1, administration_cost_center_count());
+ }
+
+ administration_reader_open_existing(test_file_path);
+ {
+ ASSERT_EQ(count+1, administration_cost_center_count());
+ ASSERT_EQ(1, administration_cost_center_get_by_id(&pr, pw.id));
+ ASSERT_STR_EQ(pr.id, pw.id);
+ ASSERT_STR_EQ(pr.code, pw.code);
+ ASSERT_STR_EQ(pr.description, pw.description);
+ }
+
+ unlink(test_file_path);
+
+ PASS();
+}
+
+TEST _administration_rw_project(void)
+{
+ project pw;
+ project pr;
+
+ administration_writer_create();
+
+ administration_create_empty(test_file_path);
+ {
+ pw = administration_project_create_empty();
+ strops_copy(pw.description, "Test Project", sizeof(pw.description));
+ administration_project_add(pw);
+
+ ASSERT_EQ(1, administration_project_count());
+ }
+
+ administration_reader_open_existing(test_file_path);
+ {
+ ASSERT_EQ(1, administration_project_count());
+ ASSERT_EQ(1, administration_project_get_by_id(&pr, pw.id));
+ ASSERT_STR_EQ(pr.id, pw.id);
+ ASSERT_STR_EQ(pr.description, pw.description);
+ }
+
+ unlink(test_file_path);
+
+ PASS();
+}
+
+SUITE(administration_io) {
+ RUN_TEST(_administration_rw_taxbrackets);
+ RUN_TEST(_administration_rw_costcenter);
+ RUN_TEST(_administration_rw_project);
+}
+
+GREATEST_MAIN_DEFS();
+int main(int argc, char **argv) {
+ timer_lib_initialize();
+
+ GREATEST_MAIN_BEGIN();
+ RUN_SUITE(administration_io);
+ GREATEST_MAIN_END();
+} \ No newline at end of file