Skip to content

[C++] Cleaning up unit tests' global namespaces #545

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

Merged
merged 1 commit into from
Mar 13, 2018
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
3 changes: 1 addition & 2 deletions sbe-tool/src/test/cpp/BoundsCheckTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,6 @@
#include "code_generation_test/MessageHeader.h"
#include "code_generation_test/Car.h"

using namespace std;
using namespace code::generation::test;

#define SERIAL_NUMBER 1234u
Expand Down
3 changes: 1 addition & 2 deletions sbe-tool/src/test/cpp/CodeGenTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
#include "code_generation_test/MessageHeader.h"
#include "code_generation_test/Car.h"

using namespace std;
using namespace code::generation::test;

static const std::size_t BUFFER_LEN = 2048;
Expand Down
4 changes: 1 addition & 3 deletions sbe-tool/src/test/cpp/CompositeElementsTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,9 +22,7 @@
#include "otf/OtfHeaderDecoder.h"
#include "otf/OtfMessageDecoder.h"

using namespace std;
using namespace composite::elements;
using namespace sbe::otf;

enum EventNumber
{
Expand Down
3 changes: 1 addition & 2 deletions sbe-tool/src/test/cpp/CompositeOffsetsCodeGenTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
#include "composite_offsets_test/MessageHeader.h"
#include "composite_offsets_test/TestMessage1.h"

using namespace std;
using namespace composite::offsets::test;

class CompositeOffsetsCodeGenTest : public testing::Test
Expand Down
6 changes: 2 additions & 4 deletions sbe-tool/src/test/cpp/CompositeOffsetsIrTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,9 +22,7 @@
#include "otf/OtfMessageDecoder.h"
#include "otf/IrDecoder.h"

using namespace std;
using namespace composite::offsets::test;
using namespace sbe::otf;

static const char *SCHEMA_FILENAME = "composite-offsets-schema.sbeir";

Expand Down Expand Up @@ -165,4 +163,4 @@ TEST_F(CompositeOffsetsIrTest, shouldHandleAllEventsCorrectltInOrder)
EXPECT_EQ(result, static_cast<std::size_t>(52 - MessageHeader::encodedLength()));

EXPECT_EQ(m_eventNumber, 5);
}
}
4 changes: 2 additions & 2 deletions sbe-tool/src/test/cpp/GroupWithDataTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
#include "group_with_data/TestMessage3.h"
#include "group_with_data/TestMessage4.h"

using namespace std;
// using namespace std;
using namespace group::with::data;

static const std::uint32_t TAG_1 = 32;
Expand Down
6 changes: 2 additions & 4 deletions sbe-tool/src/test/cpp/MessageBlockLengthTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,9 +22,7 @@
#include "otf/OtfHeaderDecoder.h"
#include "otf/OtfMessageDecoder.h"

using namespace std;
using namespace message::block::length::test;
using namespace sbe::otf;

class MessageBlockLengthIrTest : public testing::Test, public OtfMessageDecoder::BasicTokenListener
{
Expand Down Expand Up @@ -191,4 +189,4 @@ TEST_F(MessageBlockLengthIrTest, shouldHandleAllEventsCorrectltInOrder)
EXPECT_EQ(result, static_cast<std::size_t>(54 - MessageHeader::encodedLength()));

EXPECT_EQ(m_eventNumber, 7);
}
}
39 changes: 19 additions & 20 deletions sbe-tool/src/test/cpp/Rc3OtfFullIrTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 Real Logic Ltd.
* Copyright 2013-2018 Real Logic Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@
#include "otf/OtfHeaderDecoder.h"
#include "otf/OtfMessageDecoder.h"

using namespace std;
using namespace code::generation::test;

static const char *SCHEMA_FILENAME = "code-generation-schema.sbeir";
Expand Down Expand Up @@ -283,7 +282,7 @@ class Rc3OtfFullIrTest : public testing::Test

void onBeginMessage(Token& token)
{
cout << m_eventNumber << ": Begin Message " << token.name() << " id " << token.fieldId() << "\n";
std::cout << m_eventNumber << ": Begin Message " << token.name() << " id " << token.fieldId() << "\n";

EXPECT_EQ(EventNumber(m_eventNumber), EN_beginMessage);
EXPECT_EQ(token.fieldId(), Car::sbeTemplateId());
Expand All @@ -292,7 +291,7 @@ class Rc3OtfFullIrTest : public testing::Test

void onEndMessage(Token& token)
{
cout << m_eventNumber << ": End Message " << token.name() << "\n";
std::cout << m_eventNumber << ": End Message " << token.name() << "\n";

EXPECT_EQ(EventNumber(m_eventNumber), EN_endMessage);
EXPECT_EQ(token.fieldId(), Car::sbeTemplateId());
Expand All @@ -306,7 +305,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::uint64_t actingVersion)
{
std::string name = (m_compositeLevel > 1) ? typeToken.name() : fieldToken.name();
cout << m_eventNumber << ": Encoding " << name << " offset " << typeToken.offset() << "\n";
std::cout << m_eventNumber << ": Encoding " << name << " offset " << typeToken.offset() << "\n";

const Encoding& encoding = typeToken.encoding();

Expand Down Expand Up @@ -543,7 +542,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::size_t toIndex,
std::uint64_t actingVersion)
{
cout << m_eventNumber << ": Enum " << determineName(fieldToken, tokens, fromIndex) << "\n";
std::cout << m_eventNumber << ": Enum " << determineName(fieldToken, tokens, fromIndex) << "\n";

const Token& typeToken = tokens.at(fromIndex + 1);
const Encoding& encoding = typeToken.encoding();
Expand All @@ -564,7 +563,7 @@ class Rc3OtfFullIrTest : public testing::Test
const Token& token = tokens.at(i);
const std::uint64_t constValue = token.encoding().constValue().getAsUInt();

cout << " " << token.name() << " = " << constValue << "\n";
std::cout << " " << token.name() << " = " << constValue << "\n";

if (constValue == value)
{
Expand All @@ -589,7 +588,7 @@ class Rc3OtfFullIrTest : public testing::Test
const Token& token = tokens.at(i);
const std::int64_t constValue = token.encoding().constValue().getAsUInt();

cout << " " << token.name() << " = " << constValue << "\n";
std::cout << " " << token.name() << " = " << constValue << "\n";

if (constValue == value)
{
Expand Down Expand Up @@ -617,7 +616,7 @@ class Rc3OtfFullIrTest : public testing::Test
const Token& token = tokens.at(i);
const std::int64_t constValue = token.encoding().constValue().getAsInt();

cout << " " << token.name() << " = " << constValue << "\n";
std::cout << " " << token.name() << " = " << constValue << "\n";

if (constValue == value.getAsInt())
{
Expand All @@ -641,7 +640,7 @@ class Rc3OtfFullIrTest : public testing::Test
const Token& token = tokens.at(i);
const std::int64_t constValue = token.encoding().constValue().getAsUInt();

cout << " " << token.name() << " = " << constValue << "\n";
std::cout << " " << token.name() << " = " << constValue << "\n";

if (constValue == value)
{
Expand All @@ -667,7 +666,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::size_t toIndex,
std::uint64_t actingVersion)
{
cout << m_eventNumber << ": Bit Set " << fieldToken.name() << "\n";
std::cout << m_eventNumber << ": Bit Set " << fieldToken.name() << "\n";

const Token& typeToken = tokens.at(fromIndex + 1);
const Encoding& encoding = typeToken.encoding();
Expand All @@ -690,15 +689,15 @@ class Rc3OtfFullIrTest : public testing::Test

if (constValue && value)
{
cout << " * ";
std::cout << " * ";
bitsSet++;
}
else
{
cout << " ";
std::cout << " ";
}

cout << token.name() << " = " << constValue << "\n";
std::cout << token.name() << " = " << constValue << "\n";
}
EXPECT_EQ(bitsSet, 2);
break;
Expand All @@ -719,7 +718,7 @@ class Rc3OtfFullIrTest : public testing::Test
m_compositeLevel++;
std::string name = determineName(fieldToken, tokens, fromIndex);

cout << m_eventNumber << ": Begin Composite " << name << "\n";
std::cout << m_eventNumber << ": Begin Composite " << name << "\n";

switch (EventNumber(m_eventNumber))
{
Expand Down Expand Up @@ -749,7 +748,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::string name = determineName(fieldToken, tokens, fromIndex);
m_compositeLevel--;

cout << m_eventNumber << ": End Composite " << name << "\n";
std::cout << m_eventNumber << ": End Composite " << name << "\n";

switch (EventNumber(m_eventNumber))
{
Expand All @@ -774,7 +773,7 @@ class Rc3OtfFullIrTest : public testing::Test
Token& token,
std::uint64_t numInGroup)
{
cout << m_eventNumber << ": Group Header " << token.name() << " num " << numInGroup << "\n";
std::cout << m_eventNumber << ": Group Header " << token.name() << " num " << numInGroup << "\n";

switch (EventNumber(m_eventNumber))
{
Expand Down Expand Up @@ -815,7 +814,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::uint64_t groupIndex,
std::uint64_t numInGroup)
{
cout << m_eventNumber << ": Begin Group " << token.name() << " " << groupIndex + 1 << "/" << numInGroup << "\n";
std::cout << m_eventNumber << ": Begin Group " << token.name() << " " << groupIndex + 1 << "/" << numInGroup << "\n";

switch (EventNumber(m_eventNumber))
{
Expand Down Expand Up @@ -908,7 +907,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::uint64_t groupIndex,
std::uint64_t numInGroup)
{
cout << m_eventNumber << ": End Group " << token.name() << " " << groupIndex + 1 << "/" << numInGroup << "\n";
std::cout << m_eventNumber << ": End Group " << token.name() << " " << groupIndex + 1 << "/" << numInGroup << "\n";

switch (EventNumber(m_eventNumber))
{
Expand Down Expand Up @@ -1002,7 +1001,7 @@ class Rc3OtfFullIrTest : public testing::Test
std::uint64_t length,
Token& typeToken)
{
cout << m_eventNumber << ": Data " << fieldToken.name() << "\n";
std::cout << m_eventNumber << ": Data " << fieldToken.name() << "\n";

switch (EventNumber(m_eventNumber))
{
Expand Down