Sha256: d6a1e3a36701894bc6e64d38b6f04057ab5b2f65ebd4508852220cb6fb010d70

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

require 'test/unit'

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'cartesian'

class TestCartesian < Test::Unit::TestCase
  def test_arrays
    foo = [1,2,3]
    bar = %w{a b c}
    expected = [[1, "a"], [1, "b"], [1, "c"], [2, "a"], [2, "b"],
                [2, "c"], [3, "a"], [3, "b"], [3, "c"]]
    assert(foo.x(bar).to_a == expected)
  end

  def test_ranges
    foo = 1..3
    bar = 4..6
    expected = [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5],
                [2, 6], [3, 4], [3, 5], [3, 6]]
    assert(foo.x(bar).to_a == expected)
  end

  def test_mixed
    foo = 1..3
    bar = %w{a b c}
    expected = [[1, "a"], [1, "b"], [1, "c"], [2, "a"], [2, "b"],
                [2, "c"], [3, "a"], [3, "b"], [3, "c"]]
    assert(foo.x(bar).to_a == expected)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Cartesian-0.2.1 tests/tc_cartesian.rb
Cartesian-0.2.3 tests/tc_cartesian.rb