packages feed

bytestring-tree-builder-0.2.7.11: tasty/Main.hs

module Main where

import BasePrelude hiding (assert)
import ByteString.TreeBuilder
import qualified Data.ByteString.Lazy
import Test.QuickCheck.Instances ()
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck

main :: IO ()
main =
  defaultMain tree

tree :: TestTree
tree =
  testGroup
    "All tests"
    [ testProperty "Concatting a list of bytestrings is isomorphic to appending a list of builders (strict)" $
        \bytestrings ->
          mconcat bytestrings
            === toByteString (foldMap byteString bytestrings),
      testProperty "Concatting a list of bytestrings is isomorphic to appending a list of builders (lazy)" $
        \bytestrings ->
          mconcat bytestrings
            === Data.ByteString.Lazy.toStrict (toLazyByteString (foldMap byteString bytestrings)),
      testCase "Regression (Issue #5)" $
        let fn name =
              toByteString $
                "FETCH FORWARD "
                  <> asciiIntegral 10
                  <> " FROM "
                  <> byteString name
         in assertEqual
              ""
              "FETCH FORWARD 10 FROM abc"
              (fn "abc")
    ]