Files
FairMQ/test/parts/_add_part.cxx
Claude f1ae05b45c test: use comparison assertions that print both values
- EXPECT_EQ/EXPECT_NE instead of EXPECT_TRUE(a == b) in the parts,
  memory resource and plugin manager tests; split the && checks
- ASSERT_NE on the message pointer before it is dereferenced
- ASSERT_TRUE/ASSERT_FALSE instead of ASSERT_EQ(x, true/false)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:00:01 +01:00

74 lines
2.3 KiB
C++

/********************************************************************************
* 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_EQ(mParts.Size(), newSize);
}
TEST_F(AddPart, SinglePart)
{
auto const oldSize = mParts.Size();
mParts.AddPart(mFactory->NewSimpleMessage("asdf"));
ASSERT_EQ(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_EQ(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_EQ(newParts.Size(), 3U);
}
} // namespace