-
Say I have this code:
and I want to test the error case where socket creation fails.
The problem, or at least one problem, is with the definition of the traits and the mock objects. Another is with my understanding of how mockall works. Does
automatically create a mock of the zmq::Socket stuct? The error I am getting is with the declaration of the socket function in MockZmqContext. The compiler is telling me that I have to put 'dyn' in front of MockSocket because MockSocket is a trait object but that leads to other errors and I think the problem is more fundamental than that. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 16 replies
-
Is |
Beta Was this translation helpful? Give feedback.
Is
zmq::Socket
a struct or a trait? Because what you wrote assumes that it's a trait. And if you fix that , then what it will create is a struct with the same API as the real struct, but it can't be passed to functions expecting the real struct. So you need to make the substitution at compile time. First fix your trait/struct confusion and then the next step will be more obvious.