Skip to content

Commit 88c244e

Browse files
committed
Add test case for Show Options instance
1 parent c9d9fdc commit 88c244e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/UnitTests.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ tests = testGroup "unit" [
9191
, testGroup "FromJSONKey" $ fmap (testCase "-") fromJSONKeyAssertions
9292
, testCase "PR #455" pr455
9393
, testCase "Unescape string (PR #477)" unescapeString
94+
, testCase "Show Options" showOptions
9495
]
9596

9697
roundTripCamel :: String -> Assertion
@@ -483,6 +484,20 @@ pr455 = assertEqual "FooCons FooNil"
483484
foo :: Foo Int
484485
foo = FooCons FooNil
485486

487+
showOptions :: Assertion
488+
showOptions =
489+
assertEqual
490+
"Show Options"
491+
( "Options {"
492+
++ "fieldLabelModifier =~ \"exampleField\""
493+
++ ", constructorTagModifier =~ \"ExampleConstructor\""
494+
++ ", allNullaryToStringTag = True"
495+
++ ", omitNothingFields = False"
496+
++ ", sumEncoding = TaggedObject {tagFieldName = \"tag\", contentsFieldName = \"contents\"}"
497+
++ ", unwrapUnaryRecords = False"
498+
++ "}")
499+
(show defaultOptions)
500+
486501
deriveJSON defaultOptions{omitNothingFields=True} ''MyRecord
487502

488503
deriveToJSON defaultOptions ''Foo

0 commit comments

Comments
 (0)