Sha256: 415b5dd6d8a8b1abc0c7842a5e20a8a6e39a98e9d143c4ade3207b51c2867543

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

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

require 'numerals'
include Numerals

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

  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

2 entries across 2 versions & 1 rubygems

Version Path
numerals-0.2.0 test/test_repeat_detector.rb
numerals-0.1.0 test/test_repeat_detector.rb