diff options
author | Colin Walters <walters@verbum.org> | 2011-09-22 16:08:35 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2011-09-22 20:05:38 -0400 |
commit | f42fe6cdc056b77f74ff6e332389d444c50ae7dc (patch) | |
tree | b0b6d6bb1bd548a748041351a9c58ae1d3f88a9a /tests | |
parent | 1df8160fa675b225809eed2f86d2489133e5e54d (diff) |
gvalue: Add explicitly signed g_value_get_schar() and g_value_set_schar()
The documentation for G_TYPE_CHAR says:
"The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed
integer."
However the return value for g_value_get_char() was just "char" which
in C has an unspecified signedness; on e.g. x86 it's signed (which
matches the GType), but on e.g. PowerPC or ARM, it's not.
We can't break the old API, so we need to suck it up and add new API.
Port most internal users, but keep some tests of the old API too.
https://bugzilla.gnome.org/show_bug.cgi?id=659870
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gobject/gvalue-test.c | 1 | ||||
-rw-r--r-- | tests/gobject/paramspec-test.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/gobject/gvalue-test.c b/tests/gobject/gvalue-test.c index 516a484a1..bec3c64eb 100644 --- a/tests/gobject/gvalue-test.c +++ b/tests/gobject/gvalue-test.c @@ -50,6 +50,7 @@ test_enum_transformation (void) g_value_init (&xform, G_TYPE_CHAR); g_value_transform (&orig, &xform); g_assert (g_value_get_char (&xform) == 1); + g_assert (g_value_get_schar (&xform) == 1); memset (&xform, 0, sizeof (GValue)); g_value_init (&xform, G_TYPE_UCHAR); diff --git a/tests/gobject/paramspec-test.c b/tests/gobject/paramspec-test.c index 6de850fe4..d09945b3b 100644 --- a/tests/gobject/paramspec-test.c +++ b/tests/gobject/paramspec-test.c @@ -67,6 +67,22 @@ test_param_spec_char (void) modified = g_param_value_validate (pspec, &value); g_assert (modified && g_value_get_char (&value) == 40); + g_value_set_schar (&value, 0); + modified = g_param_value_validate (pspec, &value); + g_assert (modified && g_value_get_schar (&value) == 20); + + g_value_set_schar (&value, 20); + modified = g_param_value_validate (pspec, &value); + g_assert (!modified && g_value_get_schar (&value) == 20); + + g_value_set_schar (&value, 40); + modified = g_param_value_validate (pspec, &value); + g_assert (!modified && g_value_get_schar (&value) == 40); + + g_value_set_schar (&value, 60); + modified = g_param_value_validate (pspec, &value); + g_assert (modified && g_value_get_schar (&value) == 40); + g_param_spec_unref (pspec); } |