Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #29 from komainu8/ignore_difference_in_accuracy_of…
Browse files Browse the repository at this point in the history
…_float

response-comparer: Modify to ignore the difference in accuracy of float values

Patch by Yasuhiro Horimoto. Thanks!!!
  • Loading branch information
kou committed Jun 12, 2018
2 parents 80a571f + ba89fc7 commit 6603616
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/groonga-query-log/response-comparer.rb
Expand Up @@ -68,7 +68,11 @@ def same_select_response?
same_response?
end
else
same_size_response?
if same_location_information?
same_size_response?
else
false
end
end
end

Expand Down Expand Up @@ -120,6 +124,19 @@ def same_size_response?
end
end

def same_location_information?
if @response1.body[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 = @command.output_columns
return false if output_columns.nil?
Expand Down
8 changes: 8 additions & 0 deletions test/test-response-comparer.rb
Expand Up @@ -306,6 +306,14 @@ def test_different_order
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 = [
Expand Down

0 comments on commit 6603616

Please sign in to comment.