mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
tests: Utils -> easytest
This commit is contained in:
parent
f713a413ff
commit
bbecb28cae
@ -18,10 +18,10 @@ tests_Hledger = TestList
|
||||
tests_Hledger_Data
|
||||
,tests_Hledger_Query
|
||||
,tests_Hledger_Reports
|
||||
,tests_Hledger_Utils
|
||||
]
|
||||
|
||||
easytests_Hledger = tests "Hledger" [
|
||||
easytests_Data
|
||||
,easytests_Read
|
||||
,easytests_Utils
|
||||
]
|
||||
|
@ -4,6 +4,7 @@ Standard imports and utilities which are useful everywhere, or needed low
|
||||
in the module hierarchy. This is the bottom of hledger's module graph.
|
||||
|
||||
-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Hledger.Utils (---- provide these frequently used modules - or not, for clearer api:
|
||||
-- module Control.Monad,
|
||||
@ -216,6 +217,6 @@ sequence' ms = do
|
||||
mapM' :: Monad f => (a -> f b) -> [a] -> f [b]
|
||||
mapM' f = sequence' . map f
|
||||
|
||||
tests_Hledger_Utils = TestList [
|
||||
tests_Hledger_Utils_Text
|
||||
easytests_Utils = tests "Utils" [
|
||||
easytests_Text
|
||||
]
|
||||
|
@ -54,7 +54,8 @@ module Hledger.Utils.Text
|
||||
-- fitStringMulti,
|
||||
textPadLeftWide,
|
||||
textPadRightWide,
|
||||
tests_Hledger_Utils_Text
|
||||
-- -- * tests
|
||||
easytests_Text
|
||||
)
|
||||
where
|
||||
|
||||
@ -419,12 +420,14 @@ textWidth s = maximum $ map (T.foldr (\a b -> charWidth a + b) 0) $ T.lines s
|
||||
-- | otherwise -> 1
|
||||
|
||||
|
||||
tests_Hledger_Utils_Text = TestList [
|
||||
quoteIfSpaced "a'a" ~?= "a'a"
|
||||
, quoteIfSpaced "a\"a" ~?= "a\"a"
|
||||
, quoteIfSpaced "a a" ~?= "\"a a\""
|
||||
, quoteIfSpaced "mimi's cafe" ~?= "\"mimi's cafe\""
|
||||
, quoteIfSpaced "\"alex\" cafe" ~?= "\"\\\"alex\\\" cafe\""
|
||||
, quoteIfSpaced "le'shan's cafe" ~?= "\"le'shan's cafe\""
|
||||
, quoteIfSpaced "\"be'any's\" cafe" ~?= "\"\\\"be'any's\\\" cafe\""
|
||||
easytests_Text = tests "Text" [
|
||||
tests "quoteIfSpaced" [
|
||||
expectEq' "a'a" (quoteIfSpaced "a'a")
|
||||
,expectEq' "a\"a" (quoteIfSpaced "a\"a")
|
||||
,expectEq' "\"a a\"" (quoteIfSpaced "a a")
|
||||
,expectEq' "\"mimi's cafe\"" (quoteIfSpaced "mimi's cafe")
|
||||
,expectEq' "\"\\\"alex\\\" cafe\"" (quoteIfSpaced "\"alex\" cafe")
|
||||
,expectEq' "\"le'shan's cafe\"" (quoteIfSpaced "le'shan's cafe")
|
||||
,expectEq' "\"\\\"be'any's\\\" cafe\"" (quoteIfSpaced "\"be'any's\" cafe")
|
||||
]
|
||||
]
|
Loading…
Reference in New Issue
Block a user