diff options
author | Tanner Gooding <tagoo@outlook.com> | 2018-07-20 10:19:33 -0700 |
---|---|---|
committer | Tanner Gooding <tagoo@outlook.com> | 2018-07-24 12:34:57 -0700 |
commit | c7e0651e675d510c0575f27d084eb612dfdf0532 (patch) | |
tree | 383caa50244ef54287324ca9f44126588cf8eeec /tests/src | |
parent | e6ada167d7991b1ab6e1ea921c521a691610e269 (diff) | |
download | coreclr-c7e0651e675d510c0575f27d084eb612dfdf0532.tar.gz coreclr-c7e0651e675d510c0575f27d084eb612dfdf0532.tar.bz2 coreclr-c7e0651e675d510c0575f27d084eb612dfdf0532.zip |
Adding TestLibrary.Generator methods for unsigned types
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/Common/CoreCLRTestLibrary/Generator.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/src/Common/CoreCLRTestLibrary/Generator.cs b/tests/src/Common/CoreCLRTestLibrary/Generator.cs index 666ce5b736..6fc32b3f31 100644 --- a/tests/src/Common/CoreCLRTestLibrary/Generator.cs +++ b/tests/src/Common/CoreCLRTestLibrary/Generator.cs @@ -86,6 +86,30 @@ namespace TestLibrary return iVal; } + // returns a UInt64 between 0 and UInt64.MaxValue + public static UInt64 GetUInt64(Int32 new_seed) + { + Seed = new_seed; + return GetUInt64(); + } + public static UInt64 GetUInt64() + { + byte[] buffer = new byte[8]; + UInt64 iVal; + + GetBytes(buffer); + + // convert to UInt64 + iVal = 0; + for (int i = 0; i < buffer.Length; i++) + { + iVal |= ((UInt64)buffer[i] << (i * 8)); + } + + TestFramework.LogVerbose("Random UInt64 produced: " + iVal.ToString()); + return iVal; + } + // returns a non-negative Int32 between 0 and Int32.MaxValue public static Int32 GetInt32(Int32 new_seed) { @@ -99,6 +123,30 @@ namespace TestLibrary return i; } + // returns a UInt32 between 0 and UInt32.MaxValue + public static UInt32 GetUInt32(Int32 new_seed) + { + Seed = new_seed; + return GetUInt32(); + } + public static UInt32 GetUInt32() + { + byte[] buffer = new byte[4]; + UInt32 iVal; + + GetBytes(buffer); + + // convert to UInt32 + iVal = 0; + for (int i = 0; i < buffer.Length; i++) + { + iVal |= ((UInt32)buffer[i] << (i * 4)); + } + + TestFramework.LogVerbose("Random UInt32 produced: " + iVal.ToString()); + return iVal; + } + // returns a non-negative Int16 between 0 and Int16.MaxValue public static Int16 GetInt16(Int32 new_seed) { @@ -112,6 +160,19 @@ namespace TestLibrary return i; } + // returns a UInt16 between 0 and UInt16.MaxValue + public static UInt16 GetUInt16(Int32 new_seed) + { + Seed = new_seed; + return GetUInt16(); + } + public static UInt16 GetUInt16() + { + UInt16 i = Convert.ToUInt16(m_rand.Next() % (1 + UInt16.MaxValue)); + TestFramework.LogVerbose("Random UInt16 produced: " + i.ToString()); + return i; + } + // returns a non-negative Byte between 0 and Byte.MaxValue public static Byte GetByte(Int32 new_seed) { @@ -125,6 +186,19 @@ namespace TestLibrary return i; } + // returns a non-negative SByte between 0 and SByte.MaxValue + public static SByte GetSByte(Int32 new_seed) + { + Seed = new_seed; + return GetSByte(); + } + public static SByte GetSByte() + { + SByte i = Convert.ToSByte(m_rand.Next() % (1 + SByte.MaxValue)); + TestFramework.LogVerbose("Random SByte produced: " + i.ToString()); + return i; + } + // returns a non-negative Double between 0.0 and 1.0 public static Double GetDouble(Int32 new_seed) { |