Open zaq7434 opened 5 days ago
This is really a duplicate of #602 . I can easily fix it; however that will break one other user's use case. Sadly, I think I'll have to do that. But until then, the easiest way for you to fix your problem is to not link the C file into your project when you build the unit tests. Only link the C file into your real executable. That's usually a good idea anyway.
This is really a duplicate of #602 . I can easily fix it; however that will break one other user's use case. Sadly, I think I'll have to do that. But until then, the easiest way for you to fix your problem is to not link the C file into your project when you build the unit tests. Only link the C file into your real executable. That's usually a good idea anyway.
If you don't link C libraries, you can, but this is to design the test framework for c, and I want to use cargo test to test rust and c together. So I'd like to be able to mock C, like do_something() in the example, which he didn't import into Rust.
In your test program, do you expect that get_num
will be called by another C function, or by a Rust function?
In your test program, do you expect that
get_num
will be called by another C function, or by a Rust function?
'get_num' will called by rust function, 'get_num' call another C function -- 'do something', i want mock 'do something'
But in the example, you showed mocking get_num
, not do_something
. How are you getting multiple definition errors of functions that you haven't mocked?
my project with rust and c. i want use rust to rest c function. when i to make mock c function in rust, get multiple definition error!
use build.rs to build c file.
when i run 'cargo test' error: multiple definition of `get_num'
Another problem is that: how to mock 'do_someting()'
I hope you can give me some suggestions. thank you very mach!