end)
end
+ for i,c in ipairs(cases) do
+ test("Trie search, table version " .. i, function()
+ local match = {}
+
+ match = trie:match(c[1])
+
+ assert_equal(c[2], #match > 0, tostring(c[2]) .. ' while matching ' .. c[1])
+
+ if match and #match > 0 then
+ local res = {}
+ -- Convert to something that this test expects
+ for pat,hits in pairs(match) do
+ for _,pos in ipairs(hits) do
+ table.insert(res, {pos, pat})
+ end
+ end
+ table.sort(res, function(a, b) return a[2] > b[2] end)
+ table.sort(c[3], function(a, b) return a[2] > b[2] end)
+ local cmp = comparetables(res, c[3])
+ assert_true(cmp, 'valid results for case: ' .. c[1] ..
+ ' got: ' .. logger.slog('%s', res) .. ' expected: ' ..
+ logger.slog('%s', c[3])
+ )
+ end
+ end)
+ end
+
end)