From b88479446c3ef33d5e0b754b2199bef2e2f13888 Mon Sep 17 00:00:00 2001 From: Sunshine Date: Sat, 4 Apr 2020 08:21:41 -0400 Subject: [PATCH] implement unit tests for macros --- src/tests/macros/empty_image.rs | 14 ++++++++++++++ src/tests/macros/mod.rs | 2 ++ src/tests/macros/str.rs | 24 ++++++++++++++++++++++++ src/tests/mod.rs | 1 + 4 files changed, 41 insertions(+) create mode 100644 src/tests/macros/empty_image.rs create mode 100644 src/tests/macros/mod.rs create mode 100644 src/tests/macros/str.rs diff --git a/src/tests/macros/empty_image.rs b/src/tests/macros/empty_image.rs new file mode 100644 index 0000000..c37e199 --- /dev/null +++ b/src/tests/macros/empty_image.rs @@ -0,0 +1,14 @@ +// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ +// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ +// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ +// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ +// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ +// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ + +#[cfg(test)] +mod passing { + #[test] + fn contains_correct_image_data() { + assert_eq!(empty_image!(), "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAQAAADY4iz3AAAAEUlEQVR42mNkwAkYR6UolgIACvgADsuK6xYAAAAASUVORK5CYII="); + } +} diff --git a/src/tests/macros/mod.rs b/src/tests/macros/mod.rs new file mode 100644 index 0000000..b665c79 --- /dev/null +++ b/src/tests/macros/mod.rs @@ -0,0 +1,2 @@ +mod empty_image; +mod str; diff --git a/src/tests/macros/str.rs b/src/tests/macros/str.rs new file mode 100644 index 0000000..d083772 --- /dev/null +++ b/src/tests/macros/str.rs @@ -0,0 +1,24 @@ +// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗ +// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝ +// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗ +// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║ +// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝ +// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ + +#[cfg(test)] +mod passing { + #[test] + fn returns_empty_string() { + assert_eq!(str!(), ""); + } + + #[test] + fn converts_integer_into_string() { + assert_eq!(str!(123), "123"); + } + + #[test] + fn converts_str_into_string() { + assert_eq!(str!("abc"), "abc"); + } +} diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 0d1368a..dd0fcef 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -2,4 +2,5 @@ mod cli; mod css; mod html; mod js; +mod macros; mod utils;