@@ -149,6 +149,8 @@ void test_vector_to_string() {
149149
150150void test_vector_from_string () {
151151 assert_equal (pqxx::from_string<pgvector::Vector>(" [1,2,3]" ), pgvector::Vector{{1 , 2 , 3 }});
152+
153+ // not valid, but test current behavior
152154 assert_equal (pqxx::from_string<pgvector::Vector>(" []" ), pgvector::Vector{std::vector<float >{}});
153155
154156 assert_exception<pqxx::conversion_error>([] {
@@ -191,6 +193,8 @@ void test_halfvec_to_string() {
191193
192194void test_halfvec_from_string () {
193195 assert_equal (pqxx::from_string<pgvector::HalfVector>(" [1,2,3]" ), pgvector::HalfVector{{1 , 2 , 3 }});
196+
197+ // not valid, but test current behavior
194198 assert_equal (pqxx::from_string<pgvector::HalfVector>(" []" ), pgvector::HalfVector{std::vector<pgvector::Half>{}});
195199
196200 assert_exception<pqxx::conversion_error>([] {
@@ -231,7 +235,14 @@ void test_sparsevec_to_string() {
231235void test_sparsevec_from_string () {
232236 assert_equal (pqxx::from_string<pgvector::SparseVector>(" {1:1,3:2,5:3}/6" ), pgvector::SparseVector{{1 , 0 , 2 , 0 , 3 , 0 }});
233237 assert_equal (pqxx::from_string<pgvector::SparseVector>(" {}/6" ), pgvector::SparseVector{{0 , 0 , 0 , 0 , 0 , 0 }});
238+
239+ // not valid, but test current behavior
234240 assert_equal (pqxx::from_string<pgvector::SparseVector>(" {}/0" ), pgvector::SparseVector{std::vector<float >{}});
241+ assert_equal (pqxx::from_string<pgvector::SparseVector>(" {1:2,1:3}/1" ), pgvector::SparseVector{{2 }});
242+
243+ auto vec = pqxx::from_string<pgvector::SparseVector>(" {2:4,1:3}/2" );
244+ assert_equal (vec.indices () == std::vector<int >{0 , 1 }, true );
245+ assert_equal (vec.values () == std::vector<float >{3 , 4 }, true );
235246
236247 assert_exception<pqxx::conversion_error>([] {
237248 auto _ = pqxx::from_string<pgvector::SparseVector>(" " );
0 commit comments