summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-10-20 09:34:26 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-10-20 09:34:26 +0200
commit5c22a35be47a10f85107107a9124ec401e6cd28d (patch)
tree32953b14f791d0dee055543245039e37396c0cc1 /tests
parentfdc74456a98fe9076ff5d029b37cdf5fdd18b1d1 (diff)
tax tests
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp3
-rw-r--r--tests/tax_tests.cpp46
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index d9bd1c9..04b4407 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -3,7 +3,7 @@
#include "administration_rw_tests.cpp"
#include "administration_validation_tests.cpp"
#include "peppol_write_tests.cpp"
-
+#include "tax_tests.cpp"
#include "nl_tax_tests.cpp"
GREATEST_MAIN_DEFS();
@@ -12,6 +12,7 @@ int main(int argc, char **argv) {
GREATEST_MAIN_BEGIN();
RUN_SUITE(nl_tax_statement);
+ RUN_SUITE(tax_generic_tests);
RUN_SUITE(administration_rw);
RUN_SUITE(administration_validate);
RUN_SUITE(peppol_write);
diff --git a/tests/tax_tests.cpp b/tests/tax_tests.cpp
new file mode 100644
index 0000000..3debaa8
--- /dev/null
+++ b/tests/tax_tests.cpp
@@ -0,0 +1,46 @@
+TEST _tax_uniqueness_test(void)
+{
+ s32 country_count = country::get_count();
+
+ for (s32 i = 0; i < country_count; i++)
+ {
+ tax_rate* trb1 = (tax_rate*)memops::alloc(sizeof(tax_rate) * 500);
+ u32 trc1 = country::get_available_tax_rates(country::get_code_by_index(i), trb1, 500);
+
+ // check for duplicates in country.
+ for (u32 x1 = 0; x1 < trc1; x1++)
+ {
+ for (u32 x2 = 0; x2 < trc1; x2++)
+ {
+ if (x1 == x2) continue;
+ if (strops::equals(trb1[x1].internal_code, trb1[x2].internal_code)) {
+ FAIL();
+ }
+ }
+ }
+
+ // cross check with other countries.
+ for (s32 x = 0; x < country_count; x++)
+ {
+ if (x==i) continue;
+ tax_rate* trb2 = (tax_rate*)memops::alloc(sizeof(tax_rate) * 500);
+ u32 trc2 = country::get_available_tax_rates(country::get_code_by_index(x), trb2, 500);
+
+ for (u32 x1 = 0; x1 < trc1; x1++)
+ {
+ for (u32 x2 = 0; x2 < trc2; x2++)
+ {
+ if (strops::equals(trb1[x1].internal_code, trb2[x2].internal_code)) {
+ FAIL();
+ }
+ }
+ }
+ }
+ }
+
+ PASS();
+}
+
+SUITE(tax_generic_tests) {
+ RUN_TEST(_tax_uniqueness_test);
+} \ No newline at end of file