Skip to content

Instantly share code, notes, and snippets.

@remear
Created April 10, 2012 16:11
Show Gist options
  • Select an option

  • Save remear/2352505 to your computer and use it in GitHub Desktop.

Select an option

Save remear/2352505 to your computer and use it in GitHub Desktop.
require "test/unit"
class TestMaximum < Test::Unit::TestCase
def maximum(arr)
arr.length == 1 ? arr.first : arr.sort.last
end
def test_maximum
assert_equal maximum([2, 42, 22, 02]), 42
assert_equal maximum([-2, 0, 33, 304, 2, -2]), 304
assert_equal maximum([1]), 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment