Skip to content

Commit

Permalink
fix: Fix bug in logic on listing 5.20 (#772)
Browse files Browse the repository at this point in the history
Fixes #728

By happenstance of default value being 0 and that being the value of
Black, test was passing. Changed to yellow to make it clear that this
failed
  • Loading branch information
BenjaminMichaelis authored Apr 4, 2024
1 parent eea3619 commit 027b36e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Errata.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Zhou Jing | 20 | 1018 | Change paragraph beginning with "The need to support TAP
Zhou Jing | 18 | 911 | Change CommandLineRequiredAttribute to CommandLineSwitchRequiredAttribute
Zhou Jing | 18 | 902-903 | Change CommandLineAliasAttribute to CommandLineSwitchAliasAttribute
Zhou Jing | 23 | 1105 | Change `Length = 10` in listing 23.20 to `Length = 12` to show entire output message
Zhou Jing | 18 | 926-927 | Change 'LastName' references to be 'FirstName' in paragraphs
Zhou Jing | 18 | 926-927 | Change 'LastName' references to be 'FirstName' in paragraphs
Jinhang He | 5 | 255 | Edit listing 5.20 to used `image[index]` for the second print statement
9 changes: 3 additions & 6 deletions src/Chapter05.Tests/Listing05.20.ReturningAReference.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ public class ProgramTests
public void Main_InputInigoMontoya_WriteFullName()
{
string expected = @"image\[*\]=Red
image\[*\]=Black";
image\[*\]=Yellow";

IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected,
() =>
{
Program.Main();
});
IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected,
() => Program.Main());
}
}
6 changes: 3 additions & 3 deletions src/Chapter05/Listing05.20.ReturningAReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public static void Main()
#region HIGHLIGHT
// Obtain a reference to the first red pixel
ref byte redPixel = ref FindFirstRedEyePixel(image);
// Update it to be Black
redPixel = (byte)ConsoleColor.Black;
// Update it to be Yellow
redPixel = (byte)ConsoleColor.Yellow;
#endregion HIGHLIGHT
Console.WriteLine(
$"image[{index}]={(ConsoleColor)image[redPixel]}");
$"image[{index}]={(ConsoleColor)image[index]}");
}
#endregion INCLUDE
}

0 comments on commit 027b36e

Please sign in to comment.