RandomTextString() public static method

public static RandomTextString ( RandomGenerator rand ) : string
rand PeterO.RandomGenerator
return string
Beispiel #1
0
        public static CBORObject RandomCBORObject(IRandomGenExtended rand, int
                                                  depth)
        {
            int nextval = rand.GetInt32(11);

            switch (nextval)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                return(RandomNumberOrRational(rand));

            case 4:
                return(rand.GetInt32(2) == 0 ? CBORObject.True : CBORObject.False);

            case 5:
                return(rand.GetInt32(2) == 0 ? CBORObject.Null :
                       CBORObject.Undefined);

            case 6:
                return(CBORObject.FromObject(
                           RandomObjects.RandomTextString(rand)));

            case 7:
                return(CBORObject.FromObject(
                           RandomObjects.RandomByteString(rand)));

            case 8:
                return(RandomCBORArray(rand, depth));

            case 9:
                return(RandomCBORMap(rand, depth));

            case 10:
                return(RandomCBORTaggedObject(rand, depth));

            default: return(RandomNumber(rand));
            }
        }
Beispiel #2
0
        public static CBORObject RandomCBORObject(RandomGenerator rand, int
                                                  depth)
        {
            int nextval = rand.UniformInt(11);

            switch (nextval)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                return(RandomNumberOrRational(rand));

            case 4:
                return(rand.UniformInt(2) == 0 ? CBORObject.True : CBORObject.False);

            case 5:
                return(rand.UniformInt(2) == 0 ? CBORObject.Null :
                       CBORObject.Undefined);

            case 6:
                return(ToObjectTest.TestToFromObjectRoundTrip(
                           RandomObjects.RandomTextString(rand)));

            case 7:
                return(ToObjectTest.TestToFromObjectRoundTrip(
                           RandomObjects.RandomByteString(rand)));

            case 8:
                return(RandomCBORArray(rand, depth));

            case 9:
                return(RandomCBORMap(rand, depth));

            case 10:
                return(RandomCBORTaggedObject(rand, depth));

            default: return(RandomNumber(rand));
            }
        }