On Wed, Feb 13, 2013 at 11:51 AM, Iustin Pop <[email protected]> wrote:
> On Tue, Feb 12, 2013 at 06:34:48PM +0100, Michele Tartara wrote: > > 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) > > Don't do this. It means it has to generate an arbitrary char (out of the > entire Unicode range), and then filter out the ones that are not ASCII. > Ok, I see what the problem is. Look at the already existing DNSChar/genName functions on how to do it; > it might even be that 'genName' satisfies your requirements already. > It only creates simple strings, but it's more than enough, thanks. I'll drop this patch, then. Michele
