forked from gren-lang/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Should fix gren-lang#48 Using suggested fix from https://github.com/elm/core/pull/1092/files
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Test.Bytes exposing (tests) | ||
|
||
import Bytes exposing (Bytes) | ||
import Bytes.Encode | ||
import Expect | ||
import Fuzz | ||
import Test exposing (..) | ||
|
||
|
||
encodeString : String -> Bytes | ||
encodeString s = | ||
Bytes.Encode.encode <| | ||
Bytes.Encode.string s | ||
|
||
|
||
encodeInt : Int -> Bytes | ||
encodeInt i = | ||
Bytes.Encode.encode <| | ||
Bytes.Encode.signedInt8 i | ||
|
||
|
||
tests : Test | ||
tests = | ||
describe "Byte comparison" | ||
[ fuzz Fuzz.string "same strings are equal" <| \s -> | ||
Expect.equal (encodeString s) (encodeString s) | ||
, fuzz (Fuzz.intRange -128 127) "same ints are equal" <| \i -> | ||
Expect.equal (encodeInt i) (encodeInt i) | ||
, fuzz Fuzz.string "different strings are not equal" <| \s -> | ||
Expect.notEqual (encodeString s) (encodeString (s ++ "a")) | ||
, fuzz (Fuzz.intRange -100 100) "different ints are not equal" <| \i -> | ||
Expect.notEqual (encodeInt i) (encodeInt (i + 1)) | ||
, fuzz2 Fuzz.string (Fuzz.intRange 1 127) "string and int are not equal" <| \s i -> | ||
Expect.notEqual (encodeString s) (encodeInt i) | ||
] |