The following commit has been merged in the master branch: commit bb854aa57be3642fe7d1b7e997f5899693703048 Author: Guillem Jover <guil...@debian.org> Date: Sat Feb 4 14:46:07 2012 +0100
libdpkg: Add minimal triggers test case for trig_name_is_illegal() diff --git a/lib/dpkg/test/.gitignore b/lib/dpkg/test/.gitignore index bacf610..8f56d8c 100644 --- a/lib/dpkg/test/.gitignore +++ b/lib/dpkg/test/.gitignore @@ -12,5 +12,6 @@ t-progname t-string t-subproc t-test +t-trigger t-varbuf t-version diff --git a/lib/dpkg/test/Makefile.am b/lib/dpkg/test/Makefile.am index ab85c1b..dea5bcc 100644 --- a/lib/dpkg/test/Makefile.am +++ b/lib/dpkg/test/Makefile.am @@ -28,6 +28,7 @@ check_PROGRAMS = \ t-pkginfo \ t-pkg-list \ t-pkg-queue \ + t-trigger \ t-mod-db TESTS = $(check_PROGRAMS) diff --git a/lib/dpkg/test/t-mod-db.c b/lib/dpkg/test/t-trigger.c similarity index 52% copy from lib/dpkg/test/t-mod-db.c copy to lib/dpkg/test/t-trigger.c index d3cd55d..5c8d202 100644 --- a/lib/dpkg/test/t-mod-db.c +++ b/lib/dpkg/test/t-trigger.c @@ -1,8 +1,8 @@ /* * libdpkg - Debian packaging suite library routines - * t-db.c - test database implementation + * t-trigger.c - test triggers * - * Copyright © 2011 Guillem Jover <guil...@debian.org> + * Copyright © 2012 Guillem Jover <guil...@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,36 +21,28 @@ #include <config.h> #include <compat.h> -#include <stdlib.h> - #include <dpkg/test.h> -#include <dpkg/dpkg-db.h> +#include <dpkg/triglib.h> static void -test_db_dir(void) +test_trig_name_is_illegal(void) { - char *dir; - - test_str(dpkg_db_get_dir(), ==, ADMINDIR); - - dpkg_db_set_dir("testdir"); - test_str(dpkg_db_get_dir(), ==, "testdir"); - - setenv("DPKG_ADMINDIR", "testenvdir", 1); - dpkg_db_set_dir(NULL); - test_str(dpkg_db_get_dir(), ==, "testenvdir"); - - unsetenv("DPKG_ADMINDIR"); - dpkg_db_set_dir(NULL); - test_str(dpkg_db_get_dir(), ==, ADMINDIR); - - dir = dpkg_db_get_path("testfile"); - test_str(dir, ==, ADMINDIR "/testfile"); - free(dir); + /* Test invalid trigger names. */ + test_fail(trig_name_is_illegal("") == NULL); + test_fail(trig_name_is_illegal("\a") == NULL); + test_fail(trig_name_is_illegal("\t") == NULL); + test_fail(trig_name_is_illegal("\200") == NULL); + test_fail(trig_name_is_illegal("trigger name") == NULL); + + /* Test valid trigger names. */ + test_pass(trig_name_is_illegal("TRIGGER") == NULL); + test_pass(trig_name_is_illegal("trigger") == NULL); + test_pass(trig_name_is_illegal("0123456789") == NULL); + test_pass(trig_name_is_illegal("/file/trigger") == NULL); } -static void +void test(void) { - test_db_dir(); + test_trig_name_is_illegal(); } -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org