• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  ptstutils.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef PTSTUTILS_H
21 #define PTSTUTILS_H
22 
23 
24 
25 #include "pstdio.h"
26 
27 #ifdef ASSERT
28 #undef ASSERT
29 #endif
30 
31 /**
32  * Macros defined to facilitate the writing of test programs.
33  * That's why they are not dependent on any compile-time flag.
34  */
35 #define ASSERT(x) \
36   do { \
37     if (!(x)) \
38     { \
39       pfprintf(PSTDERR, L(__FILE__ "(%d): " #x " failed: aborting.\n"), __LINE__); \
40       exit(-1); \
41     } \
42   } \
43   while(0)
44 
45 #define ESR_ASSERT(x) \
46   do { \
47     if ((x) != ESR_SUCCESS) \
48     { \
49       pfprintf(PSTDERR, L(__FILE__ "(%d): " #x " failed: aborting.\n"), __LINE__); \
50       exit(-1); \
51     } \
52   } \
53   while(0)
54 
55 #define ASSERT2(x, count) \
56   do { \
57     if (!(x)) \
58     { \
59       pfprintf(PSTDERR, L(__FILE__ "(%d): " #x " failed.\n"), __LINE__); \
60       ++count; \
61     } \
62   } \
63   while(0)
64 
65 #endif
66