示例#1
0
 public void TestMemberFn_GetHashCode_i ()
 {
     HashSet<Int32> hs = new HashSet<Int32>();
     var rand = new System.Random();
     var buff = new Byte[8];
     UInt32 collisions = 0;
     for(Int32 i = 0; i < Settings.NumTests; ++i)
     {
         rand.NextBytes(buff);
         UInt64 packed = BitConverter.ToUInt64(buff, 0);
         var packedObj = new NormalisedShort4();
         packedObj.PackedValue = packed;
         Int32 hc = packedObj.GetHashCode ();
         if(hs.Contains(hc)) ++collisions;
         hs.Add(hc);
     }
     Assert.That(collisions, Is.LessThan(10));
 }