mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-08 01:36:44 +08:00
Implemented a test for std::hash.
This commit is contained in:
parent
9517c4879c
commit
5b3bad3ce5
@ -16,7 +16,7 @@
|
||||
BETTER_ENUM(Channel, short, Red, Green, Blue)
|
||||
BETTER_ENUM(Depth, short, HighColor = 40, TrueColor = 20)
|
||||
BETTER_ENUM(Compression, short, None, Huffman, Default = Huffman)
|
||||
|
||||
BETTER_ENUMS_DECLARE_STD_HASH(Channel)
|
||||
|
||||
|
||||
namespace test {
|
||||
@ -158,9 +158,17 @@ static_assert_1(same_string(Depth::_names()[0], "HighColor"));
|
||||
|
||||
#endif // #ifdef _ENUM_HAVE_CONSTEXPR
|
||||
|
||||
|
||||
|
||||
// Run-time testing.
|
||||
class HashTests : public CxxTest::TestSuite {
|
||||
public:
|
||||
void test_same_values()
|
||||
{
|
||||
TS_ASSERT_EQUALS(std::hash<Channel>().operator()(Channel::Red), std::hash<int>().operator()(0));
|
||||
TS_ASSERT_EQUALS(std::hash<Channel>().operator()(Channel::Green), std::hash<int>().operator()(1));
|
||||
TS_ASSERT_EQUALS(std::hash<Channel>().operator()(Channel::Blue), std::hash<int>().operator()(2));
|
||||
}
|
||||
};
|
||||
|
||||
class EnumTests : public CxxTest::TestSuite {
|
||||
public:
|
||||
void test_constant_values()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user