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

Is it possible to mock static functions?


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

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?


"Do or do not. There is no try"
  Yoda Master

Re: Is it possible to mock static functions?Andreas Schneider <asn@xxxxxxxxxxxxxx>