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:
parent
9d7dee4a8f
commit
ccad6e94e2
3 changed files with 128 additions and 24 deletions
|
@ -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!";
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue