* tests/cmp_unit_test.c: Add missing failure message.

* tests/example_unit_test.c: Likewise.
	* tests/printf_unit_test.c: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-05-30 13:54:30 +02:00
parent 941e3a6d96
commit 1c4afb6095
4 changed files with 156 additions and 146 deletions

View file

@ -1,3 +1,9 @@
2012-05-30 Vladimir Serbinenko <phcoder@gmail.com>
* tests/cmp_unit_test.c: Add missing failure message.
* tests/example_unit_test.c: Likewise.
* tests/printf_unit_test.c: Likewise.
2012-05-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/gptsync.c (grub_cmd_gptsync): Propagate the

View file

@ -23,6 +23,8 @@
GRUB_MOD_LICENSE ("GPLv3+");
#define MSG "cmp test failed"
/* Functional test main method. */
static void
cmp_test (void)
@ -31,193 +33,193 @@ cmp_test (void)
const char *s2 = "aa";
const char *s3 = "â";
grub_test_assert (grub_strlen (s1) == 1);
grub_test_assert (grub_strlen (s2) == 2);
grub_test_assert (grub_strlen (s3) == 2);
grub_test_assert (grub_strlen (s1) == 1, MSG);
grub_test_assert (grub_strlen (s2) == 2, MSG);
grub_test_assert (grub_strlen (s3) == 2, MSG);
grub_test_assert (grub_strcmp (s1, s1) == 0);
grub_test_assert (grub_strcmp (s1, s2) < 0);
grub_test_assert (grub_strcmp (s1, s3) < 0);
grub_test_assert (grub_strcmp (s1, s1) == 0, MSG);
grub_test_assert (grub_strcmp (s1, s2) < 0, MSG);
grub_test_assert (grub_strcmp (s1, s3) < 0, MSG);
grub_test_assert (grub_strcmp (s2, s1) > 0);
grub_test_assert (grub_strcmp (s2, s2) == 0);
grub_test_assert (grub_strcmp (s2, s3) < 0);
grub_test_assert (grub_strcmp (s2, s1) > 0, MSG);
grub_test_assert (grub_strcmp (s2, s2) == 0, MSG);
grub_test_assert (grub_strcmp (s2, s3) < 0, MSG);
grub_test_assert (grub_strcmp (s3, s1) > 0);
grub_test_assert (grub_strcmp (s3, s2) > 0);
grub_test_assert (grub_strcmp (s3, s3) == 0);
grub_test_assert (grub_strcmp (s3, s1) > 0, MSG);
grub_test_assert (grub_strcmp (s3, s2) > 0, MSG);
grub_test_assert (grub_strcmp (s3, s3) == 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s1) == 0);
grub_test_assert (grub_strcasecmp (s1, s2) < 0);
grub_test_assert (grub_strcasecmp (s1, s3) < 0);
grub_test_assert (grub_strcasecmp (s1, s1) == 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s2) < 0, MSG);
grub_test_assert (grub_strcasecmp (s1, s3) < 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s1) > 0);
grub_test_assert (grub_strcasecmp (s2, s2) == 0);
grub_test_assert (grub_strcasecmp (s2, s3) < 0);
grub_test_assert (grub_strcasecmp (s2, s1) > 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s2) == 0, MSG);
grub_test_assert (grub_strcasecmp (s2, s3) < 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s1) > 0);
grub_test_assert (grub_strcasecmp (s3, s2) > 0);
grub_test_assert (grub_strcasecmp (s3, s3) == 0);
grub_test_assert (grub_strcasecmp (s3, s1) > 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s2) > 0, MSG);
grub_test_assert (grub_strcasecmp (s3, s3) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s1, 2) == 0);
grub_test_assert (grub_memcmp (s1, s2, 2) < 0);
grub_test_assert (grub_memcmp (s1, s3, 2) < 0);
grub_test_assert (grub_memcmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s2, s1, 2) > 0);
grub_test_assert (grub_memcmp (s2, s2, 2) == 0);
grub_test_assert (grub_memcmp (s2, s3, 2) < 0);
grub_test_assert (grub_memcmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_memcmp (s3, s1, 2) > 0);
grub_test_assert (grub_memcmp (s3, s2, 2) > 0);
grub_test_assert (grub_memcmp (s3, s3, 2) == 0);
grub_test_assert (grub_memcmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s1, 1) == 0);
grub_test_assert (grub_memcmp (s1, s2, 1) == 0);
grub_test_assert (grub_memcmp (s1, s3, 1) < 0);
grub_test_assert (grub_memcmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_memcmp (s2, s1, 1) == 0);
grub_test_assert (grub_memcmp (s2, s2, 1) == 0);
grub_test_assert (grub_memcmp (s2, s3, 1) < 0);
grub_test_assert (grub_memcmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_memcmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_memcmp (s3, s1, 1) > 0);
grub_test_assert (grub_memcmp (s3, s2, 1) > 0);
grub_test_assert (grub_memcmp (s3, s3, 1) == 0);
grub_test_assert (grub_memcmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_memcmp (s3, s3, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s1, 2) == 0);
grub_test_assert (grub_strncmp (s1, s2, 2) < 0);
grub_test_assert (grub_strncmp (s1, s3, 2) < 0);
grub_test_assert (grub_strncmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s2, s1, 2) > 0);
grub_test_assert (grub_strncmp (s2, s2, 2) == 0);
grub_test_assert (grub_strncmp (s2, s3, 2) < 0);
grub_test_assert (grub_strncmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_strncmp (s3, s1, 2) > 0);
grub_test_assert (grub_strncmp (s3, s2, 2) > 0);
grub_test_assert (grub_strncmp (s3, s3, 2) == 0);
grub_test_assert (grub_strncmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s1, 1) == 0);
grub_test_assert (grub_strncmp (s1, s2, 1) == 0);
grub_test_assert (grub_strncmp (s1, s3, 1) < 0);
grub_test_assert (grub_strncmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_strncmp (s2, s1, 1) == 0);
grub_test_assert (grub_strncmp (s2, s2, 1) == 0);
grub_test_assert (grub_strncmp (s2, s3, 1) < 0);
grub_test_assert (grub_strncmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_strncmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_strncmp (s3, s1, 1) > 0);
grub_test_assert (grub_strncmp (s3, s2, 1) > 0);
grub_test_assert (grub_strncmp (s3, s3, 1) == 0);
grub_test_assert (grub_strncmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_strncmp (s3, s3, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s1, 2) == 0);
grub_test_assert (grub_strncasecmp (s1, s2, 2) < 0);
grub_test_assert (grub_strncasecmp (s1, s3, 2) < 0);
grub_test_assert (grub_strncasecmp (s1, s1, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s2, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s3, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s1, 2) > 0);
grub_test_assert (grub_strncasecmp (s2, s2, 2) == 0);
grub_test_assert (grub_strncasecmp (s2, s3, 2) < 0);
grub_test_assert (grub_strncasecmp (s2, s1, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s2, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s3, 2) < 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s1, 2) > 0);
grub_test_assert (grub_strncasecmp (s3, s2, 2) > 0);
grub_test_assert (grub_strncasecmp (s3, s3, 2) == 0);
grub_test_assert (grub_strncasecmp (s3, s1, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s2, 2) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s3, 2) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s1, 1) == 0);
grub_test_assert (grub_strncasecmp (s1, s2, 1) == 0);
grub_test_assert (grub_strncasecmp (s1, s3, 1) < 0);
grub_test_assert (grub_strncasecmp (s1, s1, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s2, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s1, s3, 1) < 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s1, 1) == 0);
grub_test_assert (grub_strncasecmp (s2, s2, 1) == 0);
grub_test_assert (grub_strncasecmp (s2, s3, 1) < 0);
grub_test_assert (grub_strncasecmp (s2, s1, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s2, 1) == 0, MSG);
grub_test_assert (grub_strncasecmp (s2, s3, 1) < 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s1, 1) > 0);
grub_test_assert (grub_strncasecmp (s3, s2, 1) > 0);
grub_test_assert (grub_strncasecmp (s3, s3, 1) == 0);
grub_test_assert (grub_strncasecmp (s3, s1, 1) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s2, 1) > 0, MSG);
grub_test_assert (grub_strncasecmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strlen (s1) == 1);
grub_test_assert (strlen (s2) == 2);
grub_test_assert (strlen (s3) == 2);
grub_test_assert (strlen (s1) == 1, MSG);
grub_test_assert (strlen (s2) == 2, MSG);
grub_test_assert (strlen (s3) == 2, MSG);
grub_test_assert (strcmp (s1, s1) == 0);
grub_test_assert (strcmp (s1, s2) < 0);
grub_test_assert (strcmp (s1, s3) < 0);
grub_test_assert (strcmp (s1, s1) == 0, MSG);
grub_test_assert (strcmp (s1, s2) < 0, MSG);
grub_test_assert (strcmp (s1, s3) < 0, MSG);
grub_test_assert (strcmp (s2, s1) > 0);
grub_test_assert (strcmp (s2, s2) == 0);
grub_test_assert (strcmp (s2, s3) < 0);
grub_test_assert (strcmp (s2, s1) > 0, MSG);
grub_test_assert (strcmp (s2, s2) == 0, MSG);
grub_test_assert (strcmp (s2, s3) < 0, MSG);
grub_test_assert (strcmp (s3, s1) > 0);
grub_test_assert (strcmp (s3, s2) > 0);
grub_test_assert (strcmp (s3, s3) == 0);
grub_test_assert (strcmp (s3, s1) > 0, MSG);
grub_test_assert (strcmp (s3, s2) > 0, MSG);
grub_test_assert (strcmp (s3, s3) == 0, MSG);
grub_test_assert (memcmp (s1, s1, 2) == 0);
grub_test_assert (memcmp (s1, s2, 2) < 0);
grub_test_assert (memcmp (s1, s3, 2) < 0);
grub_test_assert (memcmp (s1, s1, 2) == 0, MSG);
grub_test_assert (memcmp (s1, s2, 2) < 0, MSG);
grub_test_assert (memcmp (s1, s3, 2) < 0, MSG);
grub_test_assert (memcmp (s2, s1, 2) > 0);
grub_test_assert (memcmp (s2, s2, 2) == 0);
grub_test_assert (memcmp (s2, s3, 2) < 0);
grub_test_assert (memcmp (s2, s1, 2) > 0, MSG);
grub_test_assert (memcmp (s2, s2, 2) == 0, MSG);
grub_test_assert (memcmp (s2, s3, 2) < 0, MSG);
grub_test_assert (memcmp (s3, s1, 2) > 0);
grub_test_assert (memcmp (s3, s2, 2) > 0);
grub_test_assert (memcmp (s3, s3, 2) == 0);
grub_test_assert (memcmp (s3, s1, 2) > 0, MSG);
grub_test_assert (memcmp (s3, s2, 2) > 0, MSG);
grub_test_assert (memcmp (s3, s3, 2) == 0, MSG);
grub_test_assert (memcmp (s1, s1, 1) == 0);
grub_test_assert (memcmp (s1, s2, 1) == 0);
grub_test_assert (memcmp (s1, s3, 1) < 0);
grub_test_assert (memcmp (s1, s1, 1) == 0, MSG);
grub_test_assert (memcmp (s1, s2, 1) == 0, MSG);
grub_test_assert (memcmp (s1, s3, 1) < 0, MSG);
grub_test_assert (memcmp (s2, s1, 1) == 0);
grub_test_assert (memcmp (s2, s2, 1) == 0);
grub_test_assert (memcmp (s2, s3, 1) < 0);
grub_test_assert (memcmp (s2, s1, 1) == 0, MSG);
grub_test_assert (memcmp (s2, s2, 1) == 0, MSG);
grub_test_assert (memcmp (s2, s3, 1) < 0, MSG);
grub_test_assert (memcmp (s3, s1, 1) > 0);
grub_test_assert (memcmp (s3, s2, 1) > 0);
grub_test_assert (memcmp (s3, s3, 1) == 0);
grub_test_assert (memcmp (s3, s1, 1) > 0, MSG);
grub_test_assert (memcmp (s3, s2, 1) > 0, MSG);
grub_test_assert (memcmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s1, 2) == 0);
grub_test_assert (strncmp (s1, s2, 2) < 0);
grub_test_assert (strncmp (s1, s3, 2) < 0);
grub_test_assert (strncmp (s1, s1, 2) == 0, MSG);
grub_test_assert (strncmp (s1, s2, 2) < 0, MSG);
grub_test_assert (strncmp (s1, s3, 2) < 0, MSG);
grub_test_assert (strncmp (s2, s1, 2) > 0);
grub_test_assert (strncmp (s2, s2, 2) == 0);
grub_test_assert (strncmp (s2, s3, 2) < 0);
grub_test_assert (strncmp (s2, s1, 2) > 0, MSG);
grub_test_assert (strncmp (s2, s2, 2) == 0, MSG);
grub_test_assert (strncmp (s2, s3, 2) < 0, MSG);
grub_test_assert (strncmp (s3, s1, 2) > 0);
grub_test_assert (strncmp (s3, s2, 2) > 0);
grub_test_assert (strncmp (s3, s3, 2) == 0);
grub_test_assert (strncmp (s3, s1, 2) > 0, MSG);
grub_test_assert (strncmp (s3, s2, 2) > 0, MSG);
grub_test_assert (strncmp (s3, s3, 2) == 0, MSG);
grub_test_assert (strncmp (s1, s1, 1) == 0);
grub_test_assert (strncmp (s1, s2, 1) == 0);
grub_test_assert (strncmp (s1, s3, 1) < 0);
grub_test_assert (strncmp (s1, s1, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s2, 1) == 0, MSG);
grub_test_assert (strncmp (s1, s3, 1) < 0, MSG);
grub_test_assert (strncmp (s2, s1, 1) == 0);
grub_test_assert (strncmp (s2, s2, 1) == 0);
grub_test_assert (strncmp (s2, s3, 1) < 0);
grub_test_assert (strncmp (s2, s1, 1) == 0, MSG);
grub_test_assert (strncmp (s2, s2, 1) == 0, MSG);
grub_test_assert (strncmp (s2, s3, 1) < 0, MSG);
grub_test_assert (strncmp (s3, s1, 1) > 0);
grub_test_assert (strncmp (s3, s2, 1) > 0);
grub_test_assert (strncmp (s3, s3, 1) == 0);
grub_test_assert (strncmp (s3, s1, 1) > 0, MSG);
grub_test_assert (strncmp (s3, s2, 1) > 0, MSG);
grub_test_assert (strncmp (s3, s3, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s1, 2) == 0);
grub_test_assert (strncasecmp (s1, s2, 2) < 0);
grub_test_assert (strncasecmp (s1, s3, 2) < 0);
grub_test_assert (strncasecmp (s1, s1, 2) == 0, MSG);
grub_test_assert (strncasecmp (s1, s2, 2) < 0, MSG);
grub_test_assert (strncasecmp (s1, s3, 2) < 0, MSG);
grub_test_assert (strncasecmp (s2, s1, 2) > 0);
grub_test_assert (strncasecmp (s2, s2, 2) == 0);
grub_test_assert (strncasecmp (s2, s3, 2) < 0);
grub_test_assert (strncasecmp (s2, s1, 2) > 0, MSG);
grub_test_assert (strncasecmp (s2, s2, 2) == 0, MSG);
grub_test_assert (strncasecmp (s2, s3, 2) < 0, MSG);
grub_test_assert (strncasecmp (s3, s1, 2) > 0);
grub_test_assert (strncasecmp (s3, s2, 2) > 0);
grub_test_assert (strncasecmp (s3, s3, 2) == 0);
grub_test_assert (strncasecmp (s3, s1, 2) > 0, MSG);
grub_test_assert (strncasecmp (s3, s2, 2) > 0, MSG);
grub_test_assert (strncasecmp (s3, s3, 2) == 0, MSG);
grub_test_assert (strncasecmp (s1, s1, 1) == 0);
grub_test_assert (strncasecmp (s1, s2, 1) == 0);
grub_test_assert (strncasecmp (s1, s3, 1) < 0);
grub_test_assert (strncasecmp (s1, s1, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s2, 1) == 0, MSG);
grub_test_assert (strncasecmp (s1, s3, 1) < 0, MSG);
grub_test_assert (strncasecmp (s2, s1, 1) == 0);
grub_test_assert (strncasecmp (s2, s2, 1) == 0);
grub_test_assert (strncasecmp (s2, s3, 1) < 0);
grub_test_assert (strncasecmp (s2, s1, 1) == 0, MSG);
grub_test_assert (strncasecmp (s2, s2, 1) == 0, MSG);
grub_test_assert (strncasecmp (s2, s3, 1) < 0, MSG);
grub_test_assert (strncasecmp (s3, s1, 1) > 0);
grub_test_assert (strncasecmp (s3, s2, 1) > 0);
grub_test_assert (strncasecmp (s3, s3, 1) == 0);
grub_test_assert (strncasecmp (s3, s1, 1) > 0, MSG);
grub_test_assert (strncasecmp (s3, s2, 1) > 0, MSG);
grub_test_assert (strncasecmp (s3, s3, 1) == 0, MSG);
}
/* Register example_test method as a functional test. */

View file

@ -27,7 +27,7 @@ static void
example_test (void)
{
/* Check if 1st argument is true and report with default error message. */
grub_test_assert (1 == 1);
grub_test_assert (1 == 1, "1 equal 1 expected");
/* Check if 1st argument is true and report with custom error message. */
grub_test_assert (2 == 2, "2 equal 2 expected");

View file

@ -21,6 +21,8 @@
#include <grub/test.h>
#include <grub/misc.h>
#define MSG "printf test failed"
static void
printf_test (void)
{
@ -28,16 +30,16 @@ printf_test (void)
char expected[512];
grub_snprintf (real, sizeof (real), "%d %d %d", 1, 2, 3);
snprintf (expected, sizeof (expected), "%d %d %d", 1, 2, 3);
grub_test_assert (strcmp (real, expected) == 0);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%3$d %2$d %1$d", 1, 2, 3);
snprintf (expected, sizeof (expected), "%3$d %2$d %1$d", 1, 2, 3);
grub_test_assert (strcmp (real, expected) == 0);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%d %lld %d", 1, 2LL, 3);
snprintf (expected, sizeof (expected), "%d %lld %d", 1, 2LL, 3);
grub_test_assert (strcmp (real, expected) == 0);
grub_test_assert (strcmp (real, expected) == 0, MSG);
grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3);
snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3);
grub_test_assert (strcmp (real, expected) == 0);
grub_test_assert (strcmp (real, expected) == 0, MSG);
}
GRUB_UNIT_TEST ("printf_unit_test", printf_test);