public unsafe void GuidParsingUtf16(string format) { var parsedFormat = StandardFormat.Parse(format); var random = new Random(1000); var guidBytes = new byte[16]; var expected = guidWithAllNonZeroDigits; for (int i = 0; i < 100; i++) { string expectedString = expected.ToString(format, CultureInfo.InvariantCulture); Assert.True(Utf16Parser.TryParseGuid(expectedString.ToCharArray(), out Guid parsed, out int charactersConsumed, parsedFormat)); Assert.Equal(expected, parsed); Assert.Equal(expectedString.Length, charactersConsumed); random.NextBytes(guidBytes); expected = new Guid(guidBytes); } }