Sha256: 4e6783e376d7545e72631519cbd172187bf5e3b422145ead1da3784bebb49fdc
Contents?: true
Size: 785 Bytes
Versions: 4
Compression:
Stored size: 785 Bytes
Contents
require_relative 'spec_helper' describe Melisa::IntTrie do let(:hash) { {'one' => 1, 'two' => 2, 'onetwo' => 3} } let(:trie) { Melisa::IntTrie.new(hash) } it "stores values" do trie['one'].should == 1 trie['two'].should == 2 trie['onetwo'].should == 3 end it "sets and gets values" do trie['five'] = 5 expect(trie['five']).to eq 5 end it "retreives many values by prefix" do trie.get_all('one').should =~ [1, 3] end it "#each iterates yielding integer values" do expect { |b| trie.each(&b) }.to \ yield_successive_args(['onetwo', 3], ['one', 1], ['two', 2]) end it "#sum produces the total value of subtree" do expect(trie.sum).to eq 6 expect(trie.sum('one')).to eq(4) expect(trie.sum('two')).to eq(2) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
melisa-0.2.5 | spec/int_trie_spec.rb |
melisa-0.2.4 | spec/int_trie_spec.rb |
melisa-0.2.3 | spec/int_trie_spec.rb |
melisa-0.2.2 | spec/int_trie_spec.rb |