rust_programming_book 0.1.1

Programming works from THE RUST PROGRAMMING LANGUAGE
Documentation
// we need to write this statement in integration testing as each file under test directory is
// separate crate
// compiler knows all files under tests folder are integration test files(except under /tests/common/).

/**

 * integration test run if all unit tests are passed
 */
use rust_programming_book::impl_dyn::{Animal, Cow, Dog, Herbivore};

/**

 * difference of mod and use is
 * mod: is used to add the file to include it to the module tree(main.rs for bin project, lib.rs for unit testing and integration_test.rs
 * for integration testing)
 * use: is used to access the data from any mod when the module tree file makes other mods public.
 */
mod common;

#[test]
fn integration_adds_ten() {
    // integration test can use the public function from unit test files(lib.rs, controlling_test.rs etc)not the test function.
    assert_eq!(20, 10 + 10)
}

// we can only the the integration test using "cargo test --test integration_test " command
#[test]
fn dyn_impl_testing() {
    let animal1 = rust_programming_book::impl_dyn::Dog {
        name: "Mikky".to_string(),
        age: 1,
    };
    let cow = Cow {
        name: "Pretty cow".to_string(),
        weight: 243,
    };

    cow.eats();

    assert_eq!(animal1.feed(), "yerp");
}

#[test]
fn factorial_testing() {
    // we could use "use common::factorial" on the top
    assert_eq!(120, common::factorial(5))
}