1
0
mirror of https://github.com/chylex/Brotli-Builder.git synced 2025-04-13 00:15:42 +02:00

Allow combining contents of two BitStream objects

This commit is contained in:
chylex 2018-11-15 21:46:37 +01:00
parent 97fdcfc7e6
commit c9bc34a216
2 changed files with 25 additions and 0 deletions
BrotliLib/IO
UnitTests/IO

View File

@ -115,6 +115,16 @@ namespace BrotliLib.IO{
++Length;
}
/// <summary>
/// Appends all bits from the provided <paramref name="stream"/> to the end of this stream.
/// </summary>
/// <param name="stream">Input stream.</param>
public void AddAll(BitStream stream){
foreach(bool bit in stream){
Add(bit);
}
}
#endregion

View File

@ -111,6 +111,21 @@ module Mutability =
Assert.Equal(expected, stream.ToString())
[<Theory>]
[<InlineData("", "")>]
[<InlineData("0", "")>]
[<InlineData("0", "1")>]
[<InlineData("11110000", "1010")>]
let ``appending stream to another stream in either direction yields correct text representation`` (first: string, second: string) =
let firstsecond = BitStream(first)
firstsecond.AddAll(BitStream(second))
let secondfirst = BitStream(second)
secondfirst.AddAll(BitStream(first))
Assert.Equal(first + second, firstsecond.ToString())
Assert.Equal(second + first, secondfirst.ToString())
module Cloning =
[<Theory>]