blob: e3984ca171bf04d2db6189fb978bd94090e90ffd [file] [log] [blame]
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +01001#include "utils/conversion.hpp"
2
3#include <gmock/gmock.h>
4
5using namespace testing;
6
7class TestEnum : public Test
8{
9 public:
10 enum class Enum
11 {
12 zero = 0,
13 one,
14 two
15 };
16
17 Enum toEnum(int x)
18 {
19 return utils::toEnum<Enum, Enum::zero, Enum::two>(x);
20 }
21};
22
23TEST_F(TestEnum, passValueInRangeExpectToGetValidOutput)
24{
25 EXPECT_EQ(toEnum(0), Enum::zero);
26 EXPECT_EQ(toEnum(2), Enum::two);
27}
28
29TEST_F(TestEnum, passInvalidValueExpectToThrowOutOfRangeException)
30{
31 EXPECT_THROW(toEnum(-1), std::out_of_range);
32 EXPECT_THROW(toEnum(3), std::out_of_range);
33}