gnucash unstable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Mar 9 16:07:46 EST 2018
Updated via https://github.com/Gnucash/gnucash/commit/fbb172d0 (commit)
via https://github.com/Gnucash/gnucash/commit/c3180ab3 (commit)
from https://github.com/Gnucash/gnucash/commit/79dd7d69 (commit)
commit fbb172d09672ae059d13210ead18a7738313af4f
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Mar 9 13:04:17 2018 -0800
Bug 793900 - 2.7.5: test failure: 105 - python-bindings.
unittest_support.py is in ${CMAKE_SOURCE_DIR} for a tarball build
and ${CMAKE_BINARY_DIR} for a vcs build. Look for it rather than
assuming it's in ${CMAKE_BINARY_DIR}.
diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt
index 55285a3..93476ff 100644
--- a/bindings/python/tests/CMakeLists.txt
+++ b/bindings/python/tests/CMakeLists.txt
@@ -1,11 +1,12 @@
IF (WITH_PYTHON)
+ find_path(test_core_dir "unittest_support.py" PATHS ${CMAKE_BINARY_DIR}/common/test-core ${CMAKE_SOURCE_DIR}/common/test-core)
add_custom_target(test-python-bindings ALL DEPENDS unittest_support gnucash-core-c-build gnucash-core-c-py)
add_dependencies(check test-python-bindings)
ADD_TEST(python-bindings ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/runTests.py.in)
SET_PROPERTY(TEST python-bindings PROPERTY ENVIRONMENT
GNC_BUILDDIR=${CMAKE_BINARY_DIR}
- PYTHONPATH=${PYTHON_SYSCONFIG_BUILD}:${LIBDIR_BUILD}/gnucash:${CMAKE_BINARY_DIR}/common/test-core
+ PYTHONPATH=${PYTHON_SYSCONFIG_BUILD}:${LIBDIR_BUILD}/gnucash:${test_core_dir}
)
ENDIF()
commit c3180ab374ad9a2c2c0861b85c85299fe9bc16fb
Author: John Ralls <jralls at ceridwen.us>
Date: Thu Mar 8 12:47:26 2018 -0800
Operator << fix.
diff --git a/libgnucash/engine/gnc-numeric.cpp b/libgnucash/engine/gnc-numeric.cpp
index 0fc47d5..3d54005 100644
--- a/libgnucash/engine/gnc-numeric.cpp
+++ b/libgnucash/engine/gnc-numeric.cpp
@@ -1303,6 +1303,18 @@ main(int argc, char ** argv)
}
#endif
+
+std::ostream&
+operator<<(std::ostream& s, GncNumeric n)
+{
+ std::basic_ostringstream<wchar_t> ss;
+ ss.imbue(s.getloc());
+ ss << n;
+ std::wstring_convert<std::codecvt_utf8<wchar_t>> make_utf8;
+ s << make_utf8.to_bytes(ss.str());
+ return s;
+}
+
const char* gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
{
switch (error_code)
diff --git a/libgnucash/engine/gnc-numeric.hpp b/libgnucash/engine/gnc-numeric.hpp
index d9ff3d7..a22f89b 100644
--- a/libgnucash/engine/gnc-numeric.hpp
+++ b/libgnucash/engine/gnc-numeric.hpp
@@ -27,6 +27,7 @@
#include <iostream>
#include <locale>
#include <typeinfo> // For std::bad_cast exception
+#include <codecvt> // UTF-8 <--> UTF16 conversion
#include "gnc-rational-rounding.hpp"
class GncRational;
@@ -339,6 +340,7 @@ inline GncNumeric operator/(int64_t a, GncNumeric b)
* decimal if the denominator is a multiple of 10, otherwise as
* "numerator/denominator".
*/
+std::ostream& operator<<(std::ostream&, GncNumeric);
/* Implementation adapted from "The C++ Standard Library, Second Edition" by
* Nicolai M. Josuttis, Addison-Wesley, 2012, ISBN 978-0-321-62321-8.
@@ -349,10 +351,10 @@ std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
std::basic_ostringstream<charT, traits> ss;
std::locale loc = s.getloc();
ss.imbue(loc);
- char dec_pt = '.';
+ auto dec_pt = static_cast<charT>('.');
try
{
- dec_pt = std::use_facet<std::numpunct<char>>(loc).decimal_point();
+ dec_pt = std::use_facet<std::numpunct<charT>>(loc).decimal_point();
}
catch(const std::bad_cast& err) {} //Don't do anything, num_sep is already set.
@@ -369,7 +371,6 @@ std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
return s;
}
-
/**
* std::stream input operator.
*
@@ -386,7 +387,7 @@ std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
template <typename charT, typename traits>
std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& s, GncNumeric& n)
{
- std::string instr;
+ std::basic_string<charT, traits> instr;
s >> instr;
if (s)
n = GncNumeric(instr, true);
diff --git a/libgnucash/engine/test/gtest-gnc-numeric.cpp b/libgnucash/engine/test/gtest-gnc-numeric.cpp
index 82d6b8f..8326071 100644
--- a/libgnucash/engine/test/gtest-gnc-numeric.cpp
+++ b/libgnucash/engine/test/gtest-gnc-numeric.cpp
@@ -213,10 +213,15 @@ TEST(gncnumeric_stream, output_stream)
EXPECT_EQ("123/456", output.str());
try
{
- output.imbue(std::locale("fr_FR.utf8"));
+ auto loc = std::locale("fr_FR.utf8");
+ auto thou_sep = std::use_facet<std::numpunct<wchar_t>>(loc).thousands_sep();
+ output.imbue(loc);
output.str("");
output << simple_int;
- EXPECT_EQ("123 456", output.str());
+ if (thou_sep == L' ')
+ EXPECT_EQ("123 456", output.str());
+ else
+ EXPECT_EQ("123\xe2\x80\xaf""456", output.str());
}
catch (std::runtime_error)
{
Summary of changes:
bindings/python/tests/CMakeLists.txt | 3 ++-
libgnucash/engine/gnc-numeric.cpp | 12 ++++++++++++
libgnucash/engine/gnc-numeric.hpp | 9 +++++----
libgnucash/engine/test/gtest-gnc-numeric.cpp | 9 +++++++--
4 files changed, 26 insertions(+), 7 deletions(-)
More information about the gnucash-changes
mailing list