Sha256: 7c58cb7cfd9b1acf370664e3c36a0df4926f0a900d77c6a06718b36edbae6e30
Contents?: true
Size: 943 Bytes
Versions: 3
Compression:
Stored size: 943 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, 1.0, 2], [1.0, 2.0, 2], [2.0, 3.0, 1] ], histogram.each_bin.map(&: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 -|**************************************************\nmax_count=2\n" assert_equal output_expected, output.string end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
more_math-0.4.0 | tests/histogram_test.rb |
more_math-0.3.3 | tests/histogram_test.rb |
more_math-0.3.2 | tests/histogram_test.rb |