Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code style only: wrap after open parenthesis if not in one line #280

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ std::vector<uint8_t> get_input_buffer(const std::string & uri)
decompressed_buffer.data(), sizeof(uint8_t), decompressed_buffer.size(), file_pointer);

if (read_count != decompressed_buffer_length) {
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM("Bytes read (" << read_count <<
") != decompressed_buffer_length (" << decompressed_buffer.size() << ")!");
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM(
"Bytes read (" << read_count <<
") != decompressed_buffer_length (" << decompressed_buffer.size() << ")!");
// An error indicator is set by this, so the following check will throw
}

Expand Down Expand Up @@ -120,8 +121,9 @@ void write_output_buffer(
file_pointer);

if (write_count != output_buffer.size()) {
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM("Bytes written (" << write_count <<
") != output_buffer size (" << output_buffer.size() << ")!");
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM(
"Bytes written (" << write_count <<
") != output_buffer size (" << output_buffer.size() << ")!");
// An error indicator is set by fwrite, so the following check will throw.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ std::vector<uint8_t> get_input_buffer(const std::string & uri)
compressed_buffer_length, file_pointer);

if (read_count != compressed_buffer_length) {
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM("Bytes read !(" <<
read_count << ") != compressed_buffer size (" << compressed_buffer.size() <<
")!");
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM(
"Bytes read !(" <<
read_count << ") != compressed_buffer size (" << compressed_buffer.size() <<
")!");
// An error indicator is set by fread, so the following check will throw.
}

Expand Down Expand Up @@ -136,9 +137,10 @@ void write_output_buffer(
output_buffer.size(), file_pointer);

if (write_count != output_buffer.size()) {
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM("Bytes written (" <<
write_count << " != output_buffer size (" << output_buffer.size() <<
")!");
ROSBAG2_COMPRESSION_LOG_ERROR_STREAM(
"Bytes written (" <<
write_count << " != output_buffer size (" << output_buffer.size() <<
")!");
// An error indicator is set by fwrite, so the following check will throw.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ void CdrConverter::serialize(
} // namespace rosbag2_converter_default_plugins

#include "pluginlib/class_list_macros.hpp" // NOLINT
PLUGINLIB_EXPORT_CLASS(rosbag2_converter_default_plugins::CdrConverter,
PLUGINLIB_EXPORT_CLASS(
rosbag2_converter_default_plugins::CdrConverter,
rosbag2_cpp::converter_interfaces::SerializationFormatConverter)
6 changes: 4 additions & 2 deletions rosbag2_cpp/src/rosbag2_cpp/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ rosbag2_storage::BagMetadata Info::read_metadata(
std::shared_ptr<rosbag2_storage::storage_interfaces::ReadOnlyInterface> storage;
storage = factory.open_read_only(uri, storage_id);
if (!storage) {
throw std::runtime_error("The metadata.yaml file does not exist and the bag could not be "
throw std::runtime_error(
"The metadata.yaml file does not exist and the bag could not be "
"opened.");
}
auto bag_metadata = storage->get_metadata();
return bag_metadata;
}
throw std::runtime_error("The metadata.yaml file does not exist. Please specify a the "
throw std::runtime_error(
"The metadata.yaml file does not exist. Please specify a the "
"storage id of the bagfile to query it directly");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ class SerializationFormatConverterFactoryImpl
const std::vector<std::string> & registered_converter_classes,
const std::vector<std::string> & registered_interface_classes)
{
auto class_exists_in_converters = std::find(registered_converter_classes.begin(),
registered_converter_classes.end(), converter_id);
auto class_exists_in_deserializers = std::find(registered_interface_classes.begin(),
registered_interface_classes.end(), converter_id);
auto class_exists_in_converters = std::find(
registered_converter_classes.begin(),
registered_converter_classes.end(), converter_id);
auto class_exists_in_deserializers = std::find(
registered_interface_classes.begin(),
registered_interface_classes.end(), converter_id);
return class_exists_in_converters == registered_converter_classes.end() &&
class_exists_in_deserializers == registered_interface_classes.end();
}
Expand Down
4 changes: 2 additions & 2 deletions rosbag2_cpp/test/rosbag2_cpp/converter_test_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ void ConverterTestPlugin::serialize(
}

#include "pluginlib/class_list_macros.hpp" // NOLINT
PLUGINLIB_EXPORT_CLASS(ConverterTestPlugin,
rosbag2_cpp::converter_interfaces::SerializationFormatConverter)
PLUGINLIB_EXPORT_CLASS(
ConverterTestPlugin, rosbag2_cpp::converter_interfaces::SerializationFormatConverter)
6 changes: 4 additions & 2 deletions rosbag2_cpp/test/rosbag2_cpp/mock_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
class MockConverter : public rosbag2_cpp::converter_interfaces::SerializationFormatConverter
{
public:
MOCK_METHOD3(deserialize,
MOCK_METHOD3(
deserialize,
void(
std::shared_ptr<const rosbag2_storage::SerializedBagMessage>,
const rosidl_message_type_support_t *,
std::shared_ptr<rosbag2_cpp::rosbag2_introspection_message_t>));

MOCK_METHOD3(serialize,
MOCK_METHOD3(
serialize,
void(
std::shared_ptr<const rosbag2_cpp::rosbag2_introspection_message_t>,
const rosidl_message_type_support_t *,
Expand Down
6 changes: 4 additions & 2 deletions rosbag2_cpp/test/rosbag2_cpp/mock_converter_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
class MockConverterFactory : public rosbag2_cpp::SerializationFormatConverterFactoryInterface
{
public:
MOCK_METHOD1(load_serializer,
MOCK_METHOD1(
load_serializer,
std::unique_ptr<rosbag2_cpp::converter_interfaces::SerializationFormatSerializer>(
const std::string &));

MOCK_METHOD1(load_deserializer,
MOCK_METHOD1(
load_deserializer,
std::unique_ptr<rosbag2_cpp::converter_interfaces::SerializationFormatDeserializer>(
const std::string &));
};
Expand Down
6 changes: 4 additions & 2 deletions rosbag2_cpp/test/rosbag2_cpp/mock_storage_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
class MockStorageFactory : public rosbag2_storage::StorageFactoryInterface
{
public:
MOCK_METHOD2(open_read_only,
MOCK_METHOD2(
open_read_only,
std::shared_ptr<rosbag2_storage::storage_interfaces::ReadOnlyInterface>(
const std::string &, const std::string &));
MOCK_METHOD2(open_read_write,
MOCK_METHOD2(
open_read_write,
std::shared_ptr<rosbag2_storage::storage_interfaces::ReadWriteInterface>(
const std::string &, const std::string &));
};
Expand Down
3 changes: 2 additions & 1 deletion rosbag2_cpp/test/rosbag2_cpp/serializer_test_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ void SerializerTestPlugin::serialize(
}

#include "pluginlib/class_list_macros.hpp" // NOLINT
PLUGINLIB_EXPORT_CLASS(SerializerTestPlugin,
PLUGINLIB_EXPORT_CLASS(
SerializerTestPlugin,
rosbag2_cpp::converter_interfaces::SerializationFormatSerializer)
3 changes: 2 additions & 1 deletion rosbag2_cpp/test/rosbag2_cpp/test_converter_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ConverterFactoryTest : public Test
rosbag2_cpp::SerializationFormatConverterFactory factory;
};

TEST_F(ConverterFactoryTest,
TEST_F(
ConverterFactoryTest,
load_test_plugin_can_load_a_converter_plugin_as_both_deserializer_and_serializer)
{
auto deserializer = factory.load_deserializer("a");
Expand Down
32 changes: 20 additions & 12 deletions rosbag2_cpp/test/rosbag2_cpp/test_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,39 @@ TEST_F(TemporaryDirectoryFixture, read_metadata_makes_appropriate_call_to_metada
auto read_metadata = info.read_metadata(temporary_dir_path_, "sqlite3");

EXPECT_THAT(read_metadata.storage_identifier, Eq("sqlite3"));
EXPECT_THAT(read_metadata.relative_file_paths,
EXPECT_THAT(
read_metadata.relative_file_paths,
Eq(std::vector<std::string>({"some_relative_path", "some_other_relative_path"})));
EXPECT_THAT(read_metadata.duration, Eq(std::chrono::nanoseconds(100)));
EXPECT_THAT(read_metadata.starting_time,
Eq(std::chrono::time_point<std::chrono::high_resolution_clock>(
std::chrono::nanoseconds(1000000))));
EXPECT_THAT(
read_metadata.starting_time,
Eq(
std::chrono::time_point<std::chrono::high_resolution_clock>(
std::chrono::nanoseconds(1000000))));
EXPECT_THAT(read_metadata.message_count, Eq(50u));
EXPECT_THAT(read_metadata.topics_with_message_count,
SizeIs(2u));
EXPECT_THAT(read_metadata.topics_with_message_count, SizeIs(2u));
auto actual_first_topic = read_metadata.topics_with_message_count[0];
rosbag2_storage::TopicInformation expected_first_topic = {{"topic1", "type1", "rmw1"}, 100};
EXPECT_THAT(actual_first_topic.topic_metadata.name,
EXPECT_THAT(
actual_first_topic.topic_metadata.name,
Eq(expected_first_topic.topic_metadata.name));
EXPECT_THAT(actual_first_topic.topic_metadata.type,
EXPECT_THAT(
actual_first_topic.topic_metadata.type,
Eq(expected_first_topic.topic_metadata.type));
EXPECT_THAT(actual_first_topic.topic_metadata.serialization_format,
EXPECT_THAT(
actual_first_topic.topic_metadata.serialization_format,
Eq(expected_first_topic.topic_metadata.serialization_format));
EXPECT_THAT(actual_first_topic.message_count, Eq(expected_first_topic.message_count));
auto actual_second_topic = read_metadata.topics_with_message_count[1];
rosbag2_storage::TopicInformation expected_second_topic = {{"topic2", "type2", "rmw2"}, 200};
EXPECT_THAT(actual_second_topic.topic_metadata.name,
EXPECT_THAT(
actual_second_topic.topic_metadata.name,
Eq(expected_second_topic.topic_metadata.name));
EXPECT_THAT(actual_second_topic.topic_metadata.type,
EXPECT_THAT(
actual_second_topic.topic_metadata.type,
Eq(expected_second_topic.topic_metadata.type));
EXPECT_THAT(actual_second_topic.topic_metadata.serialization_format,
EXPECT_THAT(
actual_second_topic.topic_metadata.serialization_format,
Eq(expected_second_topic.topic_metadata.serialization_format));
EXPECT_THAT(actual_second_topic.message_count, Eq(expected_second_topic.message_count));

Expand Down
3 changes: 2 additions & 1 deletion rosbag2_cpp/test/rosbag2_cpp/test_sequential_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ TEST_F(SequentialReaderTest, open_throws_error_if_converter_plugin_does_not_exis
EXPECT_ANY_THROW(reader_->open(rosbag2_cpp::StorageOptions(), {"", output_format}));
}

TEST_F(SequentialReaderTest,
TEST_F(
SequentialReaderTest,
read_next_does_not_use_converters_if_input_and_output_format_are_equal) {
std::string storage_serialization_format = "rmw1_format";

Expand Down
15 changes: 9 additions & 6 deletions rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ class SequentialWriterTest : public Test

ON_CALL(*storage_factory_, open_read_write(_, _)).WillByDefault(
DoAll(
Invoke([this](const std::string & uri, const std::string &) {
fake_storage_size_ = 0;
fake_storage_uri_ = uri;
}),
Invoke(
[this](const std::string & uri, const std::string &) {
fake_storage_size_ = 0;
fake_storage_uri_ = uri;
}),
Return(storage_)));
EXPECT_CALL(
*storage_factory_, open_read_write(_, _)).Times(AtLeast(0));
Expand All @@ -69,7 +70,8 @@ class SequentialWriterTest : public Test
std::string fake_storage_uri_;
};

TEST_F(SequentialWriterTest,
TEST_F(
SequentialWriterTest,
write_uses_converters_to_convert_serialization_format_if_input_and_output_format_are_different) {
auto sequential_writer = std::make_unique<rosbag2_cpp::writers::SequentialWriter>(
std::move(storage_factory_), converter_factory_, std::move(metadata_io_));
Expand Down Expand Up @@ -234,7 +236,8 @@ TEST_F(SequentialWriterTest, writer_splits_when_storage_bagfile_size_gt_max_bagf
writer_.reset();
// metadata should be written now that the Writer was released.

EXPECT_EQ(fake_metadata_.relative_file_paths.size(),
EXPECT_EQ(
fake_metadata_.relative_file_paths.size(),
static_cast<unsigned int>(expected_splits)) <<
"Storage should have split bagfile " << (expected_splits - 1);

Expand Down
6 changes: 4 additions & 2 deletions rosbag2_cpp/test/rosbag2_cpp/test_typesupport_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ TEST(TypesupportHelpersTest, returns_c_type_info_for_valid_legacy_library) {
auto string_typesupport =
rosbag2_cpp::get_typesupport("test_msgs/BasicTypes", "rosidl_typesupport_cpp");

EXPECT_THAT(std::string(string_typesupport->typesupport_identifier),
EXPECT_THAT(
std::string(string_typesupport->typesupport_identifier),
ContainsRegex("rosidl_typesupport"));
}

TEST(TypesupportHelpersTest, returns_c_type_info_for_valid_library) {
auto string_typesupport =
rosbag2_cpp::get_typesupport("test_msgs/msg/BasicTypes", "rosidl_typesupport_cpp");

EXPECT_THAT(std::string(string_typesupport->typesupport_identifier),
EXPECT_THAT(
std::string(string_typesupport->typesupport_identifier),
ContainsRegex("rosidl_typesupport"));
}
22 changes: 12 additions & 10 deletions rosbag2_storage/src/rosbag2_storage/ros_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ make_empty_serialized_message(size_t size)
*msg = rcutils_get_zero_initialized_uint8_array();
auto ret = rcutils_uint8_array_init(msg, size, &allocator);
if (ret != RCUTILS_RET_OK) {
throw std::runtime_error("Error allocating resources for serialized message: " +
throw std::runtime_error(
"Error allocating resources for serialized message: " +
std::string(rcutils_get_error_string().str));
}

auto serialized_message = std::shared_ptr<rcutils_uint8_array_t>(msg,
[](rcutils_uint8_array_t * msg) {
int error = rcutils_uint8_array_fini(msg);
delete msg;
if (error != RCUTILS_RET_OK) {
ROSBAG2_STORAGE_LOG_ERROR_STREAM(
"Leaking memory. Error: " << rcutils_get_error_string().str);
}
});
auto serialized_message = std::shared_ptr<rcutils_uint8_array_t>(
msg,
[](rcutils_uint8_array_t * msg) {
int error = rcutils_uint8_array_fini(msg);
delete msg;
if (error != RCUTILS_RET_OK) {
ROSBAG2_STORAGE_LOG_ERROR_STREAM(
"Leaking memory. Error: " << rcutils_get_error_string().str);
}
});

return serialized_message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,31 @@ TEST_F(MetadataFixture, test_writing_and_reading_yaml)
EXPECT_THAT(read_metadata.duration, Eq(metadata.duration));
EXPECT_THAT(read_metadata.starting_time, Eq(metadata.starting_time));
EXPECT_THAT(read_metadata.message_count, Eq(metadata.message_count));
EXPECT_THAT(read_metadata.topics_with_message_count,
EXPECT_THAT(
read_metadata.topics_with_message_count,
SizeIs(metadata.topics_with_message_count.size()));
auto actual_first_topic = read_metadata.topics_with_message_count[0];
auto expected_first_topic = metadata.topics_with_message_count[0];
EXPECT_THAT(actual_first_topic.topic_metadata.name,
EXPECT_THAT(
actual_first_topic.topic_metadata.name,
Eq(expected_first_topic.topic_metadata.name));
EXPECT_THAT(actual_first_topic.topic_metadata.type,
EXPECT_THAT(
actual_first_topic.topic_metadata.type,
Eq(expected_first_topic.topic_metadata.type));
EXPECT_THAT(actual_first_topic.topic_metadata.serialization_format,
EXPECT_THAT(
actual_first_topic.topic_metadata.serialization_format,
Eq(expected_first_topic.topic_metadata.serialization_format));
EXPECT_THAT(actual_first_topic.message_count, Eq(expected_first_topic.message_count));
auto actual_second_topic = read_metadata.topics_with_message_count[1];
auto expected_second_topic = metadata.topics_with_message_count[1];
EXPECT_THAT(actual_second_topic.topic_metadata.name,
EXPECT_THAT(
actual_second_topic.topic_metadata.name,
Eq(expected_second_topic.topic_metadata.name));
EXPECT_THAT(actual_second_topic.topic_metadata.type,
EXPECT_THAT(
actual_second_topic.topic_metadata.type,
Eq(expected_second_topic.topic_metadata.type));
EXPECT_THAT(actual_second_topic.topic_metadata.serialization_format,
EXPECT_THAT(
actual_second_topic.topic_metadata.serialization_format,
Eq(expected_second_topic.topic_metadata.serialization_format));
EXPECT_THAT(actual_second_topic.message_count, Eq(expected_second_topic.message_count));
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ inline
void SqliteStatementWrapper::check_and_report_bind_error(int return_code, std::string value)
{
if (return_code != SQLITE_OK) {
throw SqliteException("SQLite error when binding parameter " +
throw SqliteException(
"SQLite error when binding parameter " +
std::to_string(last_bound_parameter_index_) + " to value '" + value +
"'. Return code: " + std::to_string(return_code));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void SqliteStorage::open(
read_statement_ = nullptr;
write_statement_ = nullptr;

ROSBAG2_STORAGE_DEFAULT_PLUGINS_LOG_INFO_STREAM("Opened database '" <<
relative_path_ << "' for " << to_string(io_flag) << ".");
ROSBAG2_STORAGE_DEFAULT_PLUGINS_LOG_INFO_STREAM(
"Opened database '" << relative_path_ << "' for " << to_string(io_flag) << ".");
}

void SqliteStorage::write(std::shared_ptr<const rosbag2_storage::SerializedBagMessage> message)
Expand All @@ -114,7 +114,8 @@ void SqliteStorage::write(std::shared_ptr<const rosbag2_storage::SerializedBagMe
}
auto topic_entry = topics_.find(message->topic_name);
if (topic_entry == end(topics_)) {
throw SqliteException("Topic '" + message->topic_name +
throw SqliteException(
"Topic '" + message->topic_name +
"' has not been created yet! Call 'create_topic' first.");
}

Expand Down Expand Up @@ -294,5 +295,6 @@ rosbag2_storage::BagMetadata SqliteStorage::get_metadata()
} // namespace rosbag2_storage_plugins

#include "pluginlib/class_list_macros.hpp" // NOLINT
PLUGINLIB_EXPORT_CLASS(rosbag2_storage_plugins::SqliteStorage,
PLUGINLIB_EXPORT_CLASS(
rosbag2_storage_plugins::SqliteStorage,
rosbag2_storage::storage_interfaces::ReadWriteInterface)
Loading