Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ByteArray. Apply suggestions from code review.
- Loading branch information
Showing
6 changed files
with
105 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Test.ByteArray where | ||
|
||
import Prelude | ||
import Data.Maybe (Maybe(Just)) | ||
import Effect.Class (liftEffect) | ||
import Mote (group, test) | ||
import Test.QuickCheck (quickCheck, (===)) | ||
import Test.QuickCheck.Laws.Data.Eq (checkEq) | ||
import Test.QuickCheck.Laws.Data.Monoid (checkMonoid) | ||
import Test.QuickCheck.Laws.Data.Ord (checkOrd) | ||
import Test.QuickCheck.Laws.Data.Semigroup (checkSemigroup) | ||
import TestM (TestPlanM) | ||
import Type.Proxy (Proxy(..)) | ||
import Types.ByteArray (ByteArray, byteArrayFromIntArray, byteArrayFromIntArrayUnsafe, byteArrayToHex, byteArrayToIntArray, hexToByteArray) | ||
|
||
suite :: TestPlanM Unit | ||
suite = do | ||
group "ByteArray" do | ||
test "Eq instance" $ liftEffect do | ||
checkEq (Proxy :: Proxy ByteArray) | ||
test "Ord instance" $ liftEffect do | ||
checkOrd (Proxy :: Proxy ByteArray) | ||
test "Semigroup instance" $ liftEffect do | ||
checkSemigroup (Proxy :: Proxy ByteArray) | ||
test "Monoid instance" $ liftEffect do | ||
checkMonoid (Proxy :: Proxy ByteArray) | ||
test "hexToByteArray <<< byteArrayToHex = Just" $ liftEffect do | ||
quickCheck \bytes -> | ||
hexToByteArray (byteArrayToHex bytes) === Just bytes | ||
test "byteArrayFromIntArrayUnsafe <<< byteArrayToIntArray = id" $ liftEffect do | ||
quickCheck \bytes -> | ||
byteArrayFromIntArrayUnsafe (byteArrayToIntArray bytes) === bytes | ||
test "byteArrayFromIntArray <<< byteArrayToIntArray = Just" $ liftEffect do | ||
quickCheck \bytes -> | ||
byteArrayFromIntArray (byteArrayToIntArray bytes) === Just bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters