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:
33
src/lib.rs
Normal file
33
src/lib.rs
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user