@@ -137,6 +137,13 @@ void test_precision(pqxx::connection &conn) {
137137
138138void test_vector_to_string () {
139139 assert (pqxx::to_string (pgvector::Vector ({1 , 2 , 3 })) == " [1,2,3]" );
140+
141+ try {
142+ auto unused = pqxx::to_string (pgvector::Vector (std::vector<float >(16001 )));
143+ assert (false );
144+ } catch (const pqxx::conversion_overrun& e) {
145+ assert (std::string_view (e.what ()) == " vector cannot have more than 16000 dimensions" );
146+ }
140147}
141148
142149void test_vector_from_string () {
@@ -174,6 +181,13 @@ void test_vector_from_string() {
174181
175182void test_halfvec_to_string () {
176183 assert (pqxx::to_string (pgvector::HalfVector ({1 , 2 , 3 })) == " [1,2,3]" );
184+
185+ try {
186+ auto unused = pqxx::to_string (pgvector::HalfVector (std::vector<float >(16001 )));
187+ assert (false );
188+ } catch (const pqxx::conversion_overrun& e) {
189+ assert (std::string_view (e.what ()) == " halfvec cannot have more than 16000 dimensions" );
190+ }
177191}
178192
179193void test_halfvec_from_string () {
@@ -293,6 +307,13 @@ void test_sparsevec_from_string() {
293307 } catch (const pqxx::conversion_error& e) {
294308 assert (std::string_view (e.what ()) == " Could not convert 'a' to int: Invalid argument." );
295309 }
310+
311+ try {
312+ auto unused = pqxx::to_string (pgvector::SparseVector (std::vector<float >(16001 , 1 )));
313+ assert (false );
314+ } catch (const pqxx::conversion_overrun& e) {
315+ assert (std::string_view (e.what ()) == " sparsevec cannot have more than 16000 dimensions" );
316+ }
296317}
297318
298319void test_pqxx () {
0 commit comments