2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
4 * Redistribution and modifications are permitted subject to BSD license.
6 #include <asn_internal.h>
11 asn_random_fill_result_t
12 REAL_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
13 const asn_encoding_constraints_t *constraints,
15 asn_random_fill_result_t result_ok = {ARFILL_OK, 1};
16 asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0};
17 asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0};
18 static const double values[] = {
19 0, -0.0, -1, 1, -M_E, M_E, -3.14, 3.14, -M_PI, M_PI, -255, 255,
21 -2251799813685248.0, 2251799813685248.0,
23 -4503599627370496.0, 4503599627370496.0,
25 -1267650600228229401496703205376.0, 1267650600228229401496703205376.0,
31 -FLT_TRUE_MIN, FLT_TRUE_MIN,
34 -DBL_TRUE_MIN, DBL_TRUE_MIN,
36 INFINITY, -INFINITY, NAN};
42 if(max_length == 0) return result_skipped;
44 d = values[asn_random_between(0, sizeof(values) / sizeof(values[0]) - 1)];
49 st = (REAL_t*)(*sptr = CALLOC(1, sizeof(REAL_t)));
55 if(asn_double2REAL(st, d)) {
57 ASN_STRUCT_RESET(*td, st);
59 ASN_STRUCT_FREE(*td, st);
64 result_ok.length = st->size;