• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VCM_TEST_MACROS_H
12 #define VCM_TEST_MACROS_H
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 
17 extern int vcmMacrosTests;
18 extern int vcmMacrosErrors;
19 
20 #define PRINT_ERR_MSG(msg)                              \
21     do {                                                \
22         fprintf(stderr, "Error at line %i of %s\n%s",   \
23             __LINE__, __FILE__, msg);                   \
24     } while(0)
25 
26 #define TEST(expr)                                              \
27     do {                                                        \
28         vcmMacrosTests++;                                       \
29         if (!(expr)) {                                          \
30             PRINT_ERR_MSG("Assertion failed: " #expr "\n\n");   \
31             vcmMacrosErrors++;                                  \
32         }                                                       \
33     } while(0)
34 
35 #define TEST_EXIT_ON_FAIL(expr)                                             \
36     do {                                                                    \
37         vcmMacrosTests++;                                                   \
38         if (!(expr)) {                                                      \
39             PRINT_ERR_MSG("Assertion failed: " #expr "\nExiting...\n\n");   \
40             vcmMacrosErrors++;                                              \
41             exit(EXIT_FAILURE);                                             \
42         }                                                                   \
43     } while(0)
44 
45 #endif
46