accepted all review suggestions
@@ -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";
@@ -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 );
+ }
}
}
)*
