Skip to content

Commit

Permalink
Merge pull request #55 from dominikwilkowski/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
dominikwilkowski committed Jun 11, 2022
2 parents d91c942 + 778ed2c commit 82ed7f3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
3 changes: 1 addition & 2 deletions rust/src/color.rs
Expand Up @@ -8,7 +8,7 @@ use crate::config::{BgColors, Colors};
use crate::debug::{d, Dt};

/// An enum to list the available ANSI color support in the consumers console/terminal
#[derive(Debug, PartialEq)]
#[derive(PartialEq)]
pub enum TermColorSupport {
/// 16 million colors via truecolor RGB
Ansi16m,
Expand All @@ -21,7 +21,6 @@ pub enum TermColorSupport {
}

/// An enum to list the two color layers: foreground and background
#[derive(Debug)]
pub enum ColorLayer {
Foreground,
Background,
Expand Down
4 changes: 2 additions & 2 deletions rust/src/config.rs
Expand Up @@ -306,7 +306,7 @@ impl Options {
}

/// The type of options our [`CLIOPTIONS`] can have
#[derive(Debug, Clone, PartialEq)]
#[derive(Clone, PartialEq)]
pub enum OptionType {
/// There is only one text option which is for the text
Text,
Expand All @@ -329,7 +329,7 @@ pub enum OptionType {
}

/// The struct of a single option inside our [`CLIOPTIONS`]
#[derive(Debug, Clone, PartialEq)]
#[derive(Clone, PartialEq)]
pub struct CliOption<'a> {
/// The key of this option so we can address it later
pub key: &'a str,
Expand Down
1 change: 1 addition & 0 deletions rust/tests/color_test.rs
Expand Up @@ -245,6 +245,7 @@ mod color {
fn rgb_u8_2ansi_256_works() {
assert_eq!(rgb_u8_2ansi_256(100, 200, 100), 114);
assert_eq!(rgb_u8_2ansi_256(255, 255, 255), 231);
assert_eq!(rgb_u8_2ansi_256(100, 100, 100), 241);
assert_eq!(rgb_u8_2ansi_256(0, 0, 0), 16);
assert_eq!(rgb_u8_2ansi_256(167, 5, 98), 126);
}
Expand Down
26 changes: 26 additions & 0 deletions rust/tests/config_test.rs
@@ -0,0 +1,26 @@
extern crate cfonts;

use cfonts::config::{Align, BgColors, Colors, Env, Fonts, OptionType, Options, CLIOPTIONS};

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn clone_traits_work() {
let _fonts = Fonts::FontConsole.clone();
let _colors = Colors::System.clone();
let _bgcolors = BgColors::Transparent.clone();
let _env = Env::Cli.clone();
let _align = Align::Top.clone();
let options = Options::default();
let options2 = options.clone();
assert!(options == options2);
}

#[test]
fn equality_works() {
assert!(OptionType::Text == OptionType::Text);
assert!(CLIOPTIONS[0] == CLIOPTIONS[0]);
}
}
23 changes: 23 additions & 0 deletions rust/tests/main_test.rs
@@ -0,0 +1,23 @@
extern crate cfonts;

#[cfg(test)]
mod tests {
use assert_cmd::prelude::*;
use std::process::Command;

#[test]
fn version_works() {
let output =
Command::cargo_bin("cfonts").unwrap().args(vec!["-v"]).output().expect("failed to execute rust process");

assert!(String::from_utf8_lossy(&output.stdout).to_string().contains('v'));
}

#[test]
fn help_works() {
let output =
Command::cargo_bin("cfonts").unwrap().args(vec!["-h"]).output().expect("failed to execute rust process");

assert!(String::from_utf8_lossy(&output.stdout).to_string().contains("Give your cli some love."));
}
}

0 comments on commit 82ed7f3

Please sign in to comment.