Skip to content

Commit

Permalink
added structured enum test
Browse files Browse the repository at this point in the history
  • Loading branch information
dakka committed May 19, 2024
1 parent eddcdb3 commit 97a1aae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 49 deletions.
46 changes: 0 additions & 46 deletions examples/statictest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,45 +34,6 @@
//-----------------------------------------------------------------------------------------
enum class component : int { scheme, authority, userinfo, user, password, host, port, path, query, fragment };

/*
namespace TEST
{
enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
namespace TEST1
{
enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
namespace TEST2::TEST3::TEST4::TEST5
{
enum class NineEnums : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
enum NineEnums1 : int { One, Two, Three, Four, Five, Six, Seven, Eight, Nine };
}
}
}
namespace gsdsp::dsp::fd
{
class AnalysisFrame
{
public:
enum class PrecomputedFrames
{ one };
};
}
namespace gsdsp::utilities
{
template <typename E>
[[nodiscard]]
constexpr size_t countOf()
{
return FIX8::conjure_enum<E>::count();
}
}
*/

//-----------------------------------------------------------------------------------------
using namespace FIX8;

Expand All @@ -88,12 +49,5 @@ int main(void)
for(const auto& a : conjure_enum<component>::unscoped_names)
std::cout << a << '\n';

/*
for(const auto& [a, b] : conjure_enum<TEST::TEST1::TEST2::TEST3::TEST4::TEST5::NineEnums>::entries)
std::cout << conjure_enum<TEST::TEST1::TEST2::TEST3::TEST4::TEST5::NineEnums>::enum_to_int(a) << ' ' << b << '\n';
std::cout << conjure_enum<TEST::TEST1::TEST2::TEST3::TEST4::TEST5::NineEnums>::count() << '\n';
std::cout << gsdsp::utilities::countOf<gsdsp::dsp::fd::AnalysisFrame::PrecomputedFrames>() << '\n';
*/
return 0;
}
32 changes: 29 additions & 3 deletions utests/edgetests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
#include <iostream>
#include <fix8/conjure_enum.hpp>

//-----------------------------------------------------------------------------------------
using namespace FIX8;

//-----------------------------------------------------------------------------------------
namespace
{
Expand All @@ -59,6 +56,30 @@ namespace TEST
}
}

namespace test::rsp::gd
{

class AFrame
{
public:
enum class PreFrames
{ one };
};
}

namespace test::util
{
template <typename E>
[[nodiscard]]
constexpr size_t countOf()
{
return FIX8::conjure_enum<E>::count();
}
}

//-----------------------------------------------------------------------------------------
using namespace FIX8;

//-----------------------------------------------------------------------------------------
// run as: ctest --output-on-failure
//-----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -228,3 +249,8 @@ TEST_CASE("nested anonymous type")
}

//-----------------------------------------------------------------------------------------
TEST_CASE("nested structured enum")
{
REQUIRE(test::util::countOf<test::rsp::gd::AFrame::PreFrames>() == 1);
}

0 comments on commit 97a1aae

Please sign in to comment.