Summary Files Commits Branches @commit @diff @stats
path: root / uri_test.c
diff options
context:
space:
mode:
Commit59f1c5d4dbcebc48d1d408dba0be2959d7970167 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-02-04 09:14:42 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-02-04 09:14:42 +0100
Files98e92b3ace336ba236e9d5e07c15648d070378c0 /uri_test.c
goodwolf-0.5.0-rc.1.tar
goodwolf-0.5.0-rc.1.tar.gz
goodwolf-0.5.0-rc.1.zip
Parent9765887719fd5c3f784d30084111243caf90f16f (diff)
Parenteb974dcccdbcb35fa067ace053bc1fac7406b768 (diff)
Merge branch 'release-0.5' v0.5.0-rc.1
1 files changed, 61 insertions, 0 deletions
-rw-r--r--uri_test.c61
diff --git a/uri_test.c b/uri_test.c
new file mode 100644
index 0000000..5881120
--- /dev/null
+++ b/uri_test.c
@@ -0,0 +1,61 @@
+// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "uri.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+static void
+badwolf_ensure_uri_scheme_test(void)
+{
+ const gchar *fallback = "about:blank";
+
+ struct
+ {
+ const gchar *expect;
+ const gchar *text;
+ gboolean try_file;
+ } cases[] = {
+ //
+ {"http://uri.c", "http://uri.c", FALSE},
+ {"http://uri.c", "http://uri.c", TRUE},
+ {"file:///dev/null", "file:///dev/null", FALSE},
+ {"file:///dev/null", "file:///dev/null", TRUE},
+ {fallback, NULL, FALSE},
+ {fallback, NULL, TRUE},
+ {fallback, "", FALSE},
+ {fallback, "", TRUE},
+ {"http:///dev/null", "/dev/null", FALSE},
+ {"file:///dev/null", "/dev/null", TRUE},
+ {"http://example.org", "example.org", FALSE},
+ {"http://example.org", "example.org", TRUE},
+ {"http://", "http://", FALSE},
+ {"http://", "http://", TRUE} //
+ };
+
+ for(size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); i++)
+ {
+ g_info("badwolf_ensure_uri_scheme(\"%s\", %s)",
+ cases[i].text,
+ cases[i].try_file ? "TRUE" : "FALSE");
+
+ const gchar *got = badwolf_ensure_uri_scheme(cases[i].text, cases[i].try_file);
+
+ if(g_strcmp0(got, cases[i].expect) != 0)
+ {
+ g_error("expected: \"%s\", got: \"%s\"", cases[i].expect, got);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/badwolf_ensure_uri_scheme/test", badwolf_ensure_uri_scheme_test);
+
+ return g_test_run();
+}