public void TestMemberFn_ToString_i() { var testCase = new NormalisedShort4(); testCase.PackFrom(0.656f, 0.125f, 0.222f, 0.861f); String s = testCase.ToString (); Assert.That(s, Is.EqualTo("6E341C6A100053F7")); }
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)); }
public void TestRandomValues_i() { var rand = new System.Random(); var buff = new Byte[8]; for(Int32 i = 0; i < Settings.NumTests; ++i) { rand.NextBytes(buff); UInt64 packed = BitConverter.ToUInt64(buff, 0); // Cannot guarantee that this packed value is valid. try { var packedObj = new NormalisedShort4(); packedObj.PackedValue = packed; Single realX, realY, realZ, realW = 0f; packedObj.UnpackTo(out realX, out realY, out realZ, out realW); var newPackedObj = new NormalisedShort4(realX, realY, realZ, realW); Assert.That(newPackedObj.PackedValue, Is.EqualTo(packed)); } catch(ArgumentException) { continue; } } }