2024-07-31 02:19:28 +00:00
|
|
|
module;
|
2024-02-27 21:27:05 +00:00
|
|
|
#include <gtest/gtest.h>
|
2024-07-31 02:19:28 +00:00
|
|
|
export module tests.go_interface;
|
2024-08-23 23:09:57 +00:00
|
|
|
import utempl;
|
2024-02-27 21:27:05 +00:00
|
|
|
|
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-07-31 02:19:28 +00:00
|
|
|
} // namespace utempl
|