mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Merge branch 'wfloat-conversion' into 'main'
build: Enable -Wfloat-conversion and fix warnings See merge request GNOME/glib!4126
This commit is contained in:
commit
7a7d8d548a
@ -1537,7 +1537,7 @@ g_task_thread_setup (void)
|
|||||||
if (tasks_running == G_TASK_POOL_SIZE)
|
if (tasks_running == G_TASK_POOL_SIZE)
|
||||||
task_wait_time = G_TASK_WAIT_TIME_BASE;
|
task_wait_time = G_TASK_WAIT_TIME_BASE;
|
||||||
else if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE)
|
else if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE)
|
||||||
task_wait_time *= G_TASK_WAIT_TIME_MULTIPLIER;
|
task_wait_time = (guint64) (task_wait_time * G_TASK_WAIT_TIME_MULTIPLIER);
|
||||||
|
|
||||||
if (tasks_running >= G_TASK_POOL_SIZE)
|
if (tasks_running >= G_TASK_POOL_SIZE)
|
||||||
g_source_set_ready_time (task_pool_manager, g_get_monotonic_time () + task_wait_time);
|
g_source_set_ready_time (task_pool_manager, g_get_monotonic_time () + task_wait_time);
|
||||||
@ -1562,7 +1562,7 @@ g_task_thread_cleanup (void)
|
|||||||
g_source_set_ready_time (task_pool_manager, -1);
|
g_source_set_ready_time (task_pool_manager, -1);
|
||||||
|
|
||||||
if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE)
|
if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE)
|
||||||
task_wait_time /= G_TASK_WAIT_TIME_MULTIPLIER;
|
task_wait_time = (guint64) (task_wait_time / G_TASK_WAIT_TIME_MULTIPLIER);
|
||||||
|
|
||||||
tasks_running--;
|
tasks_running--;
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *order;
|
const char *order;
|
||||||
int expected, seen;
|
gdouble expected;
|
||||||
|
unsigned int seen;
|
||||||
} ordering[] = {
|
} ordering[] = {
|
||||||
/* There are 32 legitimate orderings; the result always has to start
|
/* There are 32 legitimate orderings; the result always has to start
|
||||||
* with either "fe" (usually) or "ef" (rarely). For the remaining
|
* with either "fe" (usually) or "ef" (rarely). For the remaining
|
||||||
@ -141,8 +142,8 @@ test_srv_target_ordering (void)
|
|||||||
*/
|
*/
|
||||||
for (o = 0; o < NUM_ORDERINGS; o++)
|
for (o = 0; o < NUM_ORDERINGS; o++)
|
||||||
{
|
{
|
||||||
g_assert_cmpint (ordering[o].seen, >, ordering[o].expected / 2);
|
g_assert_cmpuint (ordering[o].seen, >, (guint64) (ordering[o].expected / 2));
|
||||||
g_assert_cmpint (ordering[o].seen, <, ordering[o].expected * 2);
|
g_assert_cmpuint (ordering[o].seen, <, (guint64) (ordering[o].expected * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_resolver_free_targets (targets);
|
g_resolver_free_targets (targets);
|
||||||
|
@ -2508,7 +2508,7 @@ gi_ir_node_build_typelib (GIIrNode *node,
|
|||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_FLOAT:
|
case GI_TYPE_TAG_FLOAT:
|
||||||
blob->size = sizeof (float);
|
blob->size = sizeof (float);
|
||||||
DO_ALIGNED_COPY (&data[blob->offset], parse_float_value (constant->value), float);
|
DO_ALIGNED_COPY (&data[blob->offset], (float) parse_float_value (constant->value), float);
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_DOUBLE:
|
case GI_TYPE_TAG_DOUBLE:
|
||||||
blob->size = sizeof (double);
|
blob->size = sizeof (double);
|
||||||
|
@ -82,15 +82,11 @@
|
|||||||
#include "gtestutils.h"
|
#include "gtestutils.h"
|
||||||
#include "gthread.h"
|
#include "gthread.h"
|
||||||
#include "gtimezone.h"
|
#include "gtimezone.h"
|
||||||
|
#include "gutilsprivate.h"
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#else
|
|
||||||
#if defined (_MSC_VER) && (_MSC_VER < 1800)
|
|
||||||
/* fallback implementation for isnan() on VS2012 and earlier */
|
|
||||||
#define isnan _isnan
|
|
||||||
#endif
|
|
||||||
#endif /* !G_OS_WIN32 */
|
#endif /* !G_OS_WIN32 */
|
||||||
|
|
||||||
struct _GDateTime
|
struct _GDateTime
|
||||||
@ -1645,7 +1641,7 @@ g_date_time_new (GTimeZone *tz,
|
|||||||
day < 1 || day > days_in_months[GREGORIAN_LEAP (year)][month] ||
|
day < 1 || day > days_in_months[GREGORIAN_LEAP (year)][month] ||
|
||||||
hour < 0 || hour > 23 ||
|
hour < 0 || hour > 23 ||
|
||||||
minute < 0 || minute > 59 ||
|
minute < 0 || minute > 59 ||
|
||||||
isnan (seconds) ||
|
g_isnan (seconds) ||
|
||||||
seconds < 0.0 || seconds >= 60.0)
|
seconds < 0.0 || seconds >= 60.0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -1670,7 +1666,7 @@ g_date_time_new (GTimeZone *tz,
|
|||||||
* is 1000000. This is not a problem with precision, it's just how
|
* is 1000000. This is not a problem with precision, it's just how
|
||||||
* FP numbers work.
|
* FP numbers work.
|
||||||
* See https://bugzilla.gnome.org/show_bug.cgi?id=697715. */
|
* See https://bugzilla.gnome.org/show_bug.cgi?id=697715. */
|
||||||
usec = seconds * USEC_PER_SECOND;
|
usec = (gint64) (seconds * USEC_PER_SECOND);
|
||||||
usecd = (usec + 1) * 1e-6;
|
usecd = (usec + 1) * 1e-6;
|
||||||
if (usecd <= seconds) {
|
if (usecd <= seconds) {
|
||||||
usec++;
|
usec++;
|
||||||
@ -1973,7 +1969,7 @@ GDateTime*
|
|||||||
g_date_time_add_seconds (GDateTime *datetime,
|
g_date_time_add_seconds (GDateTime *datetime,
|
||||||
gdouble seconds)
|
gdouble seconds)
|
||||||
{
|
{
|
||||||
return g_date_time_add (datetime, seconds * USEC_PER_SECOND);
|
return g_date_time_add (datetime, (GTimeSpan) (seconds * USEC_PER_SECOND));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -818,7 +818,7 @@ g_hash_table_resize (GHashTable *hash_table)
|
|||||||
* Immediately after growing, the load factor will be in the range
|
* Immediately after growing, the load factor will be in the range
|
||||||
* .375 .. .469. After shrinking, it will be exactly .5. */
|
* .375 .. .469. After shrinking, it will be exactly .5. */
|
||||||
|
|
||||||
g_hash_table_set_shift_from_size (hash_table, hash_table->nnodes * 1.333);
|
g_hash_table_set_shift_from_size (hash_table, (gint) (hash_table->nnodes * 1.333));
|
||||||
|
|
||||||
if (hash_table->size > old_size)
|
if (hash_table->size > old_size)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
# glib enables -Werror=format-nonliteral by default, but the embedded gnulib
|
# glib enables -Werror=format-nonliteral by default, but the embedded gnulib
|
||||||
# needs to handle user provided format strings.
|
# needs to handle user provided format strings.
|
||||||
extra_gnulib_args = cc.get_supported_arguments([
|
extra_gnulib_args = cc.get_supported_arguments([
|
||||||
'-Wno-format-nonliteral', '-Wno-duplicated-branches'])
|
'-Wno-format-nonliteral',
|
||||||
|
'-Wno-float-conversion',
|
||||||
|
'-Wno-duplicated-branches',
|
||||||
|
])
|
||||||
|
|
||||||
if host_system == 'windows' and cc.get_id() == 'clang'
|
if host_system == 'windows' and cc.get_id() == 'clang'
|
||||||
extra_gnulib_args += cc.get_supported_arguments([
|
extra_gnulib_args += cc.get_supported_arguments([
|
||||||
|
@ -745,9 +745,9 @@ static GPrintFunc g_default_print_func = NULL;
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
G_TEST_CASE_LARGS_RESULT = 0,
|
G_TEST_CASE_LARGS_RESULT = 0, /* a GTestResult */
|
||||||
G_TEST_CASE_LARGS_RUN_FORKS = 1,
|
G_TEST_CASE_LARGS_RUN_FORKS = 1, /* a gint */
|
||||||
G_TEST_CASE_LARGS_EXECUTION_TIME = 2,
|
G_TEST_CASE_LARGS_EXECUTION_TIME = 2, /* a gdouble */
|
||||||
|
|
||||||
G_TEST_CASE_LARGS_MAX
|
G_TEST_CASE_LARGS_MAX
|
||||||
};
|
};
|
||||||
@ -972,7 +972,7 @@ g_test_log (GTestLogType lbit,
|
|||||||
break;
|
break;
|
||||||
case G_TEST_LOG_STOP_CASE:
|
case G_TEST_LOG_STOP_CASE:
|
||||||
result = largs[G_TEST_CASE_LARGS_RESULT];
|
result = largs[G_TEST_CASE_LARGS_RESULT];
|
||||||
timing = largs[G_TEST_CASE_LARGS_EXECUTION_TIME];
|
timing = (gdouble) largs[G_TEST_CASE_LARGS_EXECUTION_TIME];
|
||||||
fail = result == G_TEST_RUN_FAILURE;
|
fail = result == G_TEST_RUN_FAILURE;
|
||||||
if (test_tap_log)
|
if (test_tap_log)
|
||||||
{
|
{
|
||||||
@ -4371,7 +4371,7 @@ g_test_log_dump (GTestLogMsg *msg,
|
|||||||
g_string_append_len (gstring, msg->strings[ui], l);
|
g_string_append_len (gstring, msg->strings[ui], l);
|
||||||
}
|
}
|
||||||
for (ui = 0; ui < msg->n_nums; ui++)
|
for (ui = 0; ui < msg->n_nums; ui++)
|
||||||
gstring_append_double (gstring, msg->nums[ui]);
|
gstring_append_double (gstring, (gdouble) msg->nums[ui]);
|
||||||
*len = gstring->len;
|
*len = gstring->len;
|
||||||
gstring_overwrite_int (gstring, 0, *len); /* message length */
|
gstring_overwrite_int (gstring, 0, *len); /* message length */
|
||||||
return (guint8*) g_string_free (gstring, FALSE);
|
return (guint8*) g_string_free (gstring, FALSE);
|
||||||
|
@ -2703,7 +2703,7 @@ g_uri_escape_string (const gchar *unescaped,
|
|||||||
|
|
||||||
g_return_val_if_fail (unescaped != NULL, NULL);
|
g_return_val_if_fail (unescaped != NULL, NULL);
|
||||||
|
|
||||||
s = g_string_sized_new (strlen (unescaped) * 1.25);
|
s = g_string_sized_new ((size_t) (strlen (unescaped) * 1.25));
|
||||||
|
|
||||||
g_string_append_uri_escaped (s, unescaped, reserved_chars_allowed, allow_utf8);
|
g_string_append_uri_escaped (s, unescaped, reserved_chars_allowed, allow_utf8);
|
||||||
|
|
||||||
@ -2797,7 +2797,7 @@ g_uri_escape_bytes (const guint8 *unescaped,
|
|||||||
|
|
||||||
g_return_val_if_fail (unescaped != NULL, NULL);
|
g_return_val_if_fail (unescaped != NULL, NULL);
|
||||||
|
|
||||||
string = g_string_sized_new (length * 1.25);
|
string = g_string_sized_new ((size_t) (length * 1.25));
|
||||||
|
|
||||||
_uri_encoder (string, unescaped, length,
|
_uri_encoder (string, unescaped, length,
|
||||||
reserved_chars_allowed, FALSE);
|
reserved_chars_allowed, FALSE);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "gtypes.h"
|
#include "gtypes.h"
|
||||||
#include "gtestutils.h"
|
#include "gtestutils.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -61,6 +62,23 @@ gboolean _g_localtime (time_t timet, struct tm *tm);
|
|||||||
|
|
||||||
gboolean g_set_prgname_once (const gchar *prgname);
|
gboolean g_set_prgname_once (const gchar *prgname);
|
||||||
|
|
||||||
|
/* Although isnan() is defined as a type-independent macro in C99, mingw32
|
||||||
|
* doesn’t seem to support that (it defines `isnan (float d)` only). Older
|
||||||
|
* MSVC toolchains don’t support C99 either. So we provide an internal
|
||||||
|
* abstraction macro.
|
||||||
|
*
|
||||||
|
* This should not be made public; toolchains will soon enough catch up with
|
||||||
|
* C99, so third party code should just use isnan(). */
|
||||||
|
static inline int
|
||||||
|
g_isnan (double d)
|
||||||
|
{
|
||||||
|
#if (defined (_MSC_VER) && (_MSC_VER < 1800)) || defined(__MINGW32__)
|
||||||
|
return _isnan (d);
|
||||||
|
#else
|
||||||
|
return isnan (d);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __G_UTILS_PRIVATE_H__ */
|
#endif /* __G_UTILS_PRIVATE_H__ */
|
||||||
|
@ -1409,7 +1409,7 @@ test_GDateTime_new_from_unix_utc (void)
|
|||||||
g_assert (dt == NULL);
|
g_assert (dt == NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t = t / 1e6; /* oops, this was microseconds */
|
t = t / G_USEC_PER_SEC; /* oops, this was microseconds */
|
||||||
|
|
||||||
dt = g_date_time_new_from_unix_utc (t);
|
dt = g_date_time_new_from_unix_utc (t);
|
||||||
g_assert (dt != NULL);
|
g_assert (dt != NULL);
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
|
#include "gutilsprivate.h"
|
||||||
|
|
||||||
#if defined (_MSC_VER) && (_MSC_VER <= 1800)
|
#if defined (_MSC_VER) && (_MSC_VER <= 1800)
|
||||||
#define isnan(x) _isnan(x)
|
|
||||||
|
|
||||||
#ifndef NAN
|
#ifndef NAN
|
||||||
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||||
#define NAN (*(const float *) __nan)
|
#define NAN (*(const float *) __nan)
|
||||||
@ -1625,7 +1625,7 @@ check_strtod_string (gchar *number,
|
|||||||
|
|
||||||
setlocale (LC_NUMERIC, locales[l]);
|
setlocale (LC_NUMERIC, locales[l]);
|
||||||
d = g_ascii_strtod (number, &end);
|
d = g_ascii_strtod (number, &end);
|
||||||
g_assert_true (isnan (res) ? isnan (d) : (d == res));
|
g_assert_true (g_isnan (res) ? g_isnan (d) : (d == res));
|
||||||
g_assert_true ((gsize) (end - number) ==
|
g_assert_true ((gsize) (end - number) ==
|
||||||
(check_end ? correct_len : strlen (number)));
|
(check_end ? correct_len : strlen (number)));
|
||||||
}
|
}
|
||||||
@ -1660,7 +1660,7 @@ test_ascii_strtod (void)
|
|||||||
/* Do this before any call to setlocale. */
|
/* Do this before any call to setlocale. */
|
||||||
our_nan = atof ("NaN");
|
our_nan = atof ("NaN");
|
||||||
#endif
|
#endif
|
||||||
g_assert_true (isnan (our_nan));
|
g_assert_true (g_isnan (our_nan));
|
||||||
|
|
||||||
#ifdef INFINITY
|
#ifdef INFINITY
|
||||||
our_inf = INFINITY;
|
our_inf = INFINITY;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "gvaluearray.h"
|
#include "gvaluearray.h"
|
||||||
|
|
||||||
|
|
||||||
#define G_FLOAT_EPSILON (1e-30)
|
#define G_FLOAT_EPSILON (1e-30f)
|
||||||
#define G_DOUBLE_EPSILON (1e-90)
|
#define G_DOUBLE_EPSILON (1e-90)
|
||||||
|
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ param_double_is_valid (GParamSpec *pspec,
|
|||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
|
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
|
||||||
gfloat oval = value->data[0].v_double;
|
gdouble oval = value->data[0].v_double;
|
||||||
|
|
||||||
return dspec->minimum <= oval && oval <= dspec->maximum;
|
return dspec->minimum <= oval && oval <= dspec->maximum;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ static void \
|
|||||||
value_transform_##func_name (const GValue *src_value, \
|
value_transform_##func_name (const GValue *src_value, \
|
||||||
GValue *dest_value) \
|
GValue *dest_value) \
|
||||||
{ \
|
{ \
|
||||||
ctype c_value = src_value->data[0].from_member; \
|
ctype c_value = (ctype) src_value->data[0].from_member; \
|
||||||
dest_value->data[0].to_member = c_value; \
|
dest_value->data[0].to_member = c_value; \
|
||||||
} extern void glib_dummy_decl (void)
|
} extern void glib_dummy_decl (void)
|
||||||
DEFINE_CAST (int_s8, v_int, gint8, v_int);
|
DEFINE_CAST (int_s8, v_int, gint8, v_int);
|
||||||
|
@ -190,7 +190,8 @@ value_collect_float (GValue *value,
|
|||||||
GTypeCValue *collect_values,
|
GTypeCValue *collect_values,
|
||||||
guint collect_flags)
|
guint collect_flags)
|
||||||
{
|
{
|
||||||
value->data[0].v_float = collect_values[0].v_double;
|
/* This necessarily loses precision */
|
||||||
|
value->data[0].v_float = (gfloat) collect_values[0].v_double;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ test_param_spec_float (void)
|
|||||||
g_value_set_float (&value, 0.0);
|
g_value_set_float (&value, 0.0);
|
||||||
g_assert_false (g_param_value_is_valid (pspec, &value));
|
g_assert_false (g_param_value_is_valid (pspec, &value));
|
||||||
g_assert_true (g_param_value_validate (pspec, &value));
|
g_assert_true (g_param_value_validate (pspec, &value));
|
||||||
g_assert_cmpint (g_value_get_float (&value), ==, 20.0);
|
g_assert_cmpfloat (g_value_get_float (&value), ==, 20.0);
|
||||||
|
|
||||||
g_param_spec_unref (pspec);
|
g_param_spec_unref (pspec);
|
||||||
}
|
}
|
||||||
@ -289,7 +289,21 @@ test_param_spec_double (void)
|
|||||||
g_value_set_double (&value, 0.0);
|
g_value_set_double (&value, 0.0);
|
||||||
g_assert_false (g_param_value_is_valid (pspec, &value));
|
g_assert_false (g_param_value_is_valid (pspec, &value));
|
||||||
g_assert_true (g_param_value_validate (pspec, &value));
|
g_assert_true (g_param_value_validate (pspec, &value));
|
||||||
g_assert_cmpint (g_value_get_double (&value), ==, 20.0);
|
g_assert_cmpfloat (g_value_get_double (&value), ==, 20.0);
|
||||||
|
|
||||||
|
g_param_spec_unref (pspec);
|
||||||
|
|
||||||
|
/* Test validation with some larger values, which fit in a double but not in a float.
|
||||||
|
* In particular, check there are no double → float conversions in the pipeline,
|
||||||
|
* by using a valid range which is entirely outside the range of numbers
|
||||||
|
* representable in a float. */
|
||||||
|
pspec = g_param_spec_double ("double", NULL, NULL,
|
||||||
|
1.2e308, 1.3e308, 1.21e308, G_PARAM_READWRITE);
|
||||||
|
|
||||||
|
g_param_value_set_default (pspec, &value);
|
||||||
|
g_assert_true (g_param_value_is_valid (pspec, &value));
|
||||||
|
g_assert_false (g_param_value_validate (pspec, &value));
|
||||||
|
g_assert_cmpfloat (g_value_get_double (&value), ==, 1.21e308);
|
||||||
|
|
||||||
g_param_spec_unref (pspec);
|
g_param_spec_unref (pspec);
|
||||||
}
|
}
|
||||||
@ -805,13 +819,13 @@ test_value_transform (void)
|
|||||||
GValue src = G_VALUE_INIT;
|
GValue src = G_VALUE_INIT;
|
||||||
GValue dest = G_VALUE_INIT;
|
GValue dest = G_VALUE_INIT;
|
||||||
|
|
||||||
#define CHECK_INT_CONVERSION(type, getter, value) \
|
#define CHECK_INT_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_INT, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_INT, type)); \
|
||||||
g_value_init (&src, G_TYPE_INT); \
|
g_value_init (&src, G_TYPE_INT); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_int (&src, value); \
|
g_value_set_int (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
@ -820,197 +834,197 @@ test_value_transform (void)
|
|||||||
* https://bugzilla.gnome.org/show_bug.cgi?id=659870
|
* https://bugzilla.gnome.org/show_bug.cgi?id=659870
|
||||||
* for why it is broken.
|
* for why it is broken.
|
||||||
*/
|
*/
|
||||||
CHECK_INT_CONVERSION(G_TYPE_CHAR, char, 124)
|
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpuint, char, 124)
|
||||||
|
|
||||||
CHECK_INT_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_INT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_INT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_INT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_INT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_INT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_INT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_INT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_INT_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_INT_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_INT_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_INT_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_INT_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_INT_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_INT_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_UINT_CONVERSION(type, getter, value) \
|
#define CHECK_UINT_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_UINT, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_UINT, type)); \
|
||||||
g_value_init (&src, G_TYPE_UINT); \
|
g_value_init (&src, G_TYPE_UINT); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_uint (&src, value); \
|
g_value_set_uint (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpuint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_CHAR, char, 124)
|
CHECK_UINT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_CHAR, char, 124)
|
CHECK_UINT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_UINT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_UINT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_UINT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_UINT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_UINT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_UINT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_LONG, long, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, 12345678)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_INT64, int64, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, 12345678)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_UINT_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_UINT_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_LONG_CONVERSION(type, getter, value) \
|
#define CHECK_LONG_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_LONG, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_LONG, type)); \
|
||||||
g_value_init (&src, G_TYPE_LONG); \
|
g_value_init (&src, G_TYPE_LONG); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_long (&src, value); \
|
g_value_set_long (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_LONG_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_LONG_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_LONG_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_LONG_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_LONG_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_LONG_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_LONG_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_LONG_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_LONG_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_LONG_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_ULONG_CONVERSION(type, getter, value) \
|
#define CHECK_ULONG_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_ULONG, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_ULONG, type)); \
|
||||||
g_value_init (&src, G_TYPE_ULONG); \
|
g_value_init (&src, G_TYPE_ULONG); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_ulong (&src, value); \
|
g_value_set_ulong (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpuint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_CHAR, char, 124)
|
CHECK_ULONG_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_CHAR, char, 124)
|
CHECK_ULONG_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, char, 124)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_ULONG_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_ULONG_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_ULONG_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_ULONG_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_ULONG_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_ULONG_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_LONG, long, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, 12345678)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_INT64, int64, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, 12345678)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_ULONG_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_ULONG_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_INT64_CONVERSION(type, getter, value) \
|
#define CHECK_INT64_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_INT64, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_INT64, type)); \
|
||||||
g_value_init (&src, G_TYPE_INT64); \
|
g_value_init (&src, G_TYPE_INT64); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_int64 (&src, value); \
|
g_value_set_int64 (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_INT64_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_INT64_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_INT64_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_INT64_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_INT64_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_INT64_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_INT64_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_INT64_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_INT64_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_INT64_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_UINT64_CONVERSION(type, getter, value) \
|
#define CHECK_UINT64_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_UINT64, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_UINT64, type)); \
|
||||||
g_value_init (&src, G_TYPE_UINT64); \
|
g_value_init (&src, G_TYPE_UINT64); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_uint64 (&src, value); \
|
g_value_set_uint64 (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpuint (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_UINT64_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_UINT64_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_UINT64_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_UINT64_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_UINT64_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_UINT64_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_UINT64_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_UINT64_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_UINT64_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_UINT64_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_FLOAT_CONVERSION(type, getter, value) \
|
#define CHECK_FLOAT_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_FLOAT, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_FLOAT, type)); \
|
||||||
g_value_init (&src, G_TYPE_FLOAT); \
|
g_value_init (&src, G_TYPE_FLOAT); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_float (&src, value); \
|
g_value_set_float (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpfloat (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_FLOAT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_FLOAT_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_FLOAT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_FLOAT_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_FLOAT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_FLOAT_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_FLOAT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_FLOAT_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_FLOAT_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_FLOAT_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_DOUBLE_CONVERSION(type, getter, value) \
|
#define CHECK_DOUBLE_CONVERSION(type, cmpfunc, getter, value) \
|
||||||
g_assert_true (g_value_type_transformable (G_TYPE_DOUBLE, type)); \
|
g_assert_true (g_value_type_transformable (G_TYPE_DOUBLE, type)); \
|
||||||
g_value_init (&src, G_TYPE_DOUBLE); \
|
g_value_init (&src, G_TYPE_DOUBLE); \
|
||||||
g_value_init (&dest, type); \
|
g_value_init (&dest, type); \
|
||||||
g_value_set_double (&src, value); \
|
g_value_set_double (&src, value); \
|
||||||
g_assert_true (g_value_transform (&src, &dest)); \
|
g_assert_true (g_value_transform (&src, &dest)); \
|
||||||
g_assert_cmpfloat (g_value_get_##getter (&dest), ==, value); \
|
cmpfunc (g_value_get_##getter (&dest), ==, value); \
|
||||||
g_value_unset (&src); \
|
g_value_unset (&src); \
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_CHAR, schar, -124)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, -124)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_CHAR, schar, 124)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_CHAR, g_assert_cmpint, schar, 124)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_UCHAR, uchar, 0)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 0)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_UCHAR, uchar, 255)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_UCHAR, g_assert_cmpuint, uchar, 255)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_INT, int, -12345)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, -12345)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_INT, int, 12345)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_INT, g_assert_cmpint, int, 12345)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT, uint, 0)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 0)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT, uint, 12345)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT, g_assert_cmpuint, uint, 12345)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_LONG, long, -12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_LONG, g_assert_cmpint, long, -12345678)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_ULONG, ulong, 12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_ULONG, g_assert_cmpuint, ulong, 12345678)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_INT64, int64, -12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_INT64, g_assert_cmpint, int64, -12345678)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT64, uint64, 12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_UINT64, g_assert_cmpuint, uint64, 12345678)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_FLOAT, float, 12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_FLOAT, g_assert_cmpfloat, float, 12345678)
|
||||||
CHECK_DOUBLE_CONVERSION(G_TYPE_DOUBLE, double, 12345678)
|
CHECK_DOUBLE_CONVERSION(G_TYPE_DOUBLE, g_assert_cmpfloat, double, 12345678)
|
||||||
|
|
||||||
#define CHECK_BOOLEAN_CONVERSION(type, setter, value) \
|
#define CHECK_BOOLEAN_CONVERSION(type, setter, value) \
|
||||||
g_assert_true (g_value_type_transformable (type, G_TYPE_BOOLEAN)); \
|
g_assert_true (g_value_type_transformable (type, G_TYPE_BOOLEAN)); \
|
||||||
|
@ -169,7 +169,7 @@ run_test (PerformanceTest *test)
|
|||||||
g_print ("Uncorrected round time: %.4f msecs, correction factor %.2f\n", 1000*min_elapsed, factor);
|
g_print ("Uncorrected round time: %.4f msecs, correction factor %.2f\n", 1000*min_elapsed, factor);
|
||||||
|
|
||||||
/* Calculate number of rounds needed */
|
/* Calculate number of rounds needed */
|
||||||
num_rounds = (test_length / TARGET_ROUND_TIME) + 1;
|
num_rounds = (guint64) (test_length / TARGET_ROUND_TIME) + 1;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
g_print ("Running %"G_GINT64_MODIFIER"d rounds\n", num_rounds);
|
g_print ("Running %"G_GINT64_MODIFIER"d rounds\n", num_rounds);
|
||||||
@ -505,7 +505,7 @@ complex_object_init (ComplexObject *complex_object)
|
|||||||
|
|
||||||
struct ConstructionTest {
|
struct ConstructionTest {
|
||||||
GObject **objects;
|
GObject **objects;
|
||||||
int n_objects;
|
unsigned int n_objects;
|
||||||
GType type;
|
GType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -526,9 +526,9 @@ test_construction_init (PerformanceTest *test,
|
|||||||
double count_factor)
|
double count_factor)
|
||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
int n;
|
unsigned int n;
|
||||||
|
|
||||||
n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
|
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||||
if (data->n_objects != n)
|
if (data->n_objects != n)
|
||||||
{
|
{
|
||||||
data->n_objects = n;
|
data->n_objects = n;
|
||||||
@ -543,10 +543,10 @@ test_construction_run (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
GType type = data->type;
|
GType type = data->type;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
objects[i] = g_object_new (type, NULL);
|
objects[i] = g_object_new (type, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,10 +556,10 @@ test_construction_run1 (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
objects[i] = (GObject *) g_slice_new0 (SimpleObject);
|
objects[i] = (GObject *) g_slice_new0 (SimpleObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,10 +570,10 @@ test_complex_construction_run (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
GType type = data->type;
|
GType type = data->type;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
objects[i] = g_object_new (type, "val1", 5, "val2", "thousand", NULL);
|
objects[i] = g_object_new (type, "val1", 5, "val2", "thousand", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,10 +584,10 @@ test_complex_construction_run1 (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
GType type = data->type;
|
GType type = data->type;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
{
|
{
|
||||||
ComplexObject *object;
|
ComplexObject *object;
|
||||||
object = (ComplexObject *)g_object_new (type, NULL);
|
object = (ComplexObject *)g_object_new (type, NULL);
|
||||||
@ -604,10 +604,10 @@ test_complex_construction_run2 (PerformanceTest *test,
|
|||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
GType type = data->type;
|
GType type = data->type;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
{
|
{
|
||||||
objects[i] = g_object_new (type, NULL);
|
objects[i] = g_object_new (type, NULL);
|
||||||
}
|
}
|
||||||
@ -618,9 +618,8 @@ test_construction_finish (PerformanceTest *test,
|
|||||||
gpointer _data)
|
gpointer _data)
|
||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_objects; i++)
|
for (unsigned int i = 0; i < data->n_objects; i++)
|
||||||
g_object_unref (data->objects[i]);
|
g_object_unref (data->objects[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,9 +628,8 @@ test_construction_finish1 (PerformanceTest *test,
|
|||||||
gpointer _data)
|
gpointer _data)
|
||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_objects; i++)
|
for (unsigned int i = 0; i < data->n_objects; i++)
|
||||||
g_slice_free (SimpleObject, (SimpleObject *)data->objects[i]);
|
g_slice_free (SimpleObject, (SimpleObject *)data->objects[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,16 +648,16 @@ test_finalization_init (PerformanceTest *test,
|
|||||||
double count_factor)
|
double count_factor)
|
||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
int n;
|
unsigned int n;
|
||||||
|
|
||||||
n = NUM_OBJECT_TO_CONSTRUCT * count_factor;
|
n = (unsigned int) (NUM_OBJECT_TO_CONSTRUCT * count_factor);
|
||||||
if (data->n_objects != n)
|
if (data->n_objects != n)
|
||||||
{
|
{
|
||||||
data->n_objects = n;
|
data->n_objects = n;
|
||||||
data->objects = g_renew (GObject *, data->objects, n);
|
data->objects = g_renew (GObject *, data->objects, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < data->n_objects; i++)
|
for (unsigned int i = 0; i < data->n_objects; i++)
|
||||||
{
|
{
|
||||||
data->objects[i] = g_object_new (data->type, NULL);
|
data->objects[i] = g_object_new (data->type, NULL);
|
||||||
}
|
}
|
||||||
@ -671,10 +669,10 @@ test_finalization_run (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct ConstructionTest *data = _data;
|
struct ConstructionTest *data = _data;
|
||||||
GObject **objects = data->objects;
|
GObject **objects = data->objects;
|
||||||
int i, n_objects;
|
unsigned int n_objects;
|
||||||
|
|
||||||
n_objects = data->n_objects;
|
n_objects = data->n_objects;
|
||||||
for (i = 0; i < n_objects; i++)
|
for (unsigned int i = 0; i < n_objects; i++)
|
||||||
{
|
{
|
||||||
g_object_unref (objects[i]);
|
g_object_unref (objects[i]);
|
||||||
}
|
}
|
||||||
@ -716,7 +714,7 @@ test_finalization_print_result (PerformanceTest *test,
|
|||||||
|
|
||||||
struct TypeCheckTest {
|
struct TypeCheckTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
int n_checks;
|
unsigned int n_checks;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@ -737,7 +735,7 @@ test_type_check_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct TypeCheckTest *data = _data;
|
struct TypeCheckTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_KILO_CHECKS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_KILO_CHECKS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -753,7 +751,6 @@ test_type_check_run (PerformanceTest *test,
|
|||||||
struct TypeCheckTest *data = _data;
|
struct TypeCheckTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
GType type, types[5];
|
GType type, types[5];
|
||||||
int i, j;
|
|
||||||
|
|
||||||
types[0] = test_iface1_get_type ();
|
types[0] = test_iface1_get_type ();
|
||||||
types[1] = test_iface2_get_type ();
|
types[1] = test_iface2_get_type ();
|
||||||
@ -761,10 +758,10 @@ test_type_check_run (PerformanceTest *test,
|
|||||||
types[3] = test_iface4_get_type ();
|
types[3] = test_iface4_get_type ();
|
||||||
types[4] = test_iface5_get_type ();
|
types[4] = test_iface5_get_type ();
|
||||||
|
|
||||||
for (i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
{
|
{
|
||||||
type = types[i%5];
|
type = types[i%5];
|
||||||
for (j = 0; j < 1000; j++)
|
for (unsigned int j = 0; j < 1000; j++)
|
||||||
{
|
{
|
||||||
my_type_check_instance_is_a ((GTypeInstance *)object,
|
my_type_check_instance_is_a ((GTypeInstance *)object,
|
||||||
type);
|
type);
|
||||||
@ -806,8 +803,8 @@ test_type_check_teardown (PerformanceTest *test,
|
|||||||
|
|
||||||
struct EmissionTest {
|
struct EmissionTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
int n_checks;
|
unsigned int n_checks;
|
||||||
int signal_id;
|
unsigned int signal_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -816,9 +813,8 @@ test_emission_run (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_signal_emit (object, data->signal_id, 0);
|
g_signal_emit (object, data->signal_id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,9 +824,8 @@ test_emission_run_args (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_signal_emit (object, data->signal_id, 0, 0, NULL);
|
g_signal_emit (object, data->signal_id, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,7 +840,7 @@ test_emission_unhandled_setup (PerformanceTest *test)
|
|||||||
|
|
||||||
data = g_new0 (struct EmissionTest, 1);
|
data = g_new0 (struct EmissionTest, 1);
|
||||||
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
|
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
|
||||||
data->signal_id = complex_signals[GPOINTER_TO_INT (test->extra_data)];
|
data->signal_id = complex_signals[GPOINTER_TO_UINT (test->extra_data)];
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +851,7 @@ test_emission_unhandled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -902,7 +897,7 @@ test_emission_handled_setup (PerformanceTest *test)
|
|||||||
|
|
||||||
data = g_new0 (struct EmissionTest, 1);
|
data = g_new0 (struct EmissionTest, 1);
|
||||||
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
|
data->object = g_object_new (COMPLEX_TYPE_OBJECT, NULL);
|
||||||
data->signal_id = complex_signals[GPOINTER_TO_INT (test->extra_data)];
|
data->signal_id = complex_signals[GPOINTER_TO_UINT (test->extra_data)];
|
||||||
g_signal_connect (data->object, "signal",
|
g_signal_connect (data->object, "signal",
|
||||||
G_CALLBACK (test_emission_handled_handler),
|
G_CALLBACK (test_emission_handled_handler),
|
||||||
NULL);
|
NULL);
|
||||||
@ -929,7 +924,7 @@ test_emission_handled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct EmissionTest *data = _data;
|
struct EmissionTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_EMISSIONS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_EMISSIONS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -967,7 +962,7 @@ test_emission_handled_teardown (PerformanceTest *test,
|
|||||||
|
|
||||||
struct NotifyTest {
|
struct NotifyTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
unsigned n_checks;
|
unsigned int n_checks;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -977,7 +972,7 @@ test_notify_run (PerformanceTest *test,
|
|||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
|
|
||||||
for (unsigned i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_object_notify (object, "val1");
|
g_object_notify (object, "val1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,7 +983,7 @@ test_notify_by_pspec_run (PerformanceTest *test,
|
|||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
|
|
||||||
for (unsigned i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_object_notify_by_pspec (object, pspecs[PROP_VAL1]);
|
g_object_notify_by_pspec (object, pspecs[PROP_VAL1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,7 +1008,7 @@ test_notify_unhandled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_NOTIFY_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1075,7 +1070,7 @@ test_notify_handled_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct NotifyTest *data = _data;
|
struct NotifyTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_NOTIFY_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_NOTIFY_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1117,7 +1112,7 @@ test_notify_handled_teardown (PerformanceTest *test,
|
|||||||
|
|
||||||
struct SetTest {
|
struct SetTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
unsigned n_checks;
|
unsigned int n_checks;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1127,7 +1122,7 @@ test_set_run (PerformanceTest *test,
|
|||||||
struct SetTest *data = _data;
|
struct SetTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
|
|
||||||
for (unsigned i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_object_set (object, "val1", i, NULL);
|
g_object_set (object, "val1", i, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1155,7 +1150,7 @@ test_set_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct SetTest *data = _data;
|
struct SetTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_SET_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_SET_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1194,7 +1189,7 @@ test_set_teardown (PerformanceTest *test,
|
|||||||
|
|
||||||
struct GetTest {
|
struct GetTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
unsigned n_checks;
|
unsigned int n_checks;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1205,7 +1200,7 @@ test_get_run (PerformanceTest *test,
|
|||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
for (unsigned i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
g_object_get (object, "val1", &val, NULL);
|
g_object_get (object, "val1", &val, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,7 +1228,7 @@ test_get_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct GetTest *data = _data;
|
struct GetTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_GET_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_GET_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1272,7 +1267,7 @@ test_get_teardown (PerformanceTest *test,
|
|||||||
|
|
||||||
struct RefcountTest {
|
struct RefcountTest {
|
||||||
GObject *object;
|
GObject *object;
|
||||||
int n_checks;
|
unsigned int n_checks;
|
||||||
gboolean is_toggle_ref;
|
gboolean is_toggle_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1308,7 +1303,7 @@ test_refcount_init (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct RefcountTest *data = _data;
|
struct RefcountTest *data = _data;
|
||||||
|
|
||||||
data->n_checks = factor * NUM_KILO_REFS_PER_ROUND;
|
data->n_checks = (unsigned int) (factor * NUM_KILO_REFS_PER_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1317,9 +1312,8 @@ test_refcount_run (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct RefcountTest *data = _data;
|
struct RefcountTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
{
|
{
|
||||||
g_object_ref (object);
|
g_object_ref (object);
|
||||||
g_object_ref (object);
|
g_object_ref (object);
|
||||||
@ -1341,9 +1335,8 @@ test_refcount_1_run (PerformanceTest *test,
|
|||||||
{
|
{
|
||||||
struct RefcountTest *data = _data;
|
struct RefcountTest *data = _data;
|
||||||
GObject *object = data->object;
|
GObject *object = data->object;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < data->n_checks; i++)
|
for (unsigned int i = 0; i < data->n_checks; i++)
|
||||||
{
|
{
|
||||||
g_object_ref (object);
|
g_object_ref (object);
|
||||||
g_object_unref (object);
|
g_object_unref (object);
|
||||||
@ -1457,7 +1450,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-unhandled",
|
"emit-unhandled",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL),
|
||||||
test_emission_unhandled_setup,
|
test_emission_unhandled_setup,
|
||||||
test_emission_unhandled_init,
|
test_emission_unhandled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1467,7 +1460,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-unhandled-empty",
|
"emit-unhandled-empty",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
||||||
test_emission_unhandled_setup,
|
test_emission_unhandled_setup,
|
||||||
test_emission_unhandled_init,
|
test_emission_unhandled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1477,7 +1470,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-unhandled-generic",
|
"emit-unhandled-generic",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
||||||
test_emission_unhandled_setup,
|
test_emission_unhandled_setup,
|
||||||
test_emission_unhandled_init,
|
test_emission_unhandled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1487,7 +1480,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-unhandled-generic-empty",
|
"emit-unhandled-generic-empty",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
||||||
test_emission_unhandled_setup,
|
test_emission_unhandled_setup,
|
||||||
test_emission_unhandled_init,
|
test_emission_unhandled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1497,7 +1490,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-unhandled-args",
|
"emit-unhandled-args",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
||||||
test_emission_unhandled_setup,
|
test_emission_unhandled_setup,
|
||||||
test_emission_unhandled_init,
|
test_emission_unhandled_init,
|
||||||
test_emission_run_args,
|
test_emission_run_args,
|
||||||
@ -1507,7 +1500,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-handled",
|
"emit-handled",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL),
|
||||||
test_emission_handled_setup,
|
test_emission_handled_setup,
|
||||||
test_emission_handled_init,
|
test_emission_handled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1517,7 +1510,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-handled-empty",
|
"emit-handled-empty",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_EMPTY),
|
||||||
test_emission_handled_setup,
|
test_emission_handled_setup,
|
||||||
test_emission_handled_init,
|
test_emission_handled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1527,7 +1520,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-handled-generic",
|
"emit-handled-generic",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC),
|
||||||
test_emission_handled_setup,
|
test_emission_handled_setup,
|
||||||
test_emission_handled_init,
|
test_emission_handled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1537,7 +1530,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-handled-generic-empty",
|
"emit-handled-generic-empty",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_GENERIC_EMPTY),
|
||||||
test_emission_handled_setup,
|
test_emission_handled_setup,
|
||||||
test_emission_handled_init,
|
test_emission_handled_init,
|
||||||
test_emission_run,
|
test_emission_run,
|
||||||
@ -1547,7 +1540,7 @@ static PerformanceTest tests[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"emit-handled-args",
|
"emit-handled-args",
|
||||||
GINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
GUINT_TO_POINTER (COMPLEX_SIGNAL_ARGS),
|
||||||
test_emission_handled_setup,
|
test_emission_handled_setup,
|
||||||
test_emission_handled_init,
|
test_emission_handled_init,
|
||||||
test_emission_run_args,
|
test_emission_run_args,
|
||||||
@ -1650,8 +1643,7 @@ static PerformanceTest tests[] = {
|
|||||||
static PerformanceTest *
|
static PerformanceTest *
|
||||||
find_test (const char *name)
|
find_test (const char *name)
|
||||||
{
|
{
|
||||||
gsize i;
|
for (size_t i = 0; i < G_N_ELEMENTS (tests); i++)
|
||||||
for (i = 0; i < G_N_ELEMENTS (tests); i++)
|
|
||||||
{
|
{
|
||||||
if (strcmp (tests[i].name, name) == 0)
|
if (strcmp (tests[i].name, name) == 0)
|
||||||
return &tests[i];
|
return &tests[i];
|
||||||
@ -1666,7 +1658,6 @@ main (int argc,
|
|||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *str;
|
const char *str;
|
||||||
int i;
|
|
||||||
|
|
||||||
if ((str = g_getenv ("GLIB_PERFORMANCE_FACTOR")) && str[0])
|
if ((str = g_getenv ("GLIB_PERFORMANCE_FACTOR")) && str[0])
|
||||||
{
|
{
|
||||||
@ -1691,7 +1682,7 @@ main (int argc,
|
|||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
test = find_test (argv[i]);
|
test = find_test (argv[i]);
|
||||||
if (test)
|
if (test)
|
||||||
@ -1700,8 +1691,7 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gsize k;
|
for (size_t k = 0; k < G_N_ELEMENTS (tests); k++)
|
||||||
for (k = 0; k < G_N_ELEMENTS (tests); k++)
|
|
||||||
run_test (&tests[k]);
|
run_test (&tests[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,6 +550,7 @@ endforeach
|
|||||||
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||||
warning_common_args = [
|
warning_common_args = [
|
||||||
'-Wduplicated-branches',
|
'-Wduplicated-branches',
|
||||||
|
'-Wfloat-conversion',
|
||||||
'-Wimplicit-fallthrough',
|
'-Wimplicit-fallthrough',
|
||||||
'-Wmisleading-indentation',
|
'-Wmisleading-indentation',
|
||||||
'-Wmissing-field-initializers',
|
'-Wmissing-field-initializers',
|
||||||
|
Loading…
Reference in New Issue
Block a user