diff --git a/index_test.go b/index_test.go new file mode 100644 index 0000000..38103e0 --- /dev/null +++ b/index_test.go @@ -0,0 +1,50 @@ +/* Copyright (c) 2015, Daniel Martí */ +/* See LICENSE for licensing information */ + +package fdroidcl + +import ( + "bytes" + "testing" +) + +func TestTextDesc(t *testing.T) { + for _, c := range []struct { + in string + want string + }{ + { + "Simple description.", + "Simple description.", + }, + { + "

Simple description.

", + "Simple description.\n", + }, + { + "

Multiple

Paragraphs

", + "Multiple\n\nParagraphs\n", + }, + { + "

Unordered list:

", + "Unordered list:\n\n * Item\n * Another item\n", + }, + { + "

Link: link title text

", + "Link: link title[0] text\n\n[0] http://foo.bar\n", + }, + { + "

Links: foo1 bar1

", + "Links: foo1[0] bar1[1]\n\n[0] foo\n[1] bar\n", + }, + } { + app := App{Desc: c.in} + var b bytes.Buffer + app.TextDesc(&b) + out := b.String() + if out != c.want { + t.Errorf("Description converting into text failed.\nInput:\n%s\nGot:\n%s\nWanted:\n%s\n", + c.in, out, c.want) + } + } +}