Kouhei Sutou
null+****@clear*****
Sun Nov 25 19:12:15 JST 2012
Kouhei Sutou 2012-11-25 19:12:15 +0900 (Sun, 25 Nov 2012) New Revision: 60f07a5bb497b7efee3b0efd3c752774bc8f7475 https://github.com/groonga/groonga-command/commit/60f07a5bb497b7efee3b0efd3c752774bc8f7475 Log: Move command related tests to suitable place Modified files: test/command/test-base.rb test/test-parser.rb Modified: test/command/test-base.rb (+48 -3) =================================================================== --- test/command/test-base.rb 2012-11-25 19:08:00 +0900 (bbeb3b0) +++ test/command/test-base.rb 2012-11-25 19:12:15 +0900 (15d5754) @@ -17,8 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA class BaseCommandTest < Test::Unit::TestCase - class ConvertTest < self - def test_to_uri_format + class CovnertToURIFormatTest < self + def test_no_special_characters select = Groonga::Command::Base.new("select", :table => "Users", :filter => "age<=30", @@ -27,7 +27,31 @@ class BaseCommandTest < Test::Unit::TestCase select.to_uri_format) end - def test_to_command_format + def test_double_quote + filter = 'geo_in_rectangle(location,' + + '"35.73360x139.7394","62614x139.7714") && ' + + '((type == "たいやき" || type == "和菓子")) && ' + + 'keyword @ "たいやき" &! keyword @ "白" &! keyword @ "養殖"' + select = Groonga::Command::Base.new("select", + :table => "Users", + :filter => filter, + :output_type => "json") + assert_equal("/d/select.json?filter=geo_in_rectangle%28location%2C" + + "%2235.73360x139.7394%22%2C%2262614x139.7714%22%29+" + + "%26%26+%28%28type+" + + "%3D%3D+%22%E3%81%9F%E3%81%84%E3%82%84%E3%81%8D%22+" + + "%7C%7C+type+%3D%3D+" + + "%22%E5%92%8C%E8%8F%93%E5%AD%90%22%29%29+" + + "%26%26+keyword+%40+" + + "%22%E3%81%9F%E3%81%84%E3%82%84%E3%81%8D%22+%26%21+" + + "keyword+%40+%22%E7%99%BD%22+%26%21+" + + "keyword+%40+%22%E9%A4%8A%E6%AE%96%22&table=Users", + select.to_uri_format) + end + end + + class CovnertToCommandFormatTest < self + def test_no_special_characters select = Groonga::Command::Base.new("select", :table => "Users", :filter => "age<=30", @@ -36,5 +60,26 @@ class BaseCommandTest < Test::Unit::TestCase "--output_type \"json\" --table \"Users\"", select.to_command_format) end + + def test_double_quote + filter = 'geo_in_rectangle(location,' + + '"35.73360x139.7394","62614x139.7714") && ' + + '((type == "たいやき" || type == "和菓子")) && ' + + 'keyword @ "たいやき" &! keyword @ "白" &! keyword @ "養殖"' + select = Groonga::Command::Base.new("select", + :table => "Users", + :filter => filter, + :output_type => "json") + assert_equal("select " + + "--filter " + + "\"geo_in_rectangle(location," + + "\\\"35.73360x139.7394\\\",\\\"62614x139.7714\\\") && " + + "((type == \\\"たいやき\\\" || " + + "type == \\\"和菓子\\\")) && " + + "keyword @ \\\"たいやき\\\" &! keyword @ \\\"白\\\" &! " + + "keyword @ \\\"養殖\\\"\" " + + "--output_type \"json\" --table \"Users\"", + select.to_command_format) + end end end Modified: test/test-parser.rb (+0 -51) =================================================================== --- test/test-parser.rb 2012-11-25 19:08:00 +0900 (42e0bbd) +++ test/test-parser.rb 2012-11-25 19:12:15 +0900 (0f520df) @@ -30,49 +30,6 @@ class ParserTest < Test::Unit::TestCase end end - module ParseFilterTests - def test_to_uri_format - filter = 'geo_in_rectangle(location,' + - '"35.73360x139.7394","62614x139.7714") && ' + - '((type == "たいやき" || type == "和菓子")) && ' + - 'keyword @ "たいやき" &! keyword @ "白" &! keyword @ "養殖"' - select = parse("select", - :table => "Users", - :filter => filter) - assert_equal("/d/select.json?filter=geo_in_rectangle%28location%2C" + - "%2235.73360x139.7394%22%2C%2262614x139.7714%22%29+" + - "%26%26+%28%28type+" + - "%3D%3D+%22%E3%81%9F%E3%81%84%E3%82%84%E3%81%8D%22+" + - "%7C%7C+type+%3D%3D+" + - "%22%E5%92%8C%E8%8F%93%E5%AD%90%22%29%29+" + - "%26%26+keyword+%40+" + - "%22%E3%81%9F%E3%81%84%E3%82%84%E3%81%8D%22+%26%21+" + - "keyword+%40+%22%E7%99%BD%22+%26%21+" + - "keyword+%40+%22%E9%A4%8A%E6%AE%96%22&table=Users", - select.to_uri_format) - end - - def test_to_command_format - filter = 'geo_in_rectangle(location,' + - '"35.73360x139.7394","62614x139.7714") && ' + - '((type == "たいやき" || type == "和菓子")) && ' + - 'keyword @ "たいやき" &! keyword @ "白" &! keyword @ "養殖"' - select = parse("select", - :table => "Users", - :filter => filter) - assert_equal("select " + - "--filter " + - "\"geo_in_rectangle(location," + - "\\\"35.73360x139.7394\\\",\\\"62614x139.7714\\\") && " + - "((type == \\\"たいやき\\\" || " + - "type == \\\"和菓子\\\")) && " + - "keyword @ \\\"たいやき\\\" &! keyword @ \\\"白\\\" &! " + - "keyword @ \\\"養殖\\\"\" " + - "--output_type \"json\" --table \"Users\"", - select.to_command_format) - end - end - class HTTPTest < self include GroongaCommandTestUtils::HTTPCommandParser @@ -89,10 +46,6 @@ class ParserTest < Test::Unit::TestCase class ParseTest < self include ParseTests end - - class ParseFilterTest < self - include ParseFilterTests - end end class CommandLineTest < self @@ -111,9 +64,5 @@ class ParserTest < Test::Unit::TestCase class ParseTest < self include ParseTests end - - class ParseFilterTest < self - include ParseFilterTests - end end end -------------- next part -------------- HTML����������������������������... 下载