Skip to content

Commit dc77151

Browse files
committed
test: use binary metric for binary config checks
Signed-off-by: xianliang.li <xianliang.li@zilliz.com>
1 parent 7041c3e commit dc77151

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

tests/ut/test_config.cc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,44 @@
2828
#endif
2929

3030
void
31-
checkBuildConfig(knowhere::IndexType indexType, knowhere::Json& json) {
32-
std::string msg;
31+
checkBuildConfig(knowhere::IndexType indexType, const knowhere::Json& json) {
32+
const auto version = knowhere::Version::GetCurrentVersion().VersionNumber();
3333
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::BINARY)) {
34-
CHECK(knowhere::IndexStaticFaced<knowhere::bin1>::ConfigCheck(
35-
indexType, knowhere::Version::GetCurrentVersion().VersionNumber(), json, msg) ==
34+
auto binary_json = json;
35+
binary_json[knowhere::meta::METRIC_TYPE] = knowhere::metric::HAMMING;
36+
std::string msg;
37+
CHECK(knowhere::IndexStaticFaced<knowhere::bin1>::ConfigCheck(indexType, version, binary_json, msg) ==
3638
knowhere::Status::success);
3739
CHECK(msg.empty());
3840
}
3941
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::FLOAT32)) {
40-
CHECK(knowhere::IndexStaticFaced<float>::ConfigCheck(indexType,
41-
knowhere::Version::GetCurrentVersion().VersionNumber(),
42-
json, msg) == knowhere::Status::success);
42+
std::string msg;
43+
CHECK(knowhere::IndexStaticFaced<float>::ConfigCheck(indexType, version, json, msg) ==
44+
knowhere::Status::success);
4345
CHECK(msg.empty());
4446
}
4547
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::BF16)) {
46-
CHECK(knowhere::IndexStaticFaced<knowhere::bf16>::ConfigCheck(
47-
indexType, knowhere::Version::GetCurrentVersion().VersionNumber(), json, msg) ==
48+
std::string msg;
49+
CHECK(knowhere::IndexStaticFaced<knowhere::bf16>::ConfigCheck(indexType, version, json, msg) ==
4850
knowhere::Status::success);
4951
CHECK(msg.empty());
5052
}
5153
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::FP16)) {
52-
CHECK(knowhere::IndexStaticFaced<knowhere::fp16>::ConfigCheck(
53-
indexType, knowhere::Version::GetCurrentVersion().VersionNumber(), json, msg) ==
54+
std::string msg;
55+
CHECK(knowhere::IndexStaticFaced<knowhere::fp16>::ConfigCheck(indexType, version, json, msg) ==
5456
knowhere::Status::success);
5557
CHECK(msg.empty());
5658
}
5759
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::SPARSE_U32_F32)) {
58-
CHECK(knowhere::IndexStaticFaced<float>::ConfigCheck(indexType,
59-
knowhere::Version::GetCurrentVersion().VersionNumber(),
60-
json, msg) == knowhere::Status::success);
60+
std::string msg;
61+
CHECK(knowhere::IndexStaticFaced<float>::ConfigCheck(indexType, version, json, msg) ==
62+
knowhere::Status::success);
6163
CHECK(msg.empty());
6264
}
6365
#ifndef KNOWHERE_WITH_CARDINAL
6466
if (knowhere::IndexFactory::Instance().FeatureCheck(indexType, knowhere::feature::INT8)) {
65-
CHECK(knowhere::IndexStaticFaced<knowhere::int8>::ConfigCheck(
66-
indexType, knowhere::Version::GetCurrentVersion().VersionNumber(), json, msg) ==
67+
std::string msg;
68+
CHECK(knowhere::IndexStaticFaced<knowhere::int8>::ConfigCheck(indexType, version, json, msg) ==
6769
knowhere::Status::success);
6870
CHECK(msg.empty());
6971
}

0 commit comments

Comments
 (0)