开发者

How to test COM object integrity automatically?

开发者 https://www.devze.com 2022-12-23 05:09 出处:网络
Every COM object must have integrity. In simplified terms this mean开发者_JS百科s that if an object implements 3 interfaces - A, B and C and I have A* pointer to the object I must be able to successfu

Every COM object must have integrity. In simplified terms this mean开发者_JS百科s that if an object implements 3 interfaces - A, B and C and I have A* pointer to the object I must be able to successfully QueryInterface() both B and C and having B I must be able to retrieve A and C and having C I must be able to retrieve A and B.

Now my object implements 5 interfaces and I want to test its integrity. Writing checks for all of the above myself will require a substantial effort. Is there a tool or some easily tweakable code or a code pattern that would do it?


I don't see the problem. If you implement A, B and C then interface A must QI properly for A, B, C and IUnknown. Including itself. The test is the same for all interfaces, you need only one small function that takes an IUnknown* argument.


If I understood it correctly you want to proof that your implementation abides by COM IUnknown rules (transitivity, reflexivity, etc.) and you are concerned with the exponential explosion based on the number of interfaces right?

If you have the component type library you can write an application that figures out the coclasses/interfaces and emits code to test these rules (this application is generic and can be used with any component that has a type library). Maybe you can even find one in the net (I didn't searched)

Best

Adriano

0

精彩评论

暂无评论...
验证码 换一张
取 消