aboutsummaryrefslogtreecommitdiff
path: root/c_implementation/tests
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-04-24 02:01:54 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-04-24 02:01:54 +0300
commit79f022b3a5b1d3f7bfda3762ceacc88dd971fd39 (patch)
tree0e5491a18400ee6dd43d8e87d6ca3e5ead3aba85 /c_implementation/tests
parent22d9aeb0f3057c43cf7c561bc208c3acec45135e (diff)
downloadarching-kaos-tools-79f022b3a5b1d3f7bfda3762ceacc88dd971fd39.tar.gz
arching-kaos-tools-79f022b3a5b1d3f7bfda3762ceacc88dd971fd39.tar.bz2
arching-kaos-tools-79f022b3a5b1d3f7bfda3762ceacc88dd971fd39.zip
[libaksettings] Updates
Diffstat (limited to 'c_implementation/tests')
-rw-r--r--c_implementation/tests/test_aksettings.c58
-rw-r--r--c_implementation/tests/test_aksettings_read.c2
2 files changed, 56 insertions, 4 deletions
diff --git a/c_implementation/tests/test_aksettings.c b/c_implementation/tests/test_aksettings.c
index 3a74444..4e7a091 100644
--- a/c_implementation/tests/test_aksettings.c
+++ b/c_implementation/tests/test_aksettings.c
@@ -2,13 +2,32 @@
#include <libaklog.h>
#include <stdio.h>
-int test_ak_settings_read_write_example()
+static int test_ak_settings_read_example()
{
printf("Testing: %s\n", __func__);
if (!ak_settings_load_settings_binary())
{
ak_log_warning(__func__, "No existing settings or error loading.\n");
}
+ const char *bindir = ak_settings_get_setting("AK_BINDIR");
+ if (bindir)
+ {
+ char *some_text;
+ asprintf(&some_text, "Current bin directory: %s\n", bindir);
+ ak_log_info(__func__, some_text);
+ }
+ ak_settings_free_settings();
+ return 0;
+}
+
+static int test_ak_settings_read_write_example()
+{
+ printf("Testing: %s\n", __func__);
+ if (!ak_settings_load_settings_binary())
+ {
+ ak_log_warning(__func__, "No existing settings or error loading.\n");
+ }
+ ak_settings_import_from_environment();
ak_settings_set_setting("username", "john_doe");
ak_settings_set_setting("theme", "dark");
ak_settings_set_setting("volume", "75");
@@ -26,11 +45,18 @@ int test_ak_settings_read_write_example()
asprintf(&some_text, "Current theme: %s\n", theme);
ak_log_info(__func__, some_text);
}
+ const char *bindir = ak_settings_get_setting("AK_BINDIR");
+ if (bindir)
+ {
+ char *some_text;
+ asprintf(&some_text, "Current bin directory: %s\n", bindir);
+ ak_log_info(__func__, some_text);
+ }
ak_settings_free_settings();
return 0;
}
-int test_ak_settings()
+static int test_ak_settings()
{
char *some_text;
if ( test_ak_settings_read_write_example() == 0 )
@@ -47,7 +73,33 @@ int test_ak_settings()
}
}
+static void test_import()
+{
+ ak_settings_import_from_environment();
+}
+
+static int test_read_and_dump()
+{
+ printf("Testing: %s\n", __func__);
+ if (!ak_settings_load_settings_binary())
+ {
+ ak_log_warning(__func__, "No existing settings or error loading.\n");
+ }
+ AKSetting* ak_settings;
+ ak_settings = ak_settings_get_all();
+ for ( int i = 0; ak_settings[i].key != NULL; ++i )
+ {
+ printf("%s=%s\n", ak_settings[i].key, ak_settings[i].value);
+ }
+ ak_settings_free_settings();
+ return 0;
+}
+
int main()
{
- return test_ak_settings();
+ test_import();
+ test_ak_settings();
+ test_ak_settings_read_example();
+ test_read_and_dump();
+ return 0;
}
diff --git a/c_implementation/tests/test_aksettings_read.c b/c_implementation/tests/test_aksettings_read.c
index ddef12f..e4a1061 100644
--- a/c_implementation/tests/test_aksettings_read.c
+++ b/c_implementation/tests/test_aksettings_read.c
@@ -2,7 +2,7 @@
#include <libaklog.h>
#include <stdio.h>
-void test_ak_settings_from_file()
+static void test_ak_settings_from_file()
{
printf("Testing: %s\n", __func__);
if (!ak_settings_load_settings_binary()) {