~alcinnz/fontconfig-pure

cf269460c3f55030c8e5271c0218ea333796e86e — Adrian Cochrane 1 year, 4 months ago b1d2883
Add rudimentary test suite.

Transliterates some of FontConfig's unittests to ensure the language bindings don't break things.
Could still be tested further.
2 files changed, 38 insertions(+), 0 deletions(-)

M fontconfig-pure.cabal
A test/Test.hs
M fontconfig-pure.cabal => fontconfig-pure.cabal +6 -0
@@ 101,3 101,9 @@ executable fontconfig-pure
  -- Base language which the package is written in.
  default-language:    Haskell2010

test-suite test-fontconfig
  hs-source-dirs: test
  default-language: Haskell2010
  type: exitcode-stdio-1.0
  main-is: Test.hs
  build-depends: base >= 4.12 && <4.13, fontconfig-pure, hspec, QuickCheck

A test/Test.hs => test/Test.hs +32 -0
@@ 0,0 1,32 @@
module Main where

import Test.Hspec
import Graphics.Text.Font.Choose

main :: IO ()
main = hspec spec

test query expect = nameParse query `shouldBe` expect

spec :: Spec
spec = do
    describe "Canary" $ do
        it "Test framework works" $ do
            True `shouldBe` True
    describe "Name Parse" $ do
        it "parses as expected" $ do
            "sans\\-serif" `test` [("family", [(Weak, ValueString "sans-serif")])]
            "Foo-10" `test` [("family", [(Weak, ValueString "Foo")]),
                            ("size", [(Weak, ValueDouble 10.0)])]
            "Foo,Bar-10" `test` [
                ("family", [(Weak, ValueString "Foo"), (Weak, ValueString "Bar")]),
                ("size", [(Weak, ValueDouble 10.0)])]
            "Foo:weight=medium" `test` [("family", [(Weak, ValueString "Foo")]),
                                        ("weight", [(Weak, ValueDouble 100.0)])]
            "Foo:weight_medium" `test` [("family", [(Weak, ValueString "Foo")]),
                                        ("weight", [(Weak, ValueDouble 100.0)])]
            ":medium" `test` [("weight", [(Weak, ValueInt 100)])]
            ":normal" `test` [("width", [(Weak, ValueInt 100)])]
            ":weight=[medium bold]" `test` [
                    ("weight", [(Weak, ValueRange $ Range 100.0 200.0)])]
    -- FIXME test more...