mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
feat(Parts): Refine and tweak
* Optimize appending another Parts container * Remove redundant/verbose comments * Change r-value args to move-only types into l-value args for readability * Deprecate `AtRef(int)`, redundant, just dereference at call site * Deprecate `AddPart(Message*)`, avoid owning raw pointer args * Add various const overloads * Add `Empty()` and `Clear()` member functions * Add `noexcept` where applicable
This commit is contained in:
committed by
Dennis Klein
parent
7bf1d368a8
commit
a58b4870d7
73
test/parts/_add_part.cxx
Normal file
73
test/parts/_add_part.cxx
Normal file
@@ -0,0 +1,73 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include <fairmq/Parts.h>
|
||||
#include <fairmq/TransportFactory.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AddPart : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
fair::mq::Parts mParts;
|
||||
shared_ptr<fair::mq::TransportFactory> mFactory;
|
||||
|
||||
AddPart()
|
||||
: mFactory(fair::mq::TransportFactory::CreateTransportFactory("zeromq"))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(AddPart, AnotherParts)
|
||||
{
|
||||
mParts.AddPart(mFactory->NewSimpleMessage("1"));
|
||||
mParts.AddPart(mFactory->NewSimpleMessage("2"));
|
||||
mParts.AddPart(mFactory->NewSimpleMessage("3"));
|
||||
auto const oldSize = mParts.Size();
|
||||
|
||||
fair::mq::Parts anotherParts;
|
||||
anotherParts.AddPart(mFactory->NewSimpleMessage("4"));
|
||||
anotherParts.AddPart(mFactory->NewSimpleMessage("5"));
|
||||
anotherParts.AddPart(mFactory->NewSimpleMessage("6"));
|
||||
auto const addedSize = anotherParts.Size();
|
||||
auto const newSize = oldSize + addedSize;
|
||||
|
||||
mParts.AddPart(std::move(anotherParts));
|
||||
ASSERT_TRUE(mParts.Size() == newSize);
|
||||
}
|
||||
|
||||
TEST_F(AddPart, SinglePart)
|
||||
{
|
||||
auto const oldSize = mParts.Size();
|
||||
mParts.AddPart(mFactory->NewSimpleMessage("asdf"));
|
||||
ASSERT_TRUE(mParts.Size() == oldSize + 1);
|
||||
}
|
||||
|
||||
TEST_F(AddPart, MultipleParts)
|
||||
{
|
||||
auto const oldSize = mParts.Size();
|
||||
mParts.AddPart(mFactory->NewSimpleMessage("1"),
|
||||
mFactory->NewSimpleMessage("2"),
|
||||
mFactory->NewSimpleMessage("3"));
|
||||
ASSERT_TRUE(mParts.Size() == oldSize + 3);
|
||||
}
|
||||
|
||||
TEST(Construction, AppendMultipleParts)
|
||||
{
|
||||
auto factory = fair::mq::TransportFactory::CreateTransportFactory("zeromq");
|
||||
fair::mq::Parts newParts(factory->NewSimpleMessage("1"),
|
||||
factory->NewSimpleMessage("2"),
|
||||
factory->NewSimpleMessage("3"));
|
||||
ASSERT_TRUE(newParts.Size() == 3);
|
||||
}
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user