tests: initial internal and integration tests

* src/lib.rs: examples for internel tests
* tests/integration_tests.rs: examples for external callable tests

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2019-10-30 23:40:59 +01:00
parent 61d85f155a
commit cb4c96ee63
2 changed files with 40 additions and 0 deletions

33
src/lib.rs Normal file
View File

@@ -0,0 +1,33 @@
// This function adds two integers (given as arguments) and returns the sum.
//
// # Examples
//
// ```
// assert_eq!(8, advotracker::internal_adder(4, 4));
// ```
fn internal_adder(a: i32, b: i32) -> i32 {
a + b
}
/// This function adds two to its argument.
///
/// # Examples
///
/// ```
/// assert_eq!(4, advotracker::add_two(2));
/// ```
pub fn add_two(a: i32) -> i32 {
internal_adder(a, 2)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn internal_test() {
assert_eq!(8, internal_adder(4, 4));
}
}