# Ruby Treasures 0.1
# Copyright (C) 2001 Paul Brannan <paul@atdesk.com>
# 
# You may distribute this software under the same terms as Ruby (see the file
# COPYING that was distributed with this library).
# 
require 'ds_test_helpers.rb'
require 'sorted_binary_tree'
require 'list'
require 'sorted_hash'
require 'hacks/comparable_nil'
requirelocal 'mixins/container_test'
requirelocal 'mixins/hash_like_test'
requirelocal 'mixins/orderable_test'
requirelocal 'mixins/enumerable_test'
requirelocal 'mixins/indexable_test'
requirelocal 'mixins/comparable_test'
requirelocal 'mixins/pair_enumerable_test'
requirelocal 'mixins/pair_updatable_test'
requirelocal 'mixins/reverse_enumerable_test'

make_nil_comparable(Fixnum)

N = 25

class SortedBinaryTreeTest < DS_Test_Case
  include ContainerTest
  include HashLikeTest
  include OrderableTest
  include EnumerableTest
  include IndexableTest
  include ComparableTest
  include PairEnumerableTest
  include PairUpdatableTest
  include ReverseEnumerableTest

  def initialize(*args)
    super(*args)
    @test_container               = SortedBinaryTree
    @analgous_container           = SortedHash
  end

  def generate_container_from_analgous(container)
    l = SortedBinaryTree.new
    # TODO: Why in this one oddball case is 'for' slower than 'each'?
    # for key, value in container do
    container.each do |key, value|
      # TODO: This will insert all the key/value pairs in order; perhaps they
      # should be randomized so that the tree is not lop-sided?
      l[key] = value
    end
    l # return
  end
end

exit run_test(SortedBinaryTreeTest, SortedBinaryTree)

