Skip to content

Instantly share code, notes, and snippets.

@develop7
Created March 18, 2010 09:55
Show Gist options
  • Save develop7/336234 to your computer and use it in GitHub Desktop.
Save develop7/336234 to your computer and use it in GitHub Desktop.
void testDefaultConstruction()
{
Foo foo = new Foo();
assertNotNull(foo);
}
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
}
void setLength(double length);
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);
}
}
void setLength(double length) throws IllegalArgumentException;
try {
setLength(-1.0);
fail(); // If we get here, something went wrong
}
catch (IllegalArgumentException exception) {
// If we get here, all is fine
}
public void scale(double x0, double y0, double scaleFactor)
{
// scaling logic
}
public void scale(double x0, double y0)
{
scale(x0, y0, 1.0);
}
Handle handle = manager.getHandle();
assertNotNull(handle);
String handleName = handle.getName();
assertEquals(handleName, "handle-01");
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