Skip to content

Commit

Permalink
Fix formatting problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Oct 29, 2017
1 parent 33a4e96 commit 89108a7
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 70 deletions.
4 changes: 2 additions & 2 deletions jb/etcd/detail/leader_election_runner_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ class leader_election_runner_impl : public leader_election_runner {
}
async_op_done("on_range_request()");
check_grpc_status(
op.status, log_header("on_range_request()"), ", response=",
print_to_stream(op.response));
op.status, log_header("on_range_request()"),
", response=", print_to_stream(op.response));

for (auto const& kv : op.response.kvs()) {
// ... we need to capture the key and revision of the result, so
Expand Down
4 changes: 2 additions & 2 deletions jb/etcd/grpc_errors_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ BOOST_AUTO_TEST_CASE(check_grpc_status_ok) {

etcdserverpb::LeaseKeepAliveRequest req;
BOOST_CHECK_NO_THROW(jb::etcd::check_grpc_status(
status, "test", " in iteration=", 42, ", request=",
jb::etcd::print_to_stream(req)));
status, "test", " in iteration=", 42,
", request=", jb::etcd::print_to_stream(req)));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions jb/itch5/mold2inside.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ int const port = 50000;

config::config()
: receiver(
desc("receiver"), this, jb::itch5::udp_receiver_config()
.port(defaults::port)
.local_address(defaults::local_address)
.address(defaults::address))
desc("receiver"), this,
jb::itch5::udp_receiver_config()
.port(defaults::port)
.local_address(defaults::local_address)
.address(defaults::address))
, output_file(
desc("output-file")
.help("The name of the file where to store the inside data."
Expand Down
7 changes: 4 additions & 3 deletions jb/itch5/moldfeedhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,10 @@ config::config()
"1, 4, or 8."),
this, defaults::levels)
, primary(
desc("primary"), this, jb::itch5::udp_receiver_config()
.address(defaults::mold_address)
.port(defaults::mold_port))
desc("primary"), this,
jb::itch5::udp_receiver_config()
.address(defaults::mold_address)
.port(defaults::mold_port))
, secondary(
desc("secondary"), this,
jb::itch5::udp_receiver_config().address(defaults::mold_address))
Expand Down
30 changes: 16 additions & 14 deletions jb/itch5/ut_compute_book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ void test_compute_book_add_order_message_sell() {

// ... add an initial order to the book, we expect a single update,
// and the order should be in the book when the update is called ...
EXPECT_CALL(callback, exec(
book_update{now, stock, SELL, p11, 100}, empty_bid(),
half_quote{p11, 100}, 0, 1)).Times(1);
EXPECT_CALL(
callback, exec(
book_update{now, stock, SELL, p11, 100}, empty_bid(),
half_quote{p11, 100}, 0, 1))
.Times(1);
tested.handle_message(
now, ++msgcnt, 0,
add_order_message{{add_order_message::message_type, 0, 0,
Expand All @@ -157,13 +159,14 @@ void test_compute_book_add_order_message_sell() {
BOOST_REQUIRE_EQUAL(symbols.size(), std::size_t(1));
BOOST_CHECK_EQUAL(symbols[0], stock);


// ... add an order at a better price, we expect a single update,
// and the order should be in the book when the update is called ...
now = tested.now();
EXPECT_CALL(callback, exec(
book_update{now, stock, SELL, p10, 200}, empty_bid(),
half_quote{p10, 200}, 0, 2)).Times(1);
EXPECT_CALL(
callback, exec(
book_update{now, stock, SELL, p10, 200}, empty_bid(),
half_quote{p10, 200}, 0, 2))
.Times(1);
tested.handle_message(
now, ++msgcnt, 0,
add_order_message{{add_order_message::message_type, 0, 0,
Expand All @@ -174,14 +177,15 @@ void test_compute_book_add_order_message_sell() {
stock,
p10});


// ... add an order at a worse price, we also expect a single
// update, and the order should be in the book when the update is
// called ...
// called ...
now = tested.now();
EXPECT_CALL(callback, exec(
book_update{now, stock, SELL, p12, 300}, empty_bid(),
half_quote{p10, 200}, 0, 3)).Times(1);
EXPECT_CALL(
callback, exec(
book_update{now, stock, SELL, p12, 300}, empty_bid(),
half_quote{p10, 200}, 0, 3))
.Times(1);
tested.handle_message(
now, ++msgcnt, 0,
add_order_message{{add_order_message::message_type, 0, 0,
Expand Down Expand Up @@ -535,7 +539,6 @@ void test_compute_book_order_executed_message() {
BOOST_REQUIRE_EQUAL(symbols.size(), std::size_t(1));
BOOST_CHECK_EQUAL(symbols[0], stock);


// ... add an order to the opposite side of the book ...
now = tested.now();
auto const id_sell = ++id;
Expand Down Expand Up @@ -707,7 +710,6 @@ void test_compute_book_order_replace_message() {
BOOST_REQUIRE_EQUAL(symbols.size(), std::size_t(1));
BOOST_CHECK_EQUAL(symbols[0], stock);


// ... add an order to the opposite side of the book, we expect a
// single update, and the order should be in the book when the
// update is called ...
Expand Down
3 changes: 1 addition & 2 deletions jb/itch5/ut_make_socket_udp_send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ BOOST_AUTO_TEST_CASE(itch5_make_socket_udp_send_multicast_options) {
EXPECT_CALL(
v4s, set_option(boost::asio::ip::multicast::enable_loopback(true)))
.Times(1);
EXPECT_CALL(
v4s, set_option(An<boost::asio::ip::multicast::hops const&>()))
EXPECT_CALL(v4s, set_option(An<boost::asio::ip::multicast::hops const&>()))
.Times(0);
jb::itch5::detail::setup_socket_udp_send(
v4s,
Expand Down
11 changes: 6 additions & 5 deletions jb/itch5/ut_mold_udp_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ struct mold_udp_channel_tester {
*/
BOOST_AUTO_TEST_CASE(itch5_mold_udp_channel_basic) {
struct mock_function {
MOCK_METHOD5(method, void(
std::chrono::steady_clock::time_point, std::uint64_t, std::size_t,
std::string, std::size_t));
MOCK_METHOD5(
method, void(
std::chrono::steady_clock::time_point, std::uint64_t,
std::size_t, std::string, std::size_t));
};
mock_function mock;
auto adapter = [&mock](
std::chrono::steady_clock::time_point ts, std::uint64_t seqno,
std::size_t offset, char const* msg, std::size_t msgsize) {
std::chrono::steady_clock::time_point ts, std::uint64_t seqno,
std::size_t offset, char const* msg, std::size_t msgsize) {
mock.method(ts, seqno, offset, std::string(msg, msgsize), msgsize);
};

Expand Down
48 changes: 24 additions & 24 deletions jb/itch5/ut_mold_udp_pacer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <jb/gmock/init.hpp>
#include <jb/itch5/mold_udp_pacer.hpp>
#include <jb/itch5/testing/data.hpp>
#include <jb/gmock/init.hpp>

#include <boost/array.hpp>
#include <boost/asio.hpp>
Expand Down Expand Up @@ -54,10 +54,10 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_basic) {
using namespace ::testing;
mock_clock_interface::clear();
EXPECT_CALL(mock_clock_interface::instance(), now())
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));

jb::itch5::mold_udp_pacer<mock_clock> p(
jb::itch5::mold_udp_pacer_config().maximum_delay_microseconds(5));
Expand Down Expand Up @@ -100,10 +100,10 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_coalesce) {
using namespace ::testing;
mock_clock_interface::clear();
EXPECT_CALL(mock_clock_interface::instance(), now())
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
mock_sink sink;

// ... create a pacer that commits up to 1024 bytes and blocks for
Expand Down Expand Up @@ -160,10 +160,10 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_flush_full) {
using namespace ::testing;
mock_clock_interface::clear();
EXPECT_CALL(mock_clock_interface::instance(), now())
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
mock_sink sink;

// ... create a pacer that commits up to 220 bytes and blocks for
Expand Down Expand Up @@ -219,18 +219,19 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_flush_timeout) {
using namespace ::testing;
mock_clock_interface::clear();
EXPECT_CALL(mock_clock_interface::instance(), now())
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));

struct sleep {
MOCK_METHOD1(m, void(mock_clock::duration));
} sleeper;
auto mock_sleep = [&sleeper](mock_clock::duration d) { sleeper.m(d); };
EXPECT_CALL(sleeper, m(Truly([](auto const& d) {
return d == std::chrono::microseconds(2020);
}))).Times(1);
return d == std::chrono::microseconds(2020);
})))
.Times(1);

mock_sink sink;

Expand Down Expand Up @@ -272,7 +273,6 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_flush_timeout) {
// ... that should immediately flush the first two messages ...
BOOST_REQUIRE_EQUAL(sink.packets.size(), 1);
BOOST_CHECK_EQUAL(hdrsize + 100 + 2 + 90 + 2, sink.packets.at(0).size());

}

/**
Expand All @@ -285,10 +285,10 @@ BOOST_AUTO_TEST_CASE(itch5_mold_udp_pacer_flush_on_empty) {
using namespace ::testing;
mock_clock_interface::clear();
EXPECT_CALL(mock_clock_interface::instance(), now())
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
.WillRepeatedly(Invoke([]() {
static int ts = 0;
return mock_clock::time_point(std::chrono::microseconds(++ts));
}));
mock_sink sink;

// ... create a pacer that commits up to 1024 bytes and blocks for
Expand Down
5 changes: 3 additions & 2 deletions jb/testing/check_close_enough.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ value_type format(value_type t) {
* @tparam real the type of floating point number (float, double, long double)
*/
template <
typename real, typename std::enable_if<
std::is_floating_point<real>::value>::type* = nullptr>
typename real,
typename std::enable_if<std::is_floating_point<real>::value>::type* =
nullptr>
real relative_error(real actual, real expected) {
if (std::numeric_limits<real>::is_integer) {
return std::abs(actual - expected);
Expand Down
22 changes: 10 additions & 12 deletions jb/ut_config_files_location.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <jb/config_files_location.hpp>
#include <jb/gmock/init.hpp>
#include <jb/config_files_location.hpp>

#include <boost/filesystem/operations.hpp>
#include <boost/test/unit_test.hpp>
Expand Down Expand Up @@ -27,7 +27,7 @@ typedef jb::config_files_locations<trivial_getenv, trivial_validator> trivial;

namespace boost {
namespace filesystem {
// Introduce help for GoogleMock library.
// Introduce help for GoogleMock library.
void PrintTo(path const& p, ::std::ostream* os) {
*os << p.string();
}
Expand Down Expand Up @@ -100,19 +100,17 @@ using mock_validator = shared_functor<mock_validator_f>;
using mocked = jb::config_files_locations<mock_getenv, mock_validator>;

/// Configure mocks for most tests
void set_mocks(mock_getenv& getenv, mock_validator& validator,
char const* test_root, char const* jaybeams_root,
bool valid) {
void set_mocks(
mock_getenv& getenv, mock_validator& validator, char const* test_root,
char const* jaybeams_root, bool valid) {
getenv.reset();
using namespace ::testing;
EXPECT_CALL(*getenv.mock, exec(Truly([](auto arg) {
return std::string("TEST_ROOT") == arg;
})))
.WillRepeatedly(Return(test_root));
return std::string("TEST_ROOT") == arg;
}))).WillRepeatedly(Return(test_root));
EXPECT_CALL(*getenv.mock, exec(Truly([](auto arg) {
return std::string("JAYBEAMS_ROOT") == arg;
})))
.WillRepeatedly(Return(jaybeams_root));
return std::string("JAYBEAMS_ROOT") == arg;
}))).WillRepeatedly(Return(jaybeams_root));

validator.reset();
EXPECT_CALL(*validator.mock, exec(_)).WillRepeatedly(Return(valid));
Expand All @@ -126,7 +124,7 @@ BOOST_AUTO_TEST_CASE(config_files_location_program_root) {
mock_getenv getenv;
mock_validator validator;
set_mocks(getenv, validator, "/test/path", "/install/path", true);

fs::path programdir = fs::path("/foo/var/baz");
mocked t(programdir / "program", "TEST_ROOT", getenv);

Expand Down

0 comments on commit 89108a7

Please sign in to comment.