utempl/tests/go_interface.cpp

36 lines
695 B
C++
Raw Normal View History

2024-07-31 02:19:28 +00:00
module;
#include <gtest/gtest.h>
2024-07-31 02:19:28 +00:00
export module tests.go_interface;
import utempl.go_interface;
2024-02-27 22:35:29 +00:00
namespace utempl {
struct SomeInterface {
int field;
};
struct SomeStruct {
int field;
friend auto operator==(const SomeInterface& a, const SomeStruct& b) -> bool {
return false;
};
};
struct SomeStruct2 {
int field;
};
TEST(GoInterface, Basic) {
2024-02-27 22:35:29 +00:00
GoInterface<SomeInterface> obj(SomeStruct{1});
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}});
EXPECT_EQ(obj, SomeInterface{1});
EXPECT_NE(obj, SomeStruct{1});
EXPECT_EQ(obj, SomeStruct2{1});
};
2024-07-31 02:19:28 +00:00
} // namespace utempl