Skip to content

Commit 04aa403

Browse files
committed
Switched to anonymous namespaces for tests
1 parent acd822a commit 04aa403

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

test/halfvec_test.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,39 @@
88

99
using pgvector::HalfVector;
1010

11-
static void test_constructor_vector() {
11+
namespace {
12+
void test_constructor_vector() {
1213
HalfVector vec{std::vector<pgvector::Half>{1, 2, 3}};
1314
assert_equal(vec.dimensions(), 3u);
1415
}
1516

16-
static void test_constructor_span() {
17+
void test_constructor_span() {
1718
HalfVector vec{std::span<const pgvector::Half>{{1, 2, 3}}};
1819
assert_equal(vec.dimensions(), 3u);
1920
}
2021

21-
static void test_constructor_empty() {
22+
void test_constructor_empty() {
2223
HalfVector vec{std::vector<pgvector::Half>{}};
2324
assert_equal(vec.dimensions(), 0u);
2425
}
2526

26-
static void test_dimensions() {
27+
void test_dimensions() {
2728
HalfVector vec{{1, 2, 3}};
2829
assert_equal(vec.dimensions(), 3u);
2930
}
3031

31-
static void test_values() {
32+
void test_values() {
3233
HalfVector vec{{1, 2, 3}};
3334
assert_equal(vec.values() == std::vector<pgvector::Half>{1, 2, 3}, true);
3435
}
3536

36-
static void test_string() {
37+
void test_string() {
3738
HalfVector vec{{1, 2, 3}};
3839
std::ostringstream oss;
3940
oss << vec;
4041
assert_equal(oss.str(), "[1,2,3]");
4142
}
43+
} // namespace
4244

4345
void test_halfvec() {
4446
test_constructor_vector();

test/pqxx_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "helper.hpp"
1414

15+
namespace {
1516
void setup(pqxx::connection& conn) {
1617
pqxx::nontransaction tx{conn};
1718
tx.exec("CREATE EXTENSION IF NOT EXISTS vector");
@@ -463,6 +464,7 @@ void test_halfvec_size_buffer() {
463464
void test_sparsevec_size_buffer() {
464465
assert_equal(pqxx::size_buffer(pgvector::SparseVector{{1, 2, 3}}), 103u);
465466
}
467+
} // namespace
466468

467469
void test_pqxx() {
468470
pqxx::connection conn{"dbname=pgvector_cpp_test"};

test/sparsevec_test.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010

1111
using pgvector::SparseVector;
1212

13-
static void test_constructor_vector() {
13+
namespace {
14+
void test_constructor_vector() {
1415
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
1516
assert_equal(vec.dimensions(), 6);
1617
assert_equal(vec.indices() == std::vector<int>{0, 2, 4}, true);
1718
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
1819
}
1920

20-
static void test_constructor_span() {
21+
void test_constructor_span() {
2122
SparseVector vec{std::span<const float>{{1, 0, 2, 0, 3, 0}}};
2223
assert_equal(vec.dimensions(), 6);
2324
}
2425

25-
static void test_constructor_map() {
26+
void test_constructor_map() {
2627
std::unordered_map<int, float> map{{2, 2}, {4, 3}, {3, 0}, {0, 1}};
2728
SparseVector vec{map, 6};
2829
assert_equal(vec.dimensions(), 6);
@@ -42,35 +43,36 @@ static void test_constructor_map() {
4243
);
4344
}
4445

45-
static void test_constructor_empty() {
46+
void test_constructor_empty() {
4647
SparseVector vec{std::vector<float>{}};
4748
assert_equal(vec.dimensions(), 0);
4849

4950
SparseVector vec2{{}, 0};
5051
assert_equal(vec2.dimensions(), 0);
5152
}
5253

53-
static void test_dimensions() {
54+
void test_dimensions() {
5455
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
5556
assert_equal(vec.dimensions(), 6);
5657
}
5758

58-
static void test_indices() {
59+
void test_indices() {
5960
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
6061
assert_equal(vec.indices() == std::vector<int>{0, 2, 4}, true);
6162
}
6263

63-
static void test_values() {
64+
void test_values() {
6465
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
6566
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
6667
}
6768

68-
static void test_string() {
69+
void test_string() {
6970
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
7071
std::ostringstream oss;
7172
oss << vec;
7273
assert_equal(oss.str(), "{1:1,3:2,5:3}/6");
7374
}
75+
} // namespace
7476

7577
void test_sparsevec() {
7678
test_constructor_vector();

test/vector_test.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,39 @@
88

99
using pgvector::Vector;
1010

11-
static void test_constructor_vector() {
11+
namespace {
12+
void test_constructor_vector() {
1213
Vector vec{std::vector<float>{1, 2, 3}};
1314
assert_equal(vec.dimensions(), 3u);
1415
}
1516

16-
static void test_constructor_span() {
17+
void test_constructor_span() {
1718
Vector vec{std::span<const float>{{1, 2, 3}}};
1819
assert_equal(vec.dimensions(), 3u);
1920
}
2021

21-
static void test_constructor_empty() {
22+
void test_constructor_empty() {
2223
Vector vec{std::vector<float>{}};
2324
assert_equal(vec.dimensions(), 0u);
2425
}
2526

26-
static void test_dimensions() {
27+
void test_dimensions() {
2728
Vector vec{{1, 2, 3}};
2829
assert_equal(vec.dimensions(), 3u);
2930
}
3031

31-
static void test_values() {
32+
void test_values() {
3233
Vector vec{{1, 2, 3}};
3334
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
3435
}
3536

36-
static void test_string() {
37+
void test_string() {
3738
Vector vec{{1, 2, 3}};
3839
std::ostringstream oss;
3940
oss << vec;
4041
assert_equal(oss.str(), "[1,2,3]");
4142
}
43+
} // namespace
4244

4345
void test_vector() {
4446
test_constructor_vector();

0 commit comments

Comments
 (0)