Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a minimal regression test for 3 way merge
Baptiste Daroussin committed 11 years ago
commit 578a6bf5cce68e6abbf1d5413afa308769f5c667
parent 45fa85d
3 files changed +62 -1
modified tests/Kyuafile
@@ -6,5 +6,6 @@ atf_test_program{name='pkg_validation'}
atf_test_program{name='pkg_printf'}
atf_test_program{name='plist'}
atf_test_program{name='pkg_add_dir_to_del'}
+
atf_test_program{name='merge'}

include('frontend/Kyuafile')
modified tests/Makefile.am
@@ -39,6 +39,9 @@ plist_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)
+
merge_SOURCES=	lib/merge.c
+
merge_CFLAGS=	$(PRIVATE_INCS)
+
merge_LDADD=	$(GENERIC_LDADD)

EXTRA_DIST=	frontend/png.uclin \
		frontend/sqlite3.uclin \
@@ -55,7 +58,8 @@ TESTS =
tests_programs=	pkg_printf \
		pkg_validation \
		plist \
-
		pkg_add_dir_to_del
+
		pkg_add_dir_to_del \
+
		merge
EXTRA_PROGRAMS=	$(tests_programs)
check_PROGRAMS=	$(tests_programs)
check_SCRIPTS=	frontend/pkg.sh \
added tests/lib/merge.c
@@ -0,0 +1,56 @@
+
/*-
+
 * Copyright (c) 2013 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * All rights reserved.
+
 *~
+
 * Redistribution and use in source and binary forms, with or without
+
 * modification, are permitted provided that the following conditions
+
 * are met:
+
 * 1. Redistributions of source code must retain the above copyright
+
 *    notice, this list of conditions and the following disclaimer
+
 *    in this position and unchanged.
+
 * 2. 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 THE AUTHOR(S) ``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 THE AUTHOR(S) 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 <sys/types.h>
+
#include <private/utils.h>
+
#include <sys/sbuf.h>
+

+
ATF_TC(merge);
+

+
ATF_TC_HEAD(merge, tc)
+
{
+
	atf_tc_set_md_var(tc, "descr",
+
	    "3 way merge");
+
}
+

+
ATF_TC_BODY(merge, tc)
+
{
+
	struct sbuf *b = sbuf_new_auto();
+
	char pivot[] = "test1\ntest2\n";
+
	char modified[] = "test1\n#test2\n";
+
	char new[] = "test1\ntest2\ntest3\n";
+

+
	ATF_REQUIRE_EQ(merge_3way(pivot, modified, new, b), 0);
+
	ATF_REQUIRE_STREQ(sbuf_data(b), "test1\n#test2\ntest3\n");
+
}
+

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

+
	return (atf_no_error());
+
}