ovni/test/unit/path.c
Rodrigo Arias c0afc79d4e Use OK() and ERR() in unit tests
Also remove prefixes and trailing new lines in err() and die()
2023-03-24 12:08:45 +00:00

36 lines
680 B
C

/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include "emu/path.h"
#include "common.h"
#include <string.h>
static void
test_underflow_trailing(void)
{
char in[] = { 'A', '/', '/', '/', '/', '\0', 'B' };
char out[] = { 'A', '/', '\0','\0','\0','\0', 'B' };
char *p = in + 2; /* ^here */
path_remove_trailing(p);
if (memcmp(in, out, sizeof(in)) != 0) {
for (size_t i = 0; i < sizeof(in); i++) {
err("i=%3d, in[i]=%02x out[i]=%02x", i,
(unsigned char) in[i],
(unsigned char) out[i]);
}
die("path mismatch");
}
err("OK");
}
int
main(void)
{
test_underflow_trailing();
return 0;
}