<commit_before># encoding: utf-8

require 'iso/iban'

suite "ISO::IBAN" do
  setup do
    ISO::IBAN.instance_variable_set(:@specifications, {'CH' => ISO::IBAN::Specification.new("Switzerland", "CH", "CH2!n5!n12!c", 21, "5!n12!c", 17, 4, 8, nil, nil)})
  end

  test 'ISO::IBAN::generate problem, TODO' do
    ISO::IBAN.instance_variable_set(:@specifications, {'BG' => ISO::IBAN::Specification.new("Bulgaria", "BG", "BG2!n4!a4!n2!n8!c", 22, "4!a4!n2!n8!c", 18, 4, 7, 8, 11)})
    assert ISO::IBAN.generate('BG', '1', '2', '3', 'C').valid?
  end

  test 'ISO::IBAN::load_specifications' do
    reset_test_files

    ISO::IBAN.load_specifications(test_file('test_spec.yaml'))
    specs = ISO::IBAN.specifications
    assert_kind_of Hash, specs
    specs.each do |key, value|
      assert_kind_of String, key
      assert_kind_of ISO::IBAN::Specification, value
      assert_equal key, value.a2_country_code
    end
    assert_equal ["AL", "AD"], specs.keys
  end

  test 'ISO::IBAN::numerify' do
    assert_equal 121735123459876543210910, ISO::IBAN.numerify('CH351234598765432109A')<commit_msg>Updated test-case for the still failing case.<commit_after># encoding: utf-8

require 'iso/iban'

suite "ISO::IBAN" do
  setup do
    ISO::IBAN.instance_variable_set(:@specifications, {'CH' => ISO::IBAN::Specification.new("Switzerland", "CH", "CH2!n5!n12!c", 21, "5!n12!c", 17, 4, 8, nil, nil)})
  end

  test 'ISO::IBAN::generate problem, TODO' do
    ISO::IBAN.instance_variable_set(:@specifications, {'BG' => ISO::IBAN::Specification.new("Bulgaria", "BG", "BG2!n4!a4!n2!n8!c", 22, "4!a4!n2!n8!c", 18, 4, 7, 8, 11)})
    assert ISO::IBAN.generate('BG', 'AAAA', '2', 'C').valid? # this works now
    assert ISO::IBAN.generate('BG', 'A', '2', 'C').valid? # this still fails, because ISO::IBAN::generate can't pad 'a' format fields
  end

  test 'ISO::IBAN::load_specifications' do
    reset_test_files

    ISO::IBAN.load_specifications(test_file('test_spec.yaml'))
    specs = ISO::IBAN.specifications
    assert_kind_of Hash, specs
    specs.each do |key, value|
      assert_kind_of String, key
      assert_kind_of ISO::IBAN::Specification, value
      assert_equal key, value.a2_country_code
    end
    assert_equal ["AL", "AD"], specs.keys
  end

  test 'ISO::IBAN::numerify' do
    assert_equal 121735123459876543210910, ISO::IBAN.numerify('CH351234598765432109A')
{'fraction_non_alphanumeric': 0.169699534490055, 'fraction_numerical': 0.06559458315700381, 'mean_word_length': 4.96969696969697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '485288', 'n_tokens_mistral': 998, 'n_tokens_neox': 892, 'n_words': 186}