PortAudio  2.0
qa_tools.h
Go to the documentation of this file.
1 
2 /*
3  * PortAudio Portable Real-Time Audio Library
4  * Latest Version at: http://www.portaudio.com
5  *
6  * Copyright (c) 1999-2010 Phil Burk and Ross Bencina
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files
10  * (the "Software"), to deal in the Software without restriction,
11  * including without limitation the rights to use, copy, modify, merge,
12  * publish, distribute, sublicense, and/or sell copies of the Software,
13  * and to permit persons to whom the Software is furnished to do so,
14  * subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 /*
29  * The text above constitutes the entire PortAudio license; however,
30  * the PortAudio community also makes the following non-binding requests:
31  *
32  * Any person wishing to distribute modifications to the Software is
33  * requested to send the modifications to the original developer so that
34  * they can be incorporated into the canonical version. It is also
35  * requested that these non-binding requests be included along with the
36  * license above.
37  */
38 
39 #ifndef _QA_TOOLS_H
40 #define _QA_TOOLS_H
41 
42 extern int g_testsPassed;
43 extern int g_testsFailed;
44 
45 #define QA_ASSERT_TRUE( message, flag ) \
46  if( !(flag) ) \
47  { \
48  printf( "%s:%d - ERROR - %s\n", __FILE__, __LINE__, message ); \
49  g_testsFailed++; \
50  goto error; \
51  } \
52  else g_testsPassed++;
53 
54 
55 #define QA_ASSERT_EQUALS( message, expected, actual ) \
56  if( ((expected) != (actual)) ) \
57  { \
58  printf( "%s:%d - ERROR - %s, expected %d, got %d\n", __FILE__, __LINE__, message, expected, actual ); \
59  g_testsFailed++; \
60  goto error; \
61  } \
62  else g_testsPassed++;
63 
64 #define QA_ASSERT_CLOSE( message, expected, actual, tolerance ) \
65  if (fabs((expected)-(actual))>(tolerance)) \
66  { \
67  printf( "%s:%d - ERROR - %s, expected %f, got %f, tol=%f\n", __FILE__, __LINE__, message, ((double)(expected)), ((double)(actual)), ((double)(tolerance)) ); \
68  g_testsFailed++; \
69  goto error; \
70  } \
71  else g_testsPassed++;
72 
73 #define QA_ASSERT_CLOSE_INT( message, expected, actual, tolerance ) \
74  if (abs((expected)-(actual))>(tolerance)) \
75  { \
76  printf( "%s:%d - ERROR - %s, expected %d, got %d, tol=%d\n", __FILE__, __LINE__, message, ((int)(expected)), ((int)(actual)), ((int)(tolerance)) ); \
77  g_testsFailed++; \
78  goto error; \
79  } \
80  else g_testsPassed++;
81 
82 
83 #endif
int g_testsPassed
Definition: paqa.c:54
int g_testsFailed
Definition: paqa.c:55