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:
parent
97fdcfc7e6
commit
c9bc34a216
@ -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
|
||||
|
||||
|
@ -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>]
|
||||
|
Loading…
Reference in New Issue
Block a user