Skip to content

Commit a6dda87

Browse files
committed
Added Mac to CI
1 parent d66ba0c commit a6dda87

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ name: build
22
on: [push, pull_request]
33
jobs:
44
build:
5-
runs-on: ubuntu-24.04
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
os: [ubuntu-latest, macos-latest]
9+
runs-on: ${{ matrix.os }}
610
steps:
711
- uses: actions/checkout@v6
812
- uses: ankane/setup-postgres@v1
@@ -24,7 +28,8 @@ jobs:
2428
- run: cmake --build build
2529
- run: build/test
2630

27-
- run: |
31+
- if: ${{ runner.os == 'Linux' }}
32+
run: |
2833
sudo apt-get install valgrind
2934
valgrind --leak-check=yes --error-exitcode=1 build/test
3035

test/pqxx_test.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
3644
void 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

186194
void 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

223231
void 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

Comments
 (0)