2024-02-27 21:27:05 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <utempl/go_interface.hpp>
|
|
|
|
|
2024-02-27 22:35:29 +00:00
|
|
|
namespace utempl {
|
|
|
|
|
2024-02-27 21:27:05 +00:00
|
|
|
struct SomeInterface {
|
|
|
|
int field;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SomeStruct {
|
|
|
|
int field;
|
2024-02-27 22:19:19 +00:00
|
|
|
friend auto operator==(const SomeInterface& a, const SomeStruct& b) -> bool {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SomeStruct2 {
|
|
|
|
int field;
|
2024-02-27 21:27:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST(GoInterface, Basic) {
|
2024-02-27 22:35:29 +00:00
|
|
|
GoInterface<SomeInterface> obj(SomeStruct{1});
|
2024-02-27 21:27:05 +00:00
|
|
|
EXPECT_EQ(obj.field, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST(GoInterface, Equal) {
|
2024-02-27 22:35:29 +00:00
|
|
|
GoInterface<SomeInterface> obj(SomeStruct{1});
|
|
|
|
EXPECT_EQ(obj, GoInterface{SomeInterface{1}});
|
2024-02-27 21:27:05 +00:00
|
|
|
EXPECT_EQ(obj, SomeInterface{1});
|
2024-02-27 22:19:19 +00:00
|
|
|
EXPECT_NE(obj, SomeStruct{1});
|
|
|
|
EXPECT_EQ(obj, SomeStruct2{1});
|
2024-02-27 21:27:05 +00:00
|
|
|
};
|
2024-02-27 22:35:29 +00:00
|
|
|
} // namespace utempl
|
|
|
|
|