public void GetStringOffsetAtIndex() { //cargamos 3 strings en un array MemoryStream ms = new MemoryStream(); byte[] bytes = PointerCastHelper.StringToBytes("texto 1"); ms.Write(bytes, 0, bytes.Length); bytes = PointerCastHelper.StringToBytes("texto 2"); ms.Write(bytes, 0, bytes.Length); bytes = PointerCastHelper.StringToBytes("texto 3"); ms.Write(bytes, 0, bytes.Length); byte[] data = ms.ToArray(); long offset2 = PointerCastHelper.GetStringOffsetAtIndex(data, 0, 1); long offset3 = PointerCastHelper.GetStringOffsetAtIndex(data, 0, 2); Assert.AreEqual(15, offset2, "El offset del segundo string deberÃa ser 16"); Assert.AreEqual("texto 1", PointerCastHelper.BytesToString(data, 0), "No coinciden los textos"); Assert.AreEqual("texto 2", PointerCastHelper.BytesToString(data, offset2), "No coinciden los textos"); Assert.AreEqual("texto 3", PointerCastHelper.BytesToString(data, offset3), "No coinciden los textos"); }
public void String() { string test = "String de prueba para el test"; string result = PointerCastHelper.BytesToString( PointerCastHelper.StringToBytes(test), 0); Assert.AreEqual(test, result, "Los textos no coinciden"); }