Skip to content

Commit fca8ceb

Browse files
committed
Fix windows build, using c++ std instead of c sprintf code.
1 parent 4a8abe7 commit fca8ceb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/framework/test_tapOutputter.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525

2626

2727
#include "test_tapOutputter.h"
28-
#include <stdio.h>
28+
#include <iomanip>
2929
#include <sstream>
3030

3131
namespace testsuite
@@ -102,17 +102,16 @@ void TAP::Summary( unsigned testsRun
102102
, unsigned testsFailed
103103
, std::vector<int> & failedTestsNum)
104104
{
105-
char percentage[7];
105+
std::stringstream percentage;
106106

107107
// Little data validation - otherwise sprintf can corrupt our precious stack
108108
if ( testsRun < testsFailed )
109109
testsFailed= testsRun;
110110

111111
if ( testsRun != 0 )
112-
sprintf(percentage, "%3.2f"
113-
, static_cast<float> (testsRun - testsFailed)*100 / testsRun);
112+
percentage << std::fixed <<std::setprecision(2) <<static_cast<float> (testsRun - testsFailed)*100.0 / testsRun;
114113
else
115-
strcpy(percentage, "0.00");
114+
percentage << std::fixed <<std::setprecision(2) <<(float) 0.0;
116115

117116
if ( testsFailed > 0 )
118117
{
@@ -128,7 +127,7 @@ void TAP::Summary( unsigned testsRun
128127
}
129128

130129
output << std::endl << "Failed " << testsFailed << "/" << testsRun
131-
<< ", " << percentage << "% okay" << std::endl;
130+
<< ", " << percentage.str() << "% okay" << std::endl;
132131

133132
}
134133

0 commit comments

Comments
 (0)