xref: /haiku/headers/tools/cppunit/cppunit/Portability.h (revision dcaf47fd7f841f728dd0973306e0f07128726c89)
1 #ifndef CPPUNIT_PORTABILITY_H
2 #define CPPUNIT_PORTABILITY_H
3 
4 /* include platform specific config */
5 #if defined(__BORLANDC__)
6 #    include <cppunit/config-bcb5.h>
7 #elif defined (_MSC_VER)
8 #    include <cppunit/config-msvc6.h>
9 #else
10 #    include <cppunit/config-auto.h>
11 #endif
12 
13 
14 /* Options that the library user may switch on or off.
15  * If the user has not done so, we chose default values.
16  */
17 
18 
19 #if defined(__POWERPC__) && (defined(__BEOS__) || defined(__HAIKU__))
20 #define CPPUNIT_HAVE_SSTREAM 1
21 #undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
22 #endif
23 
24 #if __GNUC__ > 2
25 #undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
26 #endif
27 
28 /* Define to 1 if you wish to have the old-style macros
29    assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
30 #ifndef CPPUNIT_ENABLE_NAKED_ASSERT
31 #define CPPUNIT_ENABLE_NAKED_ASSERT          0
32 #endif
33 
34 /* Define to 1 if you wish to have the old-style CU_TEST family
35    of macros. */
36 #ifndef CPPUNIT_ENABLE_CU_TEST_MACROS
37 #define CPPUNIT_ENABLE_CU_TEST_MACROS        0
38 #endif
39 
40 /* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
41    I don't think there is any C preprocess that does NOT support this! */
42 #ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION
43 #define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION   1
44 #endif
45 
46 // CPPUNIT_API is defined in <config_msvc6.h> if required (building or using as dll)
47 #ifndef CPPUNIT_API
48 #	ifdef BUILDING_CPPUNIT
49 #		define CPPUNIT_API	_EXPORT
50 #	else
51 #		define CPPUNIT_API	_IMPORT
52 #	endif
53 #undef CPPUNIT_NEED_DLL_DECL
54 #define CPPUNIT_NEED_DLL_DECL 0
55 #endif
56 
57 
58 /* perform portability hacks */
59 
60 
61 /* Define CPPUNIT_SSTREAM as a stream with a "string str()"
62  * method.
63  */
64 #if CPPUNIT_HAVE_SSTREAM
65 #   include <sstream>
66     namespace CppUnit {
67       class OStringStream : public std::ostringstream
68       {
69       };
70     }
71 #else
72 #if CPPUNIT_HAVE_CLASS_STRSTREAM
73 #   include <string>
74 #   if CPPUNIT_HAVE_STRSTREAM
75 #       include <strstream>
76 #   else
77 #       include <strstream.h>
78 #   endif
79 
80     namespace CppUnit {
81       class OStringStream : public std::ostrstream
82       {
83       public:
str()84           std::string str()
85           {
86             (*this) << '\0';
87             std::string msg(std::ostrstream::str());
88             std::ostrstream::freeze(false);
89             return msg;
90           }
91       };
92     }
93 #else
94 #   error Cannot define CppUnit::OStringStream.
95 #endif
96 #endif
97 
98 #endif // CPPUNIT_PORTABILITY_H
99