summaryrefslogtreecommitdiff
path: root/app/bin/unittest/catalogtest.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
commita14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (patch)
treee469179df67a0e0db49161a43cbf8076a189f6f4 /app/bin/unittest/catalogtest.c
parent5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff)
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'app/bin/unittest/catalogtest.c')
-rw-r--r--app/bin/unittest/catalogtest.c63
1 files changed, 45 insertions, 18 deletions
diff --git a/app/bin/unittest/catalogtest.c b/app/bin/unittest/catalogtest.c
index 6025990..70eeb22 100644
--- a/app/bin/unittest/catalogtest.c
+++ b/app/bin/unittest/catalogtest.c
@@ -10,31 +10,58 @@
#include <setjmp.h>
#include <cmocka.h>
+//#include "../common.h"
#include "../include/partcatalog.h"
-TrackLibrary *trackLib;
-CatalogEntry *catalog;
+ParameterLib *trackLib;
+Catalog *catalog;
+SearchResult* result;
// some dummy functions to suppress linking problems
+const char *
wGetUserHomeDir()
{
+ return("");
+}
+
+void wPrefSetString(const char* a, const char* b, const char* c)
+{
+
+}
+char* wPrefGetString(const char* section, const char* name)
+{
+ return("");
}
-wPrefSetString()
+void AbortProg(const char* a, const char* b, int c, const char*d)
{
}
-wPrefGetString()
+void *
+MyMalloc(size_t size)
{
+ return(malloc(size));
+}
+void
+MyFree(void* memory)
+{
+ free(memory);
}
-AbortProg()
+char *
+MyStrdup(const char* string)
{
+ return(strdup(string));
+}
+void *
+MyRealloc(void *memory, size_t size)
+{
+ return(realloc(memory, size));
}
static void
@@ -49,8 +76,8 @@ static void ScanEmptyDir(void **state)
{
(void)state;
bool success;
- EmptyCatalog(trackLib->catalog);
- success = GetTrackFiles(trackLib, "//");
+ DestroyCatalog(trackLib->catalog);
+ success = CreateCatalogFromDir(trackLib, "//");
assert_false(success);
}
@@ -58,8 +85,8 @@ static void ScanTestFiles(void **state)
{
(void)state;
bool success;
- EmptyCatalog(trackLib->catalog);
- success = GetTrackFiles(trackLib, ".");
+ DestroyCatalog(trackLib->catalog);
+ success = CreateCatalogFromDir(trackLib, ".");
assert_true(success);
}
@@ -73,25 +100,25 @@ static void CreateIndex(void **state)
static void SearchNothing(void **state)
{
(void)state;
- unsigned int files = SearchLibrary(trackLib, "djfhdkljhf", catalog);
+ unsigned int files = SearchLibrary(trackLib, "djfhdkljhf", result);
assert_true(files == 0);
- EmptyCatalog(catalog);
+ SearchDiscardResult(result);
}
static void SearchSingle(void **state)
{
(void)state;
- int files = SearchLibrary(trackLib, "peco", catalog );
+ int files = SearchLibrary(trackLib, "peco", result );
assert_true(files==1);
- EmptyCatalog(catalog);
+ SearchDiscardResult(result);
}
static void SearchMultiple(void **state)
{
(void)state;
- int files = SearchLibrary(trackLib, "atlas", catalog);
+ int files = SearchLibrary(trackLib, "atlas", result);
assert_true(files == 2);
- EmptyCatalog(catalog);
+ SearchDiscardResult(result);
}
static void FilterTest(void **state)
@@ -107,7 +134,7 @@ static void FilterTest(void **state)
int main(void)
{
- const struct CMUnitTest tests[] = {
+ const struct CMUnitTest tests[] = {
cmocka_unit_test(CreateLib),
cmocka_unit_test(ScanEmptyDir),
cmocka_unit_test(ScanTestFiles),
@@ -116,9 +143,9 @@ int main(void)
cmocka_unit_test(SearchSingle),
cmocka_unit_test(SearchMultiple),
cmocka_unit_test(FilterTest),
- };
+ };
catalog = InitCatalog();
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, NULL, NULL);
} \ No newline at end of file