Hello community, here is the log from the commit of package libfilezilla for openSUSE:Factory checked in at 2017-02-25 00:54:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libfilezilla (Old) and /work/SRC/openSUSE:Factory/.libfilezilla.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libfilezilla" Changes: -------- --- /work/SRC/openSUSE:Factory/libfilezilla/libfilezilla.changes 2016-12-09 09:38:38.596918173 +0100 +++ /work/SRC/openSUSE:Factory/.libfilezilla.new/libfilezilla.changes 2017-02-25 00:54:09.882890417 +0100 @@ -1,0 +2,12 @@ +Thu Feb 23 07:35:49 UTC 2017 - ec...@opensuse.org + +- update to 0.9.1 + * New features: + - Added a small helper function to fz::file to get the current + position in the file + - Added another version of fz::to_wstring_from_utf8 that takes + a char buffer + length + * Bugfixes and minor changes: + - Fixed extraction of single-character tokens in fz::strtok + +------------------------------------------------------------------- Old: ---- libfilezilla-0.9.0.tar.bz2 New: ---- libfilezilla-0.9.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libfilezilla.spec ++++++ --- /var/tmp/diff_new_pack.FF2JFq/_old 2017-02-25 00:54:10.786751738 +0100 +++ /var/tmp/diff_new_pack.FF2JFq/_new 2017-02-25 00:54:10.786751738 +0100 @@ -1,7 +1,7 @@ # # spec file for package libfilezilla # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ %define libname %{name}%{major} %define develname %{name}-devel Name: libfilezilla -Version: 0.9.0 +Version: 0.9.1 Release: 0 Summary: C++ library for filezilla License: GPL-2.0+ ++++++ libfilezilla-0.9.0.tar.bz2 -> libfilezilla-0.9.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/NEWS new/libfilezilla-0.9.1/NEWS --- old/libfilezilla-0.9.0/NEWS 2016-11-28 17:34:31.000000000 +0100 +++ new/libfilezilla-0.9.1/NEWS 2017-02-20 23:08:47.000000000 +0100 @@ -1,3 +1,9 @@ +0.9.1 (2017-02-20) + ++ Added a small helper function to fz::file to get the current position in the file ++ Added another version of fz::to_wstring_from_utf8 that takes a char buffer + length +- Fixed extraction of single-character tokens in fz::strtok + 0.9.0 (2016-11-28) + Added parameter to fz::to_integral to specify which value is returned on error. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/README new/libfilezilla-0.9.1/README --- old/libfilezilla-0.9.0/README 2016-01-31 11:35:01.000000000 +0100 +++ new/libfilezilla-0.9.1/README 2017-02-20 23:08:59.000000000 +0100 @@ -1,7 +1,7 @@ libfilezilla ------------- - Copyright (C) 2016 Tim Kosse + Copyright (C) 2017 Tim Kosse https://lib.filezilla-project.org/ Overview diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/configure new/libfilezilla-0.9.1/configure --- old/libfilezilla-0.9.0/configure 2016-11-28 17:34:57.000000000 +0100 +++ new/libfilezilla-0.9.1/configure 2017-02-20 23:10:00.000000000 +0100 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libfilezilla 0.9.0. +# Generated by GNU Autoconf 2.69 for libfilezilla 0.9.1. # # Report bugs to <tim.ko...@filezilla-project.org>. # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='libfilezilla' PACKAGE_TARNAME='libfilezilla' -PACKAGE_VERSION='0.9.0' -PACKAGE_STRING='libfilezilla 0.9.0' +PACKAGE_VERSION='0.9.1' +PACKAGE_STRING='libfilezilla 0.9.1' PACKAGE_BUGREPORT='tim.ko...@filezilla-project.org' PACKAGE_URL='https://lib.filezilla-project.org/' @@ -1396,7 +1396,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libfilezilla 0.9.0 to adapt to many kinds of systems. +\`configure' configures libfilezilla 0.9.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1466,7 +1466,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libfilezilla 0.9.0:";; + short | recursive ) echo "Configuration of libfilezilla 0.9.1:";; esac cat <<\_ACEOF @@ -1591,7 +1591,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libfilezilla configure 0.9.0 +libfilezilla configure 0.9.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2036,7 +2036,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libfilezilla $as_me 0.9.0, which was +It was created by libfilezilla $as_me 0.9.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2902,7 +2902,7 @@ # Define the identity of the package. PACKAGE='libfilezilla' - VERSION='0.9.0' + VERSION='0.9.1' cat >>confdefs.h <<_ACEOF @@ -20214,7 +20214,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libfilezilla $as_me 0.9.0, which was +This file was extended by libfilezilla $as_me 0.9.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20281,7 +20281,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libfilezilla config.status 0.9.0 +libfilezilla config.status 0.9.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/configure.ac new/libfilezilla-0.9.1/configure.ac --- old/libfilezilla-0.9.0/configure.ac 2016-11-28 17:33:58.000000000 +0100 +++ new/libfilezilla-0.9.1/configure.ac 2017-02-20 23:08:14.000000000 +0100 @@ -1,4 +1,4 @@ -AC_INIT([libfilezilla],[0.9.0],[tim.ko...@filezilla-project.org],[],[https://lib.filezilla-project.org/]) +AC_INIT([libfilezilla],[0.9.1],[tim.ko...@filezilla-project.org],[],[https://lib.filezilla-project.org/]) AC_CONFIG_HEADERS([lib/libfilezilla/private/config.hpp]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR(config) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/libfilezilla/file.hpp new/libfilezilla-0.9.1/lib/libfilezilla/file.hpp --- old/libfilezilla-0.9.0/lib/libfilezilla/file.hpp 2016-11-28 17:32:55.000000000 +0100 +++ new/libfilezilla-0.9.1/lib/libfilezilla/file.hpp 2017-02-20 22:19:51.000000000 +0100 @@ -90,6 +90,9 @@ */ int64_t seek(int64_t offset, seek_mode m); + /** \brief Get Current position in file */ + int64_t position() { return seek(0, current); } + /** \brief Truncate the file to the current position of the file pointer. * * Despite its name, this function can extend the size of the file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/libfilezilla/local_filesys.hpp new/libfilezilla-0.9.1/lib/libfilezilla/local_filesys.hpp --- old/libfilezilla-0.9.0/lib/libfilezilla/local_filesys.hpp 2015-11-19 14:20:07.000000000 +0100 +++ new/libfilezilla-0.9.1/lib/libfilezilla/local_filesys.hpp 2017-02-20 22:19:51.000000000 +0100 @@ -88,7 +88,7 @@ private: #ifndef FZ_WINDOWS - void alloc_path_buffer(char const* file); // Ensures m_raw_path is large enough to hold path and filename + void alloc_path_buffer(char const* filename); // Ensures m_raw_path is large enough to hold path and filename #endif // State for directory enumeration diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/libfilezilla/string.hpp new/libfilezilla-0.9.1/lib/libfilezilla/string.hpp --- old/libfilezilla-0.9.0/lib/libfilezilla/string.hpp 2016-11-28 17:32:55.000000000 +0100 +++ new/libfilezilla-0.9.1/lib/libfilezilla/string.hpp 2017-02-20 22:19:51.000000000 +0100 @@ -142,6 +142,7 @@ * \return the converted string on success. On failure an empty string is returned. */ std::wstring FZ_PUBLIC_SYMBOL to_wstring_from_utf8(std::string const& in); +std::wstring FZ_PUBLIC_SYMBOL to_wstring_from_utf8(char const* s, size_t len); /** \brief Converts from std::wstring into std::string in system encoding * @@ -328,11 +329,11 @@ // Not found, we're at ends; if (pos == String::npos) { - if (start + 1 < s.size()) { + if (start < s.size()) { ret.emplace_back(s.substr(start)); } } - else if (pos > start + 1) { + else if (pos > start) { // Non-empty substring ret.emplace_back(s.substr(start, pos - start)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/libfilezilla/version.hpp new/libfilezilla-0.9.1/lib/libfilezilla/version.hpp --- old/libfilezilla-0.9.0/lib/libfilezilla/version.hpp 2016-11-28 17:35:00.000000000 +0100 +++ new/libfilezilla-0.9.1/lib/libfilezilla/version.hpp 2017-02-20 23:10:02.000000000 +0100 @@ -9,15 +9,15 @@ #include <tuple> /// \brief Version string of the libfilezilla headers -#define LIBFILEZILLA_VERSION "0.9.0" +#define LIBFILEZILLA_VERSION "0.9.1" #define LIBFILEZILLA_VERSION_MAJOR 0 #define LIBFILEZILLA_VERSION_MINOR 9 -#define LIBFILEZILLA_VERSION_MICRO 0 +#define LIBFILEZILLA_VERSION_MICRO 1 #define LIBFILEZILLA_VERSION_NANO 0 /// \brief Suffix string, e.g. "rc1" -#define LIBFILEZILLA_VERSION_SUFFIX "0.9.0" +#define LIBFILEZILLA_VERSION_SUFFIX "0.9.1" namespace fz { /// \brief Get version string of libfilezilla diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/local_filesys.cpp new/libfilezilla-0.9.1/lib/local_filesys.cpp --- old/libfilezilla-0.9.0/lib/local_filesys.cpp 2016-06-20 10:08:07.000000000 +0200 +++ new/libfilezilla-0.9.1/lib/local_filesys.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -40,8 +40,9 @@ #ifdef FZ_WINDOWS DWORD result = GetFileAttributes(path.c_str()); - if (result == INVALID_FILE_ATTRIBUTES) + if (result == INVALID_FILE_ATTRIBUTES) { return unknown; + } bool is_dir = (result & FILE_ATTRIBUTE_DIRECTORY) != 0; @@ -80,15 +81,16 @@ return link; } - int result = stat(path.c_str(), &buf); + result = stat(path.c_str(), &buf); if (result) { return unknown; } } #endif - if (S_ISDIR(buf.st_mode)) + if (S_ISDIR(buf.st_mode)) { return dir; + } return file; #endif @@ -108,12 +110,15 @@ WIN32_FILE_ATTRIBUTE_DATA attributes; BOOL result = GetFileAttributesEx(fixed_path.c_str(), GetFileExInfoStandard, &attributes); if (!result) { - if (size) + if (size) { *size = -1; - if (mode) + } + if (mode) { *mode = 0; - if (modification_time) + } + if (modification_time) { *modification_time = datetime(); + } return unknown; } @@ -135,28 +140,34 @@ } } - if (mode) + if (mode) { *mode = (int)info.dwFileAttributes; + } if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - if (size) + if (size) { *size = -1; + } return dir; } - if (size) + if (size) { *size = make_int64fzT(info.nFileSizeHigh, info.nFileSizeLow); + } return file; } } - if (size) + if (size) { *size = -1; - if (mode) + } + if (mode) { *mode = 0; - if (modification_time) + } + if (modification_time) { *modification_time = datetime(); + } return is_dir ? dir : unknown; } @@ -167,17 +178,20 @@ } } - if (mode) + if (mode) { *mode = (int)attributes.dwFileAttributes; + } if (is_dir) { - if (size) + if (size) { *size = -1; + } return dir; } else { - if (size) + if (size) { *size = make_int64fzT(attributes.nFileSizeHigh, attributes.nFileSizeLow); + } return file; } #else @@ -193,26 +207,32 @@ int result = lstat(path.c_str(), &buf); if (result) { is_link = false; - if (size) + if (size) { *size = -1; - if (mode) + } + if (mode) { *mode = -1; - if (modification_time) + } + if (modification_time) { *modification_time = datetime(); + } return unknown; } #ifdef S_ISLNK if (S_ISLNK(buf.st_mode)) { is_link = true; - int result = stat(path.c_str(), &buf); + result = stat(path.c_str(), &buf); if (result) { - if (size) + if (size) { *size = -1; - if (mode) + } + if (mode) { *mode = -1; - if (modification_time) + } + if (modification_time) { *modification_time = datetime(); + } return unknown; } } @@ -220,20 +240,24 @@ #endif is_link = false; - if (modification_time) + if (modification_time) { *modification_time = datetime(buf.st_mtime, datetime::seconds); + } - if (mode) + if (mode) { *mode = buf.st_mode & 0x777; + } if (S_ISDIR(buf.st_mode)) { - if (size) + if (size) { *size = -1; + } return dir; } - if (size) + if (size) { *size = buf.st_size; + } return file; #endif @@ -523,16 +547,16 @@ } #ifndef FZ_WINDOWS -void local_filesys::alloc_path_buffer(char const* file) +void local_filesys::alloc_path_buffer(char const* filename) { - int len = strlen(file); + int len = strlen(filename); int pathlen = m_file_part - m_raw_path; if (len + pathlen >= m_buffer_length) { m_buffer_length = (len + pathlen) * 2; char* tmp = new char[m_buffer_length]; memcpy(tmp, m_raw_path, pathlen); - delete[] m_raw_path; + delete [] m_raw_path; m_raw_path = tmp; m_file_part = m_raw_path + pathlen; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/recursive_remove.cpp new/libfilezilla-0.9.1/lib/recursive_remove.cpp --- old/libfilezilla-0.9.0/lib/recursive_remove.cpp 2015-11-19 14:20:07.000000000 +0100 +++ new/libfilezilla-0.9.1/lib/recursive_remove.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -40,8 +40,9 @@ if (!dir.empty() && local_filesys::is_separator(dir.back())) { dir.pop_back(); } - if (local_filesys::get_file_type(dir) == local_filesys::unknown) + if (local_filesys::get_file_type(dir) == local_filesys::unknown) { continue; + } wcscpy(p, dir.c_str()); p += dir.size() + 1; @@ -115,16 +116,18 @@ native_string const fullName = path + fzT("/") + file; - if (local_filesys::get_file_type(fullName) == local_filesys::dir) + if (local_filesys::get_file_type(fullName) == local_filesys::dir) { dirsToVisit.push_back(fullName); - else + } + else { filesToDelete.push_back(fullName); + } } fs.end_find_files(); // Delete all files and links in current directory enumerated before - for (auto const& file : filesToDelete) { - if (unlink(file.c_str()) != 0) { + for (auto const& filename : filesToDelete) { + if (unlink(filename.c_str()) != 0) { success = false; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/lib/string.cpp new/libfilezilla-0.9.1/lib/string.cpp --- old/libfilezilla-0.9.0/lib/string.cpp 2016-10-25 15:03:50.000000000 +0200 +++ new/libfilezilla-0.9.1/lib/string.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -160,28 +160,31 @@ std::wstring to_wstring_from_utf8(std::string const& in) { + return to_wstring_from_utf8(in.c_str(), in.size()); +} + +std::wstring to_wstring_from_utf8(char const* s, size_t len) +{ std::wstring ret; - if (!in.empty()) { + if (len != 0) { #if FZ_WINDOWS - char const* const in_p = in.c_str(); - int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, in_p, static_cast<int>(in.size()), 0, 0); - if (len > 0) { - ret.resize(len); + char const* const in_p = s; + int out_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, in_p, static_cast<int>(len), 0, 0); + if (out_len > 0) { + ret.resize(out_len); wchar_t* out_p = &ret[0]; - MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, in_p, static_cast<int>(in.size()), out_p, len); + MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, in_p, static_cast<int>(len), out_p, out_len); } #else iconv_t cd = iconv_open(wchar_t_encoding(), "UTF-8"); if (cd != reinterpret_cast<iconv_t>(-1)) { - auto in_p = const_cast<iconv_second_arg_type>(in.c_str()); - size_t in_len = in.size(); - - size_t out_len = in_len * sizeof(wchar_t) * 2; + auto in_p = const_cast<iconv_second_arg_type>(s); + size_t out_len = len * sizeof(wchar_t) * 2; char* out_buf = new char[out_len]; char* out_p = out_buf; - size_t r = iconv(cd, &in_p, &in_len, &out_p, &out_len); + size_t r = iconv(cd, &in_p, &len, &out_p, &out_len); if (r != static_cast<size_t>(-1)) { ret.assign(reinterpret_cast<wchar_t*>(out_buf), reinterpret_cast<wchar_t*>(out_p)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/dispatch.cpp new/libfilezilla-0.9.1/tests/dispatch.cpp --- old/libfilezilla-0.9.0/tests/dispatch.cpp 2016-05-20 18:31:53.000000000 +0200 +++ new/libfilezilla-0.9.1/tests/dispatch.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -2,7 +2,7 @@ #include <cppunit/extensions/HelperMacros.h> -class DispatchTest : public CppUnit::TestFixture +class DispatchTest final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DispatchTest); CPPUNIT_TEST(testSingle); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/eventloop.cpp new/libfilezilla-0.9.1/tests/eventloop.cpp --- old/libfilezilla-0.9.0/tests/eventloop.cpp 2016-05-09 17:28:54.000000000 +0200 +++ new/libfilezilla-0.9.1/tests/eventloop.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -3,7 +3,7 @@ #include <cppunit/extensions/HelperMacros.h> -class EventloopTest : public CppUnit::TestFixture +class EventloopTest final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(EventloopTest); CPPUNIT_TEST(testSimple); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/format.cpp new/libfilezilla-0.9.1/tests/format.cpp --- old/libfilezilla-0.9.0/tests/format.cpp 2016-10-25 15:03:50.000000000 +0200 +++ new/libfilezilla-0.9.1/tests/format.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -6,7 +6,7 @@ * string formatting functions */ -class format_test : public CppUnit::TestFixture +class format_test final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(format_test); CPPUNIT_TEST(test_sprintf); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/iputils.cpp new/libfilezilla-0.9.1/tests/iputils.cpp --- old/libfilezilla-0.9.0/tests/iputils.cpp 2016-01-31 11:35:01.000000000 +0100 +++ new/libfilezilla-0.9.1/tests/iputils.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -6,7 +6,7 @@ * functions handling IP addresses */ -class ip_address_test : public CppUnit::TestFixture +class ip_address_test final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ip_address_test); CPPUNIT_TEST(test_addresses); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/smart_pointer.cpp new/libfilezilla-0.9.1/tests/smart_pointer.cpp --- old/libfilezilla-0.9.0/tests/smart_pointer.cpp 2016-02-22 14:42:43.000000000 +0100 +++ new/libfilezilla-0.9.1/tests/smart_pointer.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -7,7 +7,7 @@ * functions handling IP addresses */ -class smart_pointer_test : public CppUnit::TestFixture +class smart_pointer_test final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(smart_pointer_test); CPPUNIT_TEST(test_optional); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libfilezilla-0.9.0/tests/string.cpp new/libfilezilla-0.9.1/tests/string.cpp --- old/libfilezilla-0.9.0/tests/string.cpp 2016-11-28 17:32:55.000000000 +0100 +++ new/libfilezilla-0.9.1/tests/string.cpp 2017-02-20 22:19:51.000000000 +0100 @@ -6,7 +6,7 @@ * string functions */ -class string_test : public CppUnit::TestFixture +class string_test final : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(string_test); CPPUNIT_TEST(test_conversion); @@ -14,6 +14,7 @@ CPPUNIT_TEST(test_conversion_utf8); CPPUNIT_TEST(test_base64); CPPUNIT_TEST(test_trim); + CPPUNIT_TEST(test_strtok); CPPUNIT_TEST_SUITE_END(); public: @@ -25,6 +26,7 @@ void test_conversion_utf8(); void test_base64(); void test_trim(); + void test_strtok(); }; CPPUNIT_TEST_SUITE_REGISTRATION(string_test); @@ -32,7 +34,7 @@ void string_test::test_conversion() { std::string const s("hello world!"); - + std::wstring const w = fz::to_wstring(s); CPPUNIT_ASSERT_EQUAL(s.size(), w.size()); @@ -124,3 +126,24 @@ CPPUNIT_ASSERT_EQUAL(std::string("foo"), fz::trimmed(std::string("\t foo "))); CPPUNIT_ASSERT_EQUAL(std::string(""), fz::trimmed(std::string(" \t\r \n \t"))); } + +void string_test::test_strtok() +{ + auto tokens = fz::strtok<std::string>("hello world", ' '); + CPPUNIT_ASSERT_EQUAL(size_t(2), tokens.size()); + CPPUNIT_ASSERT_EQUAL(std::string("hello"), tokens[0]); + CPPUNIT_ASSERT_EQUAL(std::string("world"), tokens[1]); + + tokens = fz::strtok<std::string>(" hello world ", " eo"); + CPPUNIT_ASSERT_EQUAL(size_t(4), tokens.size()); + CPPUNIT_ASSERT_EQUAL(std::string("h"), tokens[0]); + CPPUNIT_ASSERT_EQUAL(std::string("ll"), tokens[1]); + CPPUNIT_ASSERT_EQUAL(std::string("w"), tokens[2]); + CPPUNIT_ASSERT_EQUAL(std::string("rld"), tokens[3]); + + tokens = fz::strtok<std::string>("a b c", ' '); + CPPUNIT_ASSERT_EQUAL(size_t(3), tokens.size()); + CPPUNIT_ASSERT_EQUAL(std::string("a"), tokens[0]); + CPPUNIT_ASSERT_EQUAL(std::string("b"), tokens[1]); + CPPUNIT_ASSERT_EQUAL(std::string("c"), tokens[2]); +}