@@ -12,6 +12,7 @@ import Test.HUnit hiding (Test, path)
1212main :: IO ()
1313main = defaultMain
1414 [ testCase "count scalars" caseCountScalars
15+ , testCase "largest string" caseLargestString
1516 ]
1617
1718caseCountScalars :: Assertion
@@ -27,3 +28,20 @@ caseCountScalars = do
2728 fold res EventNone = Left res
2829 fold res _ = Right res
2930 accum = (0, 0, 0) :: (Int, Int, Int)
31+
32+caseLargestString :: Assertion
33+caseLargestString = do
34+ Right res <- decodeFile filePath fold accum
35+ res @?= (length expected, expected)
36+ where
37+ expected = "this one is just a little bit bigger than the others"
38+ filePath = "test/largest-string.yaml"
39+ fold (i, s) (EventScalar bs _ _) =
40+ let s' = B8.unpack bs
41+ i' = length s'
42+ in if i' > i
43+ then Right (i', s')
44+ else Right (i, s)
45+ fold res EventNone = Left res
46+ fold res _ = Right res
47+ accum = (0, "no strings found")