summaryrefslogtreecommitdiff
path: root/src/helpers.rs
blob: e0b560b5bf736bb8a18ebafec39f9ef834399aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use ansi_term::Color::{Green, Red, Yellow};
use std::fmt::Display;

pub fn verify<T: PartialEq + Display>(left: T, right: T) {
    if left == right {
        println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
    } else {
        println!(
            "{} You submitted {}, but that's not correct!",
            Red.bold().paint("FAIL"),
            left
        );
        println!("     Please correct your code to make this test pass!");
    }
}

pub fn verify_easy<T: PartialEq + Display>(left: T, right: T) {
    if left == right {
        println!("{} {} == {}", Green.bold().paint("PASS"), left, right);
    } else {
        println!(
            "{} You submitted {}, but that's not correct!",
            Red.bold().paint("FAIL"),
            left
        );
        println!("     Expected: {}", right);
        println!("     Please correct your code to make this test pass!");
    }
}

pub fn title(s: &str) {
    println!("{} {}", Yellow.bold().paint("RUN"), s);
}