mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 21:16:15 +01:00
tests: Make testcase not pass 0 as a flags value
This will not catch the case where we fail in libffi and always use 0. In fact, be a real annoying person and use (1 << 31) as a flags value to test signedness, too. Also update the testcase to actually use flags everywhere and ot uint. https://bugzilla.gnome.org/show_bug.cgi?id=754882
This commit is contained in:
parent
7b685eab88
commit
605ff1efe7
@ -1,6 +1,13 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include "marshalers.h"
|
#include "marshalers.h"
|
||||||
|
|
||||||
|
#define g_assert_cmpflags(type,n1, cmp, n2) G_STMT_START { \
|
||||||
|
type __n1 = (n1), __n2 = (n2); \
|
||||||
|
if (__n1 cmp __n2) ; else \
|
||||||
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
|
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TEST_ENUM_NEGATIVE = -30,
|
TEST_ENUM_NEGATIVE = -30,
|
||||||
TEST_ENUM_NONE = 0,
|
TEST_ENUM_NONE = 0,
|
||||||
@ -65,9 +72,17 @@ static const GEnumValue my_enum_values[] =
|
|||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MY_FLAGS_FIRST_BIT = (1 << 0),
|
||||||
|
MY_FLAGS_THIRD_BIT = (1 << 2),
|
||||||
|
MY_FLAGS_LAST_BIT = (1 << 31)
|
||||||
|
} MyFlags;
|
||||||
|
|
||||||
static const GFlagsValue my_flag_values[] =
|
static const GFlagsValue my_flag_values[] =
|
||||||
{
|
{
|
||||||
{ 1, "the first value", "one" },
|
{ MY_FLAGS_FIRST_BIT, "the first bit", "first-bit" },
|
||||||
|
{ MY_FLAGS_THIRD_BIT, "the third bit", "third-bit" },
|
||||||
|
{ MY_FLAGS_LAST_BIT, "the last bit", "last-bit" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,15 +100,15 @@ struct _Test
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void all_types_handler (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, guint f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
static void all_types_handler (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, MyFlags f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
||||||
|
|
||||||
struct _TestClass
|
struct _TestClass
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
void (* variant_changed) (Test *, GVariant *);
|
void (* variant_changed) (Test *, GVariant *);
|
||||||
void (* all_types) (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, guint f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
void (* all_types) (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, MyFlags f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
||||||
void (* all_types_null) (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, guint f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
void (* all_types_null) (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, MyFlags f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64);
|
||||||
};
|
};
|
||||||
|
|
||||||
static GType test_get_type (void);
|
static GType test_get_type (void);
|
||||||
@ -681,7 +696,7 @@ test_generic_marshaller_signal_uint_return (void)
|
|||||||
static int all_type_handlers_count = 0;
|
static int all_type_handlers_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
all_types_handler (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, guint f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64)
|
all_types_handler (Test *test, int i, gboolean b, char c, guchar uc, guint ui, glong l, gulong ul, gint e, MyFlags f, float fl, double db, char *str, GParamSpec *param, GBytes *bytes, gpointer ptr, Test *obj, GVariant *var, gint64 i64, guint64 ui64)
|
||||||
{
|
{
|
||||||
all_type_handlers_count++;
|
all_type_handlers_count++;
|
||||||
|
|
||||||
@ -693,7 +708,7 @@ all_types_handler (Test *test, int i, gboolean b, char c, guchar uc, guint ui, g
|
|||||||
g_assert_cmpint (l, ==, -1117);
|
g_assert_cmpint (l, ==, -1117);
|
||||||
g_assert_cmpuint (ul, ==, G_MAXULONG - 999);
|
g_assert_cmpuint (ul, ==, G_MAXULONG - 999);
|
||||||
g_assert_cmpint (e, ==, 1);
|
g_assert_cmpint (e, ==, 1);
|
||||||
g_assert_cmpuint (f, ==, 0);
|
g_assert_cmpflags (MyFlags, f, ==, MY_FLAGS_FIRST_BIT | MY_FLAGS_THIRD_BIT | MY_FLAGS_LAST_BIT);
|
||||||
g_assert_cmpfloat (fl, ==, 0.25);
|
g_assert_cmpfloat (fl, ==, 0.25);
|
||||||
g_assert_cmpfloat (db, ==, 1.5);
|
g_assert_cmpfloat (db, ==, 1.5);
|
||||||
g_assert_cmpstr (str, ==, "Test");
|
g_assert_cmpstr (str, ==, "Test");
|
||||||
@ -725,7 +740,7 @@ test_all_types (void)
|
|||||||
glong l = -1117;
|
glong l = -1117;
|
||||||
gulong ul = G_MAXULONG - 999;
|
gulong ul = G_MAXULONG - 999;
|
||||||
gint e = 1;
|
gint e = 1;
|
||||||
guint f = 0;
|
MyFlags f = MY_FLAGS_FIRST_BIT | MY_FLAGS_THIRD_BIT | MY_FLAGS_LAST_BIT;
|
||||||
float fl = 0.25;
|
float fl = 0.25;
|
||||||
double db = 1.5;
|
double db = 1.5;
|
||||||
char *str = "Test";
|
char *str = "Test";
|
||||||
|
Loading…
Reference in New Issue
Block a user