Commit 7ea993e3 authored by Guido Gunther's avatar Guido Gunther

Add test to check object lifecycle bugs easily

Further tests will need mocks for phosh.c
parent cb86db1f
option('tests',
type: 'boolean', value: true,
description: 'Whether to compile unit tests')
if get_option('tests')
test_env = [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'G_DEBUG=gc-friendly,fatal-warnings',
'GSETTINGS_BACKEND=memory',
'GSETTINGS_SCHEMA_DIR=@0@/data'.format(meson.build_root()),
'PYTHONDONTWRITEBYTECODE=yes',
'MALLOC_CHECK_=2',
]
test_cflags = [
'-fPIE',
'-I../src'.format(meson.current_source_dir()),
'-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()),
]
test_link_args = [
'-fPIC',
]
cls_names = [
'favorites',
]
foreach cls_name : cls_names
t = executable('test-@0@'.format(cls_name),
['test-@0@.c'.format(cls_name),
'../src/@0@.c'.format(cls_name)],
c_args: test_cflags,
link_args: test_link_args,
dependencies: phosh_deps,
)
test(cls_name, t, env: test_env)
endforeach
endif
/*
* Copyright (C) 2018 Purism SPC
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "favorites.h"
static void
test_phosh_favorites_new(void)
{
GtkWidget *window = phosh_favorites_new ();
g_assert (window);
gtk_widget_destroy (window);
}
gint
main (gint argc,
gchar *argv[])
{
gtk_test_init (&argc, &argv, NULL);
g_test_add_func("/phosh/favorites/new", test_phosh_favorites_new);
return g_test_run();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment