Kouhei Sutou
null+****@clear*****
Mon May 30 19:19:08 JST 2016
Kouhei Sutou 2016-05-30 19:19:08 +0900 (Mon, 30 May 2016) New Revision: 9e70a24572f2817583042819c33a7388c644d819 https://github.com/groonga/groonga-query-log/commit/9e70a24572f2817583042819c33a7388c644d819 Message: Accept more columns Modified files: lib/groonga/query-log/response-comparer.rb test/test-response-comparer.rb Modified: lib/groonga/query-log/response-comparer.rb (+7 -6) =================================================================== --- lib/groonga/query-log/response-comparer.rb 2016-05-30 19:00:54 +0900 (2790afe) +++ lib/groonga/query-log/response-comparer.rb 2016-05-30 19:19:08 +0900 (4e856c8) @@ -132,14 +132,15 @@ module Groonga end end - column_to_index1 = make_column_to_index_map(columns1) - column_to_index2 = make_column_to_index_map(columns2) - records1.each_with_index do |record1, record_index| record2 = records2[record_index] - column_to_index1.each do |name, column_index1| - column_index2 = column_to_index2[name] - next if column_index2.nil? + column_offset2 = 0 + columns1.each_with_index do |name, column_index1| + column_index2 = column_offset2 + column_index1 + if name != columns2[column_index2] + column_offset2 -= 1 + next + end value1 = record1[column_index1] value2 = record2[column_index2] return false if value1 != value2 Modified: test/test-response-comparer.rb (+36 -0) =================================================================== --- test/test-response-comparer.rb 2016-05-30 19:00:54 +0900 (0a60afe) +++ test/test-response-comparer.rb 2016-05-30 19:19:08 +0900 (b0e883a) @@ -263,5 +263,41 @@ class ResponseComparerTest < Test::Unit::TestCase assert_true(same?(response1, response2)) end end + + class RecordsTest < self + def setup + super + @command["output_columns"] = "_id, -value" + end + + def test_more_columns + response1 = [ + [ + [3], + [ + ["_id", "UInt32"], + ], + [1], + [2], + [3], + ], + ] + response2 = [ + [ + [3], + [ + ["_id", "UInt32"], + ["value", nil], + ], + [1, -11], + [2, -12], + [3, -13], + ], + ] + assert do + same?(response1, response2) + end + end + end end end -------------- next part -------------- HTML����������������������������...下載