bunkum

an old and silly c99 web server with some fun features
Log | Files | Refs | README

testutils.c (642B)


      1 #include <stdlib.h>
      2 #include <string.h>
      3 #include <stdio.h>
      4 
      5 #include "test.h"
      6 
      7 void assert_str_eq(char* a, char* b) {
      8     if (strcmp(a, b) != 0) {
      9         printf("(%s != %s)", a, b);
     10         exit(1);
     11     }
     12 } 
     13 
     14 void assert_size_eq(size_t a, size_t b) {
     15     if (a != b) {
     16         printf("(%zu != %zu)", a, b);
     17         exit(1);
     18     }
     19 }
     20 
     21 void assert_int_eq(int a, int b) {
     22     if (a != b) {
     23         printf("(%d != %d)", a, b);
     24         exit(1);
     25     }
     26 }
     27 
     28 void assert_float_eq(float a, float b) {
     29     if (a != b) {
     30         printf("(%f != %f)", a, b);
     31         exit(1);
     32     }
     33 }
     34 
     35 void assert_bool(bool expr) {
     36     if (!expr) {
     37         exit(1);
     38     }
     39 }