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.53 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.52 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.51 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.50 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.49 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.48 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.47 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.46 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.45 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.44 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.43 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.42 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.41 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.40 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.39 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.38 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.37 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.36 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.34 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb
trackler-2.1.0.33 tracks/ruby/exercises/palindrome-products/palindrome_products_test.rb