Skip to content

Commit

Permalink
#235 accepted all review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
atluft committed Oct 18, 2020
1 parent e8fdd42 commit 36a9e9c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/onefetch/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,14 @@ macro_rules! define_languages {
let mut output = String::new();
output += "Colors {\n";
output += " basic_colors: vec![\n";
let mut color_index = 0;
for bc in self.basic_colors.iter() {
for (color_index, bc) in self.basic_colors.iter().enumerate() {
output += &format!( " Color::{:?}, // {}\n", bc, color_index );
color_index = color_index + 1;
}
output += " ], \n";
if let Some(tcs) = &self.true_colors {
output += " true_colors: vec![\n";
let mut color_index = 0;
for tc in tcs.iter() {
for (color_index,tc) in tcs.iter().enumerate() {
output += &format!( " Color::{:?}, // {}\n", tc, color_index );
color_index = color_index + 1;
}
} else {
output += " true_colors: None\n";
Expand All @@ -113,21 +109,21 @@ macro_rules! define_languages {
#[ignore]
fn [<$name:lower _basic_color_test>] () {
let colors = $colors;
let mut color_index = 0;
for bc in colors.basic_colors.iter() {
for (color_index, bc) in colors.basic_colors.iter().enumerate() {
let color_str = &format!( "Color::{:?}", bc );
assert!( !color_str.contains( "TrueColor" ), " language {} has true color {} in basic colors at index {} please change to a basic color: Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite", $display, color_str, color_index );
color_index = color_index + 1;
if let Color::TrueColor { .. } = bc {
panic!( "TrueColor found in basic_colors for {} at index {} found {}", stringify!( $name ), color_index, color_str );
}
}
}

#[test]
#[ignore]
fn [<$name:lower _color_vector_length_test>] () {
let colors = $colors;
let bc_count = colors.basic_colors.len();
let tc_count = if let Some(tcs) = &colors.true_colors { tcs.len() } else { bc_count };
assert_eq!( bc_count, tc_count, " left (basic) color length do not match right (true) color length.\n{}", colors );
if let Some(tcs) = &colors.true_colors {
assert_eq!( bc_count, tcs.len(), " left (basic) color length do not match right (true) color length.\n{}", colors );
}
}
}
)*
Expand Down

0 comments on commit 36a9e9c

Please sign in to comment.