public unsafe void DecoderTest() { //string str = "abcdefghijklmnop\u0135"; string str = "\u0135\u0135\u0135\u0135\u0135"; var decodeBuffer = new ArraySegment<char>(new char[3]); StringDecoder decoder = new StringDecoder(decodeBuffer); decoder.Decode(new ArraySegment<byte>(Encoding.UTF8.GetBytes(str))); var decodedString = decoder.ToString(); Console.WriteLine(decodedString); Assert.AreEqual(str, decodedString); }
public unsafe void DecoderMultipleMisalignedCallTest() { string str = "\u0135\u0136\u0137\u0138\u0139"; var decodeBuffer = new ArraySegment<char>(new char[3]); StringDecoder decoder = new StringDecoder(decodeBuffer); byte[] bytes = Encoding.UTF8.GetBytes(str); decoder.Decode(new ArraySegment<byte>(bytes.Take(3).ToArray())); decoder.Decode(new ArraySegment<byte>(bytes.Skip(3).ToArray())); var decodedString = decoder.ToString(); Console.WriteLine(decodedString); Assert.AreEqual(str, decodedString); }