Skip to content

Commit f7e9ad3

Browse files
committed
fix: add the acutall ytests
1 parent 2a6a552 commit f7e9ad3

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

bindings/cpp/tests/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2025 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
include(FetchContent)
16+
17+
set(CATCH_CONFIG_CONSOLE_WIDTH "100" CACHE STRING "" FORCE)
18+
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
19+
set(CATCH_CONFIG_ENABLE_BENCHMARKING OFF CACHE BOOL "" FORCE)
20+
set(CATCH_CONFIG_PREFIX_ALL ON CACHE BOOL "" FORCE)
21+
22+
FetchContent_Declare(
23+
Catch2
24+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
25+
GIT_TAG v3.4.0
26+
)
27+
FetchContent_MakeAvailable(Catch2)
28+
29+
# Runtime tests
30+
add_executable(svs_runtime_tests
31+
test_version_namespace.cpp
32+
)
33+
34+
target_link_libraries(svs_runtime_tests PRIVATE
35+
svs_runtime
36+
Catch2::Catch2WithMain
37+
)
38+
39+
target_compile_definitions(svs_runtime_tests PRIVATE
40+
FAISS_SVS_RUNTIME_VERSION=v0
41+
)
42+
43+
# Register with CTest
44+
include(CTest)
45+
include(Catch)
46+
catch_discover_tests(svs_runtime_tests)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2025 Intel Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <svs/runtime/version.h>
18+
#include "catch2/catch_test_macros.hpp"
19+
20+
// Validate macro is defined (like FAISS does)
21+
#ifndef FAISS_SVS_RUNTIME_VERSION
22+
#error "FAISS_SVS_RUNTIME_VERSION is not defined"
23+
#endif
24+
25+
// Create namespace alias (FAISS integration pattern)
26+
SVS_RUNTIME_CREATE_API_ALIAS(svs_runtime, FAISS_SVS_RUNTIME_VERSION);
27+
28+
CATCH_TEST_CASE("Version Namespace Compatibility", "[runtime][version]") {
29+
CATCH_SECTION("Namespace alias resolves to v0") {
30+
// Both access methods should give same values
31+
CATCH_REQUIRE(svs_runtime::VersionInfo::major == svs::runtime::v0::VersionInfo::major);
32+
CATCH_REQUIRE(svs_runtime::VersionInfo::minor == svs::runtime::v0::VersionInfo::minor);
33+
CATCH_REQUIRE(svs_runtime::VersionInfo::patch == svs::runtime::v0::VersionInfo::patch);
34+
}
35+
36+
CATCH_SECTION("Version compatibility check") {
37+
// Should be compatible with v0
38+
CATCH_REQUIRE(svs_runtime::VersionInfo::is_compatible_with_major(0));
39+
40+
// Should not be compatible with v1
41+
CATCH_REQUIRE_FALSE(svs_runtime::VersionInfo::is_compatible_with_major(1));
42+
}
43+
44+
CATCH_SECTION("Version string") {
45+
// Verify version string is accessible
46+
CATCH_REQUIRE(svs_runtime::VersionInfo::get_version() != nullptr);
47+
CATCH_REQUIRE(svs_runtime::VersionInfo::get_api_namespace() != nullptr);
48+
}
49+
}

0 commit comments

Comments
 (0)