From f704a1ebbb5cb643ff3b0c9a350543415204ec2d Mon Sep 17 00:00:00 2001 From: krunal Date: Wed, 25 Oct 2023 19:05:37 +0530 Subject: [PATCH] add test for space separated range label --- test/collection_faceting_test.cpp | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cpp index 667e8775..9dcd868b 100644 --- a/test/collection_faceting_test.cpp +++ b/test/collection_faceting_test.cpp @@ -1727,6 +1727,45 @@ TEST_F(CollectionFacetingTest, RangeFacetsMinMaxRange) { ASSERT_EQ("small", results["facet_counts"][0]["counts"][0]["value"]); } +TEST_F(CollectionFacetingTest, RangeFacetRangeLabelWithSpace) { + std::vector fields = {field("name", field_types::STRING, false), + field("inches", field_types::FLOAT, true),}; + Collection* coll1 = collectionManager.create_collection( + "coll1", 1, fields, "", 0, "", {}, {}).get(); + + nlohmann::json doc; + doc["id"] = "0"; + doc["name"] = "TV 1"; + doc["inches"] = 32.4; + + ASSERT_TRUE(coll1->add(doc.dump()).ok()); + + doc["id"] = "1"; + doc["name"] = "TV 2"; + doc["inches"] = 55; + + ASSERT_TRUE(coll1->add(doc.dump()).ok()); + + doc["id"] = "2"; + doc["name"] = "TV 3"; + doc["inches"] = 55.6; + + ASSERT_TRUE(coll1->add(doc.dump()).ok()); + + auto results = coll1->search("*", {}, + "", {"inches(small tvs with display size:[0,55])"}, + {}, {2}, 10, + 1, FREQUENCY, {true}, + 10, spp::sparse_hash_set(), + spp::sparse_hash_set(), 10, "", 30, 4, "", 10, {}, {}, {}, 0, + "", "", {}, 1000, + true, false, true, "", true).get(); + + ASSERT_EQ(1, results["facet_counts"][0]["counts"].size()); + ASSERT_EQ(2, (int) results["facet_counts"][0]["counts"][0]["count"]); + ASSERT_EQ("small tvs with display size", results["facet_counts"][0]["counts"][0]["value"]); +} + TEST_F(CollectionFacetingTest, SampleFacetCounts) { nlohmann::json schema = R"({ "name": "coll1",