aboutsummaryrefslogtreecommitdiff
path: root/src/tests/config.c
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-07 02:02:45 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-07 02:02:45 +0300
commite3a41da5a0a3d70ac53591f2b66144f2be2b3871 (patch)
tree789cc69b05f2447c11f04dbb6ae972ffa0acd1c9 /src/tests/config.c
downloadrevela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.tar.gz
revela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.zip
Initial commit.
Almost functional but still missing features and lacking testing.
Diffstat (limited to 'src/tests/config.c')
-rw-r--r--src/tests/config.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/config.c b/src/tests/config.c
new file mode 100644
index 0000000..8d86a2f
--- /dev/null
+++ b/src/tests/config.c
@@ -0,0 +1,54 @@
+#include <string.h>
+
+#include "tests/tests.h"
+#include "config.h"
+#include "log.h"
+
+#define TESTS_DIR "tests"
+#define TEST_ALBUM "tests/album.ini"
+
+static void
+test_site_config_read_ini(void)
+{
+ struct site_config *config = site_config_init();
+ asserteq(site_config_read_ini(TESTS_DIR, config), true);
+ asserteq(strcmp(config->title, "An example gallery"), 0);
+ asserteq(strcmp(config->base_url, "http://www.example.com/photos"), 0);
+ asserteq(config->max_previews, 20);
+ asserteq(config->images.strip, false);
+ asserteq(config->images.quality, 80);
+ asserteq(config->images.max_width, 3000);
+ asserteq(config->images.max_height, 2000);
+ asserteq(config->images.smart_resize, true);
+ asserteq(config->thumbnails.strip, true);
+ asserteq(config->thumbnails.quality, 75);
+ asserteq(config->thumbnails.max_width, 400);
+ asserteq(config->thumbnails.max_height, 270);
+ asserteq(config->thumbnails.smart_resize, true);
+ site_config_destroy(config);
+}
+
+static void
+test_album_config_read_ini(void)
+{
+ struct album_config *config = album_config_init();
+ asserteq(album_config_read_ini(TEST_ALBUM, config), true);
+ asserteq(strcmp(config->title, "An example album"), 0);
+ asserteq(strcmp(config->desc, "Example description"), 0);
+ album_config_destroy(config);
+}
+
+static void
+init(void)
+{
+ log_set_verbosity(LOG_SILENT);
+}
+
+int
+main(void)
+{
+ INIT_TESTS();
+ init();
+ RUN_TEST(test_site_config_read_ini);
+ RUN_TEST(test_album_config_read_ini);
+}