[Groonga-commit] groonga/groonga-query-log at ba89fc7 [master] response-comparer: Modify to ignore the difference in accuracy of float values

アーカイブの一覧に戻る

Yasuhiro Horimoto null+****@clear*****
Tue Jun 12 16:44:51 JST 2018


Yasuhiro Horimoto	2018-06-12 16:44:51 +0900 (Tue, 12 Jun 2018)

  New Revision: ba89fc753ec111b09b4ddf46947869bdb69f5286
  https://github.com/groonga/groonga-query-log/commit/ba89fc753ec111b09b4ddf46947869bdb69f5286

  Merged 6603616: Merge pull request #29 from komainu8/ignore_difference_in_accuracy_of_float

  Message:
    response-comparer: Modify to ignore the difference in accuracy of float values
    
    Because of the difference in accuracy of float values between
    before and after Groonga v6.0.4.

  Modified files:
    lib/groonga-query-log/response-comparer.rb
    test/test-response-comparer.rb

  Modified: lib/groonga-query-log/response-comparer.rb (+18 -1)
===================================================================
--- lib/groonga-query-log/response-comparer.rb    2018-06-12 09:52:13 +0900 (2ac724f)
+++ lib/groonga-query-log/response-comparer.rb    2018-06-12 16:44:51 +0900 (df8e657)
@@ -68,7 +68,11 @@ module GroongaQueryLog
           same_response?
         end
       else
-        same_size_response?
+        if same_location_information?
+          same_size_response?
+        else
+          false
+        end
       end
     end
 
@@ -120,6 +124,19 @@ module GroongaQueryLog
       end
     end
 
+    def same_location_information?
+      if****@respo*****[0][1].flatten.include?("float")
+        location_information1 =
+          @response1.body.flatten.select {|e| e.class == Float}
+        location_information2 =
+          @response2.body.flatten.select {|e| e.class == Float}
+
+        location_information1[0].round(12) == location_information2[0].round(12)
+      else
+        true
+      end
+    end
+
     def have_unary_minus_output_column?
       output_columns =****@comma*****_columns
       return false if output_columns.nil?

  Modified: test/test-response-comparer.rb (+8 -0)
===================================================================
--- test/test-response-comparer.rb    2018-06-12 09:52:13 +0900 (81746c6)
+++ test/test-response-comparer.rb    2018-06-12 16:44:51 +0900 (2c8f525)
@@ -306,6 +306,14 @@ class ResponseComparerTest < Test::Unit::TestCase
       end
     end
 
+    class CareDifferencesInAccuracyOfPosition < self
+      def test_different_accurancy_of_postion
+        assert_true(same?([[[1], [["_id", "UInt32"],["location", "float"]], [1, 139.763570507358]]],
+                          [[[1], [["_id", "UInt32"],["location", "float"]], [1, 139.7635705073576]]],
+                          :care_order => false))
+      end
+    end
+
     class ErrorTest < self
       def test_with_location
         response1_header = [
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180612/fb356ac4/attachment-0001.htm 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る