1010
1111using 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
7577void test_sparsevec () {
7678 test_constructor_vector ();
0 commit comments