Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[BUGFIX] Empty input should always be a potential match

  • Loading branch information...
commit ea6ef2204d3567c662b3fca33d27d4b00de30630 1 parent ff6265d
@benlangfeld authored
View
2  ext/ruby_speech/ruby_speech.c
@@ -82,7 +82,7 @@ static VALUE method_find_match(VALUE self, VALUE buffer)
}
return rb_funcall(self, rb_intern("match_for_buffer"), 1, buffer);
}
- if (result == PCRE_ERROR_PARTIAL) {
+ if (result == PCRE_ERROR_PARTIAL || (int)strlen(input) == 0) {
VALUE PotentialMatch = rb_const_get(GRXML, rb_intern("PotentialMatch"));
return rb_class_new_instance(0, NULL, PotentialMatch);
}
View
3  spec/ruby_speech/grxml/builtins_spec.rb
@@ -145,7 +145,8 @@
it { should match('0123*456').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6') }
it { should match('0123*456*789').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6 dtmf-star dtmf-7 dtmf-8 dtmf-9') }
- it { should not_match('') }
+ it { should potentially_match('') }
+
it { should not_match('#') }
end
View
4 spec/ruby_speech/grxml/matcher_spec.rb
@@ -27,6 +27,10 @@ module GRXML
input.should == '6'
end
+ it "should potentially match an empty buffer" do
+ subject.match('').should == GRXML::PotentialMatch.new
+ end
+
%w{1 2 3 4 5 7 8 9 10 66 26 61}.each do |input|
it "should not match '#{input}'" do
subject.match(input).should == GRXML::NoMatch.new
Please sign in to comment.
Something went wrong with that request. Please try again.