[glib] Don't g_test_assert_expected_messages for g_error
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Don't g_test_assert_expected_messages for g_error
- Date: Mon, 21 Oct 2013 18:33:18 +0000 (UTC)
commit 8dfb0703298bf8f25f3440967fca348ec71e4253
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Oct 18 20:40:57 2013 -0400
Don't g_test_assert_expected_messages for g_error
Don't allow the user to assert for expected g_error(). They need to use
subprocess for this.
https://bugzilla.gnome.org/show_bug.cgi?id=709615
glib/gmessages.c | 1 +
glib/tests/testing.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 7340307..d09552e 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -1159,6 +1159,7 @@ g_test_expect_message (const gchar *log_domain,
g_return_if_fail (log_level != 0);
g_return_if_fail (pattern != NULL);
+ g_return_if_fail (~log_level & G_LOG_LEVEL_ERROR);
expected = g_new (GTestExpectedMessage, 1);
expected->log_domain = g_strdup (log_domain);
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 21f019e..2adc003 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -381,6 +381,15 @@ test_expected_messages_null_domain (void)
}
static void
+test_expected_messages_expect_error (void)
+{
+ /* make sure we can't try to expect a g_error() */
+ g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*G_LOG_LEVEL_ERROR*");
+ g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "this won't work");
+ g_test_assert_expected_messages ();
+}
+
+static void
test_expected_messages_extra_warning (void)
{
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
@@ -590,6 +599,7 @@ main (int argc,
g_test_add_func ("/misc/expected-messages/subprocess/null-domain", test_expected_messages_null_domain);
g_test_add_func ("/misc/expected-messages/subprocess/extra-warning", test_expected_messages_extra_warning);
g_test_add_func ("/misc/expected-messages/subprocess/unexpected-extra-warning",
test_expected_messages_unexpected_extra_warning);
+ g_test_add_func ("/misc/expected-messages/expect-error", test_expected_messages_expect_error);
g_test_add_func ("/misc/dash-p", test_dash_p);
g_test_add_func ("/misc/dash-p/child", test_dash_p_child);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]