summaryrefslogtreecommitdiff
path: root/test/assert.c
blob: b252d36024c47602a3ba791b50171f2408defbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "assert.h"

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void assert(bool cond, const char *cond_str, const char *file, int line,
            const char *msg) {
  if (!cond) {
    printf("\n%s:%d: assert failed (%s): %s\n", file, line, cond_str, msg);
    raise(SIGABRT);
  }
}

void assert_streq(const char *left, const char *right, const char *file,
                  int line, const char *msg) {
  assert(strcmp(left, right) == 0, "<left string> == <right string>", file,
         line, msg);
}