cirandas.net

ref: master

test/unit/helper_test.rb


 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
61
62
require_relative "../test_helper"

class HelperTest < ActiveSupport::TestCase

  should 'assert_equivalent be true for the same arrays' do
    a1 = [1,2,3]
    a2 = [1,2,3]
    assert_equivalent a1, a2
  end

  should 'assert_equivalent be true for equivalent arrays' do
    a1 = [1,2,3]
    a2 = [3,2,1]
    assert_equivalent a1, a2
  end

  should 'assert_equivalent be true for equivalent arrays independent of parameter order' do
    a1 = [1,2,3]
    a2 = [3,2,1]
    assert_equivalent a2, a1
  end

  should 'assert_equivalent be false for different arrays' do
    a1 = [1,2,3]
    a2 = [4,2,1]
    assert_raise Minitest::Assertion do
      assert_equivalent(a1, a2)
    end
  end

  should 'assert_equivalent be false for different arrays independent of parameter order' do
    a1 = [1,2,3]
    a2 = [4,2,1]
    assert_raise Minitest::Assertion do
      assert_equivalent(a2, a1)
    end
  end

  should 'assert_equivalent be false for arrays with different sizes' do
    a1 = [1,2,3]
    a2 = [1,2,3,4]
    assert_raise Minitest::Assertion do
      assert_equivalent(a1, a2)
    end
  end

  should 'assert_equivalent be false for arrays with same elements duplicated' do
    a1 = [2,2,3]
    a2 = [2,3,3]
    assert_raise Minitest::Assertion do
      assert_equivalent(a1, a2)
    end
  end

  should 'assert_equivalent be false for arrays with same elements duplicated of different sizes' do
    a1 = [2,2,3]
    a2 = [2,3,3,3]
    assert_raise Minitest::Assertion do
      assert_equivalent(a1, a2)
    end
  end
end