Permalink
Browse files

A few basic fixes to get things to work right on Mac OS X.

  • Loading branch information...
1 parent baac9de commit 7cfb3afd5af18cf0cef582a72339e333358c9da9 @myronmarston committed Nov 18, 2008
@@ -37,10 +37,18 @@
private static final String GUIDO_SUB_DIRECTORY = "guido";
private static final String CURRENT_DIR = System.getProperty("user.dir");
private static String guidoParentDirectory = CURRENT_DIR;
- private static final String LILYPOND_EXE_FILE = "lilypond";
+ private static final String LILYPOND_EXE_FILE;
private static final Pattern LILYPOND_OR_GUIDO_OUTPUT_ERROR = Pattern.compile(".*?error.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
private static final Pattern LILYPOND_OR_GUIDO_OUTPUT_WARNING = Pattern.compile(".*?warning.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
-
+
+ static {
+ if (System.getProperty("os.name").equals("Mac OS X")) {
+ LILYPOND_EXE_FILE = "/Applications/LilyPond.app/Contents/Resources/bin/lilypond";
+ } else {
+ LILYPOND_EXE_FILE = "lilypond";
+ }
+ }
+
/**
* Constructor.
*
@@ -31,7 +31,7 @@
import org.simpleframework.xml.*;
import org.simpleframework.xml.graph.*;
-import org.simpleframework.xml.load.*;;
+import org.simpleframework.xml.load.*;
import java.io.*;
import java.lang.reflect.UndeclaredThrowableException;
@@ -34,8 +34,7 @@
@Test
public void testAVAILABLE_INSTRUMENTS() {
// test the size and that it has some basic instruments
- assertEquals(137, Instrument.AVAILABLE_INSTRUMENTS.size());
- assertTrue(Instrument.AVAILABLE_INSTRUMENTS.contains("Piano 1"));
+ assertTrue(Instrument.AVAILABLE_INSTRUMENTS.size() >= 120);
assertTrue(Instrument.AVAILABLE_INSTRUMENTS.contains("Violin"));
assertTrue(Instrument.AVAILABLE_INSTRUMENTS.contains("Viola"));
assertTrue(Instrument.AVAILABLE_INSTRUMENTS.contains("Cello"));
@@ -55,7 +55,7 @@ public void setUp() throws Exception {
@Test
public void getGuidoNotation() throws Exception {
String guidoNotationFormatString = "{" + FileHelper.NEW_LINE + "[%s\\key<0> \\meter<\"C\"> \\clef<\"g2-8\"> %s\\intens<\"mf\"> d1/4 e1/4 c1/4]" + FileHelper.NEW_LINE + "}";
- String instrumentString = "\\instr<\"Piano 1\", \"MIDI 0\"> ";
+ String instrumentString = "\\instr<\"" + Instrument.DEFAULT.getName() + "\", \"MIDI 0\"> ";
String tempoString = "\\tempo<\"Andante\",\"1/4=90\"> ";
String fullGuidoString = String.format(guidoNotationFormatString, instrumentString, tempoString);
String noInstrOrTempoGuidoString = String.format(guidoNotationFormatString, "", "");
@@ -91,7 +91,7 @@ public void serializeVoice() throws Exception {
int idStart = 51;
String expected =
- "<voice id=\"0\" uniqueIndex=\"1\" instrumentName=\"Piano 1\">\n" +
+ "<voice id=\"0\" uniqueIndex=\"1\" instrumentName=\"" + Instrument.DEFAULT.getName() + "\">\n" +
// fractal piece section that gets stripped goes here...
" <settings id=\"" + idStart++ + "\" scaleStepOffset=\"0\" octaveAdjustment=\"1\" readOnly=\"false\">\n" +
" <volumeAdjustment id=\"" + idStart++ + "\" numerator_=\"0\" denominator_=\"1\"/>\n" +
@@ -64,17 +64,17 @@ public void leastCommonMultipleForList() {
@Test
public void log2() {
- assertEquals(-3d, MathHelper.log2(0.125d));
- assertEquals(-2d, MathHelper.log2(0.25d));
- assertEquals(-1d, MathHelper.log2(0.5d));
- assertEquals(0d, MathHelper.log2(1));
- assertEquals(1d, MathHelper.log2(2));
- assertEquals(2d, MathHelper.log2(4));
- assertEquals(3d, MathHelper.log2(8));
- assertEquals(4d, MathHelper.log2(16));
+ assertEquals(-3d, MathHelper.log2(0.125d), 0.0d);
+ assertEquals(-2d, MathHelper.log2(0.25d), 0.0d);
+ assertEquals(-1d, MathHelper.log2(0.5d), 0.0d);
+ assertEquals(0d, MathHelper.log2(1), 0.0d);
+ assertEquals(1d, MathHelper.log2(2), 0.0d);
+ assertEquals(2d, MathHelper.log2(4), 0.0d);
+ assertEquals(3d, MathHelper.log2(8), 0.0d);
+ assertEquals(4d, MathHelper.log2(16), 0.0d);
// this should be 0.5, but doubles are not completely accurate....
- assertEquals(0.5000000000000001d, MathHelper.log2(Math.sqrt(2)));
+ assertEquals(0.5000000000000001d, MathHelper.log2(Math.sqrt(2)), 0.0d);
}
@Test

0 comments on commit 7cfb3af

Please sign in to comment.