sl@0
|
1 |
//We are including stdlib.h and stddef.h first because under MSVC
|
sl@0
|
2 |
//those headers contains a errno macro definition without the underlying value
|
sl@0
|
3 |
//definition.
|
sl@0
|
4 |
#include <stdlib.h>
|
sl@0
|
5 |
#include <stddef.h>
|
sl@0
|
6 |
|
sl@0
|
7 |
#include <errno.h>
|
sl@0
|
8 |
#include <errno.h> // not typo, check errno def/undef/redef
|
sl@0
|
9 |
|
sl@0
|
10 |
#ifndef _STLP_WCE
|
sl@0
|
11 |
|
sl@0
|
12 |
#include "cppunit/cppunit_proxy.h"
|
sl@0
|
13 |
|
sl@0
|
14 |
//
|
sl@0
|
15 |
// TestCase class
|
sl@0
|
16 |
//
|
sl@0
|
17 |
class ErrnoTest : public CPPUNIT_NS::TestCase
|
sl@0
|
18 |
{
|
sl@0
|
19 |
CPPUNIT_TEST_SUITE(ErrnoTest);
|
sl@0
|
20 |
CPPUNIT_TEST(check);
|
sl@0
|
21 |
CPPUNIT_TEST_SUITE_END();
|
sl@0
|
22 |
|
sl@0
|
23 |
protected:
|
sl@0
|
24 |
void check();
|
sl@0
|
25 |
};
|
sl@0
|
26 |
|
sl@0
|
27 |
CPPUNIT_TEST_SUITE_REGISTRATION(ErrnoTest);
|
sl@0
|
28 |
|
sl@0
|
29 |
void ErrnoTest::check()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
//We are using ERANGE as it is part of the C++ ISO (see Table 26 in section 19.3)
|
sl@0
|
32 |
//Using ERANGE improve the test as it means that the native errno.h file has really
|
sl@0
|
33 |
//been included.
|
sl@0
|
34 |
errno = ERANGE;
|
sl@0
|
35 |
|
sl@0
|
36 |
CPPUNIT_ASSERT( errno == ERANGE );
|
sl@0
|
37 |
errno = 0;
|
sl@0
|
38 |
|
sl@0
|
39 |
/* Note: in common, you can't write ::errno or std::errno,
|
sl@0
|
40 |
* due to errno in most cases is just a macro, that frequently
|
sl@0
|
41 |
* (in MT environment errno is a per-thread value) expand to something like
|
sl@0
|
42 |
* (*__errno_location()). I don't know way how masquerade such
|
sl@0
|
43 |
* things: name of macro can't include ::.
|
sl@0
|
44 |
*
|
sl@0
|
45 |
* - ptr, 2005-03-30
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
# if 0
|
sl@0
|
48 |
if ( ::errno != 0 ) {
|
sl@0
|
49 |
return 1;
|
sl@0
|
50 |
}
|
sl@0
|
51 |
if ( std::errno != 0 ) {
|
sl@0
|
52 |
return 1;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
# endif
|
sl@0
|
55 |
}
|
sl@0
|
56 |
#endif // _STLP_WCE
|