use std::fmt;
use std::fmt::{Display, Formatter};
use std::io::Write as _;
use colour::*;
#[test]
fn print_stdout_with_newline() {
grey_ln!("This is {}.", "grey_ln");
grey_ln!("So is this.");
grey_ln!();
gray_ln!("This is {}.", "gray_ln");
gray_ln!("So is this.");
gray_ln!();
dark_gray_ln!("This is {}.", "dark_gray_ln");
dark_gray_ln!("So is this.");
dark_gray_ln!();
red_ln!("This is {}.", "red_ln");
red_ln!("So is this.");
red_ln!();
dark_red_ln!("This is {}.", "dark_red_ln");
dark_red_ln!("So is this.");
dark_red_ln!();
green_ln!("This is {}.", "green_ln");
green_ln!("So is this.");
green_ln!();
dark_green_ln!("This is {}.", "dark_green_ln");
dark_green_ln!("So is this.");
dark_green_ln!();
yellow_ln!("This is {}.", "yellow_ln");
yellow_ln!("So is this.");
yellow_ln!();
dark_yellow_ln!("This is {}.", "dark_yellow_ln");
dark_yellow_ln!("So is this.");
dark_yellow_ln!();
blue_ln!("This is {}.", "blue_ln");
blue_ln!("So is this.");
blue_ln!();
dark_blue_ln!("This is {}.", "dark_blue_ln");
dark_blue_ln!("So is this.");
dark_blue_ln!();
magenta_ln!("This is {}.", "magenta_ln");
magenta_ln!("So is this.");
magenta_ln!();
dark_magenta_ln!("This is {}.", "dark_magenta_ln");
dark_magenta_ln!("So is this.");
dark_magenta_ln!();
cyan_ln!("This is {}.", "cyan_ln");
cyan_ln!("So is this.");
cyan_ln!();
dark_cyan_ln!("This is {}.", "dark_cyan_ln");
dark_cyan_ln!("So is this.");
dark_cyan_ln!();
black_ln!("This is {}.", "black_ln");
black_ln!("So is this.");
black_ln!();
white_ln!("This is {}.", "white_ln");
white_ln!("So is this.");
white_ln!();
println!("This is the default colour.");
}
#[test]
fn print_stdout_with_newline_bold() {
grey_ln_bold!("This is {}.", "grey_ln_bold");
grey_ln_bold!("So is this.");
grey_ln_bold!();
gray_ln_bold!("This is {}.", "gray_ln_bold");
gray_ln_bold!("So is this.");
gray_ln_bold!();
dark_grey_ln_bold!("This is {}.", "dark_grey_ln_bold");
dark_grey_ln_bold!("So is this.");
dark_grey_ln_bold!();
dark_gray_ln_bold!("This is {}.", "dark_gray_ln_bold");
dark_gray_ln_bold!("So is this.");
dark_gray_ln_bold!();
red_ln_bold!("This is {}.", "red_ln_bold");
red_ln_bold!("So is this.");
red_ln_bold!();
dark_red_ln_bold!("This is {}.", "dark_red_ln_bold");
dark_red_ln_bold!("So is this.");
dark_red_ln_bold!();
green_ln_bold!("This is {}.", "green_ln_bold");
green_ln_bold!("So is this.");
green_ln_bold!();
dark_green_ln_bold!("This is {}.", "dark_green_ln_bold");
dark_green_ln_bold!("So is this.");
dark_green_ln_bold!();
yellow_ln_bold!("This is {}.", "yellow_ln_bold");
yellow_ln_bold!("So is this.");
yellow_ln_bold!();
dark_yellow_ln_bold!("This is {}.", "dark_yellow_ln_bold");
dark_yellow_ln_bold!("So is this.");
dark_yellow_ln_bold!();
blue_ln_bold!("This is {}.", "blue_ln_bold");
blue_ln_bold!("So is this.");
blue_ln_bold!();
dark_blue_ln_bold!("This is {}.", "dark_blue_ln_bold");
dark_blue_ln_bold!("So is this.");
dark_blue_ln_bold!();
magenta_ln_bold!("This is {}.", "magenta_ln_bold");
magenta_ln_bold!("So is this.");
magenta_ln_bold!();
dark_magenta_ln_bold!("This is {}.", "dark_magenta_ln_bold");
dark_magenta_ln_bold!("So is this.");
dark_magenta_ln_bold!();
cyan_ln_bold!("This is {}.", "cyan_ln_bold");
cyan_ln_bold!("So is this.");
cyan_ln_bold!();
dark_cyan_ln_bold!("This is {}.", "dark_cyan_ln_bold");
dark_cyan_ln_bold!("So is this.");
dark_cyan_ln_bold!();
black_ln_bold!("This is {}.", "black_ln_bold");
black_ln_bold!("So is this.");
black_ln_bold!();
white_ln_bold!("This is {}.", "white_ln_bold");
white_ln_bold!("So is this.");
white_ln_bold!();
print_ln_bold!("This is {}.", "print_ln_bold");
print_ln_bold!("So is this.");
print_ln_bold!();
println_bold!("This is {}.", "println_bold");
println_bold!("So is this.");
println_bold!();
}
#[test]
fn print_stdout_no_newline() {
grey!("g");
grey!("{}, ", "rey");
gray!("g");
gray!("{}, ", "ray");
dark_grey!("d");
dark_grey!("{}, ", "ark_grey");
dark_gray!("d");
dark_gray!("{}, ", "ark_gray");
red!("r");
red!("{}, ", "ed");
dark_red!("d");
dark_red!("{}, ", "ark_red");
green!("g");
green!("{}, ", "reen");
dark_green!("d");
dark_green!("{}, ", "ark_green");
yellow!("y");
yellow!("{}, ", "ellow");
dark_yellow!("d");
dark_yellow!("{}, ", "ark_yellow");
blue!("b");
blue!("{}, ", "lue");
dark_blue!("d");
dark_blue!("{}, ", "ark_blue");
magenta!("m");
magenta!("{}, ", "agenta");
dark_magenta!("d");
dark_magenta!("{}, ", "ark_magenta");
cyan!("c");
cyan!("{}, ", "yan");
dark_cyan!("d");
dark_cyan!("{}, ", "ark_cyan");
black!("b");
black!("{}, ", "lack");
white!("w");
white!("{}, ", "hite");
print!("default colour\n\n");
}
#[test]
fn print_stdout_no_newline_bold() {
grey_bold!("g");
grey_bold!("{}, ", "rey_bold");
gray_bold!("g");
gray_bold!("{}, ", "ray_bold");
dark_grey_bold!("d");
dark_grey_bold!("{}, ", "ark_grey_bold");
dark_gray_bold!("d");
dark_gray_bold!("{}, ", "ark_gray_bold");
red_bold!("r");
red_bold!("{}, ", "ed_bold");
dark_red_bold!("d");
dark_red_bold!("{}, ", "ark_red_bold");
green_bold!("g");
green_bold!("{}, ", "reen_bold");
dark_green_bold!("d");
dark_green_bold!("{}, ", "ark_green_bold");
yellow_bold!("y");
yellow_bold!("{}, ", "ellow_bold");
dark_yellow_bold!("d");
dark_yellow_bold!("{}, ", "ark_yellow_bold");
blue_bold!("b");
blue_bold!("{}, ", "lue_bold");
dark_blue_bold!("d");
dark_blue_bold!("{}, ", "ark_blue_bold");
magenta_bold!("m");
magenta_bold!("{}, ", "agenta_bold");
dark_magenta_bold!("d");
dark_magenta_bold!("{}, ", "ark_magenta_bold");
cyan_bold!("c");
cyan_bold!("{}, ", "yan_bold");
dark_cyan_bold!("d");
dark_cyan_bold!("{}, ", "ark_cyan_bold");
black_bold!("b");
black_bold!("{}, ", "lack_bold");
white_bold!("w");
white_bold!("{}, ", "hite_bold");
print_bold!("default colour\n\n");
}
#[test]
fn print_stderr_with_newline() {
e_grey_ln!("This is {}.", "e_grey_ln");
e_grey_ln!("So is this.");
e_grey_ln!();
e_gray_ln!("This is {}.", "e_gray_ln");
e_gray_ln!("So is this.");
e_gray_ln!();
e_dark_grey_ln!("This is {}.", "e_dark_grey_ln");
e_dark_grey_ln!("So is this.");
e_dark_grey_ln!();
e_dark_gray_ln!("This is {}.", "e_dark_gray_ln");
e_dark_gray_ln!("So is this.");
e_dark_gray_ln!();
e_red_ln!("This is {}.", "e_red_ln");
e_red_ln!("So is this.");
e_red_ln!();
e_dark_red_ln!("This is {}.", "e_dark_red_ln");
e_dark_red_ln!("So is this.");
e_dark_red_ln!();
e_green_ln!("This is {}.", "e_green_ln");
e_green_ln!("So is this.");
e_green_ln!();
e_dark_green_ln!("This is {}.", "e_dark_green_ln");
e_dark_green_ln!("So is this.");
e_dark_green_ln!();
e_yellow_ln!("This is {}.", "e_yellow_ln");
e_yellow_ln!("So is this.");
e_yellow_ln!();
e_dark_yellow_ln!("This is {}.", "e_dark_yellow_ln");
e_dark_yellow_ln!("So is this.");
e_dark_yellow_ln!();
e_blue_ln!("This is {}.", "e_blue_ln");
e_blue_ln!("So is this.");
e_blue_ln!();
e_dark_blue_ln!("This is {}.", "e_dark_blue_ln");
e_dark_blue_ln!("So is this.");
e_dark_blue_ln!();
e_magenta_ln!("This is {}.", "e_magenta_ln");
e_magenta_ln!("So is this.");
e_magenta_ln!();
e_dark_magenta_ln!("This is {}.", "e_dark_magenta_ln");
e_dark_magenta_ln!("So is this.");
e_dark_magenta_ln!();
e_cyan_ln!("This is {}.", "e_cyan_ln");
e_cyan_ln!("So is this.");
e_cyan_ln!();
e_dark_cyan_ln!("This is {}.", "e_dark_cyan_ln");
e_dark_cyan_ln!("So is this.");
e_dark_cyan_ln!();
e_black_ln!("This is {}.", "e_black_ln");
e_black_ln!("So is this.");
e_black_ln!();
e_white_ln!("This is {}.", "e_white_ln");
e_white_ln!("So is this.");
e_white_ln!();
eprintln!("This is the default colour.");
}
#[test]
fn print_stderr_with_newline_bold() {
e_grey_ln_bold!("This is {}.", "e_grey_ln_bold");
e_grey_ln_bold!("So is this.");
e_grey_ln_bold!();
e_gray_ln_bold!("This is {}.", "e_gray_ln_bold");
e_gray_ln_bold!("So is this.");
e_gray_ln_bold!();
e_dark_grey_ln_bold!("This is {}.", "e_dark_grey_ln_bold");
e_dark_grey_ln_bold!("So is this.");
e_dark_grey_ln_bold!();
e_dark_gray_ln_bold!("This is {}.", "e_dark_gray_ln_bold");
e_dark_gray_ln_bold!("So is this.");
e_dark_gray_ln_bold!();
e_red_ln_bold!("This is {}.", "e_red_ln_bold");
e_red_ln_bold!("So is this.");
e_red_ln_bold!();
e_dark_red_ln_bold!("This is {}.", "e_dark_red_ln_bold");
e_dark_red_ln_bold!("So is this.");
e_dark_red_ln_bold!();
e_green_ln_bold!("This is {}.", "e_green_ln_bold");
e_green_ln_bold!("So is this.");
e_green_ln_bold!();
e_dark_green_ln_bold!("This is {}.", "e_dark_green_ln_bold");
e_dark_green_ln_bold!("So is this.");
e_dark_green_ln_bold!();
e_yellow_ln_bold!("This is {}.", "e_yellow_ln_bold");
e_yellow_ln_bold!("So is this.");
e_yellow_ln_bold!();
e_dark_yellow_ln_bold!("This is {}.", "e_dark_yellow_ln_bold");
e_dark_yellow_ln_bold!("So is this.");
e_dark_yellow_ln_bold!();
e_blue_ln_bold!("This is {}.", "e_blue_ln_bold");
e_blue_ln_bold!("So is this.");
e_blue_ln_bold!();
e_dark_blue_ln_bold!("This is {}.", "e_dark_blue_ln_bold");
e_dark_blue_ln_bold!("So is this.");
e_dark_blue_ln_bold!();
e_magenta_ln_bold!("This is {}.", "e_magenta_ln_bold");
e_magenta_ln_bold!("So is this.");
e_magenta_ln_bold!();
e_dark_magenta_ln_bold!("This is {}.", "e_dark_magenta_ln_bold");
e_dark_magenta_ln_bold!("So is this.");
e_dark_magenta_ln_bold!();
e_cyan_ln_bold!("This is {}.", "e_cyan_ln_bold");
e_cyan_ln_bold!("So is this.");
e_cyan_ln_bold!();
e_dark_cyan_ln_bold!("This is {}.", "e_dark_cyan_ln_bold");
e_dark_cyan_ln_bold!("So is this.");
e_dark_cyan_ln_bold!();
e_black_ln_bold!("This is {}.", "e_black_ln_bold");
e_black_ln_bold!("So is this.");
e_black_ln_bold!();
e_white_ln_bold!("This is {}.", "e_white_ln_bold");
e_white_ln_bold!("So is this.");
e_white_ln_bold!();
e_print_ln_bold!("This is {}.", "e_print_ln_bold");
e_print_ln_bold!("So is this.");
e_print_ln_bold!();
eprintln_bold!("This is {}.", "eprintln_bold");
eprintln_bold!("So is this.");
eprintln_bold!();
}
#[test]
fn print_stderr_no_newline() {
e_grey!("e_g");
e_grey!("{}, ", "rey");
e_gray!("e_g");
e_gray!("{}, ", "ray");
e_dark_grey!("e_d");
e_dark_grey!("{}, ", "ark_grey");
e_dark_gray!("e_d");
e_dark_gray!("{}, ", "ark_gray");
e_red!("e_r");
e_red!("{}, ", "ed");
e_dark_red!("e_d");
e_dark_red!("{}, ", "ark_red");
e_green!("e_g");
e_green!("{}, ", "reen");
e_dark_green!("e_d");
e_dark_green!("{}, ", "ark_green");
e_yellow!("e_y");
e_yellow!("{}, ", "ellow");
e_dark_yellow!("e_d");
e_dark_yellow!("{}, ", "ark_yellow");
e_blue!("e_b");
e_blue!("{}, ", "lue");
e_dark_blue!("e_d");
e_dark_blue!("{}, ", "ark_blue");
e_magenta!("e_m");
e_magenta!("{}, ", "agenta");
e_dark_magenta!("e_d");
e_dark_magenta!("{}, ", "ark_magenta");
e_cyan!("e_c");
e_cyan!("{}, ", "yan");
e_dark_cyan!("e_d");
e_dark_cyan!("{}, ", "ark_cyan");
e_black!("e_b");
e_black!("{}, ", "lack");
e_white!("e_w");
e_white!("{}, ", "hite");
eprint!("default colour\n\n");
}
#[test]
fn print_stderr_no_newline_bold() {
e_grey_bold!("e_g");
e_grey_bold!("{}, ", "rey_bold");
e_gray_bold!("e_g");
e_gray_bold!("{}, ", "ray_bold");
e_dark_grey_bold!("e_d");
e_dark_grey_bold!("{}, ", "ark_grey_bold");
e_dark_gray_bold!("e_d");
e_dark_gray_bold!("{}, ", "ark_gray_bold");
e_red_bold!("e_r");
e_red_bold!("{}, ", "ed_bold");
e_dark_red_bold!("e_d");
e_dark_red_bold!("{}, ", "ark_red_bold");
e_green_bold!("e_g");
e_green_bold!("{}, ", "reen_bold");
e_dark_green_bold!("e_d");
e_dark_green_bold!("{}, ", "ark_green_bold");
e_yellow_bold!("e_y");
e_yellow_bold!("{}, ", "ellow_bold");
e_dark_yellow_bold!("e_d");
e_dark_yellow_bold!("{}, ", "ark_yellow_bold");
e_blue_bold!("e_b");
e_blue_bold!("{}, ", "lue_bold");
e_dark_blue_bold!("e_d");
e_dark_blue_bold!("{}, ", "ark_blue_bold");
e_magenta_bold!("e_m");
e_magenta_bold!("{}, ", "agenta_bold");
e_dark_magenta_bold!("e_d");
e_dark_magenta_bold!("{}, ", "ark_magenta_bold");
e_cyan_bold!("e_c");
e_cyan_bold!("{}, ", "yan_bold");
e_dark_cyan_bold!("e_d");
e_dark_cyan_bold!("{}, ", "ark_cyan_bold");
e_black_bold!("e_b");
e_black_bold!("{}, ", "lack_bold");
e_white_bold!("e_w");
e_white_bold!("{}, ", "hite_bold");
e_print_bold!("e_p");
e_print_bold!("{}, ", "rint_bold");
eprint_bold!("ep");
eprint_bold!("{}\n\n", "rint_bold");
}
#[test]
fn readme_example() {
let err: Result<(), u8> = Err(1);
yellow_ln!("Failed on {}", 9);
print!("Error details: ");
dark_red_ln_bold!("{:?}", err);
grey_ln!("grey");
grey_ln_bold!("bold grey");
dark_grey_ln!("dark grey");
dark_grey_ln_bold!("bold dark grey");
red_ln!("red");
red_ln_bold!("bold red");
dark_red_ln!("dark red");
dark_red_ln_bold!("bold dark red");
green_ln!("green");
green_ln_bold!("bold green");
dark_green_ln!("dark green");
dark_green_ln_bold!("bold dark green");
yellow_ln!("yellow");
yellow_ln_bold!("bold yellow");
dark_yellow_ln!("dark yellow");
dark_yellow_ln_bold!("bold dark yellow");
blue_ln!("blue");
blue_ln_bold!("bold blue");
dark_blue_ln!("dark blue");
dark_blue_ln_bold!("bold dark blue");
magenta_ln!("magenta");
magenta_ln_bold!("bold magenta");
dark_magenta_ln!("dark magenta");
dark_magenta_ln_bold!("bold dark magenta");
cyan_ln!("cyan");
cyan_ln_bold!("bold cyan");
dark_cyan_ln!("dark cyan");
dark_cyan_ln_bold!("bold dark cyan");
black_ln!("black");
black_ln_bold!("bold black");
white_ln!("white");
white_ln_bold!("bold white");
println!("default colour");
println_bold!("bold default colour");
}
#[test]
fn write_stdout_with_newline() {
writeln_grey!(std::io::stdout(), "This is {}.", "writeln_grey").unwrap();
writeln_grey!(std::io::stdout(), "So is this.\n").unwrap();
writeln_grey_bold!(std::io::stdout(), "This is {}.", "writeln_grey_bold").unwrap();
writeln_grey_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_gray!(std::io::stdout(), "This is {}.", "writeln_gray").unwrap();
writeln_gray!(std::io::stdout(), "So is this.\n").unwrap();
writeln_gray_bold!(std::io::stdout(), "This is {}.", "writeln_gray_bold").unwrap();
writeln_gray_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_grey!(std::io::stdout(), "This is {}.", "writeln_dark_grey").unwrap();
writeln_dark_grey!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_grey_bold!(std::io::stdout(), "This is {}.", "writeln_dark_grey_bold").unwrap();
writeln_dark_grey_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_gray!(std::io::stdout(), "This is {}.", "writeln_dark_gray").unwrap();
writeln_dark_gray!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_gray_bold!(std::io::stdout(), "This is {}.", "writeln_dark_gray_bold").unwrap();
writeln_dark_gray_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_red!(std::io::stdout(), "This is {}.", "writeln_red").unwrap();
writeln_red!(std::io::stdout(), "So is this.\n").unwrap();
writeln_red_bold!(std::io::stdout(), "This is {}.", "writeln_red_bold").unwrap();
writeln_red_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_red!(std::io::stdout(), "This is {}.", "writeln_dark_red").unwrap();
writeln_dark_red!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_red_bold!(std::io::stdout(), "This is {}.", "writeln_dark_red_bold").unwrap();
writeln_dark_red_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_green!(std::io::stdout(), "This is {}.", "writeln_green").unwrap();
writeln_green!(std::io::stdout(), "So is this.\n").unwrap();
writeln_green_bold!(std::io::stdout(), "This is {}.", "writeln_green_bold").unwrap();
writeln_green_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_green!(std::io::stdout(), "This is {}.", "writeln_dark_green").unwrap();
writeln_dark_green!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_green_bold!(std::io::stdout(), "This is {}.", "writeln_dark_green_bold").unwrap();
writeln_dark_green_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_yellow!(std::io::stdout(), "This is {}.", "writeln_yellow").unwrap();
writeln_yellow!(std::io::stdout(), "So is this.\n").unwrap();
writeln_yellow_bold!(std::io::stdout(), "This is {}.", "writeln_yellow_bold").unwrap();
writeln_yellow_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_yellow!(std::io::stdout(), "This is {}.", "writeln_dark_yellow").unwrap();
writeln_dark_yellow!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_yellow_bold!(std::io::stdout(), "This is {}.", "writeln_dark_yellow_bold")
.unwrap();
writeln_dark_yellow_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_blue!(std::io::stdout(), "This is {}.", "writeln_blue").unwrap();
writeln_blue!(std::io::stdout(), "So is this.\n").unwrap();
writeln_blue_bold!(std::io::stdout(), "This is {}.", "writeln_blue_bold").unwrap();
writeln_blue_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_blue!(std::io::stdout(), "This is {}.", "writeln_dark_blue").unwrap();
writeln_dark_blue!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_blue_bold!(std::io::stdout(), "This is {}.", "writeln_dark_blue_bold").unwrap();
writeln_dark_blue_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_magenta!(std::io::stdout(), "This is {}.", "writeln_magenta").unwrap();
writeln_magenta!(std::io::stdout(), "So is this.\n").unwrap();
writeln_magenta_bold!(std::io::stdout(), "This is {}.", "writeln_magenta_bold").unwrap();
writeln_magenta_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_magenta!(std::io::stdout(), "This is {}.", "writeln_dark_magenta").unwrap();
writeln_dark_magenta!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_magenta_bold!(
std::io::stdout(),
"This is {}.",
"writeln_dark_magenta_bold"
)
.unwrap();
writeln_dark_magenta_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_cyan!(std::io::stdout(), "This is {}.", "writeln_cyan").unwrap();
writeln_cyan!(std::io::stdout(), "So is this.\n").unwrap();
writeln_cyan_bold!(std::io::stdout(), "This is {}.", "writeln_cyan_bold").unwrap();
writeln_cyan_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_cyan!(std::io::stdout(), "This is {}.", "writeln_dark_cyan").unwrap();
writeln_dark_cyan!(std::io::stdout(), "So is this.\n").unwrap();
writeln_dark_cyan_bold!(std::io::stdout(), "This is {}.", "writeln_dark_cyan_bold").unwrap();
writeln_dark_cyan_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_black!(std::io::stdout(), "This is {}.", "writeln_black").unwrap();
writeln_black!(std::io::stdout(), "So is this.\n").unwrap();
writeln_black_bold!(std::io::stdout(), "This is {}.", "writeln_black_bold").unwrap();
writeln_black_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_white!(std::io::stdout(), "This is {}.", "writeln_white").unwrap();
writeln_white!(std::io::stdout(), "So is this.\n").unwrap();
writeln_white_bold!(std::io::stdout(), "This is {}.", "writeln_white_bold").unwrap();
writeln_white_bold!(std::io::stdout(), "So is this.\n").unwrap();
writeln_bold!(std::io::stdout(), "This is {}.", "writeln_bold").unwrap();
writeln_bold!(std::io::stdout(), "So is this.\n").unwrap();
}
#[test]
fn write_stdout_no_newline() {
write_grey!(std::io::stdout(), "write_g").unwrap();
write_grey!(std::io::stdout(), "{}, ", "rey").unwrap();
write_grey_bold!(std::io::stdout(), "write_g").unwrap();
write_grey_bold!(std::io::stdout(), "{}, ", "rey_bold").unwrap();
write_gray!(std::io::stdout(), "write_g").unwrap();
write_gray!(std::io::stdout(), "{}, ", "ray").unwrap();
write_gray_bold!(std::io::stdout(), "write_g").unwrap();
write_gray_bold!(std::io::stdout(), "{}, ", "ray_bold").unwrap();
write_dark_grey!(std::io::stdout(), "write_d").unwrap();
write_dark_grey!(std::io::stdout(), "{}, ", "ark_grey").unwrap();
write_dark_grey_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_grey_bold!(std::io::stdout(), "{}, ", "ark_grey_bold").unwrap();
write_dark_gray!(std::io::stdout(), "write_d").unwrap();
write_dark_gray!(std::io::stdout(), "{}, ", "ark_gray").unwrap();
write_dark_gray_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_gray_bold!(std::io::stdout(), "{}, ", "ark_gray_bold").unwrap();
write_red!(std::io::stdout(), "write_r").unwrap();
write_red!(std::io::stdout(), "{}, ", "ed").unwrap();
write_red_bold!(std::io::stdout(), "write_r").unwrap();
write_red_bold!(std::io::stdout(), "{}, ", "ed_bold").unwrap();
write_dark_red!(std::io::stdout(), "write_d").unwrap();
write_dark_red!(std::io::stdout(), "{}, ", "ark_red").unwrap();
write_dark_red_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_red_bold!(std::io::stdout(), "{}, ", "ark_red_bold").unwrap();
write_green!(std::io::stdout(), "write_g").unwrap();
write_green!(std::io::stdout(), "{}, ", "reen").unwrap();
write_green_bold!(std::io::stdout(), "write_g").unwrap();
write_green_bold!(std::io::stdout(), "{}, ", "reen_bold").unwrap();
write_dark_green!(std::io::stdout(), "write_d").unwrap();
write_dark_green!(std::io::stdout(), "{}, ", "ark_green").unwrap();
write_dark_green_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_green_bold!(std::io::stdout(), "{}, ", "ark_green_bold").unwrap();
write_yellow!(std::io::stdout(), "write_y").unwrap();
write_yellow!(std::io::stdout(), "{}, ", "ellow").unwrap();
write_yellow_bold!(std::io::stdout(), "write_y").unwrap();
write_yellow_bold!(std::io::stdout(), "{}, ", "ellow_bold").unwrap();
write_dark_yellow!(std::io::stdout(), "write_d").unwrap();
write_dark_yellow!(std::io::stdout(), "{}, ", "ark_yellow").unwrap();
write_dark_yellow_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_yellow_bold!(std::io::stdout(), "{}, ", "ark_yellow_bold").unwrap();
write_blue!(std::io::stdout(), "write_b").unwrap();
write_blue!(std::io::stdout(), "{}, ", "lue").unwrap();
write_blue_bold!(std::io::stdout(), "write_b").unwrap();
write_blue_bold!(std::io::stdout(), "{}, ", "lue_bold").unwrap();
write_dark_blue!(std::io::stdout(), "write_d").unwrap();
write_dark_blue!(std::io::stdout(), "{}, ", "ark_blue").unwrap();
write_dark_blue_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_blue_bold!(std::io::stdout(), "{}, ", "ark_blue_bold").unwrap();
write_magenta!(std::io::stdout(), "write_m").unwrap();
write_magenta!(std::io::stdout(), "{}, ", "agenta").unwrap();
write_magenta_bold!(std::io::stdout(), "write_m").unwrap();
write_magenta_bold!(std::io::stdout(), "{}, ", "agenta_bold").unwrap();
write_dark_magenta!(std::io::stdout(), "write_d").unwrap();
write_dark_magenta!(std::io::stdout(), "{}, ", "ark_magenta").unwrap();
write_dark_magenta_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_magenta_bold!(std::io::stdout(), "{}, ", "ark_magenta_bold").unwrap();
write_cyan!(std::io::stdout(), "write_c").unwrap();
write_cyan!(std::io::stdout(), "{}, ", "yan").unwrap();
write_cyan_bold!(std::io::stdout(), "write_c").unwrap();
write_cyan_bold!(std::io::stdout(), "{}, ", "yan_bold").unwrap();
write_dark_cyan!(std::io::stdout(), "write_d").unwrap();
write_dark_cyan!(std::io::stdout(), "{}, ", "ark_cyan").unwrap();
write_dark_cyan_bold!(std::io::stdout(), "write_d").unwrap();
write_dark_cyan_bold!(std::io::stdout(), "{}, ", "ark_cyan_bold").unwrap();
write_black!(std::io::stdout(), "write_b").unwrap();
write_black!(std::io::stdout(), "{}, ", "lack").unwrap();
write_black_bold!(std::io::stdout(), "write_b").unwrap();
write_black_bold!(std::io::stdout(), "{}, ", "lack_bold").unwrap();
write_white!(std::io::stdout(), "write_w").unwrap();
write_white!(std::io::stdout(), "{}, ", "hite").unwrap();
write_white_bold!(std::io::stdout(), "write_w").unwrap();
write_white_bold!(std::io::stdout(), "{}, ", "hite_bold").unwrap();
write_bold!(std::io::stdout(), "write_b").unwrap();
write_bold!(std::io::stdout(), "{}\n\n", "old").unwrap();
}
#[test]
fn write_to_formatter_with_newline() {
struct A;
impl Display for A {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
writeln_grey!(f, "This is {}.", "writeln_grey")?;
writeln_grey!(f, "So is this.\n")?;
writeln_grey_bold!(f, "This is {}.", "writeln_grey_bold")?;
writeln_grey_bold!(f, "So is this.\n")?;
writeln_gray!(f, "This is {}.", "writeln_gray")?;
writeln_gray!(f, "So is this.\n")?;
writeln_gray_bold!(f, "This is {}.", "writeln_gray_bold")?;
writeln_gray_bold!(f, "So is this.\n")?;
writeln_dark_grey!(f, "This is {}.", "writeln_dark_grey")?;
writeln_dark_grey!(f, "So is this.\n")?;
writeln_dark_grey_bold!(f, "This is {}.", "writeln_dark_grey_bold")?;
writeln_dark_grey_bold!(f, "So is this.\n")?;
writeln_dark_gray!(f, "This is {}.", "writeln_dark_gray")?;
writeln_dark_gray!(f, "So is this.\n")?;
writeln_dark_gray_bold!(f, "This is {}.", "writeln_dark_gray_bold")?;
writeln_dark_gray_bold!(f, "So is this.\n")?;
writeln_red!(f, "This is {}.", "writeln_red")?;
writeln_red!(f, "So is this.\n")?;
writeln_red_bold!(f, "This is {}.", "writeln_red_bold")?;
writeln_red_bold!(f, "So is this.\n")?;
writeln_dark_red!(f, "This is {}.", "writeln_dark_red")?;
writeln_dark_red!(f, "So is this.\n")?;
writeln_dark_red_bold!(f, "This is {}.", "writeln_dark_red_bold")?;
writeln_dark_red_bold!(f, "So is this.\n")?;
writeln_green!(f, "This is {}.", "writeln_green")?;
writeln_green!(f, "So is this.\n")?;
writeln_green_bold!(f, "This is {}.", "writeln_green_bold")?;
writeln_green_bold!(f, "So is this.\n")?;
writeln_dark_green!(f, "This is {}.", "writeln_dark_green")?;
writeln_dark_green!(f, "So is this.\n")?;
writeln_dark_green_bold!(f, "This is {}.", "writeln_dark_green_bold")?;
writeln_dark_green_bold!(f, "So is this.\n")?;
writeln_yellow!(f, "This is {}.", "writeln_yellow")?;
writeln_yellow!(f, "So is this.\n")?;
writeln_yellow_bold!(f, "This is {}.", "writeln_yellow_bold")?;
writeln_yellow_bold!(f, "So is this.\n")?;
writeln_dark_yellow!(f, "This is {}.", "writeln_dark_yellow")?;
writeln_dark_yellow!(f, "So is this.\n")?;
writeln_dark_yellow_bold!(f, "This is {}.", "writeln_dark_yellow_bold")?;
writeln_dark_yellow_bold!(f, "So is this.\n")?;
writeln_blue!(f, "This is {}.", "writeln_blue")?;
writeln_blue!(f, "So is this.\n")?;
writeln_blue_bold!(f, "This is {}.", "writeln_blue_bold")?;
writeln_blue_bold!(f, "So is this.\n")?;
writeln_dark_blue!(f, "This is {}.", "writeln_dark_blue")?;
writeln_dark_blue!(f, "So is this.\n")?;
writeln_dark_blue_bold!(f, "This is {}.", "writeln_dark_blue_bold")?;
writeln_dark_blue_bold!(f, "So is this.\n")?;
writeln_magenta!(f, "This is {}.", "writeln_magenta")?;
writeln_magenta!(f, "So is this.\n")?;
writeln_magenta_bold!(f, "This is {}.", "writeln_magenta_bold")?;
writeln_magenta_bold!(f, "So is this.\n")?;
writeln_dark_magenta!(f, "This is {}.", "writeln_dark_magenta")?;
writeln_dark_magenta!(f, "So is this.\n")?;
writeln_dark_magenta_bold!(f, "This is {}.", "writeln_dark_magenta_bold")?;
writeln_dark_magenta_bold!(f, "So is this.\n")?;
writeln_cyan!(f, "This is {}.", "writeln_cyan")?;
writeln_cyan!(f, "So is this.\n")?;
writeln_cyan_bold!(f, "This is {}.", "writeln_cyan_bold")?;
writeln_cyan_bold!(f, "So is this.\n")?;
writeln_dark_cyan!(f, "This is {}.", "writeln_dark_cyan")?;
writeln_dark_cyan!(f, "So is this.\n")?;
writeln_dark_cyan_bold!(f, "This is {}.", "writeln_dark_cyan_bold")?;
writeln_dark_cyan_bold!(f, "So is this.\n")?;
writeln_black!(f, "This is {}.", "writeln_black")?;
writeln_black!(f, "So is this.\n")?;
writeln_black_bold!(f, "This is {}.", "writeln_black_bold")?;
writeln_black_bold!(f, "So is this.\n")?;
writeln_white!(f, "This is {}.", "writeln_white")?;
writeln_white!(f, "So is this.\n")?;
writeln_white_bold!(f, "This is {}.", "writeln_white_bold")?;
writeln_white_bold!(f, "So is this.\n")?;
writeln_bold!(f, "This is {}.", "writeln_bold")?;
writeln_bold!(f, "So is this.\n")?;
Ok(())
}
}
println!("{A}");
}
#[test]
fn write_to_formatter_no_newline() {
struct A;
impl Display for A {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write_grey!(f, "write_g")?;
write_grey!(f, "{}, ", "rey")?;
write_grey_bold!(f, "write_g")?;
write_grey_bold!(f, "{}, ", "rey_bold")?;
write_gray!(f, "write_g")?;
write_gray!(f, "{}, ", "ray")?;
write_gray_bold!(f, "write_g")?;
write_gray_bold!(f, "{}, ", "ray_bold")?;
write_dark_grey!(f, "write_d")?;
write_dark_grey!(f, "{}, ", "ark_grey")?;
write_dark_grey_bold!(f, "write_d")?;
write_dark_grey_bold!(f, "{}, ", "ark_grey_bold")?;
write_dark_gray!(f, "write_d")?;
write_dark_gray!(f, "{}, ", "ark_gray")?;
write_dark_gray_bold!(f, "write_d")?;
write_dark_gray_bold!(f, "{}, ", "ark_gray_bold")?;
write_red!(f, "write_r")?;
write_red!(f, "{}, ", "ed")?;
write_red_bold!(f, "write_r")?;
write_red_bold!(f, "{}, ", "ed_bold")?;
write_dark_red!(f, "write_d")?;
write_dark_red!(f, "{}, ", "ark_red")?;
write_dark_red_bold!(f, "write_d")?;
write_dark_red_bold!(f, "{}, ", "ark_red_bold")?;
write_green!(f, "write_g")?;
write_green!(f, "{}, ", "reen")?;
write_green_bold!(f, "write_g")?;
write_green_bold!(f, "{}, ", "reen_bold")?;
write_dark_green!(f, "write_d")?;
write_dark_green!(f, "{}, ", "ark_green")?;
write_dark_green_bold!(f, "write_d")?;
write_dark_green_bold!(f, "{}, ", "ark_green_bold")?;
write_yellow!(f, "write_y")?;
write_yellow!(f, "{}, ", "ellow")?;
write_yellow_bold!(f, "write_y")?;
write_yellow_bold!(f, "{}, ", "ellow_bold")?;
write_dark_yellow!(f, "write_d")?;
write_dark_yellow!(f, "{}, ", "ark_yellow")?;
write_dark_yellow_bold!(f, "write_d")?;
write_dark_yellow_bold!(f, "{}, ", "ark_yellow_bold")?;
write_blue!(f, "write_b")?;
write_blue!(f, "{}, ", "lue")?;
write_blue_bold!(f, "write_b")?;
write_blue_bold!(f, "{}, ", "lue_bold")?;
write_dark_blue!(f, "write_d")?;
write_dark_blue!(f, "{}, ", "ark_blue")?;
write_dark_blue_bold!(f, "write_d")?;
write_dark_blue_bold!(f, "{}, ", "ark_blue_bold")?;
write_magenta!(f, "write_m")?;
write_magenta!(f, "{}, ", "agenta")?;
write_magenta_bold!(f, "write_m")?;
write_magenta_bold!(f, "{}, ", "agenta_bold")?;
write_dark_magenta!(f, "write_d")?;
write_dark_magenta!(f, "{}, ", "ark_magenta")?;
write_dark_magenta_bold!(f, "write_d")?;
write_dark_magenta_bold!(f, "{}, ", "ark_magenta_bold")?;
write_cyan!(f, "write_c")?;
write_cyan!(f, "{}, ", "yan")?;
write_cyan_bold!(f, "write_c")?;
write_cyan_bold!(f, "{}, ", "yan_bold")?;
write_dark_cyan!(f, "write_d")?;
write_dark_cyan!(f, "{}, ", "ark_cyan")?;
write_dark_cyan_bold!(f, "write_d")?;
write_dark_cyan_bold!(f, "{}, ", "ark_cyan_bold")?;
write_black!(f, "write_b")?;
write_black!(f, "{}, ", "lack")?;
write_black_bold!(f, "write_b")?;
write_black_bold!(f, "{}, ", "lack_bold")?;
write_white!(f, "write_w")?;
write_white!(f, "{}, ", "hite")?;
write_white_bold!(f, "write_w")?;
write_white_bold!(f, "{}, ", "hite_bold")?;
write_bold!(f, "write_b")?;
write_bold!(f, "{}\n\n", "old")?;
Ok(())
}
}
println!("{A}");
}