00001 #include "config.h" 00002 00003 #include <cassert> 00004 00005 #ifdef HAVE_LIMITS 00006 #include <limits> 00007 #endif 00008 00009 #include <limits.h> 00010 #include <float.h> 00011 00012 #include "lim.h" 00013 00014 int main(int argc, char* argv[]) 00015 { 00016 assert(max_limit<bool>() == true); 00017 assert(min_limit<bool>() == false); 00018 00019 assert(max_limit<char>() == CHAR_MAX); 00020 assert(min_limit<char>() == CHAR_MIN); 00021 00022 assert(max_limit<signed char>() == SCHAR_MAX); 00023 assert(min_limit<signed char>() == SCHAR_MIN); 00024 00025 assert(max_limit<unsigned char>() == UCHAR_MAX); 00026 assert(min_limit<unsigned char>() == 0); 00027 00028 assert(max_limit<short>() == SHRT_MAX); 00029 assert(min_limit<short>() == SHRT_MIN); 00030 00031 assert(max_limit<unsigned short>() == USHRT_MAX); 00032 assert(min_limit<unsigned short>() == 0); 00033 00034 assert(max_limit<int>() == INT_MAX); 00035 assert(min_limit<int>() == INT_MIN); 00036 00037 assert(max_limit<unsigned int>() == UINT_MAX); 00038 assert(min_limit<unsigned int>() == 0); 00039 00040 assert(max_limit<long>() == LONG_MAX); 00041 assert(min_limit<long>() == LONG_MIN); 00042 00043 assert(max_limit<unsigned long>() == ULONG_MAX); 00044 assert(min_limit<unsigned long>() == 0); 00045 00046 assert(max_limit<float>() == FLT_MAX); 00047 assert(min_limit<float>() == FLT_MIN); 00048 00049 assert(max_limit<double>() == DBL_MAX); 00050 assert(min_limit<double>() == DBL_MIN); 00051 00052 #ifdef HAVE_LIMITS 00053 assert(max_limit<bool>() == std::numeric_limits<bool>::max()); 00054 assert(min_limit<bool>() == std::numeric_limits<bool>::min()); 00055 00056 assert(max_limit<char>() == std::numeric_limits<char>::max()); 00057 assert(min_limit<char>() == std::numeric_limits<char>::min()); 00058 00059 assert(max_limit<signed char>() == std::numeric_limits<signed char>::max()); 00060 assert(min_limit<signed char>() == std::numeric_limits<signed char>::min()); 00061 00062 assert(max_limit<unsigned char>() == std::numeric_limits<unsigned char>::max()); 00063 assert(min_limit<unsigned char>() == std::numeric_limits<unsigned char>::min()); 00064 00065 assert(max_limit<short>() == std::numeric_limits<short>::max()); 00066 assert(min_limit<short>() == std::numeric_limits<short>::min()); 00067 00068 assert(max_limit<unsigned short>() == std::numeric_limits<unsigned short>::max()); 00069 assert(min_limit<unsigned short>() == std::numeric_limits<unsigned short>::min()); 00070 00071 assert(max_limit<int>() == std::numeric_limits<int>::max()); 00072 assert(min_limit<int>() == std::numeric_limits<int>::min()); 00073 00074 assert(max_limit<unsigned int>() == std::numeric_limits<unsigned int>::max()); 00075 assert(min_limit<unsigned int>() == std::numeric_limits<unsigned int>::min()); 00076 00077 assert(max_limit<long>() == std::numeric_limits<long>::max()); 00078 assert(min_limit<long>() == std::numeric_limits<long>::min()); 00079 00080 assert(max_limit<unsigned long>() == std::numeric_limits<unsigned long>::max()); 00081 assert(min_limit<unsigned long>() == std::numeric_limits<unsigned long>::min()); 00082 00083 assert(max_limit<float>() == std::numeric_limits<float>::max()); 00084 assert(min_limit<float>() == std::numeric_limits<float>::min()); 00085 00086 assert(max_limit<double>() == std::numeric_limits<double>::max()); 00087 assert(min_limit<double>() == std::numeric_limits<double>::min()); 00088 #endif 00089 00090 return(0); 00091 }