diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 10:38:46 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 10:38:46 +0100 |
| commit | c8f0894256df14e18613a7020e1d67c071acf5a2 (patch) | |
| tree | 0b8e17bd0e7ce32e02b1238c8b2aefa2bd357fe6 /bbcode | |
| parent | ca7cd4ee2470115939523bb985aa576f9d87f18f (diff) | |
| download | thermoprint-c8f0894256df14e18613a7020e1d67c071acf5a2.tar thermoprint-c8f0894256df14e18613a7020e1d67c071acf5a2.tar.gz thermoprint-c8f0894256df14e18613a7020e1d67c071acf5a2.tar.bz2 thermoprint-c8f0894256df14e18613a7020e1d67c071acf5a2.tar.xz thermoprint-c8f0894256df14e18613a7020e1d67c071acf5a2.zip | |
unit tests for Text.BBCode
Diffstat (limited to 'bbcode')
| -rw-r--r-- | bbcode/test/Text/BBCodeSpec.hs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/bbcode/test/Text/BBCodeSpec.hs b/bbcode/test/Text/BBCodeSpec.hs new file mode 100644 index 0000000..0d8949a --- /dev/null +++ b/bbcode/test/Text/BBCodeSpec.hs | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | {-# LANGUAGE OverloadedStrings, OverloadedLists #-} | ||
| 2 | |||
| 3 | module Text.BBCodeSpec (spec) where | ||
| 4 | |||
| 5 | import Test.Hspec | ||
| 6 | import Test.Hspec.QuickCheck (prop) | ||
| 7 | import Test.QuickCheck.Instances | ||
| 8 | |||
| 9 | import Text.BBCode | ||
| 10 | |||
| 11 | import Data.Text (Text) | ||
| 12 | |||
| 13 | import Control.Monad (zipWithM_) | ||
| 14 | import Data.Monoid ((<>)) | ||
| 15 | |||
| 16 | spec :: Spec | ||
| 17 | spec = do | ||
| 18 | zipWithM_ example [1..] examples | ||
| 19 | where | ||
| 20 | example n (s, ts) = let str = "Example " <> show n | ||
| 21 | in specify str (bbcode s == Right ts) | ||
| 22 | |||
| 23 | examples :: [(Text, [DomTree])] | ||
| 24 | examples = [ ("[t]test[/t]" | ||
| 25 | , [Element "t" [] [Content "test"]]) | ||
| 26 | , ("[t]te\\st[/t]" | ||
| 27 | , [Element "t" [] [Content "te\\st"]]) | ||
| 28 | , ("[t]te\\[st[/t]" | ||
| 29 | , [Element "t" [] [Content "te[st"]]) | ||
| 30 | , ("[t]test\\\\[/t]" | ||
| 31 | , [Element "t" [] [Content "test\\"]]) | ||
| 32 | , ("[\\t]test[/\\t]" | ||
| 33 | , [Element "\\t" [] [Content "test"]]) | ||
| 34 | , ("[t attr]test[/t]" | ||
| 35 | , [Element "t" [("attr", "")] [Content "test"]]) | ||
| 36 | , ("[t=attr]test[/t]" | ||
| 37 | , [Element "t" [("", "attr")] [Content "test"]]) | ||
| 38 | , ("[t attr=val]test[/t]" | ||
| 39 | , [Element "t" [("attr", "val")] [Content "test"]]) | ||
| 40 | , ("[t attr=\"val\"]test[/t]" | ||
| 41 | , [Element "t" [("attr", "val")] [Content "test"]]) | ||
| 42 | , ("[t attr=\"va]l\"]test[/t]" | ||
| 43 | , [Element "t" [("attr", "va]l")] [Content "test"]]) | ||
| 44 | , ("[t attr=\"va\\\"l\"]test[/t]" | ||
| 45 | , [Element "t" [("attr", "va\"l")] [Content "test"]]) | ||
| 46 | , ("[t attr=\"val\" attr2=\"val2\" ]test[/t]" | ||
| 47 | , [Element "t" [("attr", "val"), ("attr2", "val2")] [Content "test"]]) | ||
| 48 | , ("[br/]" | ||
| 49 | , [Element "br" [] []]) | ||
| 50 | , ("[br attr/]" | ||
| 51 | , [Element "br" [("attr", "")] []]) | ||
| 52 | , ("[br=val/]" | ||
| 53 | , [Element "br" [("", "val")] []]) | ||
| 54 | , ("[br attr=val/]" | ||
| 55 | , [Element "br" [("attr", "val")] []]) | ||
| 56 | , ("[br attr=val val2/]" | ||
| 57 | , [Element "br" [("attr", "val"), ("val2", "")] []]) | ||
| 58 | ] | ||
| 59 | |||
