Skip to content

Commit ff8317a

Browse files
committed
Add entry to changelog and test for NonEmptyString
1 parent e022903 commit ff8317a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Breaking changes (😱!!!):
99

1010
New features:
1111
- Added decoders for `NonEmptyString` and added a new `decodeNonempty` function (#94)
12+
- Added encoder for `NonEmptyString` (#98)
1213

1314
Bugfixes:
1415

test/Test/Main.purs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Data.Argonaut.Encode (encodeJson, (:=), (:=?), (~>), (~>?))
1111
import Data.Argonaut.Gen (genJson)
1212
import Data.Argonaut.Parser (jsonParser)
1313
import Data.Array.NonEmpty (NonEmptyArray)
14+
import Data.String.NonEmpty (NonEmptyString)
15+
import Data.String.NonEmpty as NonEmptyString
1416
import Data.Bifunctor (rmap)
1517
import Data.Either (Either(..), either)
1618
import Data.Foldable (foldl)
@@ -314,6 +316,21 @@ nonEmptyCheck = do
314316
Left err ->
315317
false <?> printJsonDecodeError err
316318

319+
320+
test "Test EncodeJson/DecodeJson on NonEmptyString" do
321+
quickCheck \(x :: NonEmptyString) ->
322+
case decodeJson (encodeJson x) of
323+
Right decoded ->
324+
decoded == x
325+
<?>
326+
( " x = "
327+
<> NonEmptyString.toString x
328+
<> ", decoded = "
329+
<> NonEmptyString.toString decoded
330+
)
331+
Left err ->
332+
false <?> printJsonDecodeError err
333+
317334
test "Test EncodeJson/DecodeJson on NonEmptyArray" do
318335
quickCheck \(x :: NonEmptyArray String) ->
319336
case decodeJson (encodeJson x) of

0 commit comments

Comments
 (0)