Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
snapper
pr920.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pr920.patch of Package snapper
diff --git a/configure.ac b/configure.ac index 53a095f8..899d4744 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,7 @@ AC_CONFIG_FILES([ examples/c/Makefile examples/c++-lib/Makefile dbus/Makefile + dbus/testsuite/Makefile server/Makefile client/Makefile client/utils/Makefile diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 560b02f3..9c0456a2 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -2,6 +2,8 @@ # Makefile.am for snapper/dbus # +SUBDIRS = . testsuite + AM_CPPFLAGS = -I$(top_srcdir) $(DBUS_CFLAGS) noinst_LTLIBRARIES = libdbus.la diff --git a/dbus/testsuite/.gitignore b/dbus/testsuite/.gitignore new file mode 100644 index 00000000..85f0d0bb --- /dev/null +++ b/dbus/testsuite/.gitignore @@ -0,0 +1,5 @@ +*.log +*.o +*.test +*.trs +test-suite.log diff --git a/dbus/testsuite/Makefile.am b/dbus/testsuite/Makefile.am new file mode 100644 index 00000000..52ec8242 --- /dev/null +++ b/dbus/testsuite/Makefile.am @@ -0,0 +1,14 @@ +# +# Makefile.am for snapper/dbus/testsuite +# + +AM_CPPFLAGS = -I$(top_srcdir) $(DBUS_CFLAGS) + +LDADD = ../../snapper/libsnapper.la ../libdbus.la -lboost_unit_test_framework + +check_PROGRAMS = escape.test + +TESTS = $(check_PROGRAMS) + +AM_DEFAULT_SOURCE_EXT = .cc + diff --git a/testsuite/dbus-escape.cc b/dbus/testsuite/escape.cc similarity index 100% rename from testsuite/dbus-escape.cc rename to dbus/testsuite/escape.cc diff --git a/stomp/Stomp.cc b/stomp/Stomp.cc index ebdd2af9..3fb5a27d 100644 --- a/stomp/Stomp.cc +++ b/stomp/Stomp.cc @@ -20,7 +20,6 @@ */ -#include <iostream> #include <regex> @@ -48,6 +47,7 @@ namespace Stomp { string line; getline(is, line); + line = strip_cr(line); if (state == State::Start) { @@ -150,6 +150,18 @@ namespace Stomp } + std::string + strip_cr(const std::string& in) + { + string::size_type length = in.size(); + + if (length > 0 && in[length - 1] == '\r') + return in.substr(0, length - 1); + + return in; + } + + std::string escape_header(const std::string& in) { diff --git a/stomp/Stomp.h b/stomp/Stomp.h index 2220d8dc..1a024da6 100644 --- a/stomp/Stomp.h +++ b/stomp/Stomp.h @@ -51,6 +51,8 @@ namespace Stomp Message ack(); Message nack(); + std::string strip_cr(const std::string& in); + std::string escape_header(const std::string& in); std::string unescape_header(const std::string& in); diff --git a/stomp/testsuite/read1.cc b/stomp/testsuite/read1.cc index 2d89dd70..a5c31eb4 100644 --- a/stomp/testsuite/read1.cc +++ b/stomp/testsuite/read1.cc @@ -36,9 +36,9 @@ BOOST_AUTO_TEST_CASE(test1) BOOST_AUTO_TEST_CASE(test2) { - // optional content-lenght + // optional content-lenght and body with null character - istringstream s1("HELLO\nkey:value\ncontent-length:5\n\nWORLD" + null); + istringstream s1("HELLO\nkey:value\ncontent-length:5\n\nW" + null + "RLD" + null); istream s2(s1.rdbuf()); Message msg = read_message(s2); @@ -51,6 +51,24 @@ BOOST_AUTO_TEST_CASE(test2) BOOST_CHECK_EQUAL(msg.headers["key"], "value"); BOOST_CHECK_EQUAL(msg.headers["content-length"], "5"); + BOOST_CHECK_EQUAL(msg.body, "W" + null + "RLD"); +} + + +BOOST_AUTO_TEST_CASE(cr1) +{ + // optional carriage returns + + istringstream s1("HELLO\r\nkey:value\r\n\r\nWORLD" + null); + istream s2(s1.rdbuf()); + + Message msg = read_message(s2); + + BOOST_CHECK_EQUAL(msg.command, "HELLO"); + + BOOST_CHECK_EQUAL(msg.headers.size(), 1); + BOOST_CHECK_EQUAL(msg.headers["key"], "value"); + BOOST_CHECK_EQUAL(msg.body, "WORLD"); } diff --git a/stomp/testsuite/strip.cc b/stomp/testsuite/strip.cc new file mode 100644 index 00000000..685a285d --- /dev/null +++ b/stomp/testsuite/strip.cc @@ -0,0 +1,19 @@ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE snapper + +#include <boost/test/unit_test.hpp> + +#include "../Stomp.h" + + +using namespace std; +using namespace Stomp; + + +BOOST_AUTO_TEST_CASE(cr) +{ + BOOST_CHECK_EQUAL(Stomp::strip_cr("hello"), "hello"); + BOOST_CHECK_EQUAL(Stomp::strip_cr("hello\r"), "hello"); + BOOST_CHECK_EQUAL(Stomp::strip_cr("hello\r\n"), "hello\r\n"); +} diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index ccb84d37..4ae904b7 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -7,7 +7,7 @@ LDADD = ../snapper/libsnapper.la ../dbus/libdbus.la -lboost_unit_test_framework check_PROGRAMS = sysconfig-get1.test dirname1.test basename1.test \ - equal-date.test dbus-escape.test cmp-lt.test humanstring.test \ + equal-date.test cmp-lt.test humanstring.test \ table.test table-formatter.test csv-formatter.test json-formatter.test \ getopts.test scan-datetime.test root-prefix.test
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor