summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorolivia <olivia@fastmail.com>2018-05-22 22:28:13 +0200
committerolivia <olivia@fastmail.com>2018-05-22 22:28:13 +0200
commit850a13e9133fedb2fce27884902e0aab94da9692 (patch)
tree7712ca3168ad4718f661a881ac5ef571719615ea /src
parent54f58cd726eeb7acc2ebb1491729444aab367e87 (diff)
oh, commit this
Diffstat (limited to 'src')
-rw-r--r--src/helpers.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/helpers.rs b/src/helpers.rs
new file mode 100644
index 0000000..e0b560b
--- /dev/null
+++ b/src/helpers.rs
@@ -0,0 +1,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);
+}