Skip to content

Commit

Permalink
iox-eclipse-iceoryx#563 move tests in utils moduletests into anonymou…
Browse files Browse the repository at this point in the history
…s namespace

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
  • Loading branch information
elBoberido committed Apr 1, 2021
1 parent 79db27b commit 9c04c80
Show file tree
Hide file tree
Showing 57 changed files with 215 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define IOX_UTILS_OBJECTPOOL_OBJECTPOOL_HPP

#include <cstddef> //for size_t
#include <cstdint>
#include <utility> //for std::forward

namespace iox
Expand Down
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_access_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <stdlib.h>

namespace
{
using namespace ::testing;
using namespace iox::posix;

Expand Down Expand Up @@ -258,4 +260,5 @@ TEST_F(AccessController_test, addStrangeNames)
// non-existing group name specified
EXPECT_FALSE(entryAdded);
}
} // namespace
#endif
4 changes: 3 additions & 1 deletion iceoryx_utils/test/moduletests/test_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include "iceoryx_utils/internal/posix_wrapper/shared_memory_object/allocator.hpp"
#include "test.hpp"


namespace
{
using namespace testing;

class Allocator_Test : public Test
Expand Down Expand Up @@ -116,3 +117,4 @@ TEST_F(Allocator_Test, allocateAfterFinalizeAllocation)
std::set_terminate([]() { std::cout << "", std::abort(); });
EXPECT_DEATH({ sut.allocate(5); }, ".*");
}
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

#include <cstring>

using namespace ::testing;

namespace
{
using namespace ::testing;

using byte_t = std::uint8_t;

template <size_t n, size_t alignment>
Expand Down
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_concurrent_fifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <gtest/gtest.h>
#include <stdlib.h>

namespace
{
using namespace testing;
using namespace iox::concurrent;

Expand Down Expand Up @@ -108,3 +110,4 @@ TEST_F(FiFo_Test, OverflowFromFullToEmptyRepetition)
EXPECT_THAT(sut.empty(), Eq(true));
}
}
} // namespace
4 changes: 3 additions & 1 deletion iceoryx_utils/test/moduletests/test_concurrent_loffli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include <random>
#include <vector>

namespace
{
using namespace ::testing;


constexpr uint32_t Size{4};
using LoFFLiTestSubjects = Types<iox::concurrent::LoFFLi>;
/// we require TYPED_TEST since we support gtest 1.8 for our safety targets
Expand Down Expand Up @@ -196,3 +197,4 @@ TYPED_TEST(LoFFLi_test, PushToUninitializedLoFFLi)
decltype(this->m_loffli) loFFLi;
EXPECT_THAT(loFFLi.push(0), Eq(false));
}
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <cstdint>
#include <functional>

namespace
{
using namespace ::testing;
using namespace iox;
using namespace iox::concurrent;
Expand Down Expand Up @@ -246,3 +248,4 @@ TIMING_TEST_F(PeriodicTask_test, PeriodicTaskWhichIsExecutingTheCallableIsBlocki

EXPECT_THAT(elapsedTime, Ge(SLEEP_TIME));
});
} // namespace
5 changes: 2 additions & 3 deletions iceoryx_utils/test/moduletests/test_concurrent_sofi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <gtest/gtest.h>
#include <stdlib.h>


namespace gtest_daddy_container_sofi_unittest
namespace
{
class CUnitTestContainerSoFi : public ::testing::Test
{
Expand Down Expand Up @@ -465,4 +464,4 @@ TEST_F(CUnitTestContainerSoFi, PopIfInvalidNotEmptyAfter)
}

/// @todo popif empty test
} // namespace gtest_daddy_container_sofi_unittest
} // namespace
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_concurrent_taco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <iostream>

namespace
{
using namespace ::testing;

struct TestData
Expand Down Expand Up @@ -260,3 +262,4 @@ TEST_F(TACO_test, DoubleExchange)
ASSERT_THAT(retVal_2.has_value(), Eq(true));
EXPECT_THAT(*retVal_2, Eq(ExpectedData_2));
}
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "iceoryx_utils/internal/concurrent/trigger_queue.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;

template <typename QueueType>
Expand Down Expand Up @@ -138,3 +140,5 @@ TYPED_TEST(TriggerQueue_test, Capacity)
{
EXPECT_THAT(this->m_sut->capacity(), helper::GetCapacity(this->m_sut.value()));
}

} // namespace
7 changes: 3 additions & 4 deletions iceoryx_utils/test/moduletests/test_cxx_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include "iceoryx_utils/cxx/algorithm.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::algorithm;
using namespace iox::cxx;

namespace
{
class algorithm_test : public Test
{
public:
Expand All @@ -41,8 +41,6 @@ class algorithm_test : public Test
}
};

} // namespace

TEST_F(algorithm_test, MaxOfOneElement)
{
EXPECT_THAT(max(12.34f), Eq(12.34f));
Expand Down Expand Up @@ -247,3 +245,4 @@ TEST_F(algorithm_test, MergeWithOverlappingOneElementContainer)
EXPECT_THAT(mergedContainer[i], Eq(i + OFFSET));
EXPECT_TRUE(mergedContainer == mergedContainerSwitched);
}
} // namespace
4 changes: 3 additions & 1 deletion iceoryx_utils/test/moduletests/test_cxx_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@


#include <cstdint>

namespace
{
using namespace ::testing;

using NumberType = iox::cxx::convert::NumberType;
Expand Down Expand Up @@ -351,3 +352,4 @@ TEST_F(convert_test, fromString_MinMaxUNSIGNED_Int)
source = "-1";
EXPECT_THAT(iox::cxx::convert::fromString(source.c_str(), destination), Eq(false));
}
} // namespace
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_cxx_deadline_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <chrono>
#include <thread>

namespace
{
using namespace ::testing;

using namespace iox::units;
Expand Down Expand Up @@ -140,3 +142,4 @@ TIMING_TEST_F(DeadlineTimer_test, RemainingTimeCheckIfNotExpired, Repeat(5), [&]

TIMING_TEST_EXPECT_TRUE(remainingTime >= EXPECTED_REMAINING_TIME && remainingTime <= PASSED_TIMER_TIME);
});
} // namespace
72 changes: 39 additions & 33 deletions iceoryx_utils/test/moduletests/test_cxx_expected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include "test.hpp"

using namespace ::testing;
using namespace iox::cxx;
using namespace ::iox::cxx;

namespace
{
class MockCallables
{
public:
Expand All @@ -30,47 +32,46 @@ class MockCallables
MOCK_METHOD0(onError, void());
};

class expected_test : public Test

struct TestClass
{
public:
struct TestClass
TestClass(int a, int b)
: m_a(a)
, m_b(b)
{
TestClass(int a, int b)
: m_a(a)
, m_b(b)
{
}

int gimme()
{
return m_a + m_b;
}

int constGimme() const
{
return m_a + m_b;
}

bool operator==(const TestClass& rhs) const
{
return (m_a == rhs.m_a) && (m_b == rhs.m_b);
}

int m_a;
int m_b;
};
}

int gimme()
{
return m_a + m_b;
}

int constGimme() const
{
return m_a + m_b;
}

bool operator==(const TestClass& rhs) const
{
return (m_a == rhs.m_a) && (m_b == rhs.m_b);
}

int m_a;
int m_b;
};

} // namespace

namespace iox
{
namespace cxx
{
template <>
struct ErrorTypeAdapter<expected_test::TestClass>
struct ErrorTypeAdapter<TestClass>
{
static expected_test::TestClass getInvalidState()
static TestClass getInvalidState()
{
return expected_test::TestClass(-1, -1);
return TestClass(-1, -1);
}
};

Expand All @@ -85,8 +86,13 @@ struct ErrorTypeAdapter<std::string>
} // namespace cxx
} // namespace iox

namespace
{
class expected_test : public Test
{
};

using TestClassAdapter = iox::cxx::ErrorTypeAdapter<expected_test::TestClass>;
using TestClassAdapter = iox::cxx::ErrorTypeAdapter<TestClass>;

enum class TestError : uint8_t
{
Expand Down Expand Up @@ -597,4 +603,4 @@ TEST_F(expected_test, OrElseInErrorExpectedWithEmptyCallableDoesNotDie)
sut1.or_else(iox::cxx::function_ref<void(TestError&)>());
sut2.or_else(iox::cxx::function_ref<void(TestError&)>());
}

} // namespace
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_cxx_function_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "iceoryx_utils/cxx/function_ref.hpp"
#include "test.hpp"

namespace
{
using namespace ::testing;
using namespace iox::cxx;

Expand Down Expand Up @@ -313,3 +315,4 @@ TEST_F(function_refTest, CallOverloadedFunctionResultsInCallOfIntInt)
auto value = SameSignature([](int value1, int value2 [[gnu::unused]]) -> int { return value1; });
EXPECT_THAT(value, Eq(sameSignatureIntIntTestValue));
}
} // namespace
4 changes: 3 additions & 1 deletion iceoryx_utils/test/moduletests/test_cxx_generic_raii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "iceoryx_utils/cxx/optional.hpp"
#include "test.hpp"


namespace
{
using namespace ::testing;
using namespace iox::cxx;

Expand Down Expand Up @@ -137,3 +138,4 @@ TEST_F(GenericRAII_test, MoveAssignedCallsCleanupWhenOutOfScope)

EXPECT_THAT(hasCalledCleanup2, Eq(1));
}
} // namespace
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_cxx_helplets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <type_traits>

namespace
{
using namespace ::testing;
using namespace iox::cxx;

Expand Down Expand Up @@ -187,3 +189,4 @@ TYPED_TEST(Helplets_test_isPowerOfTwo, MaxValueForTypeIsNotPowerOfTwo)
{
EXPECT_FALSE(isPowerOfTwo(static_cast<typename TestFixture::CurrentType>(TestFixture::MAX)));
}
} // namespace
5 changes: 2 additions & 3 deletions iceoryx_utils/test/moduletests/test_cxx_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
#include "iceoryx_utils/cxx/list.hpp"
#include "test.hpp"


namespace
{
using namespace ::testing;
using namespace iox::cxx;

namespace
{
static constexpr uint64_t TESTLISTCAPACITY{10U};
static constexpr int64_t TEST_LIST_ELEMENT_DEFAULT_VALUE{-99L};

Expand Down
4 changes: 3 additions & 1 deletion iceoryx_utils/test/moduletests/test_cxx_method_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

#include "iceoryx_utils/cxx/method_callback.hpp"

namespace
{
using namespace ::testing;
using namespace iox;
using namespace iox::cxx;


class MethodCallback_test : public Test
{
public:
Expand Down Expand Up @@ -373,3 +374,4 @@ TEST_F(MethodCallback_test, MoveAssignemtnDestinationCanCallCallbackForMethod)
ASSERT_FALSE(result.has_error());
EXPECT_EQ(*result, 22);
}
} // namespace
3 changes: 3 additions & 0 deletions iceoryx_utils/test/moduletests/test_cxx_newtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "test.hpp"
#include "testutils/compile_test.hpp"

namespace
{
using namespace ::testing;
using namespace iox;
using namespace iox::cxx;
Expand Down Expand Up @@ -144,3 +146,4 @@ TEST(NewType, AssignByValueMoveDoesCompile)

EXPECT_TRUE(a == b);
}
} // namespace
Loading

0 comments on commit 9c04c80

Please sign in to comment.