Skip to content

Commit 68ba295

Browse files
committed
Added a test whether allocation failure in a final aggregate call throws
1 parent d181823 commit 68ba295

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/user_defined_functions.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,17 @@ TEST_CASE("custom functions") {
305305
storage.sync_schema();
306306

307307
storage.create_aggregate_function<MeanFunction>();
308-
// test the case when `MeanFunction::step()` was never called
309-
{ REQUIRE_NOTHROW(storage.select(func<MeanFunction>(&User::id))); }
308+
// test w/o a result set, i.e when the final aggregate call is the first to require the aggregate function
309+
REQUIRE_NOTHROW(storage.select(func<MeanFunction>(&User::id)));
310310
storage.delete_aggregate_function<MeanFunction>();
311311

312+
storage.create_aggregate_function<NonAllocatableAggregateFunction>();
313+
// test w/o a result set, i.e when the final aggregate call is the first to require the aggregate function
314+
REQUIRE_THROWS_MATCHES(storage.select(func<NonAllocatableAggregateFunction>(&User::id)),
315+
std::system_error,
316+
ErrorCodeExceptionMatcher(sqlite_errc(SQLITE_NOMEM)));
317+
storage.delete_aggregate_function<NonAllocatableAggregateFunction>();
318+
312319
// call before creation
313320
REQUIRE_THROWS_WITH(storage.select(func<SqrtFunction>(4)), ContainsSubstring("no such function"));
314321

0 commit comments

Comments
 (0)