static void cast_int8(void)
{
        idmef_value_t *value;

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_UINT8, -1) < 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_UINT16, -1) < 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_UINT32, -1) < 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_UINT64, -1) < 0);

        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_INT16, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_INT16);
        assert(idmef_value_get_int16(value) == INT8_MIN);
        idmef_value_destroy(value);

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_INT32, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_INT32);
        assert(idmef_value_get_int32(value) == INT8_MIN);
        idmef_value_destroy(value);

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_INT64, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_INT64);
        assert(idmef_value_get_int64(value) == INT8_MIN);
        idmef_value_destroy(value);

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_FLOAT, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_FLOAT);
        assert(idmef_value_get_float(value) == INT8_MIN);
        idmef_value_destroy(value);

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_DOUBLE, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_DOUBLE);
        assert(idmef_value_get_double(value) == INT8_MIN);
        idmef_value_destroy(value);

        assert(idmef_value_new_int8(&value, INT8_MIN) == 0);
        assert(_idmef_value_cast(value, IDMEF_VALUE_TYPE_DATA, -1) == 0);
        assert(idmef_value_get_type(value) == IDMEF_VALUE_TYPE_DATA);
        assert((int) idmef_data_get_uint32(idmef_value_get_data(value)) == INT8_MIN);
        idmef_value_destroy(value);
}
/**
 * idmef_message_get_number:
 * @message: Pointer to an #idmef_message_t object.
 * @path: Path to retrieve the number from within @message.
 * @result: Pointer where the result should be stored.
 *
 * Retrieve the number stored within @path of @message and store it
 * in the user provided @result.
 *
 * Returns: A positive value in case @path was successfully retrieved
 * 0 if the path is empty, or a negative value if an error occured.
 */
int idmef_message_get_number(idmef_message_t *message, const char *path, double *result)
{
        int ret;
        idmef_value_t *iv;

        ret = idmef_message_get_value(message, path, &iv);
        if ( ret <= 0 )
                return ret;

        if ( idmef_value_get_type(iv) != IDMEF_VALUE_TYPE_DOUBLE ) {
                ret = _idmef_value_cast(iv, IDMEF_VALUE_TYPE_DOUBLE, 0);
                if ( ret < 0 )
                        goto err;
        }

        *result = idmef_value_get_double(iv);

err:
        idmef_value_destroy(iv);
        return ret;
}