diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-11-01 08:58:34 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-11-01 08:58:34 +0100 |
| commit | 9b8664daf17dac9efb1f4add9d00c562e4ddbf40 (patch) | |
| tree | 6c3396be134996ee3ce75b0ff9a2eca09452104d /src | |
| parent | 60488d722bf29f3ff0ce3e08b90f30523a8d7b6d (diff) | |
fix tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/administration_writer.cpp | 48 | ||||
| -rw-r--r-- | src/countries.cpp | 2 | ||||
| -rw-r--r-- | src/countries/nl.cpp | 2 |
3 files changed, 42 insertions, 10 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index c45ec6e..c699a0a 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -54,8 +54,12 @@ static void on_administration_data_changed() if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, 0); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_administration_data_deleted(char id[MAX_LEN_ID]) @@ -75,8 +79,12 @@ static void on_administration_data_deleted(char id[MAX_LEN_ID]) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)id_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_invoice_changed(invoice* inv) @@ -97,8 +105,12 @@ static void on_invoice_changed(invoice* inv) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)inv_copy2); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_contact_changed_changed(contact* cc) @@ -107,19 +119,23 @@ static void on_contact_changed_changed(contact* cc) contact* cc_copy = (contact*)memops::alloc(sizeof(contact)); memops::copy(cc_copy, cc, sizeof(contact)); - + auto* func = new auto([](void* arg) { contact* cc = (contact*)arg; administration_writer::save_contact_blocking(*cc); administration_writer::save_administration_info_blocking(); memops::unalloc(arg); - + _is_writing = false; if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)cc_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_taxrate_changed_changed(tax_rate* rate) @@ -139,8 +155,12 @@ static void on_taxrate_changed_changed(tax_rate* rate) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)rate_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_costcenter_changed_changed(cost_center* cc) @@ -159,8 +179,12 @@ static void on_costcenter_changed_changed(cost_center* cc) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)cc_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_project_changed_changed(project* pp) @@ -180,8 +204,12 @@ static void on_project_changed_changed(project* pp) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; - thrd_t thr; thrd_create(&thr, trampoline, (void*)pp_copy); + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; + thrd_t thr; thrd_create(&thr, trampoline, (void*)pp_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } bool administration_writer::create() diff --git a/src/countries.cpp b/src/countries.cpp index 337b10b..34aacf1 100644 --- a/src/countries.cpp +++ b/src/countries.cpp @@ -312,5 +312,7 @@ u32 country::get_available_tax_rates(char* country_code, tax_rate* buffer, u32 b s32 index = get_index_by_country_code(country_code); assert(index != -1); + if (!country_map[index].get_available_tax_rates) return 0; + return country_map[index].get_available_tax_rates(buffer, buffer_size); }
\ No newline at end of file diff --git a/src/countries/nl.cpp b/src/countries/nl.cpp index c4abc9d..8a56e71 100644 --- a/src/countries/nl.cpp +++ b/src/countries/nl.cpp @@ -30,6 +30,7 @@ #include <math.h> #include "countries.hpp" +#include "memops.hpp" #include "strops.hpp" time_t _nl_get_default_invoice_expire_duration() @@ -172,6 +173,7 @@ static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, char* static tax_rate _create_tax_rate(tax_rate_type type, char* internal_code, float rate, ...) { tax_rate result; + memops::zero(&result, sizeof(tax_rate)); result.type = type; result.tax_section_count = 0; result.rate = rate; |
