Skip to content

Commit 021454e

Browse files
committed
BST spec now multi-ruby
1 parent 91665f9 commit 021454e

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

ext/containers/bst/bst.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static VALUE rb_bst_size(VALUE self) {
192192

193193
static VALUE mContainers;
194194

195-
void Init_cbst() {
195+
void Init_CBst() {
196196
id_compare_operator = rb_intern("<=>");
197197
mContainers = rb_define_module("Containers");
198198
VALUE cbst_class = rb_define_class_under(mContainers,"CBst",rb_cObject);
@@ -203,11 +203,3 @@ void Init_cbst() {
203203
rb_define_method(cbst_class,"delete",rb_bst_delete,1);
204204
rb_define_method(cbst_class,"size",rb_bst_size,0);
205205
}
206-
207-
/*
208-
Local Variables:
209-
mode:c
210-
indent-tabs-mode:nil
211-
c-basic-offset:4
212-
End:
213-
*/

spec/bst_spec.rb

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
$: << File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
22
require "algorithms"
33

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
1012

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
2022

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
2629
end
30+
rescue Exception
2731
end

0 commit comments

Comments
 (0)