File: Tests.hs

package info (click to toggle)
haskell-feed 1.3.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: haskell: 4,735; xml: 4,315; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,184 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Text.Atom.Validate.Tests
  ( atomValidateTests
  ) where

import Prelude.Compat

import Data.Text (Text)
import Data.Text.Lazy (fromStrict)

import Data.XML.Types

import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, assertEqual)

import Text.Atom.Feed.Validate

import qualified Text.XML as C

atomValidateTests :: Test
atomValidateTests = testGroup "Text.Atom.Validate" [testAtomValidate]

sampleEntryText :: Text
sampleEntryText =
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"><id>http://example.com</id><title type=\"text\">example</title><updated>2000-01-01T00:00:00Z</updated><author><name>Nobody</name></author><content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">This is <b>XHTML</b> content.</div></content></entry>"

testAtomValidate :: Test
testAtomValidate = testCase "simple entry is valid" testValid
  where
    testValid :: Assertion
    testValid = do
      let document = C.toXMLDocument $ C.parseText_ C.def $ fromStrict sampleEntryText
      let entry = documentRoot document
      assertEqual "" [] $ flattenT $ validateEntry entry