<commit_before>require 'cases/helper'

class UrlSafeBase64Test < ActiveRecord::TestCase
  def test_encode_with_nil
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(nil)
    end
  end

  def test_encode_with_false
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(false)
    end
  end

  def test_encode_with_number
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(12345)
    end
  end

  def test_encode_with_null_string
    assert_equal "AAAAAAAAAAAAAAAAAAAAAA", GoldRecord.urlsafe_encode64("\000" * 16)
  end

  def test_encode_omits_padding_characters
    assert_no_match /[=]/, GoldRecord.urlsafe_encode64("\001" * 16)
  end

  def test_encode_omits_newlines
    assert_no_match /[\r\n]/, GoldRecord.urlsafe_encode64("\002" * 16)
  end
  
  def test_translation_of_plus_characters
    encoded = GoldRecord.urlsafe_encode64("\x7e" * 16)
    assert_no_match /[+]/, encoded
    assert_equal "fn5-fn5-fn5-fn5-fn5-fg", encoded
  end
  
  def test_translation_of_slash_characters
    encoded = GoldRecord.urlsafe_encode64("\x7f" * 16)
    assert_no_match /\//, encoded
    assert_equal "f39_f39_f39_f39_f39_fw", encoded
  end
end<commit_msg>Initial tests for URL-safe Base64 decoding.<commit_after>require 'cases/helper'

class UrlSafeBase64Test < ActiveRecord::TestCase
  def test_encode_with_nil
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(nil)
    end
  end

  def test_encode_with_false
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(false)
    end
  end

  def test_encode_with_number
    assert_raise TypeError do
      GoldRecord.urlsafe_encode64(12345)
    end
  end

  def test_encode_with_null_string
    assert_equal "AAAAAAAAAAAAAAAAAAAAAA", GoldRecord.urlsafe_encode64("\000" * 16)
  end

  def test_encode_omits_padding_characters
    assert_no_match /[=]/, GoldRecord.urlsafe_encode64("\001" * 16)
  end

  def test_encode_omits_newlines
    assert_no_match /[\r\n]/, GoldRecord.urlsafe_encode64("\002" * 16)
  end
  
  def test_translation_of_plus_characters
    encoded = GoldRecord.urlsafe_encode64("\x7e" * 16)
    assert_no_match /[+]/, encoded
    assert_equal "fn5-fn5-fn5-fn5-fn5-fg", encoded
  end
  
  def test_translation_of_slash_characters
    encoded = GoldRecord.urlsafe_encode64("\x7f" * 16)
    assert_no_match /\//, encoded
    assert_equal "f39_f39_f39_f39_f39_fw", encoded
  end

  def test_decode_with_nil
    assert_raise NoMethodError do
      GoldRecord.urlsafe_decode64(nil)
    end
  end

  def test_decode_with_false
    assert_raise NoMethodError do
      GoldRecord.urlsafe_decode64(false)
    end
  end

  def test_decode_with_number
    assert_raise NoMethodError do
      GoldRecord.urlsafe_decode64(12345)
    end
  end
end
{'fraction_non_alphanumeric': 0.07163636363636364, 'fraction_numerical': 0.047636363636363636, 'mean_word_length': 3.895017793594306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4533817', 'n_tokens_mistral': 1045, 'n_tokens_neox': 969, 'n_words': 172}