25#define TEST_GLOBAL_INIT test_init()
30#include <freeradius-devel/util/dict_test.h>
31#include <freeradius-devel/util/pair.h>
61 pair_ctx->
list = list;
70 char const in[] =
"Test-String-0 = \"hello world\"";
85 TEST_CASE(
"A leaf parsed from the root leaves the context at the root");
96 char const in[] =
"Test-Uint32-0 == 42, Test-String-0 = bob";
106 TEST_CASE(
"The caller consumes the comma");
136 char const in[] =
" Test-String-0 = bob";
155 char const in[] =
" \t ";
174 TEST_CASE(
"A bare structural attribute changes the context");
179 TEST_CASE(
"After a leading '.', the leaf is a child of the current context");
189 TEST_CASE(
"A structural attribute followed by a comma leaves the comma for the caller");
206 TEST_CASE(
"A dotted reference descends from the root");
219 TEST_CASE(
"'..' is the parent of the current context");
224 TEST_CASE(
"After a leading '.', a structural attribute is a child of the current context");
229 TEST_CASE(
"'..' followed by a leaf parses the leaf under the parent of the current context");
241 TEST_CASE(
"'..' followed by a reference descends from the parent of the current context");
248 TEST_CASE(
"Each further '.' walks one level further up");
277 "Attribute 'Test-Nope' not found in namespace 'test'");
279 TEST_CASE(
"The error offset counts leading whitespace");
281 "Attribute 'Test-Nope' not found in namespace 'test'");
284 "Expected operator");
287 "Invalid string quotation");
290 "Unterminated string");
293 "Unexpected text after attribute");
296 "Attribute 'Nope' not found in namespace 'Test-TLV-0'");
298 TEST_CASE(
"A trailing '.' has no attribute to set the context from");
303 TEST_CASE(
"The dictionary root has no parent, so '..' at the root fails");
306 "No parent above the dictionary root");
#define TEST_ASSERT(cond)
Common initialisation for acutest binaries.
#define TEST_CHECK_SLEN(_got, _exp)
#define TEST_CHECK_STRCMP(_got, _exp)
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_dict_attr_t const * fr_dict_attr_test_tlv_string
fr_dict_attr_t const * fr_dict_attr_test_tlv
fr_dict_attr_t const * fr_dict_attr_test_nested_top_tlv
fr_dict_attr_t const * fr_dict_attr_test_uint32
fr_dict_attr_t const * fr_dict_attr_test_string
fr_dict_attr_t const * fr_dict_attr_test_nested_child_tlv
int fr_dict_test_init(TALLOC_CTX *ctx, fr_dict_t **dict_p, fr_dict_test_attr_t const *test_defs)
Initialise a test dictionary and add our test_defs to it.
fr_dict_attr_t const * fr_dict_attr_test_group
fr_dict_attr_t const * fr_dict_attr_test_nested_leaf_int32
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
static void test_whitespace_only(void)
static TALLOC_CTX * autofree
static void pair_ctx_init(fr_pair_ctx_t *pair_ctx, fr_pair_list_t *list)
Start a parsing context at the root of the test dictionary.
static void test_leaf_quoted(void)
static void test_context_structural(void)
static fr_dict_t * test_dict
static void test_context_nested(void)
static void test_leaf_bareword_stops_at_comma(void)
static void pair_ctx_check_error(fr_pair_ctx_t *pair_ctx, char const *in, fr_slen_t offset, char const *msg)
Check that a parse fails at the expected offset with the expected message.
static void test_init(void)
Global initialisation.
static void test_errors(void)
static void test_leaf_leading_whitespace(void)
The sbuff bounds the input, so skipping leading whitespace cannot run past the end of the input.
#define FR_SBUFF_IN(_start, _len_or_end)
#define fr_sbuff_is_char(_sbuff_or_marker, _c)
#define FR_SBUFF_IN_STR(_start)
#define fr_sbuff_advance(_sbuff_or_marker, _len)
#define fr_sbuff_remaining(_sbuff_or_marker)
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
TALLOC_CTX * ctx
to allocate VPs in
fr_slen_t fr_pair_ctx_afrom_substr(fr_pair_ctx_t *pair_ctx, fr_sbuff_t *in)
Parse one pair, or one context change, from a string.
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
fr_pair_t * fr_pair_list_tail(fr_pair_list_t const *list)
Get the tail of a valuepair list.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_ctx_reset(fr_pair_ctx_t *pair_ctx, fr_dict_t const *dict)
Reset a pair_ctx to the dictionary root.
fr_pair_list_t * list
of VPs to add
fr_dict_attr_t const * parent
current attribute to allocate VPs in
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
char const * fr_strerror(void)
Get the last library error.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
void fr_strerror_clear(void)
Clears all pending messages from the talloc pools.
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
#define RADIUSD_MAGIC_NUMBER
static fr_sbuff_err_t char size_t fr_sbuff_t * in