2024-02-27 21:27:05 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <utempl/go_interface.hpp>
|
|
|
|
|
|
|
|
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) {
|
|
|
|
utempl::GoInterface<SomeInterface> obj(SomeStruct{1});
|
|
|
|
EXPECT_EQ(obj.field, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST(GoInterface, Equal) {
|
|
|
|
utempl::GoInterface<SomeInterface> obj(SomeStruct{1});
|
|
|
|
EXPECT_EQ(obj, utempl::GoInterface{SomeInterface{1}});
|
|
|
|
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
|
|
|
};
|