Skip to content

Commit c540652

Browse files
committed
Split some unit tests from UnitTests-megamodule
This helps with recompilation speed while developing
1 parent 0b33f6f commit c540652

File tree

8 files changed

+348
-288
lines changed

8 files changed

+348
-288
lines changed

aeson.cabal

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,18 @@ test-suite aeson-tests
163163
PropertyRTFunctors
164164
PropertyTH
165165
PropUtils
166+
Regression.Issue351
166167
Regression.Issue571
167168
Regression.Issue967
168169
SerializationFormatSpec
169170
Types
170171
UnitTests
172+
UnitTests.FromJSONKey
173+
UnitTests.Hashable
174+
UnitTests.KeyMapInsertWith
175+
UnitTests.MonadFix
171176
UnitTests.NullaryConstructors
177+
UnitTests.UTCTime
172178

173179
build-depends:
174180
aeson

tests/Regression/Issue351.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
module Regression.Issue351 (issue351) where
3+
4+
import Test.Tasty (TestTree, testGroup)
5+
import Test.Tasty.HUnit (testCase, assertEqual)
6+
import Data.Maybe (fromMaybe)
7+
8+
import qualified Data.ByteString.Lazy as L
9+
10+
import Data.Aeson
11+
12+
-- A regression test for: https://github.com/bos/aeson/issues/351
13+
overlappingRegression :: FromJSON a => L.ByteString -> [a]
14+
overlappingRegression bs = fromMaybe [] $ decode bs
15+
16+
issue351 :: TestTree
17+
issue351 = testGroup "Issue #351" $ map (testCase "-")
18+
[ assertEqual "Int" ([1, 2, 3] :: [Int]) $ overlappingRegression "[1, 2, 3]"
19+
, assertEqual "Char" ("abc" :: String) $ overlappingRegression "\"abc\""
20+
, assertEqual "Char" ("" :: String) $ overlappingRegression "[\"a\", \"b\", \"c\"]"
21+
]

0 commit comments

Comments
 (0)