summaryrefslogtreecommitdiff
path: root/test/test_list.rb
blob: 6e4c1deaebd97f5347f0bf0887d03b12934be865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env ruby
# coding: utf-8

require "test_helper"

require "highline/list"

class TestHighLineList < Minitest::Test
  def setup
    @items = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" ]
  end

  def test_in_2_cols
    list_in_two_cols =
      [ [ "a", "b" ],
        [ "c", "d" ],
        [ "e", "f" ],
        [ "g", "h" ],
        [ "i", "j" ] ]

    highline_list = HighLine::List.new(@items, cols: 2)

    assert_equal list_in_two_cols, highline_list.list
  end

  def test_in_2_cols_col_down
    col_down_list =
      [ [ "a", "f"],
        [ "b", "g"],
        [ "c", "h"],
        [ "d", "i"],
        [ "e", "j"] ]

    highline_list = HighLine::List.new(@items, cols: 2, col_down: true)

    assert_equal col_down_list, highline_list.list
  end

  def test_in_2_cols_transposed
    transposed_list =
      [ [ "a", "c", "e", "g", "i" ],
        [ "b", "d", "f", "h", "j" ] ]

    highline_list = HighLine::List.new(@items, cols: 2, transpose: true)

    assert_equal transposed_list, highline_list.list
  end

  def test_in_3_cols
    list_in_three_cols =
      [ [ "a", "b", "c" ],
        [ "d", "e", "f" ],
        [ "g", "h", "i" ],
        [ "j" ] ]

    highline_list = HighLine::List.new(@items, cols: 3)

    assert_equal list_in_three_cols, highline_list.list
  end
end