|
1 | 1 | $: << File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
|
2 | 2 | require "algorithms"
|
3 | 3 |
|
4 |
| -describe "binary search tree" do |
5 |
| - it "should let user insert new elements with key" do |
6 |
| - @bst = Containers::CBst.new |
7 |
| - 100.times { |x| @bst.insert(x, "hello : #{x}") } |
8 |
| - @bst.size.should eql(100) |
9 |
| - end |
| 4 | +begin |
| 5 | + Containers::CBst |
| 6 | + describe "binary search tree" do |
| 7 | + it "should let user insert new elements with key" do |
| 8 | + @bst = Containers::CBst.new |
| 9 | + 100.times { |x| @bst.insert(x, "hello : #{x}") } |
| 10 | + @bst.size.should eql(100) |
| 11 | + end |
10 | 12 |
|
11 |
| - it "should allow users to delete elements" do |
12 |
| - @bst = Containers::CBst.new |
13 |
| - @bst.insert(10, "hello world") |
14 |
| - @bst.insert(11, "hello world") |
15 |
| - @bst.delete(11) |
16 |
| - @bst.size.should eql(1) |
17 |
| - @bst.delete(10) |
18 |
| - @bst.size.should eql(0) |
19 |
| - end |
| 13 | + it "should allow users to delete elements" do |
| 14 | + @bst = Containers::CBst.new |
| 15 | + @bst.insert(10, "hello world") |
| 16 | + @bst.insert(11, "hello world") |
| 17 | + @bst.delete(11) |
| 18 | + @bst.size.should eql(1) |
| 19 | + @bst.delete(10) |
| 20 | + @bst.size.should eql(0) |
| 21 | + end |
20 | 22 |
|
21 |
| - it "should throw exception on invalid key delete" do |
22 |
| - @bst = Containers::CBst.new |
23 |
| - @bst.insert(10,"Hello world") |
24 |
| - lambda { @bst.delete(20) }.should raise_error(ArgumentError) |
25 |
| - @bst.size.should eql(1) |
| 23 | + it "should throw exception on invalid key delete" do |
| 24 | + @bst = Containers::CBst.new |
| 25 | + @bst.insert(10,"Hello world") |
| 26 | + lambda { @bst.delete(20) }.should raise_error(ArgumentError) |
| 27 | + @bst.size.should eql(1) |
| 28 | + end |
26 | 29 | end
|
| 30 | +rescue Exception |
27 | 31 | end
|
0 commit comments