Skip to content
This repository
Browse code

[BUGFIX] Empty input should always be a potential match

  • Loading branch information...
commit ea6ef2204d3567c662b3fca33d27d4b00de30630 1 parent ff6265d
Ben Langfeld authored
2  ext/ruby_speech/ruby_speech.c
@@ -82,7 +82,7 @@ static VALUE method_find_match(VALUE self, VALUE buffer)
82 82 }
83 83 return rb_funcall(self, rb_intern("match_for_buffer"), 1, buffer);
84 84 }
85   - if (result == PCRE_ERROR_PARTIAL) {
  85 + if (result == PCRE_ERROR_PARTIAL || (int)strlen(input) == 0) {
86 86 VALUE PotentialMatch = rb_const_get(GRXML, rb_intern("PotentialMatch"));
87 87 return rb_class_new_instance(0, NULL, PotentialMatch);
88 88 }
3  spec/ruby_speech/grxml/builtins_spec.rb
@@ -145,7 +145,8 @@
145 145 it { should match('0123*456').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6') }
146 146 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') }
147 147
148   - it { should not_match('') }
  148 + it { should potentially_match('') }
  149 +
149 150 it { should not_match('#') }
150 151 end
151 152
4 spec/ruby_speech/grxml/matcher_spec.rb
@@ -27,6 +27,10 @@ module GRXML
27 27 input.should == '6'
28 28 end
29 29
  30 + it "should potentially match an empty buffer" do
  31 + subject.match('').should == GRXML::PotentialMatch.new
  32 + end
  33 +
30 34 %w{1 2 3 4 5 7 8 9 10 66 26 61}.each do |input|
31 35 it "should not match '#{input}'" do
32 36 subject.match(input).should == GRXML::NoMatch.new

0 comments on commit ea6ef22

Please sign in to comment.
Something went wrong with that request. Please try again.