- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 glib 测试框架编写测试。他们有诸如 g_assert_true 之类的断言,在他们的文档中说:
Debugging macro to check that an expression is true. If the assertion fails (i.e. the expression is not true), an error message is logged and the application is either terminated or the testcase marked as failed. See g_test_set_nonfatal_assertions().
g_test_set_nonfatal_assertions() 定义为:
Changes the behaviour of g_assert_cmpstr(), g_assert_cmpint(), g_assert_cmpuint(), g_assert_cmphex(), g_assert_cmpfloat(), g_assert_true(), g_assert_false(), g_assert_null(), g_assert_no_error(), g_assert_error(), g_test_assert_expected_messages() and the various g_test_trap_assert_*() macros to not abort to program, but instead call g_test_fail() and continue. (This also changes the behavior of g_test_fail() so that it will not cause the test program to abort after completing the failed test.) Note that the g_assert_not_reached() and g_assert() are not affected by this. This function can only be called after g_test_init().
这意味着通过调用 g_test_set_nonfatal_assertions,而不是关闭它的测试程序应该继续运行,它应该继续运行并将测试用例标记为失败。但是我有以下代码片段:
void test_subscribe(mfixture* mf, gconstpointer ignored)
{
g_assert_true(FALSE);
}
void test_test(mfixture* mf, gconstpointer ignored)
{
}
int main(int argc, char **argv){
g_test_init(&argc, &argv, NULL);
g_test_set_nonfatal_assertions ();
g_test_add ("/set1/subscribe test", mfixture, NULL,message_setup, test_subscribe, message_teardown);
g_test_add ("/set1/test test", mfixture, NULL,message_setup, test_test, message_teardown);
return g_test_run();
}
我得到以下输出:
ERROR:HubSubscriptions_test.c:32:test_subscribe: FALSE make: * [test-all] Aborted (core dumped)
鉴于文档,您可能希望它不会被中止。在我看来,g_test_set_nonfatal_assertions() 只是不起作用。有谁知道这是否是一个现有错误,或者我是否遗漏了一个步骤?
最佳答案
是a known issue如果不在单独的进程中实际运行每个单独的测试单元,就无法轻易修复。
关于c - 使用 glib 测试框架时,g_test_set_nonfatal_assertions() 仍然中止(核心转储),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22669182/
我想在 GLib 中将整数值转换为字符串。是否有任何宏或函数?或者我可以在同一个双向链表中存储不同的数据类型吗? 最佳答案 gchar *my_string = g_strdup_printf("%i
所以基本上我正在编写以下步骤来创建基于 dbus 的应用程序。1. g_bus_watch_name(特定服务出现的回调)2. g_signal_connect 附加到服务提供的某些信号。 g_sig
所以基本上我正在编写以下步骤来创建基于 dbus 的应用程序。1. g_bus_watch_name(特定服务出现的回调)2. g_signal_connect 附加到服务提供的某些信号。 g_sig
我尝试使用JUCE框架构建cpp程序,但出现错误 make: *** No rule to make target '/usr/include/glib-2.0/glib/gurifuncs.h',
我有一些使用 dbus-glib 通过 dbus 编写服务器导出和接口(interface)。 我正在尝试编写一个将字节数组作为输入的方法,但是我很难确定在我的方法参数中使用什么类型。 例如,如果我有
我一直在研究 python-mpdor 的源代码它提到它是 gobject-based, for easy event handling (in the high-level client class
假设我有一个 GLib.Array并想将其转换为 Item[] ,我将如何在 Vala 中做到这一点? 最佳答案 首先,除非您需要与现有代码进行互操作,否则不要使用 GLib.Array。使用 GLi
我正在尝试使用 GLib 的 spawn_command_line_sync 将 echo 的输出通过管道传输到命令中方法。我遇到的问题是 echo 将整个命令解释为参数。 为了更好地解释,我在我的代
我似乎无法使用 glib.h 编译这个基本程序... #include glib.h #include stdio.h int main () { return ((glib_major_ver
我刚开始学习 vala。我尝试了来自 vala tutorial 的以下程序. class Demo.Hello : Glib.Object { public static int main( s
在调查一些性能问题时,我最终进入了 gthread-posix.c。 在那里我找到了如下代码: static void __attribute__((noinline)) g_mutex_lock_s
这个问题在这里已经有了答案: Undefined reference to 'pthread_create' — linker command option order (libraries bef
我正在学习使用 GLib 编写简单、高效的套接字服务器的基础知识。我正在试验 GSocketService。到目前为止,我似乎只能接受连接,但它们会立即关闭。从文档中我无法弄清楚我缺少的步骤。我希望有
我在 gobject 上阅读了一个维基百科页面,上面写着, Depending only on GLib and libc, GObject is a cornerstone of GNOME and
我尝试了sudo apt-get install libglib2.0-dev并得到了 libglib2.0-dev is already the newest version. 我仍然收到错误 co
所以我正在尝试使用 GtkSourceViewmm 在 C++ 中使用 GtkSourceView ,其文档和支持水平给我的印象是很长一段时间没有仔细研究它。但我始终是一个乐观主义者 :) 我正在尝试
我是编程新手。我正在创建一个 Qt GUI 应用程序。这是一个小的拼字游戏。问题是每当我在构建它后从命令提示符启动这个程序时,我都会在命令提示符下得到以下输出: JumbleGame 1.0 Laun
我正在尝试创建一个相当简单的使用自动工具的 BitBake 配方,您可以在这里看到: SUMMARY = "an example autotools recipe" LICENSE = "MIT" L
我正在尝试创建一个相当简单的使用自动工具的 BitBake 配方,您可以在这里看到: SUMMARY = "an example autotools recipe" LICENSE = "MIT" L
我正在查看一段代码,它直到最近才有效。基本上,我有一个 C++ 类,我在其中使用 G_LOCK_DEFINE 宏保护一个变量。 class CSomeClass { private: gulo
我是一名优秀的程序员,十分优秀!