diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 15:41:41 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 16:06:03 +0200 |
| commit | 939b9a8deae07c2f06aa16c08f3ddad70f97b261 (patch) | |
| tree | 00245f8e747349ddcca171be878e5ac19e8110a4 /tools/test_api.c | |
| parent | 91c6aa07597462705a7f30ee5b97e2c7943b5616 (diff) | |
| download | langdet-master.tar.gz langdet-master.zip | |
Diffstat (limited to 'tools/test_api.c')
| -rw-r--r-- | tools/test_api.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/test_api.c b/tools/test_api.c index 6923102..18f68b6 100644 --- a/tools/test_api.c +++ b/tools/test_api.c @@ -5,6 +5,10 @@ #include <stdlib.h> #include <string.h> +#ifdef USE_OPENBLAS +#include <cblas.h> +#endif + #define CHECK(condition) do { \ if (!(condition)) { \ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, #condition); \ @@ -40,6 +44,9 @@ int main(int argc, char **argv) { langdet_t *first = langdet_open(model_dir, 1, error, sizeof(error)); CHECK(first && !error[0]); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 1); +#endif langdet_result_t result; const char *english = "This is an English sentence."; CHECK(langdet_predict(first, english, &result, error, sizeof(error)) == 0); @@ -80,10 +87,19 @@ int main(int argc, char **argv) { langdet_t *second = langdet_open(model_dir, 4, error, sizeof(error)); CHECK(second && !error[0]); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 4); +#endif CHECK(langdet_predict(first, english, &result, error, sizeof(error)) == 0); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 1); +#endif CHECK(result.score == saved.score); langdet_free(first); CHECK(langdet_predict(second, english, &result, error, sizeof(error)) == 0); +#ifdef USE_OPENBLAS + CHECK(openblas_get_num_threads() == 4); +#endif CHECK(result.score == saved.score); langdet_free(second); puts("PASS: public API, repeated predictions, result ownership, truncation, errors, and lifecycle."); |
