Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/vsag/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ class Index {
*/
[[nodiscard]] virtual std::string
GetStats() const {
throw std::runtime_error("Index not support range search");
throw std::runtime_error("Index not support GetStats");
}

/**
Expand Down
7 changes: 6 additions & 1 deletion tests/test_simple_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ TEST_CASE("Test Simple Index", "[ft][simple_index]") {
REQUIRE_THROWS(index->EstimateMemory(1000));
REQUIRE_THROWS(index->GetEstimateBuildMemory(1000));
REQUIRE_THROWS(index->Feedback(dataset->query_, 10, ""));
REQUIRE_THROWS(index->GetStats());
try {
index->GetStats();
FAIL("Expected GetStats to throw");
} catch (const std::runtime_error& e) {
REQUIRE(std::string(e.what()) == "Index not support GetStats");
Comment on lines +119 to +123
}
Comment on lines +119 to +124
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this try-catch block is correct, it can be simplified by using the REQUIRE_THROWS_WITH macro from catch2. This makes the test more concise and idiomatic.

Note that REQUIRE_THROWS_WITH with a string literal performs a case-sensitive substring match. For this particular error message, a substring match is likely sufficient. If an exact match is strictly required, you can use catch2 matchers like Catch::Matchers::Equals(...), which may require including an additional header.

    REQUIRE_THROWS_WITH(index->GetStats(), "Index not support GetStats");

REQUIRE_THROWS(index->UpdateId(0, 1));
REQUIRE_THROWS(index->UpdateVector(0, dataset->query_));
REQUIRE_THROWS(index->ContinueBuild(dataset->base_, binary));
Expand Down
Loading