on master help sign in
Add tests for tracking JSONPath
commit4bf469182d0acb0e25ab81a85f1269ff5fd6dc70 authorlyxia <li-yao.xia@ens.fr> dateFri 20 May 2016, 17:05 (10 years ago) parentccb35ec
1 file changed+7−1
tests/UnitTests.hs+7−1
tests/UnitTests.hs+7−1
@@ -86,7 +86,9 @@ camelFrom c s = let (p:ps) = split c s
8686data Wibble = Wibble {
8787 wibbleString :: String
8888 , wibbleInt :: Int
89− } deriving (Generic, Show)
89+ } deriving (Generic, Show, Eq)
90+
91+instance FromJSON Wibble
9092
9193instance ToJSON Wibble where
9294 toJSON = genericToJSON defaultOptions
@@ -263,6 +265,10 @@ jsonPath = [
263265 , assertEqual "Seq a"
264266 (Left "Error in $[2]: expected Int, encountered Boolean")
265267 (eitherDecode "[0,1,true]" :: Either String (Seq Int))
268+ , assertEqual "Wibble"
269+ (Left "Error in $.wibbleInt: expected Int, encountered Boolean")
270+ (eitherDecode "{\"wibbleString\":\"\",\"wibbleInt\":true}"
271+ :: Either String Wibble)
266272 ]
267273
268274------------------------------------------------------------------------------