1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

C API: add (un)initialized value checks

This commit is contained in:
José Luis Lafuente 2024-04-20 22:09:32 +02:00
parent 9d7dee4a8f
commit ccad6e94e2
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
3 changed files with 128 additions and 24 deletions

View file

@ -24,7 +24,9 @@ protected:
nix_c_context * ctx;
inline void assert_ctx_ok() {
inline void assert_ctx_ok()
{
if (nix_err_code(ctx) == NIX_OK) {
return;
}
@ -33,5 +35,14 @@ protected:
std::string msg(p, n);
FAIL() << "nix_err_code(ctx) != NIX_OK, message: " << msg;
}
inline void assert_ctx_err()
{
if (nix_err_code(ctx) != NIX_OK) {
return;
}
FAIL() << "Got NIX_OK, but expected an error!";
}
};
}