Sha256: 83f8535b7ab0e881f243e694ac1e459872d31d0fb027718d372df1ba5ee9419e
Contents?: true
Size: 1014 Bytes
Versions: 45
Compression:
Stored size: 1014 Bytes
Contents
#!/usr/bin/env ruby require 'minitest/autorun' require_relative 'pythagorean_triplet' class TripletTest < Minitest::Test def test_sum assert_equal 12, Triplet.new(3, 4, 5).sum end def test_product skip assert_equal 60, Triplet.new(3, 4, 5).product end def test_pythagorean skip assert Triplet.new(3, 4, 5).pythagorean? end def test_not_pythagorean skip refute Triplet.new(5, 6, 7).pythagorean? end def test_triplets_upto_10 skip triplets = Triplet.where(max_factor: 10) products = triplets.map(&:product).sort assert_equal [60, 480], products end def test_triplets_from_11_upto_20 skip triplets = Triplet.where(min_factor: 11, max_factor: 20) products = triplets.map(&:product).sort assert_equal [3840], products end def test_triplets_where_sum_x skip triplets = Triplet.where(sum: 180, max_factor: 100) products = triplets.map(&:product).sort assert_equal [118_080, 168_480, 202_500], products end end
Version data entries
45 entries across 45 versions & 1 rubygems