Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Improve test harness to cover some missing cases.

Kishore Nallanb3689e16aa78
diff --git a/TODO.md b/TODO.md
index 5c722715..32344bac 100644
--- a/TODO.md
+++ b/TODO.md
@@ -62,17 +62,17 @@
- ~~init_collection of Collection manager should probably take seq_id as param~~
- ~~node score should be int32, no longer uint16 like in document struct~~
- ~~Typo in prefix search~~
-- Proper logging
-- https support
-- Validate before string to int conversion in the http api layer
-- When field of "id" but not string, what happens?
-- test for num_documents
-- test for string filter comparison: title < "foo"
+- ~~When field of "id" but not string, what happens?~~
+- ~~test for num_documents~~
+- ~~test for string filter comparison: title < "foo"~~
+- ~~Test for sorted_array::indexOf when length is 0~~
- test for token ranking on float field
- test for float int field deletion during doc deletion
-- Test for sorted_array::indexOf when length is 0
- Test for snippets
- Test for pagination
+- Proper logging
+- https support
+- Validate before string to int conversion in the http api layer
- > INT32_MAX validation for float field
- art bool support
- Add docs/explanation around ranking calc
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index 2f8f6374..58fb82f4 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -63,6 +63,11 @@ protected:
}
};
+TEST_F(CollectionTest, VerifyCountOfDocuments) {
+ // we have 1 dummy record to match the line numbers on the fixtures file with sequence numbers
+ ASSERT_EQ(24+1, collection->get_num_documents());
+}
+
TEST_F(CollectionTest, RetrieveADocumentById) {
Option<nlohmann::json> doc_option = collection->get("1");
ASSERT_TRUE(doc_option.ok());
@@ -908,6 +913,16 @@ TEST_F(CollectionTest, FilterOnTextFields) {
results = coll_array_fields->search("Jeremy", query_fields, "tags: BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();
ASSERT_EQ(0, results["hits"].size());
+ // when comparators are used, should just treat them as part of search string
+ results = coll_array_fields->search("Jeremy", query_fields, "tags:<BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();
+ ASSERT_EQ(0, results["hits"].size());
+
+ results = coll_array_fields->search("Jeremy", query_fields, "tags:<=BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();
+ ASSERT_EQ(0, results["hits"].size());
+
+ results = coll_array_fields->search("Jeremy", query_fields, "tags:>BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();
+ ASSERT_EQ(0, results["hits"].size());
+
collectionManager.drop_collection("coll_array_fields");
}
@@ -1342,6 +1357,8 @@ TEST_F(CollectionTest, DeletionOfADocument) {
collection_for_del->add(json_line);
}
+ ASSERT_EQ(25, collection_for_del->get_num_documents());
+
infile.close();
nlohmann::json results;
@@ -1376,6 +1393,8 @@ TEST_F(CollectionTest, DeletionOfADocument) {
collection_for_del->remove(std::to_string(id));
}
+ ASSERT_EQ(0, collection_for_del->get_num_documents());
+
it = store->get_iterator();
num_keys = 0;
for (it->SeekToFirst(); it->Valid(); it->Next()) {
diff --git a/test/sorted_array_test.cpp b/test/sorted_array_test.cpp
index b3388eb6..5dc14993 100644
--- a/test/sorted_array_test.cpp
+++ b/test/sorted_array_test.cpp
@@ -9,6 +9,7 @@ TEST(SortedArrayTest, Append) {
const int SIZE = 10 * 1000;
EXPECT_EQ(arr.getLength(), 0);
+ EXPECT_EQ(arr.indexOf(100), 0); // when not found must be equal to length (0 in this case)
for(uint32_t i=0; i < SIZE; i++) {
arr.append(i);