Skip to content

Commit

Permalink
chg test_result_errors to exercise sqlite3_result_error() as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsink committed Jun 26, 2019
1 parent 9ae8c0c commit 50d3782
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/common/tests_xunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,12 @@ public void test_result_null()
[Fact]
public void test_result_errors()
{
int code = 10;
const int code = 10;
const string MSG = "epic fail";

delegate_function_scalar errormsg_func =
(ctx, user_data, args) => raw.sqlite3_result_error(ctx, MSG);

delegate_function_scalar errorcode_func =
(ctx, user_data, args) => raw.sqlite3_result_error_code(ctx, code);

Expand All @@ -1050,10 +1055,19 @@ public void test_result_errors()

using (sqlite3 db = ugly.open(":memory:"))
{
db.create_function("errormsg", 0, null, errormsg_func);
db.create_function("errorcode", 0, null, errorcode_func);
db.create_function("toobig", 0, null, toobig_func);
db.create_function("nomem", 0, null, nomem_func);

{
var e = Assert.Throws<ugly.sqlite3_exception>(
() => db.exec("select errormsg();")
);
Assert.Equal(raw.SQLITE_ERROR, e.errcode);
Assert.Equal(MSG, e.errmsg);
}

{
var e = Assert.Throws<ugly.sqlite3_exception>(
() => db.exec("select errorcode();")
Expand Down

0 comments on commit 50d3782

Please sign in to comment.