Skip to content
Snippets Groups Projects
Commit 030fd0a4 authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

test: drop ok/is/isnt message from unit/xmalloc test

Just to demonstrate that the format argument of ok/is/isnt macros is now
optional.

NO_DOC=test
NO_CHANGELOG=test

(cherry picked from commit e13f2bf5)
parent 209a6c78
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ test_xmalloc(void) ...@@ -12,7 +12,7 @@ test_xmalloc(void)
plan(1); plan(1);
const int size = 9000; const int size = 9000;
char *p = xmalloc(size); char *p = xmalloc(size);
isnt(p, NULL, "p != NULL"); isnt(p, NULL);
if (p != NULL) { if (p != NULL) {
memset(p, 'x', size); memset(p, 'x', size);
free(p); free(p);
...@@ -29,14 +29,14 @@ test_xcalloc(void) ...@@ -29,14 +29,14 @@ test_xcalloc(void)
const int nmemb = 42; const int nmemb = 42;
const int size = 9000; const int size = 9000;
char *p = xcalloc(nmemb, size); char *p = xcalloc(nmemb, size);
isnt(p, NULL, "p != NULL"); isnt(p, NULL);
if (p != NULL) { if (p != NULL) {
bool is_zeroed = true; bool is_zeroed = true;
for (int i = 0; i < nmemb * size && is_zeroed; i++) { for (int i = 0; i < nmemb * size && is_zeroed; i++) {
if (p[i] != 0) if (p[i] != 0)
is_zeroed = false; is_zeroed = false;
} }
ok(is_zeroed, "p is zeroed"); ok(is_zeroed);
free(p); free(p);
} }
check_plan(); check_plan();
...@@ -50,18 +50,18 @@ test_xrealloc(void) ...@@ -50,18 +50,18 @@ test_xrealloc(void)
plan(3); plan(3);
const int size = 9000; const int size = 9000;
char *p = xrealloc(NULL, size); char *p = xrealloc(NULL, size);
isnt(p, NULL, "p != NULL on alloc"); isnt(p, NULL);
if (p != NULL) if (p != NULL)
memset(p, 'x', size); memset(p, 'x', size);
p = xrealloc(p, size * 2); p = xrealloc(p, size * 2);
isnt(p, NULL, "p != NULL on realloc"); isnt(p, NULL);
if (p != NULL) { if (p != NULL) {
bool is_same = true; bool is_same = true;
for (int i = 0; i < size && is_same; i++) { for (int i = 0; i < size && is_same; i++) {
if (p[i] != 'x') if (p[i] != 'x')
is_same = false; is_same = false;
} }
ok(is_same, "p is same after realloc"); ok(is_same);
memset(p, 'x', size * 2); memset(p, 'x', size * 2);
free(p); free(p);
} }
...@@ -76,14 +76,14 @@ test_xstrdup(void) ...@@ -76,14 +76,14 @@ test_xstrdup(void)
plan(3); plan(3);
const int size = 9000; const int size = 9000;
char *s = xmalloc(size); char *s = xmalloc(size);
isnt(s, NULL, "s != NULL"); isnt(s, NULL);
if (s != NULL) { if (s != NULL) {
memset(s, 'x', size); memset(s, 'x', size);
s[size - 1] = 0; s[size - 1] = 0;
char *copy = xstrdup(s); char *copy = xstrdup(s);
isnt(copy, NULL, "copy != NULL"); isnt(copy, NULL);
if (copy != NULL) { if (copy != NULL) {
is(strcmp(s, copy), 0, "strcmp(s, copy) == 0"); is(strcmp(s, copy), 0);
free(copy); free(copy);
} }
free(s); free(s);
...@@ -100,18 +100,17 @@ test_xstrndup(void) ...@@ -100,18 +100,17 @@ test_xstrndup(void)
const int size = 9000; const int size = 9000;
const int n = size / 2; const int n = size / 2;
char *s = xmalloc(size); char *s = xmalloc(size);
isnt(s, NULL, "s != NULL"); isnt(s, NULL);
if (s != NULL) { if (s != NULL) {
memset(s, 'x', size); memset(s, 'x', size);
s[size - 1] = 0; s[size - 1] = 0;
char *copy = xstrndup(s, n); char *copy = xstrndup(s, n);
isnt(copy, NULL, "copy != NULL"); isnt(copy, NULL);
if (copy != NULL) { if (copy != NULL) {
is(strlen(copy), (size_t)n, "strlen(copy) == n"); is(strlen(copy), (size_t)n);
is(strncmp(s, copy, n), 0, "strncmp(s, copy, n) == 0"); is(strncmp(s, copy, n), 0);
ok(strncmp(s, copy, n + 1) > 0, ok(strncmp(s, copy, n + 1) > 0);
"strncmp(s, copy, n + 1) > 0"); ok(strcmp(s, copy) > 0);
ok(strcmp(s, copy) > 0, "strcmp(s, copy) > 0");
free(copy); free(copy);
} }
free(s); free(s);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment