mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-02-03 13:03:22 +00:00
FEXLinuxTests/thunks: Add tests for opaque types
This commit is contained in:
parent
6a6886305e
commit
0cf2695772
@ -10,4 +10,13 @@ extern "C" {
|
||||
|
||||
uint32_t GetDoubledValue(uint32_t);
|
||||
|
||||
|
||||
/// Interfaces used to test opaque_type and assume_compatible_data_layout annotations
|
||||
|
||||
struct OpaqueType;
|
||||
|
||||
OpaqueType* MakeOpaqueType(uint32_t data);
|
||||
uint32_t ReadOpaqueTypeData(OpaqueType*);
|
||||
void DestroyOpaqueType(OpaqueType*);
|
||||
|
||||
}
|
||||
|
@ -6,4 +6,20 @@ uint32_t GetDoubledValue(uint32_t input) {
|
||||
return 2 * input;
|
||||
}
|
||||
|
||||
struct OpaqueType {
|
||||
uint32_t data;
|
||||
};
|
||||
|
||||
OpaqueType* MakeOpaqueType(uint32_t data) {
|
||||
return new OpaqueType { data };
|
||||
}
|
||||
|
||||
uint32_t ReadOpaqueTypeData(OpaqueType* value) {
|
||||
return value->data;
|
||||
}
|
||||
|
||||
void DestroyOpaqueType(OpaqueType* value) {
|
||||
delete value;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
@ -12,3 +12,8 @@ template<auto, int, typename>
|
||||
struct fex_gen_param {};
|
||||
|
||||
template<> struct fex_gen_config<GetDoubledValue> {};
|
||||
|
||||
template<> struct fex_gen_type<OpaqueType> : fexgen::opaque_type {};
|
||||
template<> struct fex_gen_config<MakeOpaqueType> {};
|
||||
template<> struct fex_gen_config<ReadOpaqueTypeData> {};
|
||||
template<> struct fex_gen_config<DestroyOpaqueType> {};
|
||||
|
@ -17,8 +17,18 @@ struct Fixture {
|
||||
|
||||
#define GET_SYMBOL(name) decltype(&::name) name = (decltype(name))dlsym(lib, #name)
|
||||
GET_SYMBOL(GetDoubledValue);
|
||||
|
||||
GET_SYMBOL(MakeOpaqueType);
|
||||
GET_SYMBOL(ReadOpaqueTypeData);
|
||||
GET_SYMBOL(DestroyOpaqueType);
|
||||
};
|
||||
|
||||
TEST_CASE_METHOD(Fixture, "Trivial") {
|
||||
CHECK(GetDoubledValue(10) == 20);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(Fixture, "Opaque data types") {
|
||||
auto data = MakeOpaqueType(0x1234);
|
||||
CHECK(ReadOpaqueTypeData(data) == 0x1234);
|
||||
DestroyOpaqueType(data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user