Sha256: ab3d2000353c28a8a423b665300a0424f3d9bc6fed6cc4116e330ec4d2a220fd

Contents?: true

Size: 708 Bytes

Versions: 16

Compression:

Stored size: 708 Bytes

Contents

#!/usr/bin/env ruby

require 'test_helper'
require 'more_math'

class CantorPairingFunctionTest < Test::Unit::TestCase
  include MoreMath::Functions

  def test_cantor_pairing_function
    assert_equal 69, cantor_pairing([ 1, 2, 3 ])
    assert_equal 69, cantor_pairing(1, 2, 3)
    assert_equal 172, cantor_pairing(3, 2, 1)
    assert_raise(ArgumentError) { cantor_pairing([ 1 ]) }
    assert_raise(ArgumentError) { cantor_pairing(1) }
  end

  def test_cantor_pairing_function_inv
    assert_equal [ 8, 3 ], cantor_pairing_inv(69)
    assert_equal [ 1, 2, 3 ], cantor_pairing_inv(69, 3)
    assert_equal [ 17, 1 ], cantor_pairing_inv(172)
    assert_equal [ 3, 2, 1 ], cantor_pairing_inv(172, 3)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
more_math-1.3.0 tests/cantor_pairing_function_test.rb
more_math-1.2.2 tests/cantor_pairing_function_test.rb
more_math-1.2.1 tests/cantor_pairing_function_test.rb
more_math-1.2.0 tests/cantor_pairing_function_test.rb
more_math-1.1.0 tests/cantor_pairing_function_test.rb
more_math-1.0.2 tests/cantor_pairing_function_test.rb
more_math-1.0.1 tests/cantor_pairing_function_test.rb
more_math-1.0.0 tests/cantor_pairing_function_test.rb
more_math-0.4.0 tests/cantor_pairing_function_test.rb
more_math-0.3.3 tests/cantor_pairing_function_test.rb
more_math-0.3.2 tests/cantor_pairing_function_test.rb
more_math-0.3.1 tests/cantor_pairing_function_test.rb
more_math-0.3.0 tests/cantor_pairing_function_test.rb
more_math-0.2.1 tests/cantor_pairing_function_test.rb
more_math-0.1.0 tests/cantor_pairing_function_test.rb
more_math-0.0.4 tests/cantor_pairing_function_test.rb