Skip to content

Commit

Permalink
Forming a sensible sentence for the "empty points" error message. Tes…
Browse files Browse the repository at this point in the history
…ting that case.
  • Loading branch information
abscondment committed Jan 29, 2009
1 parent 12ffa8d commit 2b79e60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/rb_cComputation.c
Expand Up @@ -34,7 +34,7 @@ RubyVor_from_points(VALUE self, VALUE pointsArray)

/* Require nonzero size and x & y methods on each array object */
if (RARRAY(pointsArray)->len < 1)
rb_raise(rb_eRuntimeError, "points array have a nonzero length");
rb_raise(rb_eRuntimeError, "input points array must have a nonzero length");
for (i = 0; i < RARRAY(pointsArray)->len; i++) {
if(!rb_respond_to(RARRAY(pointsArray)->ptr[i], x) || !rb_respond_to(RARRAY(pointsArray)->ptr[i], y))
rb_raise(rb_eRuntimeError, "members of points array must respond to 'x' and 'y'");
Expand Down
10 changes: 10 additions & 0 deletions test/test_computation.rb
Expand Up @@ -9,6 +9,16 @@ def initialize(*args)
super(*args)
end

def test_empty_points
assert_raises TypeError do
RubyVor::VDDT::Computation.from_points(nil)
end

assert_raises RuntimeError do
RubyVor::VDDT::Computation.from_points([])
end
end

def test_nn_graph
comp = RubyVor::VDDT::Computation.from_points(sample_points)

Expand Down

0 comments on commit 2b79e60

Please sign in to comment.