static void test_want_double(Constraint *constraint, const char *function, intptr_t actual, const char *test_file, int test_line, TestReporter *reporter) { (*reporter->assert_true)( reporter, test_file, test_line, (*constraint->compare)(constraint, actual), "Wanted [%d], but got [%d] in function [%s] parameter [%s]", as_double(constraint->expected), as_double(actual), function, constraint->parameter); unbox_double(actual); }
static void test_do_not_want_double(Constraint *constraint, const char *function, intptr_t actual, const char *test_file, int test_line, TestReporter *reporter) { (*reporter->assert_true)( reporter, test_file, test_line, (*constraint->compare)(constraint, actual), "Did not want [%f], but got [%f] in function [%s] parameter [%s]", as_double(constraint->expected_value), as_double(actual), function, constraint->parameter_name); (void)unbox_double(actual); }
static int param_to_mono_array (caddr_t *list_args, int n_args, MonoArray ** p_i_array, MonoArray **p_o_array) { caddr_t * line; MonoObject *arg = NULL; MonoDomain *domain = virtuoso_domain; MonoArray *i_array, *o_array; guint32 is_object; int inx; i_array = (MonoArray*)mono_array_new (domain, mono_get_object_class (), n_args); o_array = (MonoArray*)mono_array_new (domain, mono_get_intptr_class (), n_args); for (inx = 0; inx < n_args; ++inx) { line = (caddr_t *) list_args[inx]; is_object = 0; if (DV_TYPE_OF (line[1]) == DV_DB_NULL) { arg = NULL; goto put_it; } if (!strncmp (line[0], "System.String", sizeof ("System.String")) || !strncmp (line[0], "String", sizeof ("String"))) { if (!DV_STRINGP (line[1])) goto convert_error; arg = (MonoObject *) mono_string_new (domain, line[1]); } else if (!strncmp (line[0], "Int32", sizeof ("Int32")) || !strncmp (line[0], "System.Int32", sizeof ("System.Int32")) || !strncmp (line[0], "int", sizeof ("int"))) { gint32 ivalue; if (DV_TYPE_OF (line[1]) != DV_LONG_INT) goto convert_error; ivalue = unbox (line[1]); arg = mono_value_box (domain, mono_get_int32_class (), &ivalue); } else if (!strncmp (line[0], "System.Single", sizeof ("System.Single")) || !strncmp (line[0], "Single", sizeof ("Single"))) { float flt_value; if (DV_TYPE_OF (line[1]) != DV_SINGLE_FLOAT) goto convert_error; flt_value = unbox_float (line[1]); arg = mono_value_box (domain, mono_get_single_class (), &flt_value); } else if (!strncmp (line[0], "System.Data.SqlTypes.SqlDouble", sizeof ("System.Data.SqlTypes.SqlDouble")) || !strncmp (line[0], "System.Double", sizeof ("System.Double")) || !strncmp (line[0], "Double", sizeof ("Double"))) { double dbl_value; if (DV_TYPE_OF (line[1]) != DV_DOUBLE_FLOAT) goto convert_error; dbl_value = unbox_double (line[1]); arg = mono_value_box (domain, mono_get_double_class (), &dbl_value); } else /*if (!strncmp (line[0], "CLRObject", sizeof ("CLRObject"))) */ { gint32 ivalue; if (DV_TYPE_OF (line[1]) != DV_LONG_INT) goto convert_error; is_object = unbox (line[1]); arg = mono_value_box (domain, mono_get_int32_class (), &ivalue); } put_it: mono_array_set (i_array, gpointer, inx, arg); mono_array_set (o_array, gpointer, inx, (gpointer) is_object); } *p_i_array = i_array; *p_o_array = o_array; return 0; convert_error: sqlr_new_error ("22023", "XXXXX", "wrong or unknown type"); return 0; }
void destroy_double_constraint(Constraint *constraint) { (void)unbox_double(constraint->expected_value); destroy_empty_constraint(constraint); }
static void destroy_double_constraint(Constraint *constraint) { unbox_double(constraint->expected); destroy_empty_constraint(constraint); }
caddr_t arithm_dt_add_num (ccaddr_t box1, ccaddr_t box2, int subtraction, caddr_t *err_ret) { int dt_type = DT_DT_TYPE (box1); dtp_t dtp2 = DV_TYPE_OF (box2); boxint whole_seconds = 0; boxint nanoseconds = 0; TIMESTAMP_STRUCT ts; caddr_t res; switch (dtp2) { case DV_LONG_INT: whole_seconds = unbox (box2); break; case DV_DOUBLE_FLOAT: { double n = unbox_double (box2); double rest; whole_seconds = (n >= 0.0) ? floor(n + 0.5) : ceil(n - 0.5); rest = n - whole_seconds; if (abs(rest/n) > (3 * DBL_EPSILON)) nanoseconds = (n - whole_seconds) * 1000000000L; break; } case DV_NUMERIC: { numeric_t n = (numeric_t)box2; if (NUMERIC_STS_SUCCESS != numeric_to_int64 (n, &whole_seconds)) { err_ret[0] = srv_make_new_error ("22003", "SR087", "Wrong arguments for datetime arithmetic: decimal is out of range."); return NULL; } if (n->n_scale > 0) { char *nptr = n->n_value + n->n_len; int ctr; int mult = 1; for (ctr = 9; ctr > n->n_scale; ctr--) mult *= 10; while (ctr--) { nanoseconds += mult * nptr[ctr]; mult *= 10; } } break; } default: return NULL; } DT_AUDIT_FIELDS (dt); dt_to_GMTimestamp_struct (box1, &ts); ts_add (&ts, (subtraction ? -whole_seconds : whole_seconds), "second"); if (nanoseconds) ts_add (&ts, (subtraction ? -nanoseconds : nanoseconds), "nanosecond"); res = dk_alloc_box (DT_LENGTH, DV_DATETIME); GMTimestamp_struct_to_dt (&ts, res); DT_SET_TZ (res, DT_TZ (box1)); if ((DT_TYPE_DATE == dt_type) && (0 == (((whole_seconds * 1000000000L) + nanoseconds) % (SPERDAY * 1000000000L)))) DT_SET_DT_TYPE (res, dt_type); DT_AUDIT_FIELDS (dt); return res; }