public unsafe void TestIndexOf(string str, char c, int expected) { byte[] bytes = Encoding.UTF8.GetBytes(str + '\0'); fixed(byte *fbytes = &bytes[0]) { MetadataName name = new MetadataName(fbytes, null); Assert.That(name.IndexOf(checked ((byte)c)), Is.EqualTo(expected)); } }
private static unsafe void TestIndexOf(string str, char c, int expected) { byte[] bytes = Encoding.UTF8.GetBytes(str + '\0'); fixed (byte* fbytes = &bytes[0]) { MetadataName name = new MetadataName(fbytes, null); Assert(name.IndexOf(checked((byte)c)) == expected); } }