Hi everyone,
I added c++ library to my rust code and I want to use it in tests. My issue is that output from this library displayed before main output (but expected result is opposite). This is how c++ function was added:
#[cfg(test)]
mod tests {
// ...
extern "C" {
#[link(name="srp6_dir", kind="static")]
fn test_srp6(B_str: *const c_char, s_str: *const c_char, account_str: *const c_char);
}
}
and next I use it in one of my tests:
#[test]
fn test_proof() {
// ... rest of calculations and output
let B_str = CString::new(format!("{:?}", B)).expect("Failed to create CString for B");
let s_str = CString::new(format!("{:?}", _salt)).expect("Failed to create CString for s");
let account_str = CString::new(account.to_string()).expect("Failed to create CString for account");
unsafe {
println!("C++ code result");
test_srp6(B_str.as_ptr(), s_str.as_ptr(), account_str.as_ptr());
}
}
Expected result:
... rest of calculations and output
C++ code result
... output from test_srp6
Actual result:
... output from test_srp6
... rest of calculations and output
C++ code result
Could somebody explain why this happen and how to fix it ?