Skip to content

Commit

Permalink
added tests for waves 1 & 2
Browse files Browse the repository at this point in the history
  • Loading branch information
CheezItMan committed Oct 1, 2019
1 parent 98623ce commit 0ce0f46
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
70 changes: 70 additions & 0 deletions test/max_sub_array_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
require_relative "test_helper"

xdescribe "max subarray" do
it "will work for [-2,1,-3,4,-1,2,1,-5,4]" do
# Arrange
input = [-2,1,-3,4,-1,2,1,-5,4]

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_equal 6
end

it "will work with a totally negative array" do
# Arrange
input = [-3, -4, -5, -6, -7]

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_equal(-3)
end

it "will work with a totally negative array with the largest element at the rear" do
# Arrange
input = [ -4, -5, -6, -7, -3]

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_equal(-3)
end

it "will work with a 1-element array" do
# Arrange
input = [3]

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_equal 3
end

it "will return nil for an empty array" do
# Arrange
input = []

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_be_nil
end

it "will work for [50, -50, 50]" do
# Arrange
input = [50, -50, 50]

# Act
answer = max_sub_array(input)

# Assert
expect(answer).must_equal 50
end

end
2 changes: 1 addition & 1 deletion test/newman_conway_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Act-Assert
expect {
answer = newman_conway(input)
newman_conway(input)
}.must_raise ArgumentError


Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new

require_relative '../lib/newman_conway'
require_relative "../lib/newman_conway"
require_relative "../lib/max_subarray"

0 comments on commit 0ce0f46

Please sign in to comment.