[Groonga-commit] groonga/groonga [master] test: add --evaluate-formula option

Back to archive index

HAYASHI Kentaro null+****@clear*****
Wed Nov 14 16:49:38 JST 2012


HAYASHI Kentaro	2012-11-14 16:49:38 +0900 (Wed, 14 Nov 2012)

  New Revision: 5c46e18175df5fe49b651f7aabaee784c78135ec
  https://github.com/groonga/groonga/commit/5c46e18175df5fe49b651f7aabaee784c78135ec

  Log:
    test: add --evaluate-formula option

  Modified files:
    test/command/tools/geo/generate-grntest-data.rb

  Modified: test/command/tools/geo/generate-grntest-data.rb (+18 -0)
===================================================================
--- test/command/tools/geo/generate-grntest-data.rb    2012-11-14 15:52:29 +0900 (a15e09c)
+++ test/command/tools/geo/generate-grntest-data.rb    2012-11-14 16:49:38 +0900 (1b8a715)
@@ -942,6 +942,10 @@ if __FILE__ == $0
             "update csv field") do |update_csv_field|
     OPTS[:update_csv_field] = update_csv_field
   end
+  parser.on("--evaluate-formula",
+            "check with evaluated formula") do |evaluate_formula|
+    OPTS[:evaluate_formula] = evaluate_formula
+  end
 
   parser.parse!(ARGV)
 
@@ -1081,6 +1085,20 @@ if __FILE__ == $0
                                   File.basename(test_name, ".test"))
           grndata.output_file(:expected, expected_name, dot_expected, i, line)
         end
+
+        if OPTS.has_key?(:evaluate_formula)
+          if grndata.formula
+            evaluated = (eval grndata.formula).floor
+            if evaluated != grndata.distance
+              description = "calculated distance does not match"
+              message = sprintf("%s: manual:%d[m] calculated:%d[m] at %s line:%d",
+                                description, evaluated, grndata.distance,
+                                OPTS[:csv], i+1)
+              raise Exception, message
+            end
+          end
+        end
+
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index