Skip to content

Commit

Permalink
Avoid conflict of mock class name to fix test failure (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#1819)

Rename MockIndex to FaissMockIndex in faiss_wrapper_unit_test.cpp to avoid interference during unit tests. Also, rename MockIDMap to FaissMockIdMap for consistency. The MockIndex class is defined in tests/mocks/faiss_index_mock.h

Signed-off-by: Heemin Kim <heemin@amazon.com>
  • Loading branch information
heemin32 authored Jul 11, 2024
1 parent a8d83bf commit 6d1b7c8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions jni/tests/faiss_wrapper_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ using ::testing::NiceMock;

using idx_t = faiss::idx_t;

struct MockIndex : faiss::IndexHNSW {
explicit MockIndex(idx_t d) : faiss::IndexHNSW(d, 32) {
struct FaissMockIndex : faiss::IndexHNSW {
explicit FaissMockIndex(idx_t d) : faiss::IndexHNSW(d, 32) {
}
};

struct MockIdMap : faiss::IndexIDMap {
struct FaissMockIdMap : faiss::IndexIDMap {
mutable idx_t nCalled{};
mutable const float *xCalled{};
mutable int kCalled{};
Expand All @@ -40,7 +40,7 @@ struct MockIdMap : faiss::IndexIDMap {
mutable const faiss::SearchParametersHNSW *paramsCalled{};
mutable faiss::RangeSearchResult *resCalled{};

explicit MockIdMap(MockIndex *index) : faiss::IndexIDMapTemplate<faiss::Index>(index) {
explicit FaissMockIdMap(FaissMockIndex *index) : faiss::IndexIDMapTemplate<faiss::Index>(index) {
}

void search(
Expand Down Expand Up @@ -108,8 +108,8 @@ class FaissWrappeterParametrizedTestFixture : public testing::TestWithParam<Quer
}

protected:
MockIndex index_;
MockIdMap id_map_;
FaissMockIndex index_;
FaissMockIdMap id_map_;
};

class FaissWrapperParametrizedRangeSearchTestFixture : public testing::TestWithParam<RangeSearchTestInput> {
Expand All @@ -119,8 +119,8 @@ class FaissWrapperParametrizedRangeSearchTestFixture : public testing::TestWithP
}

protected:
MockIndex index_;
MockIdMap id_map_;
FaissMockIndex index_;
FaissMockIdMap id_map_;
};

namespace query_index_test {
Expand Down Expand Up @@ -369,4 +369,3 @@ namespace range_search_test {
)
);
}

0 comments on commit 6d1b7c8

Please sign in to comment.