Sha256: 020d94238a904b558ef120d90ce0e1c4e8a860a9580930d83b33de97c314599b

Contents?: true

Size: 901 Bytes

Versions: 2

Compression:

Stored size: 901 Bytes

Contents

require_relative 'test_helper'

require 'test/unit'
require 'chartd'

class Chartd::EncodeTest < Test::Unit::TestCase
  def test_encode
    testcases = [
      [[1.2, 2.4, 3.1], 'Am9'],
      [[40, 50, 33.2], 'Y8A'],
      [[0, 9, 9], 'A99'],
      [[0.944, 0.170, 0.201, 0.839, 0.284, 0.485, 0.154, 0.431, 0.119, 0.679], '9DG1MbCXAp'],
      [[0, -2, 9], 'LA9'],
      [[0], 'A'],
      [[], ''],
    ]

    testcases.each do |d, expected|
      assert_equal expected, Chartd::Encoder.encode(d)
    end
  end

  def test_encode_custom_min_max
    testcases = {
      'Ueo' => [[20, 30, 40], 0, 60],
      'Ae9' => [[20, 30, 40], 20, 40],
    }

    testcases.each do |expected, data|
      assert_equal expected, Chartd::Encoder.encode(data[0], min: data[1], max: data[2])
    end
  end

  def test_encode_helper
    assert_equal Chartd::Encoder.encode([1, 2, 3]), Chartd.encode([1, 2, 3])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chartd-1.0.1 test/test_encode.rb
chartd-1.0.0 test/test_encode.rb