26#include <freeradius-devel/util/value.h>
288 TEST_MSG(
"Expected 12345, got %u", dst.vb_uint32);
413 TEST_CHECK(dst.vb_strvalue != src.vb_strvalue);
429 TEST_CHECK(memcmp(dst.vb_octets,
"\x01\x02\x03", 3) == 0);
483 TEST_CHECK(memcmp(vb.vb_strvalue,
"hello\0world", 11) == 0);
601 TEST_MSG(
"Expected 42, got %u", vb.vb_uint32);
611 TEST_MSG(
"Expected 0 (wrap), got %u", vb.vb_uint8);
621 TEST_MSG(
"Expected 0, got %d", vb.vb_int32);
715 TEST_MSG(
"Expected 0x12345678, got 0x%08x", dst.vb_uint32);
725 fr_value_box(&src, (uint64_t) 0x0102030405060708ULL,
false);
740 TEST_CHECK(dst.vb_uint64 == 0x0102030405060708ULL);
820 fr_sbuff_terminate(&sbuff);
833 fr_sbuff_terminate(&sbuff);
846 fr_sbuff_terminate(&sbuff);
861 fr_sbuff_terminate(&sbuff);
867 fr_sbuff_terminate(&sbuff);
880 fr_sbuff_terminate(&sbuff);
894 "12345", strlen(
"12345"), NULL) > 0);
897 TEST_MSG(
"Expected 12345, got %u", vb.vb_uint32);
905 "-42", strlen(
"-42"), NULL) > 0);
908 TEST_MSG(
"Expected -42, got %d", vb.vb_int32);
916 "yes", strlen(
"yes"), NULL) > 0);
926 "3.14", strlen(
"3.14"), NULL) > 0);
928 TEST_CHECK((vb.vb_float64 > 3.13) && (vb.vb_float64 < 3.15));
929 TEST_MSG(
"Expected ~3.14, got %f", vb.vb_float64);
937 "0xdeadbeef", strlen(
"0xdeadbeef"), NULL) > 0);
940 TEST_CHECK(memcmp(vb.vb_octets,
"\xde\xad\xbe\xef", 4) == 0);
950 "hello world", strlen(
"hello world"), NULL) > 0);
969 fr_sbuff_terminate(&sbuff);
985 fr_sbuff_terminate(&sbuff);
1001 fr_sbuff_terminate(&sbuff);
static int const char char buffer[256]
#define TEST_CHECK_STRCMP(_got, _exp)
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_FLOAT64
Double precision floating point.
#define FR_SBUFF_OUT(_start, _len_or_end)
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
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
size_t fr_value_box_network_length(fr_value_box_t const *value)
Get the size of the value held by the fr_value_box_t.
uint32_t fr_value_box_hash(fr_value_box_t const *vb)
Hash the contents of a value box.
ssize_t fr_value_box_print(fr_sbuff_t *out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules)
Print one boxed value to a string.
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, fr_value_box_t const *src)
Convert one type of fr_value_box_t to another.
int fr_value_box_asprintf(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, bool tainted, char const *fmt,...)
Print a formatted string using our internal printf wrapper and assign it to a value box.
int8_t fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b)
Compare two values.
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
int fr_value_box_cmp_op(fr_token_t op, fr_value_box_t const *a, fr_value_box_t const *b)
Compare two attributes using an operator.
uint64_t fr_value_box_as_uint64(fr_value_box_t const *vb)
Return a uint64_t from a fr_value_box_t.
bool fr_value_box_is_truthy(fr_value_box_t const *in)
Check truthiness of values.
int fr_value_box_cast_in_place(TALLOC_CTX *ctx, fr_value_box_t *vb, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv)
Convert one type of fr_value_box_t to another in place.
ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules)
void fr_value_box_increment(fr_value_box_t *vb)
Increment a boxed value.
int fr_value_box_strdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted)
Copy a nul terminated string to a fr_value_box_t.
void fr_value_box_clear(fr_value_box_t *data)
Clear/free any existing value and metadata.
ssize_t fr_value_box_to_network(fr_dbuff_t *dbuff, fr_value_box_t const *value)
Encode a single value box, serializing its contents in generic network format.
int fr_value_box_bstrndup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, size_t len, bool tainted)
Copy a string to to a fr_value_box_t.
int fr_value_box_memdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted)
Copy a buffer to a fr_value_box_t.
#define fr_value_box_init_null(_vb)
Initialise an empty/null box that will be filled later.
#define fr_value_box(_box, _var, _tainted)
Automagically fill in a box, determining the value type from the type of the C variable.
static void test_clear(void)
static void test_cmp_int32(void)
static void test_strdup(void)
static void test_copy_string(void)
static void test_tainted_flag(void)
static void test_from_str_int32(void)
static void test_cmp_op_ge(void)
static void test_cmp_uint32_equal(void)
static void test_cmp_op_ne(void)
static void test_cmp_octets_length(void)
static void test_round_trip_network_uint32(void)
static void test_network_int32(void)
static void test_cast_uint32_to_uint64(void)
static void test_as_uint64(void)
static void test_from_str_float64(void)
static void test_from_str_string(void)
static void test_print_octets(void)
static void test_network_uint32(void)
static TALLOC_CTX * autofree
static void test_round_trip_uint32(void)
static void test_copy_uint32(void)
static void test_print_string(void)
static void test_round_trip_int64(void)
static void test_asprintf(void)
static void test_print_uint32(void)
static void test_network_uint64(void)
static void test_network_length(void)
static void test_cast_uint32_to_string(void)
static void test_bstrndup(void)
static void test_print_int32_negative(void)
static void test_increment_uint32(void)
static void test_cast_int32_to_int64(void)
static void test_round_trip_bool(void)
static void test_cast_in_place_uint32_to_string(void)
static void test_increment_uint8_overflow(void)
static void test_truthy_bool(void)
static void test_hash_different_values(void)
static void test_cast_uint8_to_uint32(void)
static void test_cmp_op_lt(void)
static void test_cast_same_type(void)
static void test_cmp_octets(void)
static void test_cast_bool_to_uint32(void)
static void test_from_str_bool(void)
static void test_cmp_op_eq(void)
static void test_cast_in_place_uint32_to_uint64(void)
static void test_cast_uint32_to_bool(void)
static void test_copy_preserves_tainted(void)
static void test_cmp_different_types(void)
static void test_cmp_string(void)
static void test_hash_same_values(void)
static void test_cmp_float64(void)
static void test_truthy_octets(void)
static void test_from_str_octets(void)
static void test_cast_string_to_uint32(void)
static void test_clear_string(void)
static void test_init(void)
static void test_hash_string(void)
static void test_cmp_op_le(void)
static void test_truthy_uint32(void)
static void test_memdup(void)
static void test_increment_int32(void)
static void test_cmp_op_gt(void)
static void test_print_bool(void)
static void test_truthy_string(void)
static void test_cmp_bool(void)
static void test_cmp_uint32_less(void)
static void test_copy_octets(void)
static void test_from_str_uint32(void)
static void test_network_bool(void)