From 7f48313225537a7bcc92c0f1c73754bdc50a2ca4 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Tue, 8 Apr 2003 10:57:30 -0400 Subject: Remove nan and inf, use iostreams to set precision, fix file name, and remove bogus files --- Source/cmCTest.cxx | 42 +++++++++++++++++++++++++++++------------- Source/cmCTest.h | 2 ++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c5cfda8..dcd6e3a 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -26,6 +26,9 @@ #include #include +#include + +#define FIXNUM(x) ((isnan(x))?((0)):((isinf(x))?(0):(x))) #ifdef HAVE_CURL static struct tm* GetNightlyTime(std::string str) @@ -1319,8 +1322,10 @@ int cmCTest::CoverageDirectory() { //std::cerr << "Compare -- " << cov.m_FullPath << std::endl; //std::cerr << " -- " << src_dir << std::endl; + cov.m_Show = false; continue; } + cov.m_Show = true; } for ( cc = 0; cc < lines.size(); cc ++ ) { @@ -1362,6 +1367,11 @@ int cmCTest::CoverageDirectory() std::string local_end_time; for ( cit = coverageresults.begin(); cit != coverageresults.end(); cit ++ ) { + cmCTest::cmCTestCoverage &cov = cit->second; + if ( !cov.m_Show ) + { + continue; + } if ( ccount == 100 ) { local_end_time = ::CurrentTime(); @@ -1392,7 +1402,6 @@ int cmCTest::CoverageDirectory() } //std::cerr << "Final process of Source file: " << cit->first << std::endl; - cmCTest::cmCTestCoverage &cov = cit->second; std::ifstream ifile(cov.m_AbsolutePath.c_str()); @@ -1411,7 +1420,7 @@ int cmCTest::CoverageDirectory() cmSystemTools::Split(buffer, lines); delete [] buffer; cfileoutput << "\tfirst << "\" FullPath=\"" - << cov.m_FullPath << std::endl << "\">\n" + << cov.m_FullPath << "\">\n" << "\t\t" << std::endl; for ( cc = 0; cc < lines.size(); cc ++ ) { @@ -1428,24 +1437,26 @@ int cmCTest::CoverageDirectory() total_untested += cov.m_UnTested; float cper = 0; float cmet = 0; - if ( total_tested + total_untested > 0 ) + if ( total_tested + total_untested > 0 && (cov.m_Tested + cov.m_UnTested) > 0) { cper = (100 * static_cast(cov.m_Tested)/ static_cast(cov.m_Tested + cov.m_UnTested)); cmet = ( static_cast(cov.m_Tested + 10) / static_cast(cov.m_Tested + cov.m_UnTested + 10)); } - char cmbuff[100]; - char cpbuff[100]; - sprintf(cmbuff, "%.2f", cmet); - sprintf(cpbuff, "%.2f", cper); log << "\tfirst << "\" FullPath=\"" << cov.m_FullPath << "\" Covered=\"" << (cmet>0?"true":"false") << "\">\n" << "\t\t" << cov.m_Tested << "\n" << "\t\t" << cov.m_UnTested << "\n" - << "\t\t" << cpbuff << "\n" - << "\t\t" << cmbuff << "\n" + << "\t\t"; + log.setf(std::ios::fixed, std::ios::floatfield); + log.precision(2); + log << FIXNUM(cper) << "\n" + << "\t\t"; + log.setf(std::ios::fixed, std::ios::floatfield); + log.precision(2); + log << FIXNUM(cmet) << "\n" << "\t" << std::endl; ccount ++; } @@ -1468,13 +1479,14 @@ int cmCTest::CoverageDirectory() } std::string end_time = ::CurrentTime(); - char buffer[100]; - sprintf(buffer, "%.2f", percent_coverage); log << "\t" << total_tested << "\n" << "\t" << total_untested << "\n" << "\t" << total_lines << "\n" - << "\t" << buffer << "\n" + << "\t"; + log.setf(std::ios::fixed, std::ios::floatfield); + log.precision(2); + log << FIXNUM(percent_coverage)<< "\n" << "\t" << end_time << "\n" << "\n" << "" << std::endl; @@ -1482,7 +1494,11 @@ int cmCTest::CoverageDirectory() std::cout << "\tCovered LOC: " << total_tested << std::endl << "\tNot covered LOC: " << total_untested << std::endl << "\tTotal LOC: " << total_lines << std::endl - << "\tPercentage Coverage: " << percent_coverage << "%" << std::endl; + << "\tPercentage Coverage: "; + + std::cout.setf(std::ios::fixed, std::ios::floatfield); + std::cout.precision(2); + std::cout << FIXNUM(percent_coverage) << "%" << std::endl; return 1; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 8ab2aa9..926d5de 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -181,6 +181,7 @@ private: m_Tested = 0; m_UnTested = 0; m_Lines.clear(); + m_Show = false; } std::string m_AbsolutePath; std::string m_FullPath; @@ -188,6 +189,7 @@ private: int m_Tested; int m_UnTested; std::vector m_Lines; + bool m_Show; }; typedef std::vector tm_TestResultsVector; -- cgit v0.12