mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
C API: add check_value_[in,out] helper functions
This commit is contained in:
parent
ff76dd2211
commit
8d70db3251
2 changed files with 54 additions and 64 deletions
|
@ -139,13 +139,20 @@ TEST_F(nix_api_expr_test, nix_build_and_init_list)
|
|||
ListBuilder * builder = nix_make_list_builder(ctx, state, size);
|
||||
|
||||
Value * intValue = nix_alloc_value(ctx, state);
|
||||
Value * intValue2 = nix_alloc_value(ctx, state);
|
||||
|
||||
// `init` and `insert` can be called in any order
|
||||
nix_init_int(ctx, intValue, 42);
|
||||
nix_list_builder_insert(ctx, builder, 0, intValue);
|
||||
nix_list_builder_insert(ctx, builder, 1, intValue2);
|
||||
nix_init_int(ctx, intValue2, 43);
|
||||
|
||||
nix_make_list(ctx, builder, value);
|
||||
nix_list_builder_free(builder);
|
||||
|
||||
ASSERT_EQ(42, nix_get_int(ctx, nix_get_list_byidx(ctx, value, state, 0)));
|
||||
ASSERT_EQ(nullptr, nix_get_list_byidx(ctx, value, state, 1));
|
||||
ASSERT_EQ(43, nix_get_int(ctx, nix_get_list_byidx(ctx, value, state, 1)));
|
||||
ASSERT_EQ(nullptr, nix_get_list_byidx(ctx, value, state, 2));
|
||||
ASSERT_EQ(10, nix_get_list_size(ctx, value));
|
||||
|
||||
ASSERT_STREQ("a list", nix_get_typename(ctx, value));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue