<commit_before>require 'spec_helper'
require File.dirname(__FILE__)+'/../../lib/cloak_id/cloak_id_encoder'

describe CloakId::CloakIdEncoder do

  it 'should raise exception when the id to be cloaked is not numeric' do
    expect {CloakId::CloakIdEncoder.cloak(id)}.to raise_error
  end

  it 'should return the base id after cloaking twice' do
    cloaked_v = CloakId::CloakIdEncoder.cloak(10000,0)
    expect(CloakId::CloakIdEncoder.cloak(cloaked_v,0)).to eql 10000

    cloaked_v = CloakId::CloakIdEncoder.cloak(0xffff25,0x1234)
    expect(CloakId::CloakIdEncoder.cloak(cloaked_v,0x1234)).to eql 0xffff25
  end


  it 'should enforce a minimum length when using modified base 35 encoding' do
    cloaked_v = CloakId::CloakIdEncoder.cloak_mod_35(10000,0,40)

    expect(cloaked_v).to include 'ZZZZZZZZZ'
    expect(cloaked_v).to have(40).characters

    decloaked_id = CloakId::CloakIdEncoder.decloak_mod_35(cloaked_v,0)
    expect(decloaked_id).to eql 10000
  end


  it 'should not modify the cloaked id if the cloaked value is already long enough' do
    cloaked_v = CloakId::CloakIdEncoder.cloak_mod_35(10000,0,5)
    expect(cloaked_v).to_not include 'Z'
    expect(cloaked_v).to have_at_least(5).characters
  end
end<commit_msg>Added test case for base 36 encoding.  Right now this isn't really available, but I will add this as an option later.<commit_after>require 'spec_helper'
require File.dirname(__FILE__)+'/../../lib/cloak_id/cloak_id_encoder'

describe CloakId::CloakIdEncoder do

  it 'should raise exception when the id to be cloaked is not numeric' do
    expect {CloakId::CloakIdEncoder.cloak(id)}.to raise_error
  end

  it 'should return the base id after cloaking twice' do
    cloaked_v = CloakId::CloakIdEncoder.cloak(10000,0)
    expect(CloakId::CloakIdEncoder.cloak(cloaked_v,0)).to eql 10000

    cloaked_v = CloakId::CloakIdEncoder.cloak(0xffff25,0x1234)
    expect(CloakId::CloakIdEncoder.cloak(cloaked_v,0x1234)).to eql 0xffff25
  end

  it 'should be able to perform a base 36 encoding and decoding successfully' do
    cloaked_v = CloakId::CloakIdEncoder.cloak_base36(10000,0)
    decloaked_v = CloakId::CloakIdEncoder.decloak_base36(cloaked_v,0)
    expect(decloaked_v).to eql 10000
  end

  it 'should enforce a minimum length when using modified base 35 encoding' do
    cloaked_v = CloakId::CloakIdEncoder.cloak_mod_35(10000,0,40)

    expect(cloaked_v).to include 'ZZZZZZZZZ'
    expect(cloaked_v).to have(40).characters

    decloaked_id = CloakId::CloakIdEncoder.decloak_mod_35(cloaked_v,0)
    expect(decloaked_id).to eql 10000
  end


  it 'should not modify the cloaked id if the cloaked value is already long enough' do
    cloaked_v = CloakId::CloakIdEncoder.cloak_mod_35(10000,0,5)
    expect(cloaked_v).to_not include 'Z'
    expect(cloaked_v).to have_at_least(5).characters
  end
end
{'fraction_non_alphanumeric': 0.09151943462897527, 'fraction_numerical': 0.04946996466431095, 'mean_word_length': 4.873443983402489, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3504635', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1043, 'n_words': 236}