Fixed issue with matcher

This commit is contained in:
Jocelyn Fiat
2011-07-22 17:28:42 +02:00
parent 6599bf1a07
commit 4940ddb8f5
4 changed files with 20 additions and 5 deletions

View File

@@ -178,7 +178,7 @@ feature -- Match
else
from
l_expressions.start
p := 1
p := 0
l_offset := 0
until
l_expressions.after or not b
@@ -187,10 +187,14 @@ feature -- Match
vn := exp.expression
q := exp.position
--| Check text between vars
--| FIXME jfiat [2011/07/22] : check this ...
if p = q then
--| There should be at least one literal between two expression
--| {var}{foobar} is ambigous for matching ...
if q > p then
b := False
elseif q > p then
if p = 0 then
p := 1
end
t := tpl.substring (p, q - 1)
s := a_uri.substring (p + l_offset, q + l_offset - 1)
b := s.same_string (t)

View File

@@ -29,6 +29,12 @@ feature -- Test routines
local
tpl: URI_TEMPLATE
do
create tpl.make ("{version}/{id}")
uri_template_match (tpl, "v2/123", <<["version", "v2"], ["id" , "123"]>>, <<>>)
create tpl.make ("api/{foo}{bar}/id/{id}")
uri_template_mismatch (tpl, "api/foobar/id/123")
create tpl.make ("api/foo/{foo_id}/{?id,extra}")
uri_template_match (tpl, "api/foo/bar/", <<["foo_id", "bar"]>>, <<>>)
uri_template_match (tpl, "api/foo/bar/?id=123", <<["foo_id", "bar"]>>, <<["id", "123"]>>)

View File

@@ -29,6 +29,13 @@ feature -- Test routines
local
tpl: URI_TEMPLATE
do
create tpl.make ("{version}/{id}")
uri_template_match (tpl, "v2/123", <<["version", "v2"], ["id" , "123"]>>, <<>>)
create tpl.make ("api/{foo}{bar}/id/{id}")
uri_template_mismatch (tpl, "api/foobar/id/123")
create tpl.make ("api/foo/{foo_id}/{?id,extra}")
uri_template_match (tpl, "api/foo/bar/", <<["foo_id", "bar"]>>, <<>>)
uri_template_match (tpl, "api/foo/bar/?id=123", <<["foo_id", "bar"]>>, <<["id", "123"]>>)

View File

@@ -40,8 +40,6 @@
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
<assertions precondition="true"/>
</option>
<setting name="console_application" value="false"/>
<variable name="uri_template" value="draft_05"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<tests name="tests" location=".\tests\"/>
</target>