Skip to content

Feat/test mod#104

Open
mchalupiak wants to merge 6 commits into
mainfrom
feat/TestMod
Open

Feat/test mod#104
mchalupiak wants to merge 6 commits into
mainfrom
feat/TestMod

Conversation

@mchalupiak
Copy link
Copy Markdown
Collaborator

Test mod code

@apet2929
Copy link
Copy Markdown
Collaborator

Thoughts on adding these?

fn megaton_assert_msg<T: std::cmp::PartialEq + std::fmt::Debug>(&mut self, result: T, expected: T, msg: &str) {
        self.total_tests += 1;
        self.category_tests += 1;
        if result != expected {
            self.megaton_log(format!("Test number {:#?} failed: got {:#?}, expected {:#?}. Message: {:?}\n", self.total_tests, result, expected, msg).as_str());
        } else {
            self.passed_tests += 1;
            self.category_passed_tests += 1;
        }
    }

    fn megaton_assert_ok<T,E>(&mut self, result: Result<T,E>, msg: &str) -> Option<T> 
    where 
        T: std::fmt::Debug,
        E: std::fmt::Debug 
        {
        self.total_tests += 1;
        self.category_tests += 1;
        if result.is_err() {
            self.megaton_log(format!("Test number {:#?} failed: received Err: {:?}. Message: {:?}\n", self.total_tests, result.unwrap_err(), msg).as_str());
            return None;
        } else {
            self.passed_tests += 1;
            self.category_passed_tests += 1;
            return Some(result.unwrap());
        }
    }
    ```

Copy link
Copy Markdown
Collaborator

@Pistonight Pistonight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see the functions that we were talking about in the meeting (like assert_ok), please make sure all changes are pushed

Comment thread packages/test-mod/src/lib.rs Outdated
passed_tests: usize,
category_tests: usize,
category_passed_tests: usize,
category: &'a str
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lifetime will give a lot of trouble, recommend to just make it &'static

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants