public void AddRaw() { var buffer = new StringsStreamBuffer(); 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 stringsStream = buffer.CreateStream(); Assert.Equal(string1, stringsStream.GetStringByIndex(index2)); }
public void AddDuplicate() { var buffer = new StringsStreamBuffer(); 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 stringsStream = buffer.CreateStream(); Assert.Equal(string1, stringsStream.GetStringByIndex(index1)); }
public void ImportStringsStreamWithDuplicateStrings() { var existingStringsStream = new SerializedStringsStream(StringsStream.DefaultName, Encoding.UTF8.GetBytes( "\0" + "String\0" + "String\0" + "String\0")); var buffer = new StringsStreamBuffer(); buffer.ImportStream(existingStringsStream); var newStream = buffer.CreateStream(); Assert.Equal("String", newStream.GetStringByIndex(1)); Assert.Equal("String", newStream.GetStringByIndex(8)); Assert.Equal("String", newStream.GetStringByIndex(15)); }
public void ImportStringStreamShouldIndexExistingStrings() { var existingStringsStream = new SerializedStringsStream(StringsStream.DefaultName, Encoding.UTF8.GetBytes( "\0" + "String\0" + "LongerString\0" + "AnEvenLongerString\0")); var buffer = new StringsStreamBuffer(); buffer.ImportStream(existingStringsStream); var newStream = buffer.CreateStream(); Assert.Equal("String", newStream.GetStringByIndex(1)); Assert.Equal("LongerString", newStream.GetStringByIndex(8)); Assert.Equal("AnEvenLongerString", newStream.GetStringByIndex(21)); }