Move mockall to dev-dependencies

This commit is contained in:
Nicolas 2022-04-11 20:27:38 +02:00
parent d914bdfe75
commit 941ecfb757
9 changed files with 24 additions and 10 deletions

View File

@ -14,4 +14,6 @@ anyhow = "1.0"
clap = { version = "3.1", features = ["derive"]} clap = { version = "3.1", features = ["derive"]}
crossterm = "0.23" crossterm = "0.23"
rand = "0.8" rand = "0.8"
[dev-dependencies]
mockall = "0.11" mockall = "0.11"

View File

@ -4,9 +4,10 @@ pub mod rhombus;
use crate::vec::Vector; use crate::vec::Vector;
#[cfg(test)]
use mockall::automock; use mockall::automock;
#[automock] #[cfg_attr(test, automock)]
pub trait Animation { pub trait Animation {
fn sample(&self, step: f32, pos: Vector) -> f32; fn sample(&self, step: f32, pos: Vector) -> f32;
} }

View File

@ -1,7 +1,8 @@
#[cfg(test)]
use mockall::automock; use mockall::automock;
/// Used to get a character with a given brightness. /// Used to get a character with a given brightness.
#[automock] #[cfg_attr(test, automock)]
pub trait CharSampler { pub trait CharSampler {
/// Gets a character with the given brightness. /// Gets a character with the given brightness.
/// # Arguments /// # Arguments

View File

@ -1,8 +1,10 @@
use crossterm::style::Color; use crossterm::style::Color;
#[cfg(test)]
use mockall::automock; use mockall::automock;
/// A collection of colors. /// A collection of colors.
#[automock] #[cfg_attr(test, automock)]
pub trait ColorSampler { pub trait ColorSampler {
/// Gets a color for the given fill. /// Gets a color for the given fill.
/// # Arguments /// # Arguments

View File

@ -4,10 +4,11 @@ pub mod stripes;
use crate::vec::Vector; use crate::vec::Vector;
#[cfg(test)]
use mockall::automock; use mockall::automock;
/// Used to choose the colors of characters. /// Used to choose the colors of characters.
#[automock] #[cfg_attr(test, automock)]
pub trait FillMode { pub trait FillMode {
/// Gets the color for this character. /// Gets the color for this character.
fn sample(&self, level: f32, pos: Vector) -> f32; fn sample(&self, level: f32, pos: Vector) -> f32;

View File

@ -3,9 +3,10 @@ use crate::sampler::{Sample, Sampler};
use crate::surface::Surface; use crate::surface::Surface;
use crate::Vector; use crate::Vector;
#[cfg(test)]
use mockall::automock; use mockall::automock;
#[automock] #[cfg_attr(test, automock)]
pub trait Renderer { pub trait Renderer {
fn render(&mut self, step: f32); fn render(&mut self, step: f32);
fn present(&mut self) -> Result<(), Error>; fn present(&mut self) -> Result<(), Error>;

View File

@ -1,18 +1,20 @@
use crossterm::style::Color; use crossterm::style::Color;
use mockall::automock;
use crate::animation::Animation; use crate::animation::Animation;
use crate::char::CharSampler; use crate::char::CharSampler;
use crate::color::ColorSampler; use crate::color::ColorSampler;
use crate::fill::FillMode; use crate::fill::FillMode;
use crate::vec::Vector; use crate::vec::Vector;
#[cfg(test)]
use mockall::automock;
pub enum Sample { pub enum Sample {
Keep, Keep,
Draw { char: char, color: Color }, Draw { char: char, color: Color },
Clear, Clear,
} }
#[automock] #[cfg_attr(test, automock)]
pub trait Sampler { pub trait Sampler {
fn sample(&self, step: f32, pos: Vector) -> Sample; fn sample(&self, step: f32, pos: Vector) -> Sample;
} }

View File

@ -3,11 +3,13 @@ use crossterm::cursor::MoveTo;
use crossterm::{ExecutableCommand, QueueableCommand}; use crossterm::{ExecutableCommand, QueueableCommand};
use crossterm::style::{Color, Print, SetForegroundColor}; use crossterm::style::{Color, Print, SetForegroundColor};
use crossterm::terminal::{Clear, ClearType}; use crossterm::terminal::{Clear, ClearType};
use mockall::automock;
use std::io::Write; use std::io::Write;
use crate::array::Array2D; use crate::array::Array2D;
#[automock] #[cfg(test)]
use mockall::automock;
#[cfg_attr(test, automock)]
pub trait Surface { pub trait Surface {
fn width(&self) -> usize; fn width(&self) -> usize;
fn height(&self) -> usize; fn height(&self) -> usize;

View File

@ -1,8 +1,10 @@
use std::thread::sleep; use std::thread::sleep;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
#[cfg(test)]
use mockall::automock; use mockall::automock;
#[automock] #[cfg_attr(test, automock)]
pub trait Timer { pub trait Timer {
fn sleep(&mut self); fn sleep(&mut self);