mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 15:02:42 +01:00
Use hybrid C / Pascal strings in the evaluator
Replace the null-terminated C-style strings in Value with hybrid C / Pascal strings, where the length is stored in the allocation before the data, and there is still a null byte at the end for the sake of C interopt. Co-Authored-By: Taeer Bar-Yam <taeer@bar-yam.me> Co-Authored-By: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
parent
8c113f80f3
commit
3bf8c76072
14 changed files with 279 additions and 100 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "nix/expr/tests/libexpr.hh"
|
||||
#include "nix/expr/value-to-json.hh"
|
||||
#include "nix/expr/static-string-data.hh"
|
||||
|
||||
namespace nix {
|
||||
// Testing the conversion to JSON
|
||||
|
|
@ -54,7 +55,7 @@ TEST_F(JSONValueTest, IntNegative)
|
|||
TEST_F(JSONValueTest, String)
|
||||
{
|
||||
Value v;
|
||||
v.mkStringNoCopy("test");
|
||||
v.mkStringNoCopy("test"_sds);
|
||||
ASSERT_EQ(getJSONValue(v), "\"test\"");
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ TEST_F(JSONValueTest, StringQuotes)
|
|||
{
|
||||
Value v;
|
||||
|
||||
v.mkStringNoCopy("test\"");
|
||||
v.mkStringNoCopy("test\""_sds);
|
||||
ASSERT_EQ(getJSONValue(v), "\"test\\\"\"");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue