The following commit has been merged in the master branch:
commit be7a2c7829014eaec48185add2e445f2d8570055
Author: Guillem Jover <[email protected]>
Date: Wed Nov 3 07:33:08 2010 +0100
libdpkg: Improve version strict check unit test
The current test was using a single version with lots of invalid
characters, but only the first invalid character would get checked
against. Create a version per each invalid character to be tested
instead.
diff --git a/lib/dpkg/test/t-version.c b/lib/dpkg/test/t-version.c
index deb0883..cae1c89 100644
--- a/lib/dpkg/test/t-version.c
+++ b/lib/dpkg/test/t-version.c
@@ -2,7 +2,7 @@
* libdpkg - Debian packaging suite library routines
* t-version.c - test version handling
*
- * Copyright © 2009 Guillem Jover <[email protected]>
+ * Copyright © 2009-2010 Guillem Jover <[email protected]>
*
* 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,7 +21,10 @@
#include <config.h>
#include <compat.h>
+#include <stdlib.h>
+
#include <dpkg/test.h>
+#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
#define version(epoch, version, revision) \
@@ -64,6 +67,8 @@ static void
test_version_parse(void)
{
struct versionrevision a, b;
+ const char *p;
+ char *verstr;
/* Test 0 versions. */
blankversion(&a);
@@ -137,11 +142,22 @@ test_version_parse(void)
test_fail(parseversion(&a, "A:0-0") == NULL);
/* Test invalid characters in upstream version. */
- test_fail(parseversion(&a, "0:!...@$%&/|\\<>()[]{};,=*^'-0") == NULL);
+ verstr = m_strdup("0:0-0");
+ for (p = "!...@$%&/|\\<>()[]{};,_=*^'"; *p; p++) {
+ verstr[2] = *p;
+ test_fail(parseversion(&a, verstr) == NULL);
+ }
+ free(verstr);
/* Test invalid characters in revision. */
test_fail(parseversion(&a, "0:0-0:0") == NULL);
- test_fail(parseversion(&a, "0:0...@$%&/|\\<>()[]{}:;,=*^'") == NULL);
+
+ verstr = m_strdup("0:0-0");
+ for (p = "!...@$%&/|\\<>()[]{}:;,_=*^'"; *p; p++) {
+ verstr[4] = *p;
+ test_fail(parseversion(&a, verstr) == NULL);
+ }
+ free(verstr);
/* FIXME: Complete. */
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]