File: expect_string.h

package info (click to toggle)
serd 0.32.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,816 kB
  • sloc: ansic: 7,229; python: 518; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2025 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC

#ifndef SERD_TEST_EXPECT_STRING_H
#define SERD_TEST_EXPECT_STRING_H

#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

static inline bool
expect_string(const char* const actual, const char* const expected)
{
  assert(expected);
  const bool equal = actual && !strcmp(actual, expected);
  if (!equal) {
    fprintf(stderr, "Expected:\n%s\n\n", expected);
    fprintf(stderr, "Actual:\n%s\n\n", actual ? actual : "(null)");
  }
  return equal;
}

#endif // SERD_TEST_EXPECT_STRING_H