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