From 03bb3fff07740d6198438bd808792dd21f8742c3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 3 Aug 2013 16:41:26 -0700 Subject: [PATCH] Renamed test files --- test/boost_test.rb | 41 +++++++++++++++++++++++++++++++++++++++++ test/boosting_test.rb | 41 ----------------------------------------- test/match_test.rb | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/matching_test.rb | 113 ----------------------------------------------------------------------------------------------------------------- 4 files changed, 154 insertions(+), 154 deletions(-) create mode 100644 test/boost_test.rb delete mode 100644 test/boosting_test.rb create mode 100644 test/match_test.rb delete mode 100644 test/matching_test.rb diff --git a/test/boost_test.rb b/test/boost_test.rb new file mode 100644 index 0000000..2440d5b --- /dev/null +++ b/test/boost_test.rb @@ -0,0 +1,41 @@ +require_relative "test_helper" + +class TestBoost < Minitest::Unit::TestCase + + # conversions + + def test_conversions + store [ + {name: "Tomato A", conversions: {"tomato" => 1}}, + {name: "Tomato B", conversions: {"tomato" => 2}}, + {name: "Tomato C", conversions: {"tomato" => 3}} + ] + assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"] + end + + def test_conversions_stemmed + store [ + {name: "Tomato A", conversions: {"tomato" => 1, "tomatos" => 1, "Tomatoes" => 1}}, + {name: "Tomato B", conversions: {"tomato" => 2}} + ] + assert_order "tomato", ["Tomato A", "Tomato B"] + end + + # global boost + + def test_boost + store [ + {name: "Organic Tomato A"}, + {name: "Tomato B", orders_count: 10} + ] + assert_order "tomato", ["Tomato B", "Organic Tomato A"], boost: "orders_count" + end + + def test_boost_zero + store [ + {name: "Zero Boost", orders_count: 0} + ] + assert_order "zero", ["Zero Boost"], boost: "orders_count" + end + +end diff --git a/test/boosting_test.rb b/test/boosting_test.rb deleted file mode 100644 index d1310d7..0000000 --- a/test/boosting_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative "test_helper" - -class TestBoosting < Minitest::Unit::TestCase - - # conversions - - def test_conversions - store [ - {name: "Tomato A", conversions: {"tomato" => 1}}, - {name: "Tomato B", conversions: {"tomato" => 2}}, - {name: "Tomato C", conversions: {"tomato" => 3}} - ] - assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"] - end - - def test_conversions_stemmed - store [ - {name: "Tomato A", conversions: {"tomato" => 1, "tomatos" => 1, "Tomatoes" => 1}}, - {name: "Tomato B", conversions: {"tomato" => 2}} - ] - assert_order "tomato", ["Tomato A", "Tomato B"] - end - - # global boost - - def test_boost - store [ - {name: "Organic Tomato A"}, - {name: "Tomato B", orders_count: 10} - ] - assert_order "tomato", ["Tomato B", "Organic Tomato A"], boost: "orders_count" - end - - def test_boost_zero - store [ - {name: "Zero Boost", orders_count: 0} - ] - assert_order "zero", ["Zero Boost"], boost: "orders_count" - end - -end diff --git a/test/match_test.rb b/test/match_test.rb new file mode 100644 index 0000000..de3d0a3 --- /dev/null +++ b/test/match_test.rb @@ -0,0 +1,113 @@ +require_relative "test_helper" + +class TestMatch < Minitest::Unit::TestCase + + # exact + + def test_match + store_names ["Whole Milk", "Fat Free Milk", "Milk"] + assert_search "milk", ["Milk", "Whole Milk", "Fat Free Milk"] + end + + def test_case + store_names ["Whole Milk", "Fat Free Milk", "Milk"] + assert_search "MILK", ["Milk", "Whole Milk", "Fat Free Milk"] + end + + def test_cheese_space_in_index + store_names ["Pepper Jack Cheese Skewers"] + assert_search "pepperjack cheese skewers", ["Pepper Jack Cheese Skewers"] + end + + def test_cheese_space_in_query + store_names ["Pepperjack Cheese Skewers"] + assert_search "pepper jack cheese skewers", ["Pepperjack Cheese Skewers"] + end + + def test_middle_token + store_names ["Dish Washer Amazing Organic Soap"] + assert_search "dish soap", ["Dish Washer Amazing Organic Soap"] + end + + def test_percent + store_names ["1% Milk", "2% Milk", "Whole Milk"] + assert_search "1%", ["1% Milk"] + end + + # ascii + + def test_jalapenos + store_names ["Jalapeño"] + assert_search "jalapeno", ["Jalapeño"] + end + + # stemming + + def test_stemming + store_names ["Whole Milk", "Fat Free Milk", "Milk"] + assert_search "milks", ["Milk", "Whole Milk", "Fat Free Milk"] + end + + # fuzzy + + def test_misspelling_sriracha + store_names ["Sriracha"] + assert_search "siracha", ["Sriracha"] + end + + def test_short_word + store_names ["Finn"] + assert_search "fin", ["Finn"] + end + + def test_edit_distance + store_names ["Bingo"] + assert_search "bin", [] + assert_search "bing", ["Bingo"] + assert_search "bingoo", ["Bingo"] + assert_search "bingooo", [] + assert_search "ringo", ["Bingo"] + assert_search "mango", [] + store_names ["thisisareallylongword"] + assert_search "thisisareallylongwor", ["thisisareallylongword"] # missing letter + assert_search "thisisareelylongword", [] # edit distance = 2 + end + + def test_misspelling_tabasco + store_names ["Tabasco"] + assert_search "tobasco", ["Tabasco"] + end + + def test_misspelling_zucchini + store_names ["Zucchini"] + assert_search "zuchini", ["Zucchini"] + end + + def test_misspelling_ziploc + store_names ["Ziploc"] + assert_search "zip lock", ["Ziploc"] + end + + # spaces + + def test_spaces_in_field + store_names ["Red Bull"] + assert_search "redbull", ["Red Bull"] + end + + def test_spaces_in_query + store_names ["Dishwasher"] + assert_search "dish washer", ["Dishwasher"] + end + + def test_spaces_three_words + store_names ["Dish Washer Soap", "Dish Washer"] + assert_search "dish washer soap", ["Dish Washer Soap"] + end + + def test_spaces_stemming + store_names ["Almond Milk"] + assert_search "almondmilks", ["Almond Milk"] + end + +end diff --git a/test/matching_test.rb b/test/matching_test.rb deleted file mode 100644 index 835b7ac..0000000 --- a/test/matching_test.rb +++ /dev/null @@ -1,113 +0,0 @@ -require_relative "test_helper" - -class TestMatching < Minitest::Unit::TestCase - - # exact - - def test_match - store_names ["Whole Milk", "Fat Free Milk", "Milk"] - assert_search "milk", ["Milk", "Whole Milk", "Fat Free Milk"] - end - - def test_case - store_names ["Whole Milk", "Fat Free Milk", "Milk"] - assert_search "MILK", ["Milk", "Whole Milk", "Fat Free Milk"] - end - - def test_cheese_space_in_index - store_names ["Pepper Jack Cheese Skewers"] - assert_search "pepperjack cheese skewers", ["Pepper Jack Cheese Skewers"] - end - - def test_cheese_space_in_query - store_names ["Pepperjack Cheese Skewers"] - assert_search "pepper jack cheese skewers", ["Pepperjack Cheese Skewers"] - end - - def test_middle_token - store_names ["Dish Washer Amazing Organic Soap"] - assert_search "dish soap", ["Dish Washer Amazing Organic Soap"] - end - - def test_percent - store_names ["1% Milk", "2% Milk", "Whole Milk"] - assert_search "1%", ["1% Milk"] - end - - # ascii - - def test_jalapenos - store_names ["Jalapeño"] - assert_search "jalapeno", ["Jalapeño"] - end - - # stemming - - def test_stemming - store_names ["Whole Milk", "Fat Free Milk", "Milk"] - assert_search "milks", ["Milk", "Whole Milk", "Fat Free Milk"] - end - - # fuzzy - - def test_misspelling_sriracha - store_names ["Sriracha"] - assert_search "siracha", ["Sriracha"] - end - - def test_short_word - store_names ["Finn"] - assert_search "fin", ["Finn"] - end - - def test_edit_distance - store_names ["Bingo"] - assert_search "bin", [] - assert_search "bing", ["Bingo"] - assert_search "bingoo", ["Bingo"] - assert_search "bingooo", [] - assert_search "ringo", ["Bingo"] - assert_search "mango", [] - store_names ["thisisareallylongword"] - assert_search "thisisareallylongwor", ["thisisareallylongword"] # missing letter - assert_search "thisisareelylongword", [] # edit distance = 2 - end - - def test_misspelling_tabasco - store_names ["Tabasco"] - assert_search "tobasco", ["Tabasco"] - end - - def test_misspelling_zucchini - store_names ["Zucchini"] - assert_search "zuchini", ["Zucchini"] - end - - def test_misspelling_ziploc - store_names ["Ziploc"] - assert_search "zip lock", ["Ziploc"] - end - - # spaces - - def test_spaces_in_field - store_names ["Red Bull"] - assert_search "redbull", ["Red Bull"] - end - - def test_spaces_in_query - store_names ["Dishwasher"] - assert_search "dish washer", ["Dishwasher"] - end - - def test_spaces_three_words - store_names ["Dish Washer Soap", "Dish Washer"] - assert_search "dish washer soap", ["Dish Washer Soap"] - end - - def test_spaces_stemming - store_names ["Almond Milk"] - assert_search "almondmilks", ["Almond Milk"] - end - -end -- libgit2 0.21.0