Sha256: 43ee3ee40b4585474612f03d2a058045f848a8a2f763a48ff7e9350dceab4e28

Contents?: true

Size: 914 Bytes

Versions: 5

Compression:

Stored size: 914 Bytes

Contents

#!/usr/bin/env ruby

require 'test_helper'
require 'more_math'
require 'stringio'

class HistogramTest < Test::Unit::TestCase
  include MoreMath

  def test_histogram
    sequence = Sequence.new [ 1, 2, 3, 0, 2 ]
    histogram = Histogram.new sequence, 3
    assert_equal [ [0.0, 2, 1.0], [1.0, 2, 2.0], [2.0, 1, 3.0] ],
      histogram.to_a
  end

  def test_histogram_display
    sequence = Sequence.new [ 1, 2, 3, 0, 2 ]
    histogram = Histogram.new sequence, 3
    assert_equal [[2.0, 25, 3.0], [1.0, 50, 2.0], [0.0, 50, 1.0]],
      histogram.instance_eval { prepare_display(50) }
    output = StringIO.new
    histogram.display output
    output_expected =
      "    2.50000 -|*************************\n    1.50000 -|*******************************"\
      "*******************\n    0.50000 -|**************************************************\n"
    assert_equal output_expected, output.string
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
more_math-0.3.1 tests/histogram_test.rb
more_math-0.3.0 tests/histogram_test.rb
more_math-0.2.1 tests/histogram_test.rb
more_math-0.1.0 tests/histogram_test.rb
more_math-0.0.4 tests/histogram_test.rb