我正在尝试对使用 GLib 编写的一些 C 代码运行简单的单元测试。我正在尝试做类似的事情:
#include <math.h>
#include <stdio.h>
#include <glib.h>
static void
test_stuff ()
{
g_assert (1 == 1); //Say
}
int main (int argc, char **argv)
{
g_test_init (&argc, &argv);
g_test_add_func ("/TestTest", test_stuff);
return g_test_run();
}
但是当我编译(比如一个名为 exec 的二进制文件)并尝试使用 gtester 运行它(甚至直接运行所述二进制文件)时,我收到以下错误:
me@laptop:tests$ gtester exec
TEST: exec... (pid=6503)
(process:6503): GLib-CRITICAL **: g_test_init: assertion `vararg1 == NULL' failed
FAIL: exec
Terminated
有什么我遗漏的东西,也许我在运行测试时应该通过变量?