Skip to content
Snippets Groups Projects
Commit 46436e8a authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

added test for CMS

Tests are done using check, allowing to integrate the tests into the
Autotools.
Methods that are part of another unit, but are called in this unit
aren't tested as this would interfere with the idea of unittests. This
also applies for purely wrapper functions, where a call is passed to
another unit.
parent 6a592b8d
No related branches found
No related tags found
No related merge requests found
## Process this file with automake to produce Makefile.in
SUBDIRS = src
SUBDIRS = src tests
ACLOCAL_AMFLAGS = --install -I build-macro
......@@ -30,6 +30,7 @@ AC_CHECK_HEADER([string.h])
# Makefiles
AC_CONFIG_FILES([Makefile
src/Makefile])
src/Makefile
tests/Makefile])
AC_OUTPUT
## Process this file with automake to produce Makefile.in
AM_CFLAGS = -Wall -Wextra $(CHECK_CFLAGS)
TESTS =
TESTS += sefht_cms_test
check_PROGRAMS = $(TESTS)
AM_CPPFLAGS =
AM_CPPFLAGS += -I$(top_srcdir)/src
LDADD = $(CHECK_LIBS)
sefht_cms_test_SOURCES = test_cms.c
sefht_cms_test_LDADD =
sefht_cms_test_LDADD += $(top_builddir)/src/cms.o
sefht_cms_test_LDADD += $(top_builddir)/src/data.o
sefht_cms_test_LDADD += $(LDADD)
/*
* test_cms.c
*
* Copyright 2022 Jonathan Schöbel <jonathan@Ubermos-2019>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
#include <check.h>
#include <stdlib.h>
#include "error.h"
#include "cms.h"
START_TEST(test_cms)
{
struct SH_Error error;
struct SH_Cms * cms;
cms = SH_Cms_new (NULL);
ck_assert_int_ne ((long int) cms, (long int) NULL);
SH_Cms_free (cms, NULL);
cms = SH_Cms_new (&error);
ck_assert_int_ne ((long int) cms, (long int) NULL);
ck_assert_int_eq (error.type, SUCCESS);
SH_Cms_free (cms, &error);
ck_assert_int_eq (error.type, SUCCESS);
}
END_TEST
Suite * cms_suite (void)
{
Suite *s;
TCase *tc_core;
s = suite_create ("Testsuite SeFHT CMS");
/* Core test case */
tc_core = tcase_create ("Core");
tcase_add_test (tc_core, test_cms);
suite_add_tcase (s, tc_core);
return s;
}
int main (int argc, char **argv)
{
int number_failed;
Suite *s;
SRunner *sr;
s = cms_suite ();
sr = srunner_create (s);
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment