summaryrefslogtreecommitdiff
path: root/test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test.cc')
-rw-r--r--test.cc35
1 files changed, 14 insertions, 21 deletions
diff --git a/test.cc b/test.cc
index b25ff2d..b008006 100644
--- a/test.cc
+++ b/test.cc
@@ -157,7 +157,7 @@ static_assert(::zp::maxval<long unsigned>::val == ::std::numeric_limits<lon
static_assert(::zp::maxval<long long unsigned>::val == ::std::numeric_limits<long long unsigned>::max());
static_assert(::zp::maxval<wchar_t>::val == ::std::numeric_limits<wchar_t>::max());
-template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int unsigned & numerr,long const ln,ltyp const & lvalref,rtyp const & rvalref) noexcept {
+template<typename ltyp,typename rtyp> static auto cmp(int unsigned & numerr,long const ln,ltyp const & lvalref,rtyp const & rvalref) noexcept {
char const * const ltypnm = typeid (ltyp).name();
char const * const rtypnm = typeid (rtyp).name();
@@ -172,10 +172,10 @@ template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int uns
auto const lval = getval(lvalref);
auto const rval = getval(rvalref);
- ::std::cout << " " << num++ << ". comparing " << ltypnm << " (" << lval << ") vs. " << rtypnm << " (" << rval << ")... ";
+ ::std::cout << " " << ln << ". comparing " << ltypnm << " (" << lval << ") vs. " << rtypnm << " (" << rval << ")... ";
if (lval != rval) {
- ::std::cout << "\x1B[38;5;161munequal\x1B[0m (at #" << ln << ")\n";
+ ::std::cout << "\x1B[38;5;161munequal\x1B[0m\n";
//throw ::std::exception {};
++numerr;
@@ -185,16 +185,13 @@ template<typename ltyp,typename rtyp> static auto cmp(int unsigned & num,int uns
::std::cout <<"\x1B[38;5;77mequal\x1B[0m\n";
}
-#define cmp(lval,rval) (::cmp(num,numerr,__LINE__,(lval),(rval)))
+#define cmp(lval,rval) (::cmp(numerr,__LINE__,(lval),(rval)))
int main() {
- int unsigned num;
int unsigned numerr = 0x0u;
- auto const tst = [&num](char const * const cmp_eq) noexcept {
- ::std::cout <<"\n\x1B[38;5;75mtesting\x1B[0m " <<cmp_eq <<"\n\n";
-
- num = 0x0;
+ auto const tst = [](char const * const tst) noexcept {
+ ::std::cout <<"\n\x1B[38;5;75mtesting\x1B[0m " << tst <<"\n\n";
};
::std::cout <<"zp " <<::zp::ver.api <<"." <<::zp::ver.ext <<", run-time test\n";
@@ -220,7 +217,7 @@ int main() {
}();
[&] {
- tst("mathematics");
+ tst("special numbers");
::zp::f02 f02;
::zp::f04 f04;
@@ -237,8 +234,12 @@ int main() {
f02 = ::zp::inf<::zp::f02>::val;
f04 = ::zp::inf<::zp::f04>::val;
- cmp(f02 >= ::zp::maxval<::zp::f02>::val,true);
- cmp(f04 >= ::zp::maxval<::zp::f04>::val,true);
+ cmp(f02 > ::zp::maxval<::zp::f02>::val,true);
+ cmp(f04 > ::zp::maxval<::zp::f04>::val,true);
+ }();
+
+ [&] {
+ tst("mathematics");
}();
/*[&] {
@@ -286,14 +287,6 @@ int main() {
cmp(avec2.y,-0x7);
cmp(svec2.x,-0x1);
cmp(svec2.y,+0x1);
- }();
-
- [&] {
- tst("special numbers");
-
- cmp(zp_isnanf( zp_nanf), true);
- cmp(zp_isnand( zp_nand), true);
- cmp(zp_isnandl(zp_nanld),true);
}();*/
[&] {
@@ -414,5 +407,5 @@ int main() {
::std::cout <<"\nDone \u2212 " <<numerr <<" error(s)\n";
- return EXIT_SUCCESS;
+ return numerr ? EXIT_FAILURE : EXIT_SUCCESS;
}