This test ensures that the learned songs get updated when a dwarf learns a song & goes to the tavern (which causes him to forget a song and sing it).
This also ensures that the song is properly printed when sang.
[NOTE]
====
In this section, to verify that the dwarf properly "sings" a song (prints it to the standard output) we temporarily replace System.out with a `ByteArrayOutputStream` which we then test to have been given the song. The code for doing so will be replaced by intercept1() and intercept2(), and the source code for doing so is as follows :
[source, language="java"]
----
void intercept1()
{
PrintStream defaultoutput = System.out;
ByteArrayOutputStream intercept = new ByteArrayOutputStream();
System.setOut(new PrintStream(intercept));
}
void intercept2()
{
String sang = intercept.toString().replace("\n","");
System.setOut(defaultoutput);
System.out.println(sang);
}
----
These are not actual functions in the code, this is just a way to reduce repeated and irrelevant code in the comparison.
====
===== Apache :
[source, language="java"]
...
...
@@ -382,15 +404,9 @@ This also ensures that the song is properly printed when sang.
String learnedSong = "i am a dwarf and i'm digging a hole";