It will be used in the next commits for generating test strings to be used as the description of the reason of state changes of instances.
Signed-off-by: Michele Tartara <[email protected]> --- test/hs/Test/Ganeti/TestCommon.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/hs/Test/Ganeti/TestCommon.hs b/test/hs/Test/Ganeti/TestCommon.hs index 91351b6..c39e492 100644 --- a/test/hs/Test/Ganeti/TestCommon.hs +++ b/test/hs/Test/Ganeti/TestCommon.hs @@ -28,6 +28,7 @@ module Test.Ganeti.TestCommon where import Control.Applicative import Control.Exception (catchJust) import Control.Monad +import Data.Char import Data.List import qualified Data.Set as Set import System.Environment (getEnv) @@ -303,3 +304,10 @@ genSample gen = do case values of [] -> error "sample' returned an empty list of values??" x:_ -> return x + +-- | Generates an arbitrary non-empty ASCII string +-- Note that isAlpha is not used because it could allow the generation of +-- unicode characters, that we do not want. +genNonEmptyString :: Gen String +genNonEmptyString = listOf1 $ + arbitrary `suchThat` (\c -> isAsciiUpper c || isAsciiLower c) -- 1.7.10.4
