//---------------------------------------------------------------------- // // testFixedTypes.cc // // Synopsis: test harness // // Requirements: Must #define exactly one of the environment symbols // known to FixedTypes.h (see documentation for complete list) where // indicated below; this is consistent with the usage requirements of // the FixedTypes package // // History: // 05-Feb-1997 WEB Initial draft // 16-Apr-1997 WEB Code reviewed by FPCLTF; added these opening // comments; renamed this test program (formerly test_fixed_types.cc) // 10-Sep-1997 WEB Inserted a symbol for a default testing // environment (in place of a ? symbol); updated comment to match // 26-Nov-1997 WEB Broke out into a self-contained file (instead of // being largely contained within FixedTypes.h); updated to match // newly-compliant symbols in the package // 01-Dec-1997 WEB Improved output format // 02-Mar-1998 WEB Updated for consistency with FixedTypes v2.0 // 14-Feb-2000 WEB Remove semicolons after USING() // //---------------------------------------------------------------------- #ifndef FIXED_TYPES_ENV // Replace, if needed, the following symbol by another symbol // that better identifies your test environment: #define IRIX_5_3_GPP_2_7_2_1 #endif // FIXED_TYPES_ENV #include "ZMutility/FixedTypes.h" ZM_USING_NAMESPACE( zmfxt ) // ---------------------------------------------------------------------- #include "ZMutility/iostream" USING (std::cout) USING (std::endl) #include "ZMutility/iomanip" USING (std::setw) #define Check(type,size) \ cout << setw(2) << sizeof(type) \ << " " #type " " \ << ((sizeof(type) == size) ? "ok" : "\awrong!") \ << '\n' #define CantCheck(type,size) \ cout << setw(2) << " -" \ << " " #type " " \ << "\anot available!" \ << '\n' int main() { cout << "Testing fixed-size types in environment " << FIXED_TYPES_ENV << ":\n\n"; // ---------- // Verify signed integral types Int1, Int2, Int4, Int8: // ---------- #ifdef ZMftInt1 Check(Int1,1); #else CantCheck(Int1,1); #endif #ifdef ZMftInt2 Check(Int2,2); #else CantCheck(Int2,2); #endif #ifdef ZMftInt4 Check(Int4,4); #else CantCheck(Int4,4); #endif #ifdef ZMftInt8 Check(Int8,8); #else CantCheck(Int8,8); #endif cout << endl; // ---------- // Verify unsigned integral types UInt1, UInt2, UInt4, UInt8: // ---------- #ifdef ZMftUInt1 Check(UInt1,1); #else CantCheck(UInt1,1); #endif #ifdef ZMftUInt2 Check(UInt2,2); #else CantCheck(UInt2,2); #endif #ifdef ZMftUInt4 Check(UInt4,4); #else CantCheck(UInt4,4); #endif #ifdef ZMftUInt8 Check(UInt8,8); #else CantCheck(UInt8,8); #endif cout << endl; // ---------- // Verify floating-point types Float4, Float8, Float16: // ---------- #ifdef ZMftFloat4 Check(Float4,4); #else CantCheck(Float4,4); #endif #ifdef ZMftFloat8 Check(Float8,8); #else CantCheck(Float8,8); #endif #ifdef ZMftFloat16 Check(Float16,16); #else CantCheck(Float16,16); #endif cout << endl; // ---------- // Go home: // ---------- return 0; } // main()