[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to mock static functions?


On Thursday, 22 December 2016 23:08:32 CET Daniel. wrote:
> Hi

Hello,

> I have a library that I want to test using cmocka. By the way, what a
> wonderful project!!!

thank you very much.

> That library has a static predicate function that returns true for
> connection and false for lack of it. There is another public write
> function that send data. I want to test the write function, but it
> checks if there is connection, returning error if not, so how can I
> mock the predicate to return a fake true? Is possible to mock static
> functions from a shared object?

Yes, it is possible if you include the .c file in your test source code.


	Andreas


-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx

Follow-Ups:
Re: Is it possible to mock static functions?"Daniel." <danielhilst@xxxxxxxxx>
References:
Is it possible to mock static functions?"Daniel." <danielhilst@xxxxxxxxx>