Sha256: 71eaf0c0b30c6d245c25339afb571233162f32b71b0d64434b9970ed594b1088

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb'))

require 'numerals'

class TestRepeatDetector <  Test::Unit::TestCase # < Minitest::Test

  include Numerals

  def test_repeat_detector

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], nil],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8])
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8])
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8], nil],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8], 2)
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8], 2)
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8])
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8], nil],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8], 3)
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8,6,7,8], 3)
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8,6,7,8], 2)
    )

    assert_equal(
      [[2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8], 8],
      RepeatDetector.detect([2, 5, 4, 3, 4, 2, 1, 2, 6, 7, 8, 6, 7, 8, 6, 7, 8,6,7,8])
    )

    assert_equal(
      [[3], 0],
      RepeatDetector.detect([3, 3], 1)
    )

    assert_equal(
      [[3, 3], nil],
      RepeatDetector.detect([3, 3], 2)
    )

    assert_equal(
      [[3], 0],
      RepeatDetector.detect([3, 3, 3], 2)
    )

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
numerals-0.3.1 test/test_repeat_detector.rb
numerals-0.3.0 test/test_repeat_detector.rb
numerals-0.2.1 test/test_repeat_detector.rb