<commit_before>using System;
using System.IO;
using Xunit;

namespace InvertedTomato.Compression.Integers;

public class StreamBitReaderTests
{
    [Fact]
    public void Read_8_8_0()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.True(reader.PeakBit());
        Assert.Equal((ulong)0b11111111, reader.ReadBits(8));
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(8));
        Assert.Equal((ulong)0b00000000, reader.ReadBits(0));
    }
    
    [Fact]
    public void Read_4_8_4()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.Equal((ulong)0b00001111, reader.ReadBits(4));
        Assert.True(reader.PeakBit());
        Assert.Equal((ulong)0b11110000, reader.ReadBits(8));
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
    }
    
    
    [Fact]
    public void Read_4_Align_4()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.Equal((ulong)0b00001111, reader.ReadBits(4));
        Assert.True(reader.PeakBit());
        reader.Align();
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
    }
    
    [Fact]
    public void DisposeNotOwned()
    {
        using var stream = new MemoryStream(new byte[] {0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.False(reader.IsDisposed);
        reader.Dispose();
        Assert.True(reader.IsDisposed);<commit_msg>Fixed unit test<commit_after>using System;
using System.IO;
using Xunit;

namespace InvertedTomato.Compression.Integers;

public class StreamBitReaderTests
{
    [Fact]
    public void Read_8_8_0()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.True(reader.PeakBit());
        Assert.Equal((ulong)0b11111111, reader.ReadBits(8));
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(8));
        Assert.Equal((ulong)0b00000000, reader.ReadBits(0));
    }
    
    [Fact]
    public void Read_4_8_4()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.Equal((ulong)0b00001111, reader.ReadBits(4));
        Assert.True(reader.PeakBit());
        Assert.Equal((ulong)0b00001111, reader.ReadBits(8));
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
    }
    
    [Fact]
    public void Read_4_Align_4()
    {
        using var stream = new MemoryStream(new byte[] {0b_11111111,0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.Equal((ulong)0b00001111, reader.ReadBits(4));
        Assert.True(reader.PeakBit());
        reader.Align();
        Assert.False(reader.PeakBit());
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
        Assert.Equal((ulong)0b00000000, reader.ReadBits(4));
    }
    
    [Fact]
    public void DisposeNotOwned()
    {
        using var stream = new MemoryStream(new byte[] {0b00000000});
        using var reader = new StreamBitReader(stream);
        Assert.False(reader.IsDisposed);
        reader.Dispose();
        Assert.True(reader.IsDisposed);
{'fraction_non_alphanumeric': 0.1276133586749932, 'fraction_numerical': 0.08742872658159109, 'mean_word_length': 3.05726872246696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 26, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1209364', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1144, 'n_words': 207}