diff --git a/alib2std/test-src/extensions/ChronoTest.cpp b/alib2std/test-src/extensions/ChronoTest.cpp index 7fef5eaeab8f6f97de94c7425bccacc6e600325d..9797999410a42a011b39cafdfc8702ec14fc1cbc 100644 --- a/alib2std/test-src/extensions/ChronoTest.cpp +++ b/alib2std/test-src/extensions/ChronoTest.cpp @@ -1,7 +1,7 @@ #include "ChronoTest.h" #include <chrono> #include <thread> - +#include <cmath> CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChronoTest, "bits" ); CPPUNIT_TEST_SUITE_REGISTRATION( ChronoTest ); @@ -53,9 +53,15 @@ void ChronoTest::testChrono2() { std::chrono::measurements::end(); std::cout << "Default print" << std::endl << std::chrono::measurements::results() << std::endl; + auto sum1 = std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]); + auto exp1 = std::get<2>(std::chrono::measurements::results()[3]); + + CPPUNIT_ASSERT(std::abs(sum1.count() - exp1.count()) < 2000); + + auto sum2 = std::get<3>(std::chrono::measurements::results()[0]) + std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]) + std::get<3>(std::chrono::measurements::results()[4]) + std::get<3>(std::chrono::measurements::results()[5]); + auto exp2 = std::get<2>(std::chrono::measurements::results()[6]); - CPPUNIT_ASSERT((std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]))/1000 == std::get<2>(std::chrono::measurements::results()[3])/1000); - CPPUNIT_ASSERT((std::get<3>(std::chrono::measurements::results()[0]) + std::get<3>(std::chrono::measurements::results()[1]) + std::get<3>(std::chrono::measurements::results()[2]) + std::get<3>(std::chrono::measurements::results()[3]) + std::get<3>(std::chrono::measurements::results()[4]) + std::get<3>(std::chrono::measurements::results()[5]))/1000 == std::get<2>(std::chrono::measurements::results()[6])/1000); + CPPUNIT_ASSERT(std::abs(sum2.count() - exp2.count()) < 2000); std::cout << "Tree print" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::results() << std::endl; std::cout << "Tree print none" << std::endl << std::chrono::measurements::Format::TREE << std::chrono::measurements::Filter::NONE << std::chrono::measurements::results() << std::endl;