aboutsummaryrefslogtreecommitdiff
path: root/mardown
diff options
context:
space:
mode:
Diffstat (limited to 'mardown')
-rw-r--r--mardown/ast_modifier_test.go22
-rw-r--r--mardown/ast_paragraph_test.go20
-rw-r--r--mardown/ast_quote_test.go23
-rw-r--r--mardown/ast_test.go61
4 files changed, 65 insertions, 61 deletions
diff --git a/mardown/ast_modifier_test.go b/mardown/ast_modifier_test.go
new file mode 100644
index 0000000..d805f22
--- /dev/null
+++ b/mardown/ast_modifier_test.go
@@ -0,0 +1,22 @@
+package mardown
+
+import "testing"
+
+func TestModifier(t *testing.T) {
+ content := `
+***bon*soir**
+`
+ lxs := lex(content)
+ tree, err := ast(lxs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ c, err := tree.Eval()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if c != "<p><b><em>bon</em>soir</b></p>" {
+ t.Errorf("failed, got %s", c)
+ t.Logf("lxs: %s\ntree: %s", lxs, tree)
+ }
+}
diff --git a/mardown/ast_paragraph_test.go b/mardown/ast_paragraph_test.go
new file mode 100644
index 0000000..8daba99
--- /dev/null
+++ b/mardown/ast_paragraph_test.go
@@ -0,0 +1,20 @@
+package mardown
+
+import "testing"
+
+func TestParagraph(t *testing.T) {
+ content := "bonsoir"
+ lxs := lex(content)
+ tree, err := ast(lxs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ c, err := tree.Eval()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if c != "<p>bonsoir</p>" {
+ t.Errorf("failed, got %s", c)
+ t.Logf("lxs: %s\ntree: %s", lxs, tree)
+ }
+}
diff --git a/mardown/ast_quote_test.go b/mardown/ast_quote_test.go
new file mode 100644
index 0000000..c3c7b3b
--- /dev/null
+++ b/mardown/ast_quote_test.go
@@ -0,0 +1,23 @@
+package mardown
+
+import "testing"
+
+func TestQuote(t *testing.T) {
+ content := `
+> Bonsoir, je suis un **code**
+avec une source
+`
+ lxs := lex(content)
+ tree, err := ast(lxs)
+ if err != nil {
+ t.Fatal(err)
+ }
+ c, err := tree.Eval()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if c != `<div class="quote"><blockquote>Bonsoir, je suis un <b>code</b></blockquote><p>avec une source</p></div>` {
+ t.Errorf("failed, got %s", c)
+ t.Logf("lxs: %s\ntree: %s", lxs, tree)
+ }
+}
diff --git a/mardown/ast_test.go b/mardown/ast_test.go
index d9033c2..4114150 100644
--- a/mardown/ast_test.go
+++ b/mardown/ast_test.go
@@ -3,65 +3,4 @@ package mardown
import "testing"
func TestAst(t *testing.T) {
- content := "bonsoir"
- lxs := lex(content)
- tree, err := ast(lxs)
- if err != nil {
- t.Fatal(err)
- }
- c, err := tree.Eval()
- if err != nil {
- t.Fatal(err)
- }
- if c != "<p>bonsoir</p>" {
- t.Errorf("failed, got %s", c)
- t.Logf("lxs: %s\ntree: %s", lxs, tree)
- }
- content = `
-***bon*soir**
-`
- lxs = lex(content)
- tree, err = ast(lxs)
- if err != nil {
- t.Fatal(err)
- }
- c, err = tree.Eval()
- if err != nil {
- t.Fatal(err)
- }
- if c != "<p><b><em>bon</em>soir</b></p>" {
- t.Errorf("failed, got %s", c)
- t.Logf("lxs: %s\ntree: %s", lxs, tree)
- }
- content = "je suis un `code`"
- lxs = lex(content)
- tree, err = ast(lxs)
- if err != nil {
- t.Fatal(err)
- }
- c, err = tree.Eval()
- if err != nil {
- t.Fatal(err)
- }
- if c != "<p>je suis un <code>code</code></p>" {
- t.Errorf("failed, got %s", c)
- t.Logf("lxs: %s\ntree: %s", lxs, tree)
- }
- content = `
-> Bonsoir, je suis un **code**
-avec une source
-`
- lxs = lex(content)
- tree, err = ast(lxs)
- if err != nil {
- t.Fatal(err)
- }
- c, err = tree.Eval()
- if err != nil {
- t.Fatal(err)
- }
- if c != `<div class="quote"><blockquote>Bonsoir, je suis un <b>code</b></blockquote><p>avec une source</p></div>` {
- t.Errorf("failed, got %s", c)
- t.Logf("lxs: %s\ntree: %s", lxs, tree)
- }
}