public void ToNullTerminated() { Assert.Equal(new byte[] { 0 }, NativeRustFunctions.CStyleStringFromSystemString(string.Empty)); Assert.Equal(new byte[] { 65, 0 }, NativeRustFunctions.CStyleStringFromSystemString("A")); Assert.Equal(new byte[] { 196, 132, 196, 134, 0 }, NativeRustFunctions.CStyleStringFromSystemString("ĄĆ")); Assert.Equal(new byte[] { 196, 132, 0, 196, 134, 0 }, NativeRustFunctions.CStyleStringFromSystemString("Ą\0Ć")); }
public static void Main() { using (var port = NativeRustFunctions.CreateMockServer(pact, 7000)) { var c = new HttpClient(); c.BaseAddress = new Uri($"http://localhost:{port.GetPortNumber()}"); var r = c.GetStringAsync("/customers/23").Result; Console.WriteLine(r); Console.WriteLine(NativeRustFunctions.MockServerMismatches(port)); } }
public unsafe void FromNullTerminated() { fixed(byte *p = new byte[] { 0 }) Assert.Equal(string.Empty, NativeRustFunctions.SystemStringFromCStyleString(p)); fixed(byte *p = new byte[] { 65, 0 }) Assert.Equal("A", NativeRustFunctions.SystemStringFromCStyleString(p)); fixed(byte *p = new byte[] { 196, 132, 196, 134, 0 }) Assert.Equal("ĄĆ", NativeRustFunctions.SystemStringFromCStyleString(p)); fixed(byte *p = new byte[] { 196, 132, 0, 196, 134, 0 }) Assert.Equal("Ą", NativeRustFunctions.SystemStringFromCStyleString(p)); }