示例#1
0
        public static void GetHashCode_Ordinal()
        {
            // Generate 17 all-null strings and make sure they have unique hash codes.
            // Assuming Marvin32 is a good PRF and has a full 32-bit output domain, we should
            // expect this test to fail only once every ~30 million runs due to the birthday paradox.
            // That should be good enough for inclusion as a unit test.

            HashSet <int> seenHashCodes = new HashSet <int>();

            for (int i = 0; i <= 16; i++)
            {
                using BoundedUtf8Span boundedSpan = new BoundedUtf8Span(new byte[i]);
                Utf8Span span = boundedSpan.Span;

                Assert.True(seenHashCodes.Add(span.GetHashCode()), "This hash code was previously seen.");
            }
        }
示例#2
0
 public override int GetHashCode(Utf8Span obj) => obj.GetHashCode();