Skip to content

Commit 8f747fa

Browse files
committed
gcc/linux compile/tests
1 parent f70ac1c commit 8f747fa

5 files changed

Lines changed: 83 additions & 63 deletions

File tree

CppUnit/include/CppUnit/TestCase.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class CppUnit_API TestCase: public Test
103103
protected:
104104
virtual void runTest();
105105
TestResult* defaultResult();
106-
106+
107107
void assertImplementation(bool condition,
108108
const std::string& conditionExpression = "",
109109
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
@@ -158,10 +158,15 @@ class CppUnit_API TestCase: public Test
158158
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
159159
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
160160

161-
void fail(const std::string&message = "",
161+
void fail(const std::string& message = "",
162162
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
163163
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
164164

165+
void warn(const std::string& message = "",
166+
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
167+
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
168+
169+
165170
private:
166171
const std::string _name;
167172
};

CppUnit/src/TestCase.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "CppUnit/TestResult.h"
1212
#include "CppUnit/estring.h"
1313
#include <typeinfo>
14+
#include <iostream>
1415

1516

1617
using namespace std;
@@ -94,12 +95,18 @@ void TestCase::assertNull(const void* pointer, const std::string& pointerExpress
9495
}
9596

9697

97-
void TestCase::fail (const std::string& message, long lineNumber, const std::string& fileName)
98+
void TestCase::fail(const std::string& message, long lineNumber, const std::string& fileName)
9899
{
99100
throw CppUnitException(std::string("fail: ") + message, lineNumber, fileName);
100101
}
101102

102103

104+
void TestCase::warn(const std::string& message, long lineNumber, const std::string& fileName)
105+
{
106+
std::cout << "Warning [" << fileName << ':' << lineNumber << "]: " << message << std::endl;
107+
}
108+
109+
103110
// Run the test and catch any exceptions that are triggered by it
104111
void TestCase::run(TestResult *result)
105112
{

Foundation/include/Poco/NumericString.h

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,36 @@
5050
#endif
5151
#include <limits>
5252
#include <cmath>
53+
#include <locale>
5354

5455

5556
namespace Poco {
5657

5758

59+
inline char decimalSeparator()
60+
/// Returns decimal separator from global locale or
61+
/// default '.' for platforms where locale is unavailable.
62+
{
63+
#if !defined(POCO_NO_LOCALE)
64+
return std::use_facet<std::numpunct<char> >(std::locale()).decimal_point();
65+
#else
66+
return '.';
67+
#endif
68+
}
69+
70+
71+
inline char thousandSeparator()
72+
/// Returns thousand separator from global locale or
73+
/// default ',' for platforms where locale is unavailable.
74+
{
75+
#if !defined(POCO_NO_LOCALE)
76+
return std::use_facet<std::numpunct<char> >(std::locale()).thousands_sep();
77+
#else
78+
return ',';
79+
#endif
80+
}
81+
82+
5883
template <typename I>
5984
bool strToInt(const char* pStr, I& result, short base = -1)
6085
/// Converts zero-terminated array to integer number;
@@ -71,7 +96,7 @@ bool strToInt(const char* pStr, I& result, short base = -1)
7196
if (!pStr || (pStr && *pStr == '\0')) return false;
7297
while ((*pStr != '\0') && (*pStr == ' ')) ++pStr;
7398
if (*pStr == '\0') return false;
74-
99+
75100
char sign = 1;
76101

77102
if (*pStr == '-')
@@ -92,7 +117,7 @@ bool strToInt(const char* pStr, I& result, short base = -1)
92117
result = 0;
93118
return true;
94119
}
95-
120+
96121
if ((*pStr == 'x') || (*pStr == 'X'))
97122
{
98123
base = 0x10;
@@ -129,7 +154,7 @@ bool strToInt(const char* pStr, I& result, short base = -1)
129154
}
130155
else return false;
131156
break;
132-
157+
133158
case '8': case '9':
134159
if (allowDigits && (base == 10 || base == 16))
135160
{
@@ -199,30 +224,6 @@ bool strToInt(const std::string& str, I& result, short base = -1)
199224
}
200225

201226

202-
inline char decimalSeparator()
203-
/// Returns decimal separator from global locale or
204-
/// default '.' for platforms where locale is unavailable.
205-
{
206-
#if !defined(POCO_NO_LOCALE)
207-
return std::use_facet<std::numpunct<char> >(std::locale()).decimal_point();
208-
#else
209-
return '.';
210-
#endif
211-
}
212-
213-
214-
inline char thousandSeparator()
215-
/// Returns thousand separator from global locale or
216-
/// default ',' for platforms where locale is unavailable.
217-
{
218-
#if !defined(POCO_NO_LOCALE)
219-
return std::use_facet<std::numpunct<char> >(std::locale()).thousands_sep();
220-
#else
221-
return ',';
222-
#endif
223-
}
224-
225-
226227
#ifndef POCO_NO_FPENVIRONMENT
227228

228229
namespace {

Foundation/testsuite/src/NumberParserTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "Poco/Stopwatch.h"
4242
#include <iostream>
4343
#include <iomanip>
44+
#include <cstdio>
4445

4546

4647
using Poco::NumberParser;

Foundation/testsuite/src/StringTest.cpp

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "Poco/Stopwatch.h"
4040
#include <iostream>
4141
#include <iomanip>
42+
#include <cstdio>
4243

4344

4445
using Poco::trimLeft;
@@ -527,39 +528,44 @@ void StringTest::testStringToFloatError()
527528
void StringTest::testNumericLocale()
528529
{
529530
#if !defined(POCO_NO_LOCALE)
530-
char dp = decimalSeparator();
531-
char ts = thousandSeparator();
532-
std::locale loc;
533-
std::cout << "Original locale: '" << loc.c_str() << '\'' << std::endl;
534-
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
535-
std::cout << "Thousand separator: '" << ts << '\'' << std::endl;
536-
537-
std::locale::global(std::locale("German"));
538-
std::locale locGerman;
539-
assert (',' == decimalSeparator());
540-
assert ('.' == thousandSeparator());
541-
std::cout << "New locale: '" << locGerman.c_str() << '\'' << std::endl;
542-
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
543-
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
544-
545-
std::locale::global(std::locale("US"));
546-
std::locale locUS;
547-
assert ('.' == decimalSeparator());
548-
assert (',' == thousandSeparator());
549-
std::cout << "New locale: '" << locUS.c_str() << '\'' << std::endl;
550-
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
551-
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
552-
553-
std::locale::global(loc);
554-
dp = decimalSeparator();
555-
ts = thousandSeparator();
556-
std::cout << "Final locale: '" << loc.c_str() << '\'' << std::endl;
557-
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
558-
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
559-
assert (dp == decimalSeparator());
560-
assert (ts == thousandSeparator());
561-
#else
562-
std::cout << "No locale available, skipping." << std::endl;
531+
try
532+
{
533+
char dp = decimalSeparator();
534+
char ts = thousandSeparator();
535+
std::locale loc;
536+
std::cout << "Original locale: '" << loc.name() << '\'' << std::endl;
537+
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
538+
std::cout << "Thousand separator: '" << ts << '\'' << std::endl;
539+
540+
std::locale::global(std::locale("German"));
541+
std::locale locGerman;
542+
assert (',' == decimalSeparator());
543+
assert ('.' == thousandSeparator());
544+
std::cout << "New locale: '" << locGerman.name() << '\'' << std::endl;
545+
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
546+
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
547+
548+
std::locale::global(std::locale("US"));
549+
std::locale locUS;
550+
assert ('.' == decimalSeparator());
551+
assert (',' == thousandSeparator());
552+
std::cout << "New locale: '" << locUS.name() << '\'' << std::endl;
553+
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
554+
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
555+
556+
std::locale::global(loc);
557+
dp = decimalSeparator();
558+
ts = thousandSeparator();
559+
std::cout << "Final locale: '" << loc.name() << '\'' << std::endl;
560+
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
561+
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
562+
assert (dp == decimalSeparator());
563+
assert (ts == thousandSeparator());
564+
} catch (std::runtime_error& ex)
565+
{
566+
std::cout << ex.what() << std::endl;
567+
warn ("Locale not found, skipping test");
568+
}
563569
#endif
564570
}
565571

0 commit comments

Comments
 (0)