-
Notifications
You must be signed in to change notification settings - Fork 0
/
largest_sum_test.rb
73 lines (58 loc) · 1.3 KB
/
largest_sum_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
63
64
65
66
67
68
69
70
71
72
73
require_relative 'largest_sum'
require 'test/unit'
class MyTest < Test::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
# Do nothing
end
# Called after every test method runs. Can be used to tear
# down fixture information.
def teardown
# Do nothing
end
def test_one
arr = [1]
assert_equal 1, largest_sum(arr)
end
def test_two
arr = [3, 4]
assert_equal 7, largest_sum(arr)
end
def test_three
arr = [2, -1, 3]
assert_equal 4, largest_sum(arr)
end
def test_four
arr = [2, -4, 3]
assert_equal 3, largest_sum(arr)
end
def test_five
arr = [-4, 5, -10, 11, -10, 1, 2]
assert_equal 11, largest_sum(arr)
end
def test_six
arr = [-4, 5, 0, 1, -1, 0, 0, 1, 2]
assert_equal 8, largest_sum(arr)
end
def test_seven
arr = [10, -15, 1, 2, 3, 4, -12]
assert_equal 10, largest_sum(arr)
end
def test_eight
arr = [-5, -4, -3, -2, -1, 0]
assert_equal 0, largest_sum(arr)
end
def test_nine
arr = [-5, -4, -3, -2]
assert_equal -2, largest_sum(arr)
end
def test_sample_one
arr = [-10, 2, 3, -2, 0, 5, -15]
assert_equal 8, largest_sum(arr)
end
def test_sample_two
arr = [2,3,-2,-1,10]
assert_equal 12, largest_sum(arr)
end
end