void SetUp() { dl_create_params_t p; DL_CREATE_PARAMS_SET_DEFAULT(p); p.error_msg_func = error_msg_handler; EXPECT_DL_ERR_OK( dl_context_create( &ctx, &p ) ); }
TEST_F(DLError, typelib_version_mismatch_returned) { static const unsigned char typelib[] = { #include "generated/unittest.bin.h" }; unsigned char modded_type_lib[sizeof(typelib)]; memcpy( modded_type_lib, typelib, sizeof(typelib) ); EXPECT_EQ(4u, sizeof(unsigned int)); union { unsigned char* lib; unsigned int* version; } conv; conv.lib = modded_type_lib; // testing that errors are returned correctly by modding data. unsigned int* lib_version = conv.version + 1; EXPECT_EQ(4u, *lib_version); *lib_version = 0xFFFFFFFF; dl_ctx_t tmp_ctx = 0; dl_create_params_t p; DL_CREATE_PARAMS_SET_DEFAULT(p); EXPECT_DL_ERR_OK( dl_context_create( &tmp_ctx, &p ) ); EXPECT_DL_ERR_EQ( DL_ERROR_VERSION_MISMATCH, dl_context_load_type_library( tmp_ctx, modded_type_lib, sizeof(modded_type_lib) ) ); EXPECT_DL_ERR_OK( dl_context_destroy( tmp_ctx ) ); }