public static CBORObject RandomNumberOrRational(RandomGenerator rand) { switch (rand.UniformInt(7)) { case 0: return(CBORObject.FromObject( RandomObjects.RandomDouble( rand, Int32.MaxValue))); case 1: return(CBORObject.FromObject( RandomObjects.RandomSingle( rand, Int32.MaxValue))); case 2: return(CBORObject.FromObject(RandomObjects.RandomEInteger(rand))); case 3: return(CBORObject.FromObject(RandomObjects.RandomEFloat(rand))); case 4: return (CBORObject.FromObject(RandomObjects.RandomEDecimal(rand))); case 5: return(CBORObject.FromObject(RandomObjects.RandomInt64(rand))); case 6: return(CBORObject.FromObject(RandomObjects.RandomERational(rand))); default: throw new ArgumentException(); } }
public static CBORObject RandomNumberOrRational(IRandomGenExtended rand) { object o = null; switch (rand.GetInt32(7)) { case 0: o = RandomObjects.RandomDouble( rand, Int32.MaxValue); return(CBORObject.FromObject(o)); case 1: o = RandomObjects.RandomSingle( rand, Int32.MaxValue); return(CBORObject.FromObject(o)); case 2: return(CBORObject.FromObject( RandomObjects.RandomEInteger(rand))); case 3: return(CBORObject.FromObject( RandomObjects.RandomEFloat(rand))); case 4: o = RandomObjects.RandomEDecimal(rand); return(CBORObject.FromObject(o)); case 5: o = RandomObjects.RandomInt64(rand); return(CBORObject.FromObject(o)); case 6: o = RandomObjects.RandomERational(rand); return(CBORObject.FromObject(o)); default: throw new InvalidOperationException(); } }
public static CBORObject RandomNumberOrRational(RandomGenerator rand) { object o = null; switch (rand.UniformInt(7)) { case 0: o = RandomObjects.RandomDouble( rand, Int32.MaxValue); return(ToObjectTest.TestToFromObjectRoundTrip(o)); case 1: o = RandomObjects.RandomSingle( rand, Int32.MaxValue); return(ToObjectTest.TestToFromObjectRoundTrip(o)); case 2: return(ToObjectTest.TestToFromObjectRoundTrip( RandomObjects.RandomEInteger(rand))); case 3: return(ToObjectTest.TestToFromObjectRoundTrip( RandomObjects.RandomEFloat(rand))); case 4: o = RandomObjects.RandomEDecimal(rand); return(ToObjectTest.TestToFromObjectRoundTrip(o)); case 5: o = RandomObjects.RandomInt64(rand); return(ToObjectTest.TestToFromObjectRoundTrip(o)); case 6: o = RandomObjects.RandomERational(rand); return(ToObjectTest.TestToFromObjectRoundTrip(o)); default: throw new InvalidOperationException(); } }