Sha256: 76b6e02dd9b4c2460da93039676ab3120b70f62fef7b5fdacb327df17e793006
Contents?: true
Size: 760 Bytes
Versions: 3
Compression:
Stored size: 760 Bytes
Contents
require 'test_helper' class ArrayWithTopN < Array include MemoryProfiler::TopN end class TestTopN < Minitest::Test def tn(*vals) ArrayWithTopN.new.concat(vals) end def test_top_n data = tn( 7,1,2,2,3,3,99,3 ) results = data.top_n(2) assert_equal([{data: 3, count: 3}, {data: 2, count: 2}], results) end def test_top_n_with_block data = tn( 0,3,6,1,4,2 ) results = data.top_n(2) do |r| r%3 end assert_equal([{data: 0, count: 3}, {data: 1, count: 2}], results) end def test_top_n_with_block_and_size data = tn( [1,100], [1,10], [2,1], [2,1], [2,1],[3,100] ) results = data.top_n(2) do |r| r end assert_equal([{data: 1, count: 110}, {data: 3, count: 100}], results) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
memory_profiler-0.0.3 | test/test_top_n.rb |
memory_profiler-0.0.2 | test/test_top_n.rb |
memory_profiler-0.0.1 | test/test_top_n.rb |