<commit_before>require 'test/unit'
require 'rubygems'
require 'hiredis'

class ReaderTest < Test::Unit::TestCase
  def setup
    @reader = Hiredis::Reader.new
  end

  def test_nil
    @reader.feed("$-1\r\n")
    assert_equal nil, @reader.gets
  end

  def test_integer
    value = 2**63-1 # largest 64-bit signed integer
    @reader.feed(":#{value.to_s}\r\n")
    assert_equal value, @reader.gets
  end

  def test_status_string
    @reader.feed("+status\r\n")
    assert_equal "status", @reader.gets
  end

  def test_error_string
    @reader.feed("-error\r\n")
    begin
      @reader.gets
    rescue RuntimeError => e
      assert_equal "error", e.message
    end
  end

  def test_first_error_in_nested_multi_bulk
    @reader.feed("*2\r\n-err1\r\n-err2\r\n")
    begin
      @reader.gets
    rescue RuntimeError => e
      assert_equal "err1", e.message
    end
  end

  def test_empty_bulk_string
    @reader.feed("$0\r\n\r\n")
    assert_equal "", @reader.gets
  end

  def test_bulk_string
    @reader.feed("$5\r\nhello\r\n")
    assert_equal "hello", @reader.gets
  end

  def test_null_multi_bulk
    @reader.feed("*-1\r\n")
    assert_equal nil, @reader.gets
  end

  def test_empty_multi_bulk
    @reader.feed("*0\r\n")
    assert_equal [], @reader.gets
  end

  def test_multi_bulk
    @reader.feed("*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n")
    assert_equal ["hello", "world"], @reader.gets<commit_msg>Fix tests to work when no error is raised<commit_after>require 'test/unit'
require 'rubygems'
require 'hiredis'

class ReaderTest < Test::Unit::TestCase
  def setup
    @reader = Hiredis::Reader.new
  end

  def test_nil
    @reader.feed("$-1\r\n")
    assert_equal nil, @reader.gets
  end

  def test_integer
    value = 2**63-1 # largest 64-bit signed integer
    @reader.feed(":#{value.to_s}\r\n")
    assert_equal value, @reader.gets
  end

  def test_status_string
    @reader.feed("+status\r\n")
    assert_equal "status", @reader.gets
  end

  def test_error_string
    @reader.feed("-error\r\n")
    assert_raise RuntimeError, "error" do
      @reader.gets
    end
  end

  def test_first_error_in_nested_multi_bulk
    @reader.feed("*2\r\n-err1\r\n-err2\r\n")
    assert_raise RuntimeError, "err1" do
      @reader.gets
    end
  end

  def test_empty_bulk_string
    @reader.feed("$0\r\n\r\n")
    assert_equal "", @reader.gets
  end

  def test_bulk_string
    @reader.feed("$5\r\nhello\r\n")
    assert_equal "hello", @reader.gets
  end

  def test_null_multi_bulk
    @reader.feed("*-1\r\n")
    assert_equal nil, @reader.gets
  end

  def test_empty_multi_bulk
    @reader.feed("*0\r\n")
    assert_equal [], @reader.gets
  end

  def test_multi_bulk
    @reader.feed("*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n")
    assert_equal ["hello", "world"], @reader.gets
{'fraction_non_alphanumeric': 0.13936781609195403, 'fraction_numerical': 0.01293103448275862, 'mean_word_length': 3.0303907380607815, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4470220', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1074, 'n_words': 201}