<commit_before>#!/usr/bin/env ruby
$:.unshift(File.expand_path('../../lib', __FILE__))
%w{querystring test/unit}.each{|i| require i}

class QueryStringTest < Test::Unit::TestCase
  include QueryString

  # shorthand stringify
  def s *a
    QueryString.stringify *a
  end

  def test_stringify
    # testing object
    o = { 
      :a => 1,
      :b => [2,3,4,'http://www.google.com/hello?far=near&war=peace']
    }

    queries = {
      s(o, :array_brackets => true, :array_index => true) => 
        'a=1&b[0]=2&b[1]=3&b[2]=4&b[3]=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_brackets => false, :array_index => true) =>
        'a=1&b0=2&b1=3&b2=4&b3=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_brackets => true, :array_index => false) =>
        'a=1&b[]=2&b[]=3&b[]=4&b[]=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o) =>
        'a=1&b=2&b=3&b=4&b=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :seperator => '|') =>
        'a=1|b=2|b=3|b=4|b=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :equals => '~') =>
        'a~1&b~2&b~3&b~4&b~http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_style => :combine) =>
        'a=1&b=2,3,4,http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_style => :combine, :array_seperator => '.') =>
        'a=1&b=2.3.4.http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace'
    }

    queries.each do |k,v|
      assert_equal(v,k)
    end
  end
end
<commit_msg>Adds version test<commit_after>#!/usr/bin/env ruby
$:.unshift(File.expand_path('../../lib', __FILE__))
%w{querystring test/unit}.each{|i| require i}

class QueryStringTest < Test::Unit::TestCase
  include QueryString

  # shorthand stringify
  def s *a
    QueryString.stringify *a
  end

  def test_stringify
    # testing object
    o = { 
      :a => 1,
      :b => [2,3,4,'http://www.google.com/hello?far=near&war=peace']
    }

    queries = {
      s(o, :array_brackets => true, :array_index => true) => 
        'a=1&b[0]=2&b[1]=3&b[2]=4&b[3]=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_brackets => false, :array_index => true) =>
        'a=1&b0=2&b1=3&b2=4&b3=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_brackets => true, :array_index => false) =>
        'a=1&b[]=2&b[]=3&b[]=4&b[]=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o) =>
        'a=1&b=2&b=3&b=4&b=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :seperator => '|') =>
        'a=1|b=2|b=3|b=4|b=http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :equals => '~') =>
        'a~1&b~2&b~3&b~4&b~http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_style => :combine) =>
        'a=1&b=2,3,4,http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace',
      s(o, :array_style => :combine, :array_seperator => '.') =>
        'a=1&b=2.3.4.http%3A%2F%2Fwww.google.com%2Fhello%3Ffar%3Dnear%26war%3Dpeace'
    }

    queries.each do |k,v|
      assert_equal(v,k)
    end
  end

  def test_version
    assert_not_nil(QueryString::VERSION)
  end
end

{'fraction_non_alphanumeric': 0.21251122418437593, 'fraction_numerical': 0.06944028733912003, 'mean_word_length': 3.988059701492537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, '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': '7283561', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1593, 'n_words': 152}