about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.c151
-rw-r--r--tests/test26.gmi1
-rw-r--r--tests/test27.gmi1
-rw-r--r--tests/test28.gmi1
-rw-r--r--tests/test29.gmi1
-rw-r--r--tests/test30.gmi1
6 files changed, 155 insertions, 1 deletions
diff --git a/tests/test.c b/tests/test.c
index 0854add..67cbcdc 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -92,6 +92,16 @@ const char *decodetest24 =
 "nospace";
 const char *decodetest25 =
 "yesspace";
+const char *decodetest26 =
+"Spaced heading";
+const char *decodetest27 =
+"Spaced heading";
+const char *decodetest28 =
+"Spaced heading";
+const char *decodetest29 =
+"Unspaced heading";
+const char *decodetest30 =
+"Unspaced heading";
 
 const char *encodetest1 =
 "### 2cu3nfTLaEpx1Ztbbvhy4Jg5Kj-D-bwXafbK8Ma73QGBTJap7u0Uvco_YO0X-H_d_tSbJh_N";
@@ -179,7 +189,16 @@ const char *encodetest24 =
 "=> nospace";
 const char *encodetest25 =
 "=> yesspace";
-
+const char *encodetest26 =
+"# Spaced heading";
+const char *encodetest27 =
+"## Spaced heading";
+const char *encodetest28 =
+"### Spaced heading";
+const char *encodetest29 =
+"# Unspaced heading";
+const char *encodetest30 =
+"## Unspaced heading";
 
 static void
 FAIL(char *msg)
@@ -827,6 +846,131 @@ test_25(void)
 	PASS("Test25");
 }
 
+static void
+test_26(void)
+{
+	struct gemtext_h1 *t;
+	char *text;
+
+	t = gemtext_decode_file("test26.gmi");
+	if (t == NULL)
+		FAIL("Test26");
+
+	if (t->type != GEMTEXT_H1)
+		FAIL("Test26");
+	if (strcmp(t->text, decodetest26) != 0)
+		FAIL("Test26");
+
+	if (gemtext_encode((struct gemtext *)t, &text, NULL) == -1)
+		FAIL("Test26");
+	if (strcmp(text, encodetest26) != 0)
+		FAIL("Test26");
+
+	free(text);
+	gemtext_free(t);
+	PASS("Test26");
+}
+
+static void
+test_27(void)
+{
+	struct gemtext_h2 *t;
+	char *text;
+
+	t = gemtext_decode_file("test27.gmi");
+	if (t == NULL)
+		FAIL("Test27");
+
+	if (t->type != GEMTEXT_H2)
+		FAIL("Test27");
+	if (strcmp(t->text, decodetest27) != 0)
+		FAIL("Test27");
+
+	if (gemtext_encode((struct gemtext *)t, &text, NULL) == -1)
+		FAIL("Test27");
+	if (strcmp(text, encodetest27) != 0)
+		FAIL("Test27");
+
+	free(text);
+	gemtext_free(t);
+	PASS("Test27");
+}
+
+static void
+test_28(void)
+{
+	struct gemtext_h3 *t;
+	char *text;
+
+	t = gemtext_decode_file("test28.gmi");
+	if (t == NULL)
+		FAIL("Test28");
+
+	if (t->type != GEMTEXT_H3)
+		FAIL("Test28");
+	if (strcmp(t->text, decodetest28) != 0)
+		FAIL("Test28");
+
+	if (gemtext_encode((struct gemtext *)t, &text, NULL) == -1)
+		FAIL("Test28");
+	if (strcmp(text, encodetest28) != 0)
+		FAIL("Test28");
+
+	free(text);
+	gemtext_free(t);
+	PASS("Test28");
+}
+
+static void
+test_29(void)
+{
+	struct gemtext_h1 *t;
+	char *text;
+
+	t = gemtext_decode_file("test29.gmi");
+	if (t == NULL)
+		FAIL("Test29");
+
+	if (t->type != GEMTEXT_H1)
+		FAIL("Test29");
+	if (strcmp(t->text, decodetest29) != 0)
+		FAIL("Test29");
+
+	if (gemtext_encode((struct gemtext *)t, &text, NULL) == -1)
+		FAIL("Test29");
+	if (strcmp(text, encodetest29) != 0)
+		FAIL("Test29");
+
+	free(text);
+	gemtext_free(t);
+	PASS("Test29");
+}
+
+static void
+test_30(void)
+{
+	struct gemtext_h2 *t;
+	char *text;
+
+	t = gemtext_decode_file("test30.gmi");
+	if (t == NULL)
+		FAIL("Test30");
+
+	if (t->type != GEMTEXT_H2)
+		FAIL("Test30");
+	if (strcmp(t->text, decodetest30) != 0)
+		FAIL("Test30");
+
+	if (gemtext_encode((struct gemtext *)t, &text, NULL) == -1)
+		FAIL("Test30");
+	if (strcmp(text, encodetest30) != 0)
+		FAIL("Test30");
+
+	free(text);
+	gemtext_free(t);
+	PASS("Test30");
+}
+
 int
 main(void)
 {
@@ -855,6 +999,11 @@ main(void)
 	test_23();
 	test_24();
 	test_25();
+	test_26();
+	test_27();
+	test_28();
+	test_29();
+	test_30();
 
 	return 0;
 }
diff --git a/tests/test26.gmi b/tests/test26.gmi
new file mode 100644
index 0000000..b5b1ada
--- /dev/null
+++ b/tests/test26.gmi
@@ -0,0 +1 @@
+#    Spaced heading
diff --git a/tests/test27.gmi b/tests/test27.gmi
new file mode 100644
index 0000000..7022ae5
--- /dev/null
+++ b/tests/test27.gmi
@@ -0,0 +1 @@
+##   Spaced heading
diff --git a/tests/test28.gmi b/tests/test28.gmi
new file mode 100644
index 0000000..f024520
--- /dev/null
+++ b/tests/test28.gmi
@@ -0,0 +1 @@
+###  Spaced heading
diff --git a/tests/test29.gmi b/tests/test29.gmi
new file mode 100644
index 0000000..3fc347f
--- /dev/null
+++ b/tests/test29.gmi
@@ -0,0 +1 @@
+#Unspaced heading
diff --git a/tests/test30.gmi b/tests/test30.gmi
new file mode 100644
index 0000000..a0be8cf
--- /dev/null
+++ b/tests/test30.gmi
@@ -0,0 +1 @@
+##Unspaced heading