vendredi 31 juillet 2015

In Rust, what is the idiomatic way to have a private function tested?

The Rust book says that using a "tests" module is the idiomatic way to have unit tests. But I cannot see a function from the super module in the tests module if that function is not marked 'pub'. How should one test internal functions then?

My first instinct was to look for a way to #ifdef the keyword pub. I have done this in the past for C++ testing. For Rust what I have done is simply have tests for private functions in the module and then tests for the public interface in the "tests" module.

Am I doing it right?

Aucun commentaire:

Enregistrer un commentaire