mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-25 16:13:42 +01:00
gcc/linux compile/tests
This commit is contained in:
parent
f70ac1ca07
commit
8f747fabdc
@ -162,6 +162,11 @@ protected:
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void warn(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "CppUnit/TestResult.h"
|
||||
#include "CppUnit/estring.h"
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
@ -100,6 +101,12 @@ void TestCase::fail (const std::string& message, long lineNumber, const std::str
|
||||
}
|
||||
|
||||
|
||||
void TestCase::warn(const std::string& message, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
std::cout << "Warning [" << fileName << ':' << lineNumber << "]: " << message << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// Run the test and catch any exceptions that are triggered by it
|
||||
void TestCase::run(TestResult *result)
|
||||
{
|
||||
|
@ -50,11 +50,36 @@
|
||||
#endif
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include <locale>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
inline char decimalSeparator()
|
||||
/// Returns decimal separator from global locale or
|
||||
/// default '.' for platforms where locale is unavailable.
|
||||
{
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
return std::use_facet<std::numpunct<char> >(std::locale()).decimal_point();
|
||||
#else
|
||||
return '.';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline char thousandSeparator()
|
||||
/// Returns thousand separator from global locale or
|
||||
/// default ',' for platforms where locale is unavailable.
|
||||
{
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
return std::use_facet<std::numpunct<char> >(std::locale()).thousands_sep();
|
||||
#else
|
||||
return ',';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <typename I>
|
||||
bool strToInt(const char* pStr, I& result, short base = -1)
|
||||
/// Converts zero-terminated array to integer number;
|
||||
@ -199,30 +224,6 @@ bool strToInt(const std::string& str, I& result, short base = -1)
|
||||
}
|
||||
|
||||
|
||||
inline char decimalSeparator()
|
||||
/// Returns decimal separator from global locale or
|
||||
/// default '.' for platforms where locale is unavailable.
|
||||
{
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
return std::use_facet<std::numpunct<char> >(std::locale()).decimal_point();
|
||||
#else
|
||||
return '.';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline char thousandSeparator()
|
||||
/// Returns thousand separator from global locale or
|
||||
/// default ',' for platforms where locale is unavailable.
|
||||
{
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
return std::use_facet<std::numpunct<char> >(std::locale()).thousands_sep();
|
||||
#else
|
||||
return ',';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef POCO_NO_FPENVIRONMENT
|
||||
|
||||
namespace {
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
using Poco::NumberParser;
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
using Poco::trimLeft;
|
||||
@ -527,10 +528,12 @@ void StringTest::testStringToFloatError()
|
||||
void StringTest::testNumericLocale()
|
||||
{
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
try
|
||||
{
|
||||
char dp = decimalSeparator();
|
||||
char ts = thousandSeparator();
|
||||
std::locale loc;
|
||||
std::cout << "Original locale: '" << loc.c_str() << '\'' << std::endl;
|
||||
std::cout << "Original locale: '" << loc.name() << '\'' << std::endl;
|
||||
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
|
||||
std::cout << "Thousand separator: '" << ts << '\'' << std::endl;
|
||||
|
||||
@ -538,7 +541,7 @@ void StringTest::testNumericLocale()
|
||||
std::locale locGerman;
|
||||
assert (',' == decimalSeparator());
|
||||
assert ('.' == thousandSeparator());
|
||||
std::cout << "New locale: '" << locGerman.c_str() << '\'' << std::endl;
|
||||
std::cout << "New locale: '" << locGerman.name() << '\'' << std::endl;
|
||||
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
|
||||
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
|
||||
|
||||
@ -546,20 +549,23 @@ void StringTest::testNumericLocale()
|
||||
std::locale locUS;
|
||||
assert ('.' == decimalSeparator());
|
||||
assert (',' == thousandSeparator());
|
||||
std::cout << "New locale: '" << locUS.c_str() << '\'' << std::endl;
|
||||
std::cout << "New locale: '" << locUS.name() << '\'' << std::endl;
|
||||
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
|
||||
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
|
||||
|
||||
std::locale::global(loc);
|
||||
dp = decimalSeparator();
|
||||
ts = thousandSeparator();
|
||||
std::cout << "Final locale: '" << loc.c_str() << '\'' << std::endl;
|
||||
std::cout << "Final locale: '" << loc.name() << '\'' << std::endl;
|
||||
std::cout << "Decimal point: '" << decimalSeparator() << '\'' << std::endl;
|
||||
std::cout << "Thousand separator: '" << thousandSeparator() << '\'' << std::endl;
|
||||
assert (dp == decimalSeparator());
|
||||
assert (ts == thousandSeparator());
|
||||
#else
|
||||
std::cout << "No locale available, skipping." << std::endl;
|
||||
} catch (std::runtime_error& ex)
|
||||
{
|
||||
std::cout << ex.what() << std::endl;
|
||||
warn ("Locale not found, skipping test");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user