public void AddDuplicate() { var buffer = new UserStringsStreamBuffer(); const string string1 = "String 1"; uint index1 = buffer.GetStringIndex(string1); const string string2 = "String 1"; uint index2 = buffer.GetStringIndex(string2); Assert.Equal(index1, index2); var usStream = buffer.CreateStream(); Assert.Equal(string1, usStream.GetStringByIndex(index1)); }
public void AddRaw() { var buffer = new UserStringsStreamBuffer(); const string string1 = "String 1"; var rawData = Encoding.UTF8.GetBytes(string1); uint index1 = buffer.AppendRawData(rawData); uint index2 = buffer.GetStringIndex(string1); Assert.NotEqual(index1, index2); var usStream = buffer.CreateStream(); Assert.Equal(string1, usStream.GetStringByIndex(index2)); }
public void SpecialCharactersTerminatorByte(char specialChar, byte terminatorByte) { string value = "My String" + specialChar; var buffer = new UserStringsStreamBuffer(); uint index = buffer.GetStringIndex(value); var usStream = buffer.CreateStream(); Assert.Equal(value, usStream.GetStringByIndex(index)); var reader = usStream.CreateReader(); reader.Offset = (uint)(index + Encoding.Unicode.GetByteCount(value) + 1); byte b = reader.ReadByte(); Assert.Equal(terminatorByte, b); }