TeensyMud - 'A ruby mud server.'

Browse repository
back

test_ternarytrie.rb

# Code Generated by ZenTest v. 2.3.0
# classname: asrt / meth = ratio%
# TernaryTrie: 11 / 5 = 220.00%

unless defined? $ZENTEST and $ZENTEST
require 'test/unit'
require 'utility/ternarytrie'
end

class TestTernaryTrie < Test::Unit::TestCase
def setup
@t = TernaryTrie.new
end

def test_find
assert(true, @t.insert("two", 2))
assert(true, @t.insert("three", 3))
assert_equal([3,2], @t.find("t"))
assert_equal([2], @t.find("tw"))
assert_equal([], @t.find("o"))
end

def test_find_exact
assert(true, @t.insert("one", 1))
assert_equal(1, @t.find_exact("one"))
assert_equal(nil, @t.find_exact("two"))
end

def test_insert
assert(true, @t.insert("one", 1))
assert_equal(1, @t.find_exact("one"))
end

def test_to_hash
assert(true, @t.insert("one", 1))
assert(true, @t.insert("two", 2))
assert(true, @t.insert("three", 3))
assert_equal({"one" => 1, "two" => 2, "three" => 3},
@t.to_hash)
end
end