1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 14:21:48 +02:00

test/libutil: Add OBSERVE_STRING macro

Makes string callback easier to pass, without mistakes.
This commit is contained in:
Robert Hensing 2024-04-08 13:13:02 +02:00
parent 876e70bc9a
commit a512f4eebc
4 changed files with 33 additions and 20 deletions

View file

@ -0,0 +1,9 @@
#include "string_callback.hh"
namespace nix::testing {
void observe_string_cb(const char * start, unsigned int n, std::string * user_data) {
*user_data = std::string(start);
}
}

View file

@ -0,0 +1,12 @@
#pragma once
#include <string>
namespace nix::testing {
void observe_string_cb(const char * start, unsigned int n, std::string * user_data);
inline void * observe_string_cb_data(std::string & out) {
return (void *) &out;
};
#define OBSERVE_STRING(str) (void *)nix::testing::observe_string_cb, nix::testing::observe_string_cb_data(str)
}