Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add unit test for dependency formula.
Vsevolod Stakhov committed 10 years ago
commit 2508a68a1e03b0e44b260d6bbdb178d468a6012a
parent aaad007
3 files changed +75 -0
modified tests/Kyuafile
@@ -8,5 +8,6 @@ atf_test_program{name='plist'}
atf_test_program{name='pkg_add_dir_to_del'}
atf_test_program{name='merge'}
atf_test_program{name='checksum'}
+
atf_test_program{name='deps_formula'}

include('frontend/Kyuafile')
modified tests/Makefile.am
@@ -59,6 +59,10 @@ checksum_SOURCES= lib/checksum.c
checksum_CFLAGS=	$(PRIVATE_INCS)
checksum_LDADD=		$(GENERIC_LDADD)

+
deps_formula_SOURCES=	lib/deps_formula.c
+
deps_formula_CFLAGS=	$(PRIVATE_INCS)
+
deps_formula_LDADD=		$(GENERIC_LDADD)
+

pkg_add_dir_to_del_SOURCES=	lib/pkg_add_dir_to_del.c
pkg_add_dir_to_del_CFLAGS=	$(PRIVATE_INCS)
pkg_add_dir_to_del_LDADD=	$(GENERIC_LDADD)
@@ -98,6 +102,7 @@ tests_programs= pkg_printf \
		pkg_validation \
		plist \
		checksum \
+
		deps_formula \
		pkg_add_dir_to_del \
		merge
EXTRA_PROGRAMS=	$(tests_programs)
added tests/lib/deps_formula.c
@@ -0,0 +1,69 @@
+
/*
+
 * Copyright (c) 2015, Vsevolod Stakhov
+
 * All rights reserved.
+
 *
+
 * Redistribution and use in source and binary forms, with or without
+
 * modification, are permitted provided that the following conditions are met:
+
 *	 * Redistributions of source code must retain the above copyright
+
 *	   notice, this list of conditions and the following disclaimer.
+
 *	 * Redistributions in binary form must reproduce the above copyright
+
 *	   notice, this list of conditions and the following disclaimer in the
+
 *	   documentation and/or other materials provided with the distribution.
+
 *
+
 * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY
+
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+
 * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
+
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 */
+

+

+
#include <atf-c.h>
+
#include <err.h>
+
#include <unistd.h>
+
#include <pkg.h>
+
#include <private/pkg.h>
+
#include <private/pkg_deps.h>
+

+
ATF_TC(check_parsing);
+

+
ATF_TC_HEAD(check_parsing, tc)
+
{
+
	atf_tc_set_md_var(tc, "descr", "testing parsing of deps formula");
+
}
+

+
ATF_TC_BODY(check_parsing, tc)
+
{
+
	struct pkg_dep_formula *f;
+
	const char *cases[] = {
+
		"name",
+
		"name = 1.0",
+
		"name >= 1.0,1",
+
		"name1, name2",
+
		"name1 | name2, name3",
+
		"name1 = 1.0 | name2 != 1.0, name3 > 1.0 < 2.0 != 1.5"
+
	};
+
	char *r;
+
	int i;
+

+
	for (i = 0; i < sizeof(cases) / sizeof(cases[0]); i ++) {
+
		f = pkg_deps_parse_formula(cases[i]);
+
		ATF_REQUIRE(f != NULL);
+
		r = pkg_deps_formula_tostring(f);
+
		ATF_REQUIRE_STREQ(r, cases[i]);
+
		free(r);
+
		pkg_deps_formula_free(f);
+
	}
+
}
+

+
ATF_TP_ADD_TCS(tp)
+
{
+
	ATF_TP_ADD_TC(tp, check_parsing);
+

+
	return (atf_no_error());
+
}