Sha256: 06f6871b1b9e1190c9b3f689552ea0d4f5ea681e35fe7c0d9f9c9f6e97415499

Contents?: true

Size: 1.51 KB

Versions: 45

Compression:

Stored size: 1.51 KB

Contents

#!/usr/bin/env ruby
require 'minitest/autorun'
require_relative 'palindrome_products'

class PalindromesTest < Minitest::Test
  def test_largest_palindrome_from_single_digit_factors
    palindromes = Palindromes.new(max_factor: 9)
    palindromes.generate
    largest = palindromes.largest
    assert_equal 9, largest.value
    assert_includes [[[3, 3], [1, 9]], [[1, 9], [3, 3]]], largest.factors
  end

  def test_largest_palindrome_from_double_digit_factors
    skip
    palindromes = Palindromes.new(max_factor: 99, min_factor: 10)
    palindromes.generate
    largest = palindromes.largest
    assert_equal 9009, largest.value
    assert_equal [[91, 99]], largest.factors
  end

  def test_smallest_palindrome_from_double_digit_factors
    skip
    palindromes = Palindromes.new(max_factor: 99, min_factor: 10)
    palindromes.generate
    smallest = palindromes.smallest
    assert_equal 121, smallest.value
    assert_equal [[11, 11]], smallest.factors
  end

  def test_largest_palindrome_from_triple_digit_factors
    skip
    palindromes = Palindromes.new(max_factor: 999, min_factor: 100)
    palindromes.generate
    largest = palindromes.largest
    assert_equal 906_609, largest.value
    assert_equal [[913, 993]], largest.factors
  end

  def test_smallest_palindrome_from_triple_digit_factors
    skip
    palindromes = Palindromes.new(max_factor: 999, min_factor: 100)
    palindromes.generate
    smallest = palindromes.smallest
    assert_equal 10_201, smallest.value
    assert_equal [[101, 101]], smallest.factors
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
trackler-2.1.0.32 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.31 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.30 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.29 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.28 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.27 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.26 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.25 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.24 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.23 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.22 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.21 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.20 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.19 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.18 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.17 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.16 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.15 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.14 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.13 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb