Created
March 18, 2010 09:55
-
-
Save develop7/336234 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testDefaultConstruction() | |
{ | |
Foo foo = new Foo(); | |
assertNotNull(foo); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double weight_; | |
private double x_, y_; | |
public void setWeight(int weight) | |
{ | |
weight = weight_; // error | |
} | |
public double getX() | |
{ | |
return x_; | |
} | |
public double getY() | |
{ | |
return x_; // error | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setLength(double length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testByteSwapper() | |
{ | |
for (int i = 0; i < 1000000; i++) { | |
double v0 = Random.getDouble(); | |
double v1 = ByteSwapper.swap(v0); | |
double v2 = ByteSwapper.swap(v1); | |
assertEquals(v0, v2); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setLength(double length) throws IllegalArgumentException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
setLength(-1.0); | |
fail(); // If we get here, something went wrong | |
} | |
catch (IllegalArgumentException exception) { | |
// If we get here, all is fine | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void scale(double x0, double y0, double scaleFactor) | |
{ | |
// scaling logic | |
} | |
public void scale(double x0, double y0) | |
{ | |
scale(x0, y0, 1.0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handle handle = manager.getHandle(); | |
assertNotNull(handle); | |
String handleName = handle.getName(); | |
assertEquals(handleName, "handle-01"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handle handle = manager.getHandle(); | |
assertNotNull(handle); | |
if (handle == null) return; | |
String handleName = handle.getName(); | |
assertEquals(handleName, "handle-01"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment