@@ -33,6 +33,14 @@ void assert_exception(std::function<void(void)> code, std::optional<std::string_
3333 assert (exception);
3434}
3535
36+ std::optional<std::string_view> float_error (std::string_view message) {
37+ #ifdef __linux__
38+ return message;
39+ #else
40+ return std::nullopt ;
41+ #endif
42+ }
43+
3644void test_vector (pqxx::connection &conn) {
3745 before_each (conn);
3846
@@ -168,19 +176,19 @@ void test_vector_from_string() {
168176
169177 assert_exception<pqxx::conversion_error>([] {
170178 auto unused = pqxx::from_string<pgvector::Vector>(" [hello]" );
171- }, " Could not convert 'hello' to float: Invalid argument." );
179+ }, float_error ( " Could not convert 'hello' to float: Invalid argument." ) );
172180
173181 assert_exception<pqxx::conversion_error>([] {
174182 auto unused = pqxx::from_string<pgvector::Vector>(" [4e38]" );
175- }, " Could not convert '4e38' to float: Value out of range." );
183+ }, float_error ( " Could not convert '4e38' to float: Value out of range." ) );
176184
177185 assert_exception<pqxx::conversion_error>([] {
178186 auto unused = pqxx::from_string<pgvector::Vector>(" [,]" );
179- }, " Could not convert '' to float: Invalid argument." );
187+ }, float_error ( " Could not convert '' to float: Invalid argument." ) );
180188
181189 assert_exception<pqxx::conversion_error>([] {
182190 auto unused = pqxx::from_string<pgvector::Vector>(" [1,]" );
183- }, " Could not convert '' to float: Invalid argument." );
191+ }, float_error ( " Could not convert '' to float: Invalid argument." ) );
184192}
185193
186194void test_halfvec_to_string () {
@@ -205,19 +213,19 @@ void test_halfvec_from_string() {
205213
206214 assert_exception<pqxx::conversion_error>([] {
207215 auto unused = pqxx::from_string<pgvector::HalfVector>(" [hello]" );
208- }, " Could not convert 'hello' to float: Invalid argument." );
216+ }, float_error ( " Could not convert 'hello' to float: Invalid argument." ) );
209217
210218 assert_exception<pqxx::conversion_error>([] {
211219 auto unused = pqxx::from_string<pgvector::HalfVector>(" [4e38]" );
212- }, " Could not convert '4e38' to float: Value out of range." );
220+ }, float_error ( " Could not convert '4e38' to float: Value out of range." ) );
213221
214222 assert_exception<pqxx::conversion_error>([] {
215223 auto unused = pqxx::from_string<pgvector::HalfVector>(" [,]" );
216- }, " Could not convert '' to float: Invalid argument." );
224+ }, float_error ( " Could not convert '' to float: Invalid argument." ) );
217225
218226 assert_exception<pqxx::conversion_error>([] {
219227 auto unused = pqxx::from_string<pgvector::HalfVector>(" [1,]" );
220- }, " Could not convert '' to float: Invalid argument." );
228+ }, float_error ( " Could not convert '' to float: Invalid argument." ) );
221229}
222230
223231void test_sparsevec_to_string () {
@@ -262,15 +270,15 @@ void test_sparsevec_from_string() {
262270
263271 assert_exception<pqxx::conversion_error>([] {
264272 auto unused = pqxx::from_string<pgvector::SparseVector>(" {1:4e38}/1" );
265- }, " Could not convert '4e38' to float: Value out of range." );
273+ }, float_error ( " Could not convert '4e38' to float: Value out of range." ) );
266274
267275 assert_exception<pqxx::conversion_error>([] {
268276 auto unused = pqxx::from_string<pgvector::SparseVector>(" {a:1}/1" );
269277 }, " Could not convert 'a' to int: Invalid argument." );
270278
271279 assert_exception<pqxx::conversion_error>([] {
272280 auto unused = pqxx::from_string<pgvector::SparseVector>(" {1:a}/1" );
273- }, " Could not convert 'a' to float: Invalid argument." );
281+ }, float_error ( " Could not convert 'a' to float: Invalid argument." ) );
274282
275283 assert_exception<pqxx::conversion_error>([] {
276284 auto unused = pqxx::from_string<pgvector::SparseVector>(" {}/a" );
0 commit comments