summaryrefslogtreecommitdiff
path: root/Biz/Test.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Test.hs')
-rw-r--r--Biz/Test.hs45
1 files changed, 44 insertions, 1 deletions
diff --git a/Biz/Test.hs b/Biz/Test.hs
index 7f6da61..7571008 100644
--- a/Biz/Test.hs
+++ b/Biz/Test.hs
@@ -8,12 +8,16 @@ module Biz.Test
group,
unit,
prop,
+ with,
(@=?),
+ (@?=),
+ (@?!=),
)
where
+import Alpha hiding (group)
import qualified Test.Tasty as Tasty
-import Test.Tasty.HUnit ((@=?))
+import Test.Tasty.HUnit ((@=?), (@?=))
import qualified Test.Tasty.HUnit as HUnit
import qualified Test.Tasty.QuickCheck as QuickCheck
@@ -27,3 +31,42 @@ unit = HUnit.testCase
prop :: QuickCheck.Testable a => Tasty.TestName -> a -> Tasty.TestTree
prop = QuickCheck.testProperty
+
+with ::
+ -- | Startup
+ IO a ->
+ -- | Shutdown
+ (a -> IO ()) ->
+ -- | A test group where the first argument is a function that gets the resource
+ (IO a -> Tree) ->
+ Tree
+with = Tasty.withResource
+
+-- | How is this not part of HUnit??
+assertNotEqual ::
+ (Eq a, Show a, HasCallStack) =>
+ -- | The message prefix
+ String ->
+ -- | The not-expected value
+ a ->
+ -- | The actual value
+ a ->
+ HUnit.Assertion
+assertNotEqual preface notexpected actual =
+ unless (actual /= notexpected) (HUnit.assertFailure msg)
+ where
+ msg =
+ (if null preface then "" else preface ++ "\n")
+ ++ "expected not: "
+ ++ show notexpected
+ ++ "\n but got: "
+ ++ show actual
+
+(@?!=) ::
+ (Eq a, Show a, HasCallStack) =>
+ -- | The not-expected value
+ a ->
+ -- | The actual value
+ a ->
+ HUnit.Assertion
+expected @?!= actual = assertNotEqual "" expected actual