1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 09:31:16 +02:00

C API: nix_get_string now accepts a callback to return the value

This commit is contained in:
José Luis Lafuente 2024-04-15 21:05:52 +02:00
parent 74e4bc9b1d
commit c75b143b6c
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
6 changed files with 65 additions and 35 deletions

View file

@ -6,7 +6,9 @@
#include "nix_api_expr_internal.h"
#include "nix_api_value.h"
#include "nix_api_external.h"
#include "tests/nix_api_expr.hh"
#include "tests/string_callback.hh"
#include <gtest/gtest.h>
@ -58,6 +60,9 @@ TEST_F(nix_api_expr_test, nix_expr_eval_external)
nix_value_call(ctx, state, valueFn, value, valueResult);
ASSERT_STREQ("nix-external<MyExternalValueDesc( 42 )>", nix_get_string(nullptr, valueResult));
std::string string_value;
nix_get_string(nullptr, valueResult, OBSERVE_STRING(string_value));
ASSERT_STREQ("nix-external<MyExternalValueDesc( 42 )>", string_value.c_str());
}
}