/**
* The 'TEST_INIT' macro provided by 'acutest.h' allowing to register a function to be called
* before call the unit tests. Therefore, It calls the function ALL THE TIME causing an overhead.
- * That is why we are initializing pair_tests_init() by "__attribute__((constructor));" reducing the
+ * That is why we are initializing test_init() by "__attribute__((constructor));" reducing the
* test execution by 50% of the time.
*/
#define USE_CONSTRUCTOR
* It should be declared before include the "acutest.h"
*/
#ifdef USE_CONSTRUCTOR
-static void pair_tests_init(void) __attribute__((constructor));
+static void test_init(void) __attribute__((constructor));
#else
-static void pair_tests_init(void);
-# define TEST_INIT pair_tests_init()
+static void test_init(void);
+# define TEST_INIT test_init()
#endif
#include <freeradius-devel/util/acutest.h>
#include <freeradius-devel/util/acutest_helpers.h>
+#include <freeradius-devel/util/pair_test_helpers.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict.h>
+#include <freeradius-devel/util/dict_test.h>
#include <freeradius-devel/util/pair.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/server/request.h>
#ifdef HAVE_GPERFTOOLS_PROFILER_H
-# include <gperftools/profiler.h>
+# include <gperftools/profiler.h>
#endif
-static char const *dict_dir = "share/dictionary";
-
-/* Set by pair_tests_init()*/
static TALLOC_CTX *autofree;
-static fr_pair_list_t sample_pairs;
-
-typedef struct value {
- char const *key;
- fr_value_box_t val;
-} fr_dict_adhoc_attr_value_t;
-
-typedef struct {
- int attr;
- fr_dict_attr_t const **parent;
- fr_dict_attr_t const **da;
- char const *name;
- fr_type_t type;
- void *values;
-} fr_dict_adhoc_attr_t;
-
-#define FR_TEST_INTEGER 1
-#define FR_TEST_STRING 2
-#define FR_TEST_OCTETS 3
-#define FR_TEST_VALUES 4
-#define FR_TEST_TLV_ROOT 5
-#define FR_TEST_TLV_STRING 1
-
-static fr_dict_t *dict_test;
-
-static fr_dict_attr_t const *attr_test_integer;
-static fr_dict_attr_t const *attr_test_string;
-static fr_dict_attr_t const *attr_test_octets;
-static fr_dict_attr_t const *attr_test_values;
-static fr_dict_attr_t const *attr_test_tlv_root;
-static fr_dict_attr_t const *attr_test_tlv_string;
-
-static fr_dict_adhoc_attr_value_t attr_test_values_entries[] = {
- { .key = "Tapioca123", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 123 } },
- { .key = "Tapioca321", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 321 } },
- { .key = NULL, },
-};
+static fr_pair_list_t test_pairs;
+static fr_dict_t *test_dict;
-static fr_dict_adhoc_attr_t test_dict_attrs[] = {
- { .attr = FR_TEST_INTEGER, .parent = NULL, .da = &attr_test_integer, .name = "Test-Integer", .type = FR_TYPE_UINT32, },
- { .attr = FR_TEST_STRING, .parent = NULL, .da = &attr_test_string, .name = "Test-String", .type = FR_TYPE_STRING, },
- { .attr = FR_TEST_OCTETS, .parent = NULL, .da = &attr_test_octets, .name = "Test-Octets", .type = FR_TYPE_OCTETS, },
- { .attr = FR_TEST_VALUES, .parent = NULL, .da = &attr_test_values, .name = "Test-Values", .type = FR_TYPE_UINT32, .values = &attr_test_values_entries },
- { .attr = FR_TEST_TLV_ROOT, .parent = NULL, .da = &attr_test_tlv_root, .name = "Test-TLV-Root", .type = FR_TYPE_TLV, },
- { .attr = FR_TEST_TLV_STRING, .parent = &attr_test_tlv_root, .da = &attr_test_tlv_string, .name = "Test-TLV-String", .type = FR_TYPE_STRING, },
- { .attr = -1, .parent = NULL, .da = NULL, .name = NULL, .type = FR_TYPE_NULL }
-};
-/*
- * It will be called before of unit tests.
+/** Global initialisation
*/
-static int load_attr_pairs(fr_pair_list_t *out)
-{
- fr_dict_adhoc_attr_t *p;
-
- fr_pair_list_init(out);
-
- for (p = test_dict_attrs;
- p->attr != -1;
- p++) if (fr_pair_prepend_by_da(autofree, NULL, out, *p->da) < 0) return -1;
-
- return 0;
-}
-
-static int init_adhoc_attrs(fr_dict_adhoc_attr_t *dict_adhoc)
-{
- fr_dict_adhoc_attr_t *ctx;
- fr_dict_attr_flags_t dict_flags = {
- .is_root = true
- };
-
- for (ctx = dict_adhoc;
- ctx->attr != -1;
- ctx++) {
- fr_dict_attr_t const *parent = ctx->parent ? *ctx->parent : fr_dict_root(dict_test);
- fr_dict_attr_t const *attr;
-
- if (fr_dict_attr_add(dict_test, parent, ctx->name, ctx->attr, ctx->type, &dict_flags) < 0) return -1;
-
- attr = fr_dict_attr_by_name(NULL, parent, ctx->name);
- if (!attr) return -1;
-
- /* Set the VALUES */
- if (ctx->values) {
- fr_dict_adhoc_attr_value_t *v;
-
- for (v = ctx->values;
- v->key != NULL;
- v++) fr_dict_enum_add_name(fr_dict_attr_unconst(attr), v->key, &v->val, false, false);
- }
-
- *ctx->da = attr;
- }
-
- return 0;
-}
-
-static void pair_tests_init(void)
+static void test_init(void)
{
autofree = talloc_autofree_context();
if (!autofree) {
*/
if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) goto error;
- if (!fr_dict_global_ctx_init(autofree, dict_dir)) goto error;
+ if (fr_dict_test_init(autofree, &test_dict, NULL) < 0) goto error;
- /*
- * Initialise attributes that go in requests
- */
- if (request_global_init() < 0) goto error;
-
- /*
- * Set the root name of the dictionary
- */
- dict_test = fr_dict_alloc("test", 666);
- if (!dict_test) goto error;
-
- if (init_adhoc_attrs(test_dict_attrs) < 0) goto error;
-
- /* Initialize the "sample_pairs" list */
- fr_pair_list_init(&sample_pairs);
- if (load_attr_pairs(&sample_pairs) < 0) goto error;
+ /* Initialize the "test_pairs" list */
+ fr_pair_list_init(&test_pairs);
+ if (fr_pair_test_list_alloc(autofree, &test_pairs, NULL) < 0) goto error;
+ if (request_global_init() < 0) goto error;
}
static request_t *request_fake_alloc(void)
request_t *request = request_fake_alloc();
TEST_CASE("Add 'Test-Integer' in 'request_pairs' using pair_append_request()");
- TEST_CHECK(pair_append_request(&local_vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_append_request(&local_vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
TEST_CHECK((vp = fr_pair_list_head(&request->request_pairs)) != NULL);
TEST_MSG("Set vp = 12345");
vp->vp_uint32 = 12345;
TEST_CHECK(vp->vp_uint32 == 12345);
- TEST_MSG("Expected %s == 12345", attr_test_integer->name);
+ TEST_MSG("Expected %s == 12345", fr_dict_attr_test_uint32->name);
TEST_CHECK_RET(talloc_free(request), 0);
}
request_t *request = request_fake_alloc();
TEST_CASE("Add 'Test-Integer' in 'reply_pairs' using pair_append_reply()");
- TEST_CHECK(pair_append_reply(&local_vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_append_reply(&local_vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
TEST_CHECK((vp = fr_pair_list_head(&request->reply_pairs)) != NULL);
vp->vp_uint32 = 12345;
TEST_CHECK(vp->vp_uint32 == 12345);
- TEST_MSG("Expected %s == 12345", attr_test_integer->name);
+ TEST_MSG("Expected %s == 12345", fr_dict_attr_test_uint32->name);
TEST_CHECK_RET(talloc_free(request), 0);
}
request_t *request = request_fake_alloc();
TEST_CASE("Add 'Test-Integer' in 'control_pairs' using pair_append_control()");
- TEST_CHECK(pair_append_control(&local_vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_append_control(&local_vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
TEST_CHECK((vp = fr_pair_list_head(&request->control_pairs)) != NULL);
vp->vp_uint32 = 12345;
TEST_CHECK(vp->vp_uint32 == 12345);
- TEST_MSG("Expected %s == 12345", attr_test_integer->name);
+ TEST_MSG("Expected %s == 12345", fr_dict_attr_test_uint32->name);
TEST_CHECK_RET(talloc_free(request), 0);
}
request_t *request = request_fake_alloc();
TEST_CASE("Add 'Test-Integer' in 'control_pairs' using pair_append_session_state()");
- TEST_CHECK(pair_append_session_state(&local_vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_append_session_state(&local_vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
TEST_CHECK((vp = fr_pair_list_head(&request->session_state_pairs)) != NULL);
vp->vp_uint32 = 12345;
TEST_CHECK(vp->vp_uint32 == 12345);
- TEST_MSG("Expected %s == 12345", attr_test_integer->name);
+ TEST_MSG("Expected %s == 12345", fr_dict_attr_test_uint32->name);
TEST_CHECK_RET(talloc_free(request), 0);
}
request_t *request = request_fake_alloc();
TEST_CASE("Update 'Test-Integer' in 'request_pairs' using pair_update_request()");
- TEST_CHECK(pair_update_request(&vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_update_request(&vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_MSG("Set vp = 112233");
vp->vp_uint32 = 112233;
- TEST_CASE("Expected attr_test_integer (vp->vp_uint32 == 112233)");
- TEST_CHECK((vp = fr_pair_find_by_da(&request->request_pairs, attr_test_integer)) != NULL);
+ TEST_CASE("Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 112233)");
+ TEST_CHECK((vp = fr_pair_find_by_da(&request->request_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
request_t *request = request_fake_alloc();
TEST_CASE("Update 'Test-Integer' in 'reply_pairs' using pair_update_request()");
- TEST_CHECK(pair_update_reply(&vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_update_reply(&vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_MSG("Set vp = 3333");
vp->vp_uint32 = 3333;
- TEST_CASE("Expected attr_test_integer (vp->vp_uint32 == 3333)");
- TEST_CHECK((vp = fr_pair_find_by_da(&request->reply_pairs, attr_test_integer)) != NULL);
+ TEST_CASE("Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 3333)");
+ TEST_CHECK((vp = fr_pair_find_by_da(&request->reply_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
request_t *request = request_fake_alloc();
TEST_CASE("Update 'Test-Integer' in 'control_pairs' using pair_update_control()");
- TEST_CHECK(pair_update_control(&vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_update_control(&vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_MSG("Set vp = 44444");
vp->vp_uint32 = 44444;
- TEST_CASE("Expected attr_test_integer (vp->vp_uint32 == 44444)");
- TEST_CHECK((vp = fr_pair_find_by_da(&request->control_pairs, attr_test_integer)) != NULL);
+ TEST_CASE("Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 44444)");
+ TEST_CHECK((vp = fr_pair_find_by_da(&request->control_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
request_t *request = request_fake_alloc();
TEST_CASE("Update 'Test-Integer' in 'state' using pair_update_session_state()");
- TEST_CHECK(pair_update_session_state(&vp, attr_test_integer) == 0);
+ TEST_CHECK(pair_update_session_state(&vp, fr_dict_attr_test_uint32) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_MSG("Set vp = 7890");
vp->vp_uint32 = 7890;
- TEST_CASE("Expected attr_test_integer (vp->vp_uint32 == 7890)");
- TEST_CHECK((vp = fr_pair_find_by_da(&request->session_state_pairs, attr_test_integer)) != NULL);
+ TEST_CASE("Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 7890)");
+ TEST_CHECK((vp = fr_pair_find_by_da(&request->session_state_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
{
request_t *request = request_fake_alloc();
- TEST_CASE("Copy 'sample_pairs' into 'request->request_pairs'");
- TEST_CHECK(fr_pair_list_copy(autofree, &request->request_pairs, &sample_pairs) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'request->request_pairs'");
+ TEST_CHECK(fr_pair_list_copy(autofree, &request->request_pairs, &test_pairs) > 0);
TEST_CASE("Delete 'Test-Integer' in 'request->request_pairs' using pair_delete_request()");
- TEST_CHECK(pair_delete_request(attr_test_integer) > 0);
+ TEST_CHECK(pair_delete_request(fr_dict_attr_test_uint32) > 0);
TEST_CASE("The 'Test-Integer' shouldn't exist in 'request->request_pairs'");
- TEST_CHECK(fr_pair_find_by_da(&request->request_pairs, attr_test_integer) == NULL);
+ TEST_CHECK(fr_pair_find_by_da(&request->request_pairs, fr_dict_attr_test_uint32) == NULL);
TEST_CHECK_RET(talloc_free(request), 0);
}
{
request_t *request = request_fake_alloc();
- TEST_CASE("Copy 'sample_pairs' into 'request->reply_pairs'");
- TEST_CHECK(fr_pair_list_copy(autofree, &request->reply_pairs, &sample_pairs) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'request->reply_pairs'");
+ TEST_CHECK(fr_pair_list_copy(autofree, &request->reply_pairs, &test_pairs) > 0);
TEST_CASE("Delete 'Test-Integer' in 'request->reply_pairs' using pair_delete_reply()");
- TEST_CHECK(pair_delete_reply(attr_test_integer) > 0);
+ TEST_CHECK(pair_delete_reply(fr_dict_attr_test_uint32) > 0);
TEST_CASE("The 'Test-Integer' shouldn't exist in 'request->reply_pairs'");
- TEST_CHECK(fr_pair_find_by_da(&request->reply_pairs, attr_test_integer) == NULL);
+ TEST_CHECK(fr_pair_find_by_da(&request->reply_pairs, fr_dict_attr_test_uint32) == NULL);
TEST_CHECK_RET(talloc_free(request), 0);
}
{
request_t *request = request_fake_alloc();
- TEST_CASE("Copy 'sample_pairs' into 'request->control_pairs'");
- TEST_CHECK(fr_pair_list_copy(autofree, &request->control_pairs, &sample_pairs) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'request->control_pairs'");
+ TEST_CHECK(fr_pair_list_copy(autofree, &request->control_pairs, &test_pairs) > 0);
TEST_CASE("Delete 'Test-Integer' in 'request->control_pairs' using pair_delete_control()");
- TEST_CHECK(pair_delete_control(attr_test_integer) > 0);
+ TEST_CHECK(pair_delete_control(fr_dict_attr_test_uint32) > 0);
TEST_CASE("The 'Test-Integer' shouldn't exist in 'request->control_pairs'");
- TEST_CHECK(fr_pair_find_by_da(&request->control_pairs, attr_test_integer) == NULL);
+ TEST_CHECK(fr_pair_find_by_da(&request->control_pairs, fr_dict_attr_test_uint32) == NULL);
TEST_CHECK_RET(talloc_free(request), 0);
}
{
request_t *request = request_fake_alloc();
- TEST_CASE("Copy 'sample_pairs' into 'request->state'");
- TEST_CHECK(fr_pair_list_copy(autofree, &request->session_state_pairs, &sample_pairs) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'request->state'");
+ TEST_CHECK(fr_pair_list_copy(autofree, &request->session_state_pairs, &test_pairs) > 0);
TEST_CASE("Delete 'Test-Integer' in 'request->state' using pair_delete_session_state()");
- TEST_CHECK(pair_delete_session_state(attr_test_integer) > 0);
+ TEST_CHECK(pair_delete_session_state(fr_dict_attr_test_uint32) > 0);
TEST_CASE("The 'Test-Integer' shouldn't exist in 'request->state'");
- TEST_CHECK(fr_pair_find_by_da(&request->session_state_pairs, attr_test_integer) == NULL);
+ TEST_CHECK(fr_pair_find_by_da(&request->session_state_pairs, fr_dict_attr_test_uint32) == NULL);
TEST_CHECK_RET(talloc_free(request), 0);
}
* It should be declared before include the "acutest.h"
*/
#ifdef USE_CONSTRUCTOR
-static void pair_tests_init(void) __attribute__((constructor));
+static void test_init(void) __attribute__((constructor));
#else
-static void pair_tests_init(void);
-# define TEST_INIT pair_tests_init()
+static void test_init(void);
+# define TEST_INIT test_init()
#endif
#include <freeradius-devel/util/acutest.h>
+#include <freeradius-devel/util/acutest_helpers.h>
+#include <freeradius-devel/util/pair_test_helpers.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict.h>
-#include <freeradius-devel/util/pair.h>
+#include <freeradius-devel/util/dict_test.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/talloc.h>
-#include <freeradius-devel/radius/radius.h>
-
#ifdef HAVE_GPERFTOOLS_PROFILER_H
# include <gperftools/profiler.h>
#endif
-static char const *dict_dir = "share/dictionary";
-
-/* Set by pair_tests_init()*/
static TALLOC_CTX *autofree;
-static fr_pair_list_t sample_pairs;
-static char const *sample_string = "We love Tapioca!";
-
-/*
- * Needed by fr_dict_*() API
- */
-#include "dict_priv.h"
-
-typedef struct value {
- char const *key;
- fr_value_box_t val;
-} fr_dict_adhoc_attr_value_t;
-
-typedef struct {
- int attr;
- fr_dict_attr_t const **parent;
- fr_dict_attr_t const **da;
- char const *name;
- fr_type_t type;
- void *values;
-} fr_dict_adhoc_attr_t;
-
-#define FR_TEST_INTEGER 1
-#define FR_TEST_STRING 2
-#define FR_TEST_OCTETS 3
-#define FR_TEST_VALUES 4
-#define FR_TEST_TLV_ROOT 5
-#define FR_TEST_TLV_STRING 1
-
-static fr_dict_t *dict_test;
-static fr_dict_t *dict_internal;
-
-static fr_dict_attr_t const *attr_test_integer;
-static fr_dict_attr_t const *attr_test_string;
-static fr_dict_attr_t const *attr_test_octets;
-static fr_dict_attr_t const *attr_test_values;
-static fr_dict_attr_t const *attr_test_tlv_root;
-static fr_dict_attr_t const *attr_test_tlv_string;
-
-static fr_dict_adhoc_attr_value_t attr_test_values_entries[] = {
- { .key = "Tapioca123", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 123 } },
- { .key = "Tapioca321", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 321 } },
- { .key = NULL, },
-};
+static fr_pair_list_t test_pairs;
+static fr_dict_t *test_dict;
-static fr_dict_adhoc_attr_t test_dict_attrs[] = {
- { .attr = FR_TEST_INTEGER, .parent = NULL, .da = &attr_test_integer, .name = "Test-Integer", .type = FR_TYPE_UINT32, },
- { .attr = FR_TEST_STRING, .parent = NULL, .da = &attr_test_string, .name = "Test-String", .type = FR_TYPE_STRING, },
- { .attr = FR_TEST_OCTETS, .parent = NULL, .da = &attr_test_octets, .name = "Test-Octets", .type = FR_TYPE_OCTETS, },
- { .attr = FR_TEST_VALUES, .parent = NULL, .da = &attr_test_values, .name = "Test-Values", .type = FR_TYPE_UINT32, .values = &attr_test_values_entries },
- { .attr = FR_TEST_TLV_ROOT, .parent = NULL, .da = &attr_test_tlv_root, .name = "Test-TLV-Root", .type = FR_TYPE_TLV, },
- { .attr = FR_TEST_TLV_STRING, .parent = &attr_test_tlv_root, .da = &attr_test_tlv_string, .name = "Test-TLV-String", .type = FR_TYPE_STRING, },
- { .attr = -1, .parent = NULL, .da = NULL, .name = NULL, .type = FR_TYPE_NULL }
-};
-/*
- * It will be called before of unit tests.
+/** Global initialisation
*/
-static int load_attr_pairs(fr_pair_list_t *out)
-{
- fr_dict_adhoc_attr_t *p;
-
- fr_pair_list_init(out);
-
- for (p = test_dict_attrs;
- p->attr != -1;
- p++) if (fr_pair_prepend_by_da(autofree, NULL, out, *p->da) < 0) return -1;
-
- return 0;
-}
-
-static int init_adhoc_attrs(fr_dict_adhoc_attr_t *dict_adhoc)
-{
- fr_dict_adhoc_attr_t *ctx;
- fr_dict_attr_flags_t dict_flags = {
- .is_root = true
- };
-
- for (ctx = dict_adhoc;
- ctx->attr != -1;
- ctx++) {
- fr_dict_attr_t const *parent = ctx->parent ? *ctx->parent : fr_dict_root(dict_test);
- fr_dict_attr_t const *attr;
-
- if (fr_dict_attr_add(dict_test, parent, ctx->name, ctx->attr, ctx->type, &dict_flags) < 0) return -1;
-
- attr = fr_dict_attr_by_name(NULL, parent, ctx->name);
- if (!attr) return -1;
-
- /* Set the VALUES */
- if (ctx->values) {
- fr_dict_adhoc_attr_value_t *v;
-
- for (v = ctx->values;
- v->key != NULL;
- v++) fr_dict_enum_add_name(fr_dict_attr_unconst(attr), v->key, &v->val, false, false);
- }
-
- *ctx->da = attr;
- }
-
- return 0;
-}
-
-static void pair_tests_init(void)
+static void test_init(void)
{
- printf("Setup %s\n", __func__);
-
autofree = talloc_autofree_context();
if (!autofree) {
error:
*/
if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) goto error;
- if (!fr_dict_global_ctx_init(autofree, dict_dir)) goto error;
-
- if (fr_dict_internal_afrom_file(&dict_internal, FR_DICTIONARY_INTERNAL_DIR, __FILE__) < 0) goto error;
-
- /*
- * Set the root name of the dictionary
- */
- dict_test = fr_dict_alloc("test", 666);
- if (!dict_test) goto error;
+ if (fr_dict_test_init(autofree, &test_dict, NULL) < 0) goto error;
- if (init_adhoc_attrs(test_dict_attrs) < 0) goto error;
+ /* Initialize the "test_pairs" list */
+ fr_pair_list_init(&test_pairs);
- /* Initialize the "sample_pairs" list */
- fr_pair_list_init(&sample_pairs);
- if (load_attr_pairs(&sample_pairs) < 0) goto error;
+ if (fr_pair_test_list_alloc(autofree, &test_pairs, NULL) < 0) goto error;
}
/*
fr_pair_list_init(&list);
TEST_CASE("Creating 'vp' using fr_pair_make()");
- TEST_CHECK((vp = fr_pair_make(ctx, dict_test, &list, "Test-String", sample_string, T_DOUBLE_QUOTED_STRING)) != NULL);
+ TEST_CHECK((vp = fr_pair_make(ctx, test_dict, &list, "Test-String", test_string, T_DOUBLE_QUOTED_STRING)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, sample_string) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, test_string) == 0);
fr_pair_list_free(&list);
}
fr_pair_t *vp;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CASE("Marking 'vp' using fr_pair_mark_xlat()");
- TEST_CHECK(fr_pair_mark_xlat(vp, "Hello %{Test-Integer}") == 0);
+ TEST_CHECK(fr_pair_mark_xlat(vp, "Hello %{Test-Uint32}") == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->xlat == 'Hello %{Test-Integer}')");
- TEST_CHECK(vp && strcmp(vp->xlat, "Hello %{Test-Integer}") == 0);
+ TEST_CASE("Check (vp->xlat == 'Hello %{Test-Uint32}')");
+ TEST_CHECK(vp && strcmp(vp->xlat, "Hello %{Test-Uint32}") == 0);
TEST_CHECK(vp && vp->type == VT_XLAT);
talloc_free(vp);
{
fr_pair_t *vp;
fr_pair_list_t list;
- char const *buffer = "Test-Integer = 123, Test-String = \"Tapioca\"";
+ char const *buffer = "Test-Uint32 = 123, Test-String = \"Testing123\"";
fr_pair_list_init(&list);
TEST_CASE("Create 'vp' using fr_pair_list_afrom_str()");
- TEST_CHECK(fr_pair_list_afrom_str(autofree, dict_test, buffer, strlen(buffer), &list) == T_EOL);
+ TEST_CHECK(fr_pair_list_afrom_str(autofree, test_dict, buffer, strlen(buffer), &list) == T_EOL);
- TEST_CASE("Looking for Test-Integer");
- TEST_CHECK((vp = fr_pair_find_by_da(&list, attr_test_integer)) != NULL);
+ TEST_CASE("Looking for Test-Uint32");
+ TEST_CHECK((vp = fr_pair_find_by_da(&list, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Checking if (Test-Integer == 123)");
+ TEST_CASE("Checking if (Test-Uint32 == 123)");
TEST_CHECK(vp && vp->vp_uint32 == 123);
TEST_CASE("Looking for Test-String");
- TEST_CHECK((vp = fr_pair_find_by_da(&list, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&list, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Checking if (Test-String == 'Tapioca')");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Tapioca") == 0);
+ TEST_CASE("Checking if (Test-String == 'Testing123')");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Testing123") == 0);
fr_pair_list_free(&list);
}
{
fr_pair_t *vp;
fr_pair_list_t list;
- char const *buffer = "Test-Integer = 123\nTest-String = \"Tapioca\"\n";
+ char const *buffer = "Test-Uint32 = 123\nTest-String = \"Testing123\"\n";
FILE *fp = open_buffer_as_file(buffer, strlen(buffer));
bool pfiledone;
fr_pair_list_init(&list);
TEST_CASE("Create 'vp' using fr_pair_list_afrom_file()");
- TEST_CHECK(fr_pair_list_afrom_file(autofree, dict_test, &list, fp, &pfiledone) == 0);
+ TEST_CHECK(fr_pair_list_afrom_file(autofree, test_dict, &list, fp, &pfiledone) == 0);
- TEST_CASE("Looking for Test-Integer");
- TEST_CHECK((vp = fr_pair_find_by_da(&list, attr_test_integer)) != NULL);
+ TEST_CASE("Looking for Test-Uint32");
+ TEST_CHECK((vp = fr_pair_find_by_da(&list, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Checking if (Test-Integer == 123)");
+ TEST_CASE("Checking if (Test-Uint32 == 123)");
TEST_CHECK(vp && vp->vp_uint32 == 123);
TEST_CASE("Looking for Test-String");
- TEST_CHECK((vp = fr_pair_find_by_da(&list, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&list, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Checking if (Test-String == 'Tapioca')");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Tapioca") == 0);
+ TEST_CASE("Checking if (Test-String == 'Testing123')");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Testing123") == 0);
fr_pair_list_free(&list);
fr_pair_t *vp;
fr_pair_list_t old_list, new_list;
bool pfiledone;
- char const *fake_file = "Test-Integer = 123\nTest-String = \"Tapioca\"\n";
+ char const *fake_file = "Test-Uint32 = 123\nTest-String = \"Testing123\"\n";
FILE *fp = open_buffer_as_file(fake_file, strlen(fake_file));
fr_pair_list_init(&old_list);
fr_pair_list_init(&new_list);
TEST_CASE("Create 'vp' using fr_pair_list_afrom_file()");
- TEST_CHECK(fr_pair_list_afrom_file(autofree, dict_test, &old_list, fp, &pfiledone) == 0);
+ TEST_CHECK(fr_pair_list_afrom_file(autofree, test_dict, &old_list, fp, &pfiledone) == 0);
TEST_CHECK(pfiledone == true);
TEST_CASE("Move pair from 'old_list' to 'old_list' using fr_pair_list_move()");
fr_pair_list_move(&new_list, &old_list);
- TEST_CASE("Looking for Test-Integer");
- TEST_CHECK((vp = fr_pair_find_by_da(&new_list, attr_test_integer)) != NULL);
+ TEST_CASE("Looking for Test-Uint32");
+ TEST_CHECK((vp = fr_pair_find_by_da(&new_list, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CHECK(vp != NULL);
- TEST_CASE("Checking if (Test-Integer == 123)");
+ TEST_CASE("Checking if (Test-Uint32 == 123)");
TEST_CHECK(vp && vp->vp_uint32 == 123);
TEST_CASE("Looking for Test-String");
- TEST_CHECK((vp = fr_pair_find_by_da(&new_list, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&new_list, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CHECK(vp != NULL);
- TEST_CASE("Checking if (Test-String == 'Tapioca')");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Tapioca") == 0);
+ TEST_CASE("Checking if (Test-String == 'Testing123')");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, "Testing123") == 0);
fr_pair_list_free(&old_list);
fr_pair_list_free(&new_list);
/**
* The 'TEST_INIT' macro provided by 'acutest.h' allowing to register a function to be called
* before call the unit tests. Therefore, It calls the function ALL THE TIME causing an overhead.
- * That is why we are initializing pair_tests_init() by "__attribute__((constructor));" reducing the
+ * That is why we are initializing test_init() by "__attribute__((constructor));" reducing the
* test execution by 50% of the time.
*/
#define USE_CONSTRUCTOR
* It should be declared before include the "acutest.h"
*/
#ifdef USE_CONSTRUCTOR
-static void pair_tests_init(void) __attribute__((constructor));
+static void test_init(void) __attribute__((constructor));
#else
-static void pair_tests_init(void);
-# define TEST_INIT pair_tests_init()
+static void test_init(void);
+# define TEST_INIT test_init()
#endif
#include <freeradius-devel/util/acutest.h>
+#include <freeradius-devel/util/acutest_helpers.h>
+#include <freeradius-devel/util/pair_test_helpers.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict.h>
+#include <freeradius-devel/util/dict_test.h>
#include <freeradius-devel/util/pair.h>
#include <freeradius-devel/util/talloc.h>
-#include <freeradius-devel/radius/radius.h>
-
#ifdef HAVE_GPERFTOOLS_PROFILER_H
# include <gperftools/profiler.h>
#endif
-#define ARRAY_SIZE(x) ((sizeof(x)/sizeof(x[0])))
-
-static char const *dict_dir = "share/dictionary";
-
-/* Set by pair_tests_init()*/
static TALLOC_CTX *autofree;
-static fr_pair_list_t sample_pairs;
-static char const *sample_string = "We love Tapioca!";
-static size_t sample_string_len = 16;
-static uint8_t sample_octets[] = {
- 0x53, 0x63, 0x61, 0x6c, 0x64, 0x20, 0x52,
- 0x65, 0x64, 0x64, 0x69, 0x74, 0x20, 0x41,
- 0x63, 0x61, 0x64, 0x65, 0x6d, 0x79, 0x0a
-};
+static fr_pair_list_t test_pairs;
+static fr_dict_t *test_dict;
-/*
- * Needed by fr_dict_*() API
+/** Global initialisation
*/
-#include "dict_priv.h"
-
-typedef struct value {
- char const *key;
- fr_value_box_t val;
-} fr_dict_adhoc_attr_value_t;
-
-typedef struct {
- int attr;
- fr_dict_attr_t const **parent;
- fr_dict_attr_t const **da;
- char const *name;
- fr_type_t type;
- void *values;
-} fr_dict_adhoc_attr_t;
-
-#define FR_TEST_INTEGER 1
-#define FR_TEST_STRING 2
-#define FR_TEST_OCTETS 3
-#define FR_TEST_VALUES 4
-#define FR_TEST_TLV_ROOT 5
-#define FR_TEST_TLV_STRING 1
-#define FR_TEST_DATE 6
-#define FR_TEST_IPV4_ADDR 7
-
-static fr_dict_t *dict_test;
-
-static fr_dict_attr_t const *attr_test_integer;
-static fr_dict_attr_t const *attr_test_octets;
-static fr_dict_attr_t const *attr_test_string;
-static fr_dict_attr_t const *attr_test_date;
-static fr_dict_attr_t const *attr_test_ipv4_addr;
-static fr_dict_attr_t const *attr_test_tlv_root;
-static fr_dict_attr_t const *attr_test_tlv_string;
-static fr_dict_attr_t const *attr_test_values;
-
-static fr_dict_adhoc_attr_value_t attr_test_values_entries[] = {
- { .key = "Tapioca123", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 123 } },
- { .key = "Tapioca321", .val = { .type = FR_TYPE_UINT32, .vb_uint32 = 321 } },
- { .key = NULL, },
-};
-
-static fr_dict_adhoc_attr_t test_dict_attrs[] = {
- { .attr = FR_TEST_INTEGER, .parent = NULL, .da = &attr_test_integer, .name = "Test-Integer", .type = FR_TYPE_UINT32, },
- { .attr = FR_TEST_OCTETS, .parent = NULL, .da = &attr_test_octets, .name = "Test-Octets", .type = FR_TYPE_OCTETS, },
- { .attr = FR_TEST_STRING, .parent = NULL, .da = &attr_test_string, .name = "Test-String", .type = FR_TYPE_STRING, },
- { .attr = FR_TEST_DATE, .parent = NULL, .da = &attr_test_date, .name = "Test-Date", .type = FR_TYPE_DATE, },
- { .attr = FR_TEST_IPV4_ADDR, .parent = NULL, .da = &attr_test_ipv4_addr, .name = "Test-IPv4-Addr", .type = FR_TYPE_IPV4_ADDR, },
- { .attr = FR_TEST_TLV_ROOT, .parent = NULL, .da = &attr_test_tlv_root, .name = "Test-TLV-Root", .type = FR_TYPE_TLV, },
- { .attr = FR_TEST_TLV_STRING, .parent = &attr_test_tlv_root, .da = &attr_test_tlv_string, .name = "Test-TLV-String", .type = FR_TYPE_STRING, },
- { .attr = FR_TEST_VALUES, .parent = NULL, .da = &attr_test_values, .name = "Test-Values", .type = FR_TYPE_UINT32, .values = &attr_test_values_entries },
- { .attr = -1, .parent = NULL, .da = NULL, .name = NULL, .type = FR_TYPE_NULL }
-};
-
-/*
- * It will be called before of unit tests.
- */
-static int load_attr_pairs(fr_pair_list_t *out)
-{
- fr_dict_adhoc_attr_t *p;
-
- fr_pair_list_init(out);
-
- for (p = test_dict_attrs;
- p->attr != -1;
- p++) if (fr_pair_prepend_by_da(autofree, NULL, out, *p->da) < 0) return -1;
-
- return 0;
-}
-
-static int init_adhoc_attrs(fr_dict_adhoc_attr_t *dict_adhoc)
-{
- fr_dict_adhoc_attr_t *ctx;
- fr_dict_attr_flags_t dict_flags = {
- .is_root = true
- };
-
- for (ctx = dict_adhoc;
- ctx->attr != -1;
- ctx++) {
- fr_dict_attr_t const *parent = ctx->parent ? *ctx->parent : fr_dict_root(dict_test);
- fr_dict_attr_t const *attr;
-
- if (fr_dict_attr_add(dict_test, parent, ctx->name, ctx->attr, ctx->type, &dict_flags) < 0) return -1;
-
- attr = fr_dict_attr_by_name(NULL, parent, ctx->name);
- if (!attr) return -1;
-
- /* Set the VALUES */
- if (ctx->values) {
- fr_dict_adhoc_attr_value_t *v;
-
- for (v = ctx->values;
- v->key != NULL;
- v++) fr_dict_enum_add_name(fr_dict_attr_unconst(attr), v->key, &v->val, false, false);
- }
-
- *ctx->da = attr;
- }
-
- return 0;
-}
-
-static void pair_tests_init(void)
+static void test_init(void)
{
autofree = talloc_autofree_context();
if (!autofree) {
*/
if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) goto error;
- if (!fr_dict_global_ctx_init(autofree, dict_dir)) goto error;
+ if (fr_dict_test_init(autofree, &test_dict, NULL) < 0) goto error;
- /*
- * Set the root name of the dictionary
- */
- dict_test = fr_dict_alloc("test", 666);
- if (!dict_test) goto error;
+ /* Initialize the "test_pairs" list */
+ fr_pair_list_init(&test_pairs);
- if (init_adhoc_attrs(test_dict_attrs) < 0) goto error;
-
- /* Initialize the "sample_pairs" list */
- fr_pair_list_init(&sample_pairs);
- if (load_attr_pairs(&sample_pairs) < 0) goto error;
+ if (fr_pair_test_list_alloc(autofree, &test_pairs, NULL) < 0) goto error;
}
/*
fr_pair_t *vp;
TEST_CASE("Allocation using fr_pair_afrom_da");
- TEST_CHECK((vp = fr_pair_afrom_da(autofree, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_afrom_da(autofree, fr_dict_attr_test_string)) != NULL);
- TEST_CHECK(fr_pair_value_from_str(vp, sample_string, strlen(sample_string), '"', false) == 0);
+ TEST_CHECK(fr_pair_value_from_str(vp, test_string, strlen(test_string), '"', false) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, sample_string) == 0);
- TEST_MSG("Expected vp->vp_strvalue == sample_string");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, test_string) == 0);
+ TEST_MSG("Expected vp->vp_strvalue == test_string");
talloc_free(vp);
}
static void test_fr_pair_afrom_child_num(void)
{
fr_pair_t *vp;
- unsigned int attr = FR_MODULE_RETURN_CODE;
+ unsigned int attr = FR_TEST_ATTR_STRING;
TEST_CASE("Allocation using fr_pair_afrom_child_num");
- TEST_CHECK((vp = fr_pair_afrom_child_num(autofree, fr_dict_root(dict_test), attr)) != NULL);
+ TEST_CHECK((vp = fr_pair_afrom_child_num(autofree, fr_dict_root(test_dict), attr)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CHECK(vp && vp->da->attr == FR_MODULE_RETURN_CODE);
+ TEST_CHECK(vp && vp->da->attr == FR_TEST_ATTR_STRING);
TEST_MSG("Expected attr(%d) == vp->da->attr(%d)", attr, vp->da->attr);
talloc_free(vp);
fr_pair_t *vp, *copy;
TEST_CASE("Allocation using fr_pair_copy");
- TEST_CHECK((vp = fr_pair_afrom_da(autofree, attr_test_integer)) != NULL);
+ TEST_CHECK((vp = fr_pair_afrom_da(autofree, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TALLOC_CTX *ctx = talloc_null_ctx();
TEST_CASE("Allocate a new attribute fr_pair_afrom_da");
- TEST_CHECK((vp = fr_pair_afrom_da(ctx, attr_test_integer)) != NULL);
+ TEST_CHECK((vp = fr_pair_afrom_da(ctx, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
fr_pair_t *vp;
TEST_CASE("Allocate a new attribute fr_pair_afrom_da");
- TEST_CHECK((vp = fr_pair_afrom_da(autofree, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_afrom_da(autofree, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
fr_pair_t *vp, *needle;
fr_dcursor_t cursor;
- TEST_CASE("Searching for attr_test_integer using fr_dcursor_iter_by_da_init()");
+ TEST_CASE("Searching for fr_dict_attr_test_uint32 using fr_dcursor_iter_by_da_init()");
needle = NULL;
- for (vp = fr_dcursor_iter_by_da_init(&cursor, &sample_pairs, attr_test_integer);
+ for (vp = fr_dcursor_iter_by_da_init(&cursor, &test_pairs, fr_dict_attr_test_uint32);
vp;
vp = fr_dcursor_next(&cursor)) {
if (!needle) {
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(needle);
- TEST_CASE("Expected (needle->da == attr_test_integer)");
- TEST_CHECK(needle && needle->da == attr_test_integer);
+ TEST_CASE("Expected (needle->da == fr_dict_attr_test_uint32)");
+ TEST_CHECK(needle && needle->da == fr_dict_attr_test_uint32);
}
static void test_fr_dcursor_iter_by_ancestor_init(void)
fr_pair_t *vp, *needle;
fr_dcursor_t cursor;
- TEST_CASE("Searching for attr_test_tlv_string as ascend of attr_test_tlv_root using fr_dcursor_iter_by_ancestor_init()");
+ TEST_CASE("Searching for fr_dict_attr_test_tlv_string as ascend of fr_dict_attr_test_tlv using fr_dcursor_iter_by_ancestor_init()");
needle = NULL;
- for (vp = fr_dcursor_iter_by_ancestor_init(&cursor, &sample_pairs, attr_test_tlv_root);
+ for (vp = fr_dcursor_iter_by_ancestor_init(&cursor, &test_pairs, fr_dict_attr_test_tlv);
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CHECK(vp != NULL);
- if (vp->da == attr_test_tlv_string) {
+ if (vp->da == fr_dict_attr_test_tlv_string) {
needle = vp;
continue;
}
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(needle);
- TEST_CASE("Expected (needle->da == attr_test_tlv_string)");
- TEST_CHECK(needle && needle->da == attr_test_tlv_string);
+ TEST_CASE("Expected (needle->da == fr_dict_attr_test_tlv_string)");
+ TEST_CHECK(needle && needle->da == fr_dict_attr_test_tlv_string);
}
static void test_fr_pair_find_by_da(void)
{
fr_pair_t *vp;
- TEST_CASE("Search for attr_test_tlv_string using fr_pair_find_by_da()");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_tlv_string)) != NULL);
+ TEST_CASE("Search for fr_dict_attr_test_tlv_string using fr_pair_find_by_da()");
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_tlv_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Expected (vp->da == attr_test_tlv_string)");
- TEST_CHECK(vp && vp->da == attr_test_tlv_string);
+ TEST_CASE("Expected (vp->da == fr_dict_attr_test_tlv_string)");
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_tlv_string);
}
static void test_fr_pair_find_by_child_num(void)
{
fr_pair_t *vp;
- TEST_CASE("Search for FR_TEST_STRING using fr_pair_find_by_child_num()");
- TEST_CHECK((vp = fr_pair_find_by_child_num(&sample_pairs, fr_dict_root(dict_test), FR_TEST_STRING)) != NULL);
+ TEST_CASE("Search for FR_TEST_ATTR_STRING using fr_pair_find_by_child_num()");
+ TEST_CHECK((vp = fr_pair_find_by_child_num(&test_pairs, fr_dict_root(test_dict), FR_TEST_ATTR_STRING)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Expected (vp->da == attr_test_string)");
- TEST_CHECK(vp && vp->da == attr_test_string);
+ TEST_CASE("Expected (vp->da == fr_dict_attr_test_string)");
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_string);
}
static void test_fr_pair_append(void)
fr_pair_list_init(&local_pairs);
- fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, attr_test_octets));
- fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, attr_test_integer));
- fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, attr_test_tlv_root));
+ fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, fr_dict_attr_test_octets));
+ fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, fr_dict_attr_test_uint32));
+ fr_pair_append(&local_pairs, fr_pair_afrom_da(autofree, fr_dict_attr_test_tlv));
/* lets' count */
for (vp = fr_dcursor_init(&cursor, &local_pairs);
static void test_fr_pair_delete_by_child_num(void)
{
- TEST_CASE("Delete attr_test_string using fr_pair_delete_by_child_num()");
- fr_pair_delete_by_child_num(&sample_pairs, fr_dict_root(dict_test), FR_TEST_STRING);
+ TEST_CASE("Delete fr_dict_attr_test_string using fr_pair_delete_by_child_num()");
+ fr_pair_delete_by_child_num(&test_pairs, fr_dict_root(test_dict), FR_TEST_ATTR_STRING);
- TEST_CASE("The attr_test_string shouldn't exist in 'sample_pairs'");
- TEST_CHECK(fr_pair_find_by_child_num(&sample_pairs, fr_dict_root(dict_test), FR_TEST_STRING) == NULL);
+ TEST_CASE("The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
+ TEST_CHECK(fr_pair_find_by_child_num(&test_pairs, fr_dict_root(test_dict), FR_TEST_ATTR_STRING) == NULL);
- TEST_CASE("Add attr_test_string back into 'sample_pairs'");
- TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &sample_pairs, attr_test_string) == 0);
+ TEST_CASE("Add fr_dict_attr_test_string back into 'test_pairs'");
+ TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &test_pairs, fr_dict_attr_test_string) == 0);
}
static void test_fr_pair_prepend_by_da(void)
fr_pair_list_init(&local_pairs);
TEST_CASE("Add using fr_pair_prepend_by_da()");
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_string) == 0);
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_string) == 0);
/* lets' count */
for (vp = fr_dcursor_init(&cursor, &local_pairs);
vp;
vp = fr_dcursor_next(&cursor)) {
- TEST_CASE("Expected (vp->da == attr_test_string)");
- TEST_CHECK(vp->da == attr_test_string);
+ TEST_CASE("Expected (vp->da == fr_dict_attr_test_string)");
+ TEST_CHECK(vp->da == fr_dict_attr_test_string);
}
fr_pair_list_free(&local_pairs);
fr_pair_t *vp;
TEST_CASE("Update Add using fr_pair_prepend_by_da()");
- TEST_CHECK(fr_pair_update_by_da(autofree, &vp, &sample_pairs, attr_test_integer) == 1); /* attribute already exist */
+ TEST_CHECK(fr_pair_update_by_da(autofree, &vp, &test_pairs, fr_dict_attr_test_uint32) == 1); /* attribute already exist */
vp->vp_uint32 = 54321;
- TEST_CASE("Expected attr_test_integer (vp->vp_uint32 == 54321)");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_integer)) != NULL);
+ TEST_CASE("Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 54321)");
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
static void test_fr_pair_delete_by_da(void)
{
- TEST_CASE("Delete attr_test_string using fr_pair_delete_by_da()");
- TEST_CHECK(fr_pair_delete_by_da(&sample_pairs, attr_test_string) == 1);
+ TEST_CASE("Delete fr_dict_attr_test_string using fr_pair_delete_by_da()");
+ TEST_CHECK(fr_pair_delete_by_da(&test_pairs, fr_dict_attr_test_string) == 1);
- TEST_CASE("The attr_test_string shouldn't exist in 'sample_pairs'");
- TEST_CHECK(fr_pair_find_by_da(&sample_pairs, attr_test_string) == NULL);
+ TEST_CASE("The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
+ TEST_CHECK(fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string) == NULL);
- TEST_CASE("Add attr_test_string back into 'sample_pairs'");
- TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &sample_pairs, attr_test_string) == 0);
+ TEST_CASE("Add fr_dict_attr_test_string back into 'test_pairs'");
+ TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &test_pairs, fr_dict_attr_test_string) == 0);
}
static void test_fr_pair_delete(void)
{
fr_pair_t *vp;
- TEST_CASE("Delete attr_test_string using fr_pair_delete()");
- TEST_CHECK((vp = fr_pair_find_by_child_num(&sample_pairs, fr_dict_root(dict_test), FR_TEST_STRING)) != NULL);
- fr_pair_delete(&sample_pairs, vp);
+ TEST_CASE("Delete fr_dict_attr_test_string using fr_pair_delete()");
+ TEST_CHECK((vp = fr_pair_find_by_child_num(&test_pairs, fr_dict_root(test_dict), FR_TEST_ATTR_STRING)) != NULL);
+ fr_pair_delete(&test_pairs, vp);
- TEST_CASE("The attr_test_string shouldn't exist in 'sample_pairs'");
- TEST_CHECK((vp = fr_pair_find_by_child_num(&sample_pairs, fr_dict_root(dict_test), FR_TEST_STRING)) == NULL);
+ TEST_CASE("The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
+ TEST_CHECK((vp = fr_pair_find_by_child_num(&test_pairs, fr_dict_root(test_dict), FR_TEST_ATTR_STRING)) == NULL);
- TEST_CASE("Add attr_test_string back into 'sample_pairs'");
- TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &sample_pairs, attr_test_string) == 0);
+ TEST_CASE("Add fr_dict_attr_test_string back into 'test_pairs'");
+ TEST_CHECK(fr_pair_prepend_by_da(autofree, NULL, &test_pairs, fr_dict_attr_test_string) == 0);
}
static void test_fr_pair_cmp(void)
fr_pair_t *vp1, *vp2;
TEST_CASE("Create the vp1 'Test-Integer = 123'");
- TEST_CHECK((vp1 = fr_pair_afrom_da(autofree, attr_test_integer)) != NULL);
+ TEST_CHECK((vp1 = fr_pair_afrom_da(autofree, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp1);
vp1->vp_uint32 = 123;
TEST_CASE("Create the vp2 'Test-Integer = 321'");
- TEST_CHECK((vp2 = fr_pair_afrom_da(autofree, attr_test_integer)) != NULL);
+ TEST_CHECK((vp2 = fr_pair_afrom_da(autofree, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp2);
fr_pair_list_init(&local_pairs2);
TEST_CASE("Create 'local_pairs1'");
- TEST_CHECK(load_attr_pairs(&local_pairs1) == 0);
+ TEST_CHECK(fr_pair_test_list_alloc(autofree, &local_pairs1, NULL) == 0);
TEST_CASE("Create 'local_pairs2'");
- TEST_CHECK(load_attr_pairs(&local_pairs2) == 0);
+ TEST_CHECK(fr_pair_test_list_alloc(autofree, &local_pairs2, NULL) == 0);
TEST_CASE("Check if 'local_pairs1' == 'local_pairs2' using fr_pair_list_cmp()");
TEST_CHECK(fr_pair_list_cmp(&local_pairs1, &local_pairs2) == 0);
fr_pair_list_init(&local_pairs);
- TEST_CASE("Copy 'sample_pairs' into 'local_pairs'");
- TEST_CHECK(fr_pair_list_copy(autofree, &local_pairs, &sample_pairs) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'local_pairs'");
+ TEST_CHECK(fr_pair_list_copy(autofree, &local_pairs, &test_pairs) > 0);
- TEST_CASE("Check if 'local_pairs' == 'sample_pairs' using fr_pair_list_cmp()");
- TEST_CHECK(fr_pair_list_cmp(&local_pairs, &sample_pairs) == 0);
+ TEST_CASE("Check if 'local_pairs' == 'test_pairs' using fr_pair_list_cmp()");
+ TEST_CHECK(fr_pair_list_cmp(&local_pairs, &test_pairs) == 0);
fr_pair_list_free(&local_pairs);
}
fr_pair_list_init(&local_pairs);
- TEST_CASE("Copy 'sample_pairs' into 'local_pairs'");
- TEST_CHECK(fr_pair_list_copy_by_da(autofree, &local_pairs, &sample_pairs, attr_test_string, 0) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'local_pairs'");
+ TEST_CHECK(fr_pair_list_copy_by_da(autofree, &local_pairs, &test_pairs, fr_dict_attr_test_string, 0) > 0);
- TEST_CASE("The 'local_pairs' should have only attr_test_string");
+ TEST_CASE("The 'local_pairs' should have only fr_dict_attr_test_string");
for (vp = fr_dcursor_init(&cursor, &local_pairs);
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Expected (vp->da == attr_test_string)");
- TEST_CHECK(vp->da == attr_test_string);
+ TEST_CASE("Expected (vp->da == fr_dict_attr_test_string)");
+ TEST_CHECK(vp->da == fr_dict_attr_test_string);
}
fr_pair_list_free(&local_pairs);
fr_pair_list_init(&local_pairs);
- TEST_CASE("Copy 'sample_pairs' into 'local_pairs'");
- TEST_CHECK(fr_pair_list_copy_by_ancestor(autofree, &local_pairs, &sample_pairs, attr_test_tlv_root, 0) > 0);
+ TEST_CASE("Copy 'test_pairs' into 'local_pairs'");
+ TEST_CHECK(fr_pair_list_copy_by_ancestor(autofree, &local_pairs, &test_pairs, fr_dict_attr_test_tlv, 0) > 0);
- TEST_CASE("The 'local_pairs' should have only attr_test_tlv_string (ancestor of 'Test-TLV-Root'");
+ TEST_CASE("The 'local_pairs' should have only fr_dict_attr_test_tlv_string (ancestor of 'Test-TLV-Root'");
for (vp = fr_dcursor_init(&cursor, &local_pairs);
vp;
vp = fr_dcursor_next(&cursor)) {
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- if (vp->da == attr_test_tlv_string) {
+ if (vp->da == fr_dict_attr_test_tlv_string) {
needle = vp;
break;
}
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(needle);
- TEST_CASE("Expected (needle->da == attr_test_tlv_string)");
- TEST_CHECK(needle && needle->da == attr_test_tlv_string);
+ TEST_CASE("Expected (needle->da == fr_dict_attr_test_tlv_string)");
+ TEST_CHECK(needle && needle->da == fr_dict_attr_test_tlv_string);
fr_pair_list_free(&local_pairs);
}
TEST_CASE("Create 'local_pairs' with 3 attributes not ordered");
fr_pair_list_init(&local_pairs);
- TEST_CASE("Add attr_test_string back into 'local_pairs'");
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_date) == 0);
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_ipv4_addr) == 0);
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_octets) == 0);
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_integer) == 0);
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_values) == 0); // It will be go to the tail
- TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, attr_test_string) == 0);
+ TEST_CASE("Add fr_dict_attr_test_string back into 'local_pairs'");
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_date) == 0);
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_ipv4_addr) == 0);
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_octets) == 0);
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_uint32) == 0);
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_enum) == 0); // It will be go to the tail
+ TEST_CHECK(fr_pair_prepend_by_da(ctx, NULL, &local_pairs, fr_dict_attr_test_string) == 0);
+ /*
+ * FIXME - This test doesn't check for intra-type stability
+ */
TEST_CASE("Sorting 'local_pairs' by fr_pair_list_sort(local_pairs, fr_pair_cmp_by_da)");
fr_pair_list_sort(&local_pairs, fr_pair_cmp_by_da);
- TEST_CASE("1st (da == attr_test_integer)");
+
+ TEST_CASE("1st (da == fr_dict_attr_test_string)");
TEST_CHECK((vp = fr_dcursor_init(&cursor, &local_pairs)) != NULL);
- TEST_CHECK(vp && vp->da == attr_test_integer);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_string);
+
+ TEST_CASE("2nd (da == fr_dict_attr_test_octets)");
+ TEST_CHECK((vp = fr_dcursor_next(&cursor)) != NULL);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_octets);
- TEST_CASE("2st (da == attr_test_octets)");
+ TEST_CASE("3rd (da == fr_dict_attr_test_ipv4_addr)");
TEST_CHECK((vp = fr_dcursor_next(&cursor)) != NULL);
- TEST_CHECK(vp && vp->da == attr_test_octets);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_ipv4_addr);
- TEST_CASE("3st (da == attr_test_string)");
+ TEST_CASE("4th (da == fr_dict_attr_test_uint32)");
TEST_CHECK((vp = fr_dcursor_next(&cursor)) != NULL);
- TEST_CHECK(vp && vp->da == attr_test_string);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_uint32);
- TEST_CASE("4th (da == attr_test_date)");
+ TEST_CASE("5th (da == fr_dict_attr_test_date)");
TEST_CHECK((vp = fr_dcursor_next(&cursor)) != NULL);
- TEST_CHECK(vp && vp->da == attr_test_date);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_date);
- TEST_CASE("5th (da == attr_test_ipv4_addr)");
+ TEST_CASE("6th (da == fr_dict_attr_test_enum)");
TEST_CHECK((vp = fr_dcursor_next(&cursor)) != NULL);
- TEST_CHECK(vp && vp->da == attr_test_ipv4_addr);
+ TEST_CHECK(vp && vp->da == fr_dict_attr_test_enum);
fr_pair_list_free(&local_pairs);
}
fr_pair_t *vp1, vp2;
TEST_CASE("Create 'vp1' with Test-Integer = 123");
- TEST_CHECK((vp1 = fr_pair_find_by_da(&sample_pairs, attr_test_integer)) != NULL);
+ TEST_CHECK((vp1 = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_uint32)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp1);
fr_pair_t *vp;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Convert 'sample_string' value to attribute value using fr_pair_value_from_str()");
- TEST_CHECK(fr_pair_value_from_str(vp, sample_string, strlen(sample_string), '"', false) == 0);
+ TEST_CASE("Convert 'test_string' value to attribute value using fr_pair_value_from_str()");
+ TEST_CHECK(fr_pair_value_from_str(vp, test_string, strlen(test_string), '"', false) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, sample_string) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, test_string) == 0);
}
static void test_fr_pair_value_strdup(void)
fr_pair_t *vp;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_strdup()");
- TEST_CHECK(fr_pair_value_strdup(vp, sample_string) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_strdup()");
+ TEST_CHECK(fr_pair_value_strdup(vp, test_string) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, sample_string) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, test_string) == 0);
}
static void test_fr_pair_value_strdup_shallow(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_strdup_shallow()");
- TEST_CHECK(fr_pair_value_strdup_shallow(vp, copy_sample_string, true) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
+ TEST_CHECK(fr_pair_value_strdup_shallow(vp, copy_test_string, true) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->vp_string == copy_sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue, sample_string, strlen(copy_sample_string)) == 0);
+ TEST_CASE("Check (vp->vp_string == copy_test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue, test_string, strlen(copy_test_string)) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_strtrim(void)
fr_pair_t *vp;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_strdup_shallow()");
- TEST_CHECK(fr_pair_value_strdup(vp, sample_string) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
+ TEST_CHECK(fr_pair_value_strdup(vp, test_string) == 0);
TEST_CASE("Trim the length of the string buffer using fr_pair_value_strtrim()");
TEST_CHECK(fr_pair_value_strtrim(vp) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, sample_string) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, test_string) == 0);
}
static void test_fr_pair_value_aprintf(void)
snprintf(fmt_test, sizeof(fmt_test), "Now is %ld", (long)now);
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
char *out = NULL;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CASE("Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
- TEST_CHECK(fr_pair_value_bstr_alloc(vp, &out, sample_string_len, false) == 0);
+ TEST_CHECK(fr_pair_value_bstr_alloc(vp, &out, test_string_len, false) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy 'sample_string' to the pre-allocated pointer");
- TEST_CHECK(strlcpy(out, sample_string, sample_string_len) == sample_string_len);
+ TEST_CASE("Copy 'test_string' to the pre-allocated pointer");
+ TEST_CHECK(strlcpy(out, test_string, test_string_len) == test_string_len);
- TEST_CASE("Check (out == sample_string)");
- TEST_CHECK(memcmp(out, sample_string, sample_string_len-1) == 0);
+ TEST_CASE("Check (out == test_string)");
+ TEST_CHECK(memcmp(out, test_string, test_string_len-1) == 0);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && memcmp(vp->vp_strvalue, sample_string, sample_string_len-1) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && memcmp(vp->vp_strvalue, test_string, test_string_len-1) == 0);
}
static void test_fr_pair_value_bstr_realloc(void)
char *out = NULL;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CASE("Pre-allocate 1 byte of memory buffer using fr_pair_value_bstr_alloc()");
TEST_CHECK(fr_pair_value_bstr_alloc(vp, &out, 1, false) == 0);
- TEST_CASE("Re-allocate (sample_string_len-1) byte of memory buffer using fr_pair_value_bstr_realloc()");
- TEST_CHECK(fr_pair_value_bstr_realloc(vp, &out, (sample_string_len - 1)) == 0);
+ TEST_CASE("Re-allocate (test_string_len-1) byte of memory buffer using fr_pair_value_bstr_realloc()");
+ TEST_CHECK(fr_pair_value_bstr_realloc(vp, &out, (test_string_len - 1)) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy 'sample_string' to the pre-allocated pointer");
- TEST_CHECK(strlcpy(out, sample_string, sample_string_len) == sample_string_len);
+ TEST_CASE("Copy 'test_string' to the pre-allocated pointer");
+ TEST_CHECK(strlcpy(out, test_string, test_string_len) == test_string_len);
- TEST_CASE("Check (out == sample_string)");
- TEST_CHECK(memcmp(out, sample_string, sample_string_len-1) == 0);
+ TEST_CASE("Check (out == test_string)");
+ TEST_CHECK(memcmp(out, test_string, test_string_len-1) == 0);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && memcmp(vp->vp_strvalue, sample_string, sample_string_len-1) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && memcmp(vp->vp_strvalue, test_string, test_string_len-1) == 0);
}
static void test_fr_pair_value_bstrndup(void)
fr_pair_t *vp;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_bstrndup()");
- TEST_CHECK(fr_pair_value_bstrndup(vp, sample_string, sample_string_len-1, false) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
+ TEST_CHECK(fr_pair_value_bstrndup(vp, test_string, test_string_len-1, false) == 0);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && memcmp(vp->vp_strvalue, sample_string, sample_string_len-1) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && memcmp(vp->vp_strvalue, test_string, test_string_len-1) == 0);
}
static void test_fr_pair_value_bstrdup_buffer(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'copy_sample_string' to attribute value using fr_pair_value_bstrdup_buffer()");
- TEST_CHECK(fr_pair_value_bstrdup_buffer(vp, copy_sample_string, false) == 0);
+ TEST_CASE("Copy content of 'copy_test_string' to attribute value using fr_pair_value_bstrdup_buffer()");
+ TEST_CHECK(fr_pair_value_bstrdup_buffer(vp, copy_test_string, false) == 0);
- TEST_CASE("Check (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strcmp(vp->vp_strvalue, copy_sample_string) == 0);
+ TEST_CASE("Check (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strcmp(vp->vp_strvalue, copy_test_string) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_bstrndup_shallow(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_bstrndup_shallow()");
- TEST_CHECK(fr_pair_value_bstrndup_shallow(vp, copy_sample_string, strlen(copy_sample_string), true) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup_shallow()");
+ TEST_CHECK(fr_pair_value_bstrndup_shallow(vp, copy_test_string, strlen(copy_test_string), true) == 0);
- TEST_CASE("Check (vp->vp_string == copy_sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check (vp->vp_string == copy_test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue, test_string, test_string_len) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_bstrdup_buffer_shallow(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_bstrdup_buffer_shallow()");
- TEST_CHECK(fr_pair_value_bstrdup_buffer_shallow(vp, copy_sample_string, true) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_bstrdup_buffer_shallow()");
+ TEST_CHECK(fr_pair_value_bstrdup_buffer_shallow(vp, copy_test_string, true) == 0);
- TEST_CASE("Check (vp->vp_string == copy_sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check (vp->vp_string == copy_test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue, test_string, test_string_len) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_bstrn_append(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_bstrndup()");
- TEST_CHECK(fr_pair_value_bstrndup(vp, sample_string, sample_string_len, false) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
+ TEST_CHECK(fr_pair_value_bstrndup(vp, test_string, test_string_len, false) == 0);
- TEST_CASE("Append the 'copy_sample_string' value using fr_pair_value_bstrn_append()");
- TEST_CHECK(fr_pair_value_bstrn_append(vp, copy_sample_string, sample_string_len, true) == 0);
+ TEST_CASE("Append the 'copy_test_string' value using fr_pair_value_bstrn_append()");
+ TEST_CHECK(fr_pair_value_bstrn_append(vp, copy_test_string, test_string_len, true) == 0);
// awful hack, just verify the first part of buffer and then the second part. yep, just appended twice.
- TEST_CASE("Check 1. part (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check 1. part (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue, test_string, test_string_len) == 0);
- TEST_CASE("Check 2. part ((vp->vp_string+sample_string_len) == sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue+sample_string_len, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check 2. part ((vp->vp_string+test_string_len) == test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue+test_string_len, test_string, test_string_len) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_bstr_append_buffer(void)
{
fr_pair_t *vp;
- char *copy_sample_string;
+ char *copy_test_string;
TEST_CASE("Find 'Test-String'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_string)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_string)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_string = talloc_strdup(vp, sample_string);
- talloc_set_type(copy_sample_string, char);
+ copy_test_string = talloc_strdup(vp, test_string);
+ talloc_set_type(copy_test_string, char);
- TEST_CASE("Copy content of 'sample_string' to attribute value using fr_pair_value_bstrndup()");
- TEST_CHECK(fr_pair_value_bstrndup(vp, sample_string, sample_string_len, false) == 0);
+ TEST_CASE("Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
+ TEST_CHECK(fr_pair_value_bstrndup(vp, test_string, test_string_len, false) == 0);
- TEST_CASE("Append the 'copy_sample_string' value using fr_pair_value_bstr_append_buffer()");
- TEST_CHECK(fr_pair_value_bstr_append_buffer(vp, copy_sample_string, true) == 0);
+ TEST_CASE("Append the 'copy_test_string' value using fr_pair_value_bstr_append_buffer()");
+ TEST_CHECK(fr_pair_value_bstr_append_buffer(vp, copy_test_string, true) == 0);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
// awful hack, just verify the first part of buffer and then the second part. yep, just appended twice.
- TEST_CASE("Check 1. part (vp->vp_string == sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check 1. part (vp->vp_string == test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue, test_string, test_string_len) == 0);
- TEST_CASE("Check 2. part ((vp->vp_string+sample_string_len) == sample_string)");
- TEST_CHECK(vp && strncmp(vp->vp_strvalue+sample_string_len, sample_string, sample_string_len) == 0);
+ TEST_CASE("Check 2. part ((vp->vp_string+test_string_len) == test_string)");
+ TEST_CHECK(vp && strncmp(vp->vp_strvalue+test_string_len, test_string, test_string_len) == 0);
- talloc_free(copy_sample_string);
+ talloc_free(copy_test_string);
}
static void test_fr_pair_value_mem_alloc(void)
uint8_t *out;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CASE("Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
- TEST_CHECK(fr_pair_value_mem_alloc(vp, &out, ARRAY_SIZE(sample_octets), false) == 0);
+ TEST_CHECK(fr_pair_value_mem_alloc(vp, &out, NUM_ELEMENTS(test_octets), false) == 0);
- TEST_CASE("Copy 'sample_octets' to the pre-allocated pointer");
- TEST_CHECK(memcpy(out, sample_octets, ARRAY_SIZE(sample_octets)) != NULL);
+ TEST_CASE("Copy 'test_octets' to the pre-allocated pointer");
+ TEST_CHECK(memcpy(out, test_octets, NUM_ELEMENTS(test_octets)) != NULL);
- TEST_CASE("Check (out == sample_octets)");
- TEST_CHECK(memcmp(out, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (out == test_octets)");
+ TEST_CHECK(memcmp(out, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- TEST_CASE("Check (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
}
static void test_fr_pair_value_mem_realloc(void)
uint8_t *out;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CASE("Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
- TEST_CHECK(fr_pair_value_mem_alloc(vp, &out, ARRAY_SIZE(sample_octets), false) == 0);
+ TEST_CHECK(fr_pair_value_mem_alloc(vp, &out, NUM_ELEMENTS(test_octets), false) == 0);
- TEST_CASE("Copy 'sample_octets' to the pre-allocated pointer");
- TEST_CHECK(memcpy(out, sample_octets, ARRAY_SIZE(sample_octets)) != NULL);
+ TEST_CASE("Copy 'test_octets' to the pre-allocated pointer");
+ TEST_CHECK(memcpy(out, test_octets, NUM_ELEMENTS(test_octets)) != NULL);
- TEST_CASE("Realloc pre-allocated pointer to fit extra 'sample_octets' copy");
- TEST_CHECK(fr_pair_value_mem_realloc(vp, &out, ARRAY_SIZE(sample_octets)*2) == 0);
+ TEST_CASE("Realloc pre-allocated pointer to fit extra 'test_octets' copy");
+ TEST_CHECK(fr_pair_value_mem_realloc(vp, &out, NUM_ELEMENTS(test_octets)*2) == 0);
- TEST_CASE("Copy 'sample_octets' into the tail");
- TEST_CHECK(memcpy(out+ARRAY_SIZE(sample_octets), sample_octets, ARRAY_SIZE(sample_octets)) != NULL);
+ TEST_CASE("Copy 'test_octets' into the tail");
+ TEST_CHECK(memcpy(out+NUM_ELEMENTS(test_octets), test_octets, NUM_ELEMENTS(test_octets)) != NULL);
- TEST_CASE("Check first chunk (out == sample_octets)");
- TEST_CHECK(memcmp(out, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check first chunk (out == test_octets)");
+ TEST_CHECK(memcmp(out, test_octets, NUM_ELEMENTS(test_octets)) == 0);
TEST_CHECK(vp != NULL);
- TEST_CASE("Check first chunk (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check first chunk (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- TEST_CASE("Check second chunk (out+ARRAY_SIZE(sample_octets) == sample_octets)");
- TEST_CHECK(memcmp(out+ARRAY_SIZE(sample_octets), sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check second chunk (out+NUM_ELEMENTS(test_octets) == test_octets)");
+ TEST_CHECK(memcmp(out+NUM_ELEMENTS(test_octets), test_octets, NUM_ELEMENTS(test_octets)) == 0);
- TEST_CASE("Check second chunk (vp->vp_octets+ARRAY_SIZE(sample_octets) == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets+ARRAY_SIZE(sample_octets), sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check second chunk (vp->vp_octets+NUM_ELEMENTS(test_octets) == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets+NUM_ELEMENTS(test_octets), test_octets, NUM_ELEMENTS(test_octets)) == 0);
}
static void test_fr_pair_value_memdup(void)
fr_pair_t *vp;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy content of 'sample_octets' to attribute value using fr_pair_value_memdup()");
- TEST_CHECK(fr_pair_value_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets), false) == 0);
+ TEST_CASE("Copy content of 'test_octets' to attribute value using fr_pair_value_memdup()");
+ TEST_CHECK(fr_pair_value_memdup(vp, test_octets, NUM_ELEMENTS(test_octets), false) == 0);
- TEST_CASE("Check (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
}
static void test_fr_pair_value_memdup_buffer(void)
{
fr_pair_t *vp;
- uint8_t *copy_sample_octets;
+ uint8_t *copy_test_octets;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_octets = talloc_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets));
- talloc_set_type(copy_sample_octets, uint8_t);
+ copy_test_octets = talloc_memdup(vp, test_octets, NUM_ELEMENTS(test_octets));
+ talloc_set_type(copy_test_octets, uint8_t);
- TEST_CASE("Copy content of 'sample_octets' to attribute value using fr_pair_value_memdup_buffer()");
- TEST_CHECK(fr_pair_value_memdup_buffer(vp, copy_sample_octets, true) == 0);
+ TEST_CASE("Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer()");
+ TEST_CHECK(fr_pair_value_memdup_buffer(vp, copy_test_octets, true) == 0);
- TEST_CASE("Check (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- talloc_free(copy_sample_octets);
+ talloc_free(copy_test_octets);
}
static void test_fr_pair_value_memdup_shallow(void)
{
fr_pair_t *vp;
- uint8_t *copy_sample_octets;
+ uint8_t *copy_test_octets;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_octets = talloc_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets));
- talloc_set_type(copy_sample_octets, uint8_t);
+ copy_test_octets = talloc_memdup(vp, test_octets, NUM_ELEMENTS(test_octets));
+ talloc_set_type(copy_test_octets, uint8_t);
- TEST_CASE("Copy content of 'sample_octets' to attribute value using fr_pair_value_memdup_shallow()");
- TEST_CHECK(fr_pair_value_memdup_shallow(vp, copy_sample_octets, ARRAY_SIZE(sample_octets), true) == 0);
+ TEST_CASE("Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_shallow()");
+ TEST_CHECK(fr_pair_value_memdup_shallow(vp, copy_test_octets, NUM_ELEMENTS(test_octets), true) == 0);
- TEST_CASE("Check (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- talloc_free(copy_sample_octets);
+ talloc_free(copy_test_octets);
}
static void test_fr_pair_value_memdup_buffer_shallow(void)
{
fr_pair_t *vp;
- uint8_t *copy_sample_octets;
+ uint8_t *copy_test_octets;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_octets = talloc_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets));
- talloc_set_type(copy_sample_octets, uint8_t);
+ copy_test_octets = talloc_memdup(vp, test_octets, NUM_ELEMENTS(test_octets));
+ talloc_set_type(copy_test_octets, uint8_t);
- TEST_CASE("Copy content of 'sample_octets' to attribute value using fr_pair_value_memdup_buffer_shallow()");
- TEST_CHECK(fr_pair_value_memdup_buffer_shallow(vp, copy_sample_octets, true) == 0);
+ TEST_CASE("Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer_shallow()");
+ TEST_CHECK(fr_pair_value_memdup_buffer_shallow(vp, copy_test_octets, true) == 0);
- TEST_CASE("Check (vp->vp_octets == copy_sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check (vp->vp_octets == copy_test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- talloc_free(copy_sample_octets);
+ talloc_free(copy_test_octets);
}
static void test_fr_pair_value_mem_append(void)
fr_pair_t *vp;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- TEST_CASE("Copy content of 'sample_octets' to attribute value using fr_pair_value_memdup()");
- TEST_CHECK(fr_pair_value_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets), false) == 0);
+ TEST_CASE("Copy content of 'test_octets' to attribute value using fr_pair_value_memdup()");
+ TEST_CHECK(fr_pair_value_memdup(vp, test_octets, NUM_ELEMENTS(test_octets), false) == 0);
- TEST_CASE("Append the 'sample_octets' value using fr_pair_value_mem_append()");
- TEST_CHECK(fr_pair_value_mem_append(vp, sample_octets, ARRAY_SIZE(sample_octets), true) == 0);
+ TEST_CASE("Append the 'test_octets' value using fr_pair_value_mem_append()");
+ TEST_CHECK(fr_pair_value_mem_append(vp, test_octets, NUM_ELEMENTS(test_octets), true) == 0);
// awful hack, just verify the first part of buffer and then the second part. yep, just appended twice.
- TEST_CASE("Check 1. part (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check 1. part (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- TEST_CASE("Check 2. part ((vp->vp_string+ARRAY_SIZE(sample_octets)) == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets+ARRAY_SIZE(sample_octets), sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check 2. part ((vp->vp_string+NUM_ELEMENTS(test_octets)) == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets+NUM_ELEMENTS(test_octets), test_octets, NUM_ELEMENTS(test_octets)) == 0);
}
static void test_fr_pair_value_mem_append_buffer(void)
{
fr_pair_t *vp;
- uint8_t *copy_sample_octets;
+ uint8_t *copy_test_octets;
TEST_CASE("Find 'Test-Octets'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_octets)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_octets)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
- copy_sample_octets = talloc_memdup(vp, sample_octets, ARRAY_SIZE(sample_octets));
- talloc_set_type(copy_sample_octets, uint8_t);
+ copy_test_octets = talloc_memdup(vp, test_octets, NUM_ELEMENTS(test_octets));
+ talloc_set_type(copy_test_octets, uint8_t);
- TEST_CASE("Copy content of 'copy_sample_octets' to attribute value using fr_pair_value_memdup()");
- TEST_CHECK(fr_pair_value_memdup(vp, copy_sample_octets, ARRAY_SIZE(sample_octets), false) == 0);
+ TEST_CASE("Copy content of 'copy_test_octets' to attribute value using fr_pair_value_memdup()");
+ TEST_CHECK(fr_pair_value_memdup(vp, copy_test_octets, NUM_ELEMENTS(test_octets), false) == 0);
- TEST_CASE("Append the 'copy_sample_octets' value using fr_pair_value_mem_append_buffer()");
- TEST_CHECK(fr_pair_value_mem_append_buffer(vp, copy_sample_octets, true) == 0);
+ TEST_CASE("Append the 'copy_test_octets' value using fr_pair_value_mem_append_buffer()");
+ TEST_CHECK(fr_pair_value_mem_append_buffer(vp, copy_test_octets, true) == 0);
// awful hack, just verify the first part of buffer and then the second part. yep, just appended twice.
- TEST_CASE("Check 1. part (vp->vp_octets == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets, sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check 1. part (vp->vp_octets == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets, test_octets, NUM_ELEMENTS(test_octets)) == 0);
- TEST_CASE("Check 2. part ((vp->vp_string+ARRAY_SIZE(sample_octets)) == sample_octets)");
- TEST_CHECK(vp && memcmp(vp->vp_octets+ARRAY_SIZE(sample_octets), sample_octets, ARRAY_SIZE(sample_octets)) == 0);
+ TEST_CASE("Check 2. part ((vp->vp_string+NUM_ELEMENTS(test_octets)) == test_octets)");
+ TEST_CHECK(vp && memcmp(vp->vp_octets+NUM_ELEMENTS(test_octets), test_octets, NUM_ELEMENTS(test_octets)) == 0);
- talloc_free(copy_sample_octets);
+ talloc_free(copy_test_octets);
}
static void test_fr_pair_value_enum(void)
char buf[20];
TEST_CASE("Find 'Test-Values'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_values)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_enum)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);
TEST_CHECK((var = fr_pair_value_enum(vp, buf)) != NULL);
TEST_MSG("Checking fr_pair_value_enum()");
- TEST_CHECK(var && strcmp(var, "Tapioca123") == 0);
- TEST_MSG("Expected var == 'Tapioca123'");
+ TEST_CHECK(var && strcmp(var, "test123") == 0);
+ TEST_MSG("Expected var == 'test123'");
}
static void test_fr_pair_value_enum_box(void)
fr_value_box_t const *vb;
TEST_CASE("Find 'Test-Values'");
- TEST_CHECK((vp = fr_pair_find_by_da(&sample_pairs, attr_test_values)) != NULL);
+ TEST_CHECK((vp = fr_pair_find_by_da(&test_pairs, fr_dict_attr_test_enum)) != NULL);
TEST_CASE("Validating VP_VERIFY()");
VP_VERIFY(vp);