コード例 #1
0
 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Ć"));
 }
コード例 #2
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));
     }
 }
コード例 #3
0
        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));
        }