Skip to content

Commit 77edf9f

Browse files
committed
Removed assert_true function
1 parent 820646c commit 77edf9f

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

test/helper.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ void assert_equal(const T& left, const U& right, const std::source_location& loc
1616
}
1717
}
1818

19-
inline void assert_true(bool condition, const std::source_location& loc = std::source_location::current()) {
20-
assert_equal(condition, true, loc);
21-
}
22-
2319
template<typename T>
2420
void assert_exception(std::function<void(void)> code, std::optional<std::string_view> message = std::nullopt) {
2521
bool exception = false;
@@ -31,5 +27,5 @@ void assert_exception(std::function<void(void)> code, std::optional<std::string_
3127
assert_equal(std::string_view(e.what()), *message);
3228
}
3329
}
34-
assert_true(exception);
30+
assert_equal(exception, true);
3531
}

test/pqxx_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void test_vector(pqxx::connection &conn) {
4141
assert_equal(res.size(), 3);
4242
assert_equal(res[0][0].as<pgvector::Vector>(), embedding2);
4343
assert_equal(res[1][0].as<pgvector::Vector>(), embedding);
44-
assert_true(!res[2][0].as<std::optional<pgvector::Vector>>().has_value());
44+
assert_equal(res[2][0].as<std::optional<pgvector::Vector>>().has_value(), false);
4545
}
4646

4747
void test_halfvec(pqxx::connection &conn) {
@@ -57,7 +57,7 @@ void test_halfvec(pqxx::connection &conn) {
5757
assert_equal(res.size(), 3);
5858
assert_equal(res[0][0].as<pgvector::HalfVector>(), embedding2);
5959
assert_equal(res[1][0].as<pgvector::HalfVector>(), embedding);
60-
assert_true(!res[2][0].as<std::optional<pgvector::HalfVector>>().has_value());
60+
assert_equal(res[2][0].as<std::optional<pgvector::HalfVector>>().has_value(), false);
6161
}
6262

6363
void test_bit(pqxx::connection &conn) {
@@ -72,7 +72,7 @@ void test_bit(pqxx::connection &conn) {
7272
assert_equal(res.size(), 3);
7373
assert_equal(res[0][0].as<std::string>(), embedding2);
7474
assert_equal(res[1][0].as<std::string>(), embedding);
75-
assert_true(!res[2][0].as<std::optional<std::string>>().has_value());
75+
assert_equal(res[2][0].as<std::optional<std::string>>().has_value(), false);
7676
}
7777

7878
void test_sparsevec(pqxx::connection &conn) {
@@ -87,7 +87,7 @@ void test_sparsevec(pqxx::connection &conn) {
8787
assert_equal(res.size(), 3);
8888
assert_equal(res[0][0].as<pgvector::SparseVector>(), embedding2);
8989
assert_equal(res[1][0].as<pgvector::SparseVector>(), embedding);
90-
assert_true(!res[2][0].as<std::optional<pgvector::SparseVector>>().has_value());
90+
assert_equal(res[2][0].as<std::optional<pgvector::SparseVector>>().has_value(), false);
9191
}
9292

9393
void test_sparsevec_nnz(pqxx::connection &conn) {

test/sparsevec_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ using pgvector::SparseVector;
1010
static void test_constructor_vector() {
1111
auto vec = SparseVector({1, 0, 2, 0, 3, 0});
1212
assert_equal(vec.dimensions(), 6);
13-
assert_true(vec.indices() == (std::vector<int>{0, 2, 4}));
14-
assert_true(vec.values() == (std::vector<float>{1, 2, 3}));
13+
assert_equal(vec.indices() == (std::vector<int>{0, 2, 4}), true);
14+
assert_equal(vec.values() == (std::vector<float>{1, 2, 3}), true);
1515
}
1616

1717
static void test_constructor_span() {
@@ -23,8 +23,8 @@ static void test_constructor_map() {
2323
std::unordered_map<int, float> map = {{2, 2}, {4, 3}, {3, 0}, {0, 1}};
2424
auto vec = SparseVector(map, 6);
2525
assert_equal(vec.dimensions(), 6);
26-
assert_true(vec.indices() == (std::vector<int>{0, 2, 4}));
27-
assert_true(vec.values() == (std::vector<float>{1, 2, 3}));
26+
assert_equal(vec.indices() == (std::vector<int>{0, 2, 4}), true);
27+
assert_equal(vec.values() == (std::vector<float>{1, 2, 3}), true);
2828

2929
assert_exception<std::invalid_argument>([&]{
3030
auto unused = SparseVector(map, 0);

0 commit comments

Comments
 (0)