Program: 16371
Project: 16371
Buggy source:
@Test public void testClosedCase(){
  SymmetryAxes axes=new SymmetryAxes();
  Matrix4d r90=new Matrix4d();
  r90.set(new AxisAngle4d(0,0,1,-Math.PI / 2));
  axes.addAxis(r90,4,SymmetryType.CLOSED);
  Matrix4d r180=new Matrix4d();
  r180.set(new AxisAngle4d(1,0,0,Math.PI));
  axes.addAxis(r180,2,SymmetryType.CLOSED);
  assertEquals(2,axes.getElementaryAxes().size());
  Matrix4d expectedEven=new Matrix4d();
  expectedEven.set(1);
  Matrix4d expectedOdd=new Matrix4d(r180);
  assertEquals(expectedEven,axes.getRepeatTransform(0));
  assertEquals(expectedOdd,axes.getRepeatTransform(1));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(2));
  assertEquals(expectedOdd,axes.getRepeatTransform(3));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(4));
  assertEquals(expectedOdd,axes.getRepeatTransform(5));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(6));
  assertEquals(expectedOdd,axes.getRepeatTransform(7));
  List<List<Integer>> relation=Arrays.asList(Arrays.asList(0,1,2,3,4,5,6,7),Arrays.asList(2,3,4,5,6,7,0,1));
  assertEquals(relation,axes.getRepeatRelation(0));
  relation=Arrays.asList(Arrays.asList(0,1),Arrays.asList(1,0));
  assertEquals(relation,axes.getRepeatRelation(1));
  relation=Arrays.asList(Arrays.asList(2,3),Arrays.asList(3,2));
  assertEquals(relation,axes.getRepeatRelation(1,2));
  try {
    axes.getRepeatRelation(2);
    fail("String_Node_Str");
  }
 catch (  IndexOutOfBoundsException e) {
  }
  try {
    axes.getRepeatRelation(1,1);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  relation=Arrays.asList(Arrays.asList(0,2,4,6),Arrays.asList(1,3,5,7));
  assertEquals(relation,axes.getRepeatsCyclicForm(0));
  relation=Arrays.asList(Arrays.asList(0,1));
  assertEquals(relation,axes.getRepeatsCyclicForm(1));
  relation=Arrays.asList(Arrays.asList(2,3));
  assertEquals(relation,axes.getRepeatsCyclicForm(1,2));
  try {
    axes.getRepeatsCyclicForm(2);
    fail("String_Node_Str");
  }
 catch (  IndexOutOfBoundsException e) {
  }
  try {
    axes.getRepeatsCyclicForm(1,1);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  Point3d[] repeats=new Point3d[]{new Point3d(1,1,1),new Point3d(1,-1,-1),new Point3d(-1,1,1),new Point3d(1,1,-1),new Point3d(-1,-1,1),new Point3d(-1,1,-1),new Point3d(1,-1,1),new Point3d(-1,-1,-1)};
  for (int i=0; i < 8; i++) {
    Matrix4d m=axes.getRepeatTransform(i);
    m.invert();
    Point3d x=new Point3d(repeats[0]);
    m.transform(x);
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ repeats[0]+ "String_Node_Str"+ x+ "String_Node_Str"+ repeats[i],x.epsilonEquals(repeats[i],1e-5));
  }
  for (int i=0; i < 8; i++) {
    Matrix4d m=axes.getRepeatTransform(i);
    Point3d x=new Point3d(repeats[i]);
    m.transform(x);
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ repeats[i]+ "String_Node_Str"+ x+ "String_Node_Str",x.epsilonEquals(repeats[0],1e-5));
  }
  Point3d x;
  List<Axis> symmetryAxes=axes.getSymmetryAxes();
  assertEquals(5,symmetryAxes.size());
  int axisNum=0;
  x=new Point3d(repeats[2]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[2]),round(x),round(repeats[0])),x.epsilonEquals(repeats[0],1e-5));
  assertEquals(0,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[1]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[1]),round(x),round(repeats[0])),x.epsilonEquals(repeats[0],1e-5));
  assertEquals(0,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[3]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[3]),round(x),round(repeats[2])),x.epsilonEquals(repeats[2],1e-5));
  assertEquals(2,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[5]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[5]),round(x),round(repeats[4])),x.epsilonEquals(repeats[4],1e-5));
  assertEquals(4,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[7]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[7]),round(x),round(repeats[6])),x.epsilonEquals(repeats[6],1e-5));
  assertEquals(6,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
}

Fixed version (ground truth):
@Test public void testClosedCase(){
  SymmetryAxes axes=new SymmetryAxes();
  Matrix4d r90=new Matrix4d();
  r90.set(new AxisAngle4d(0,0,1,-Math.PI / 2));
  axes.addAxis(r90,4,SymmetryType.CLOSED);
  Matrix4d r180=new Matrix4d();
  r180.set(new AxisAngle4d(1,0,0,Math.PI));
  axes.addAxis(r180,2,SymmetryType.CLOSED);
  assertEquals(2,axes.getElementaryAxes().size());
  Matrix4d expectedEven=new Matrix4d();
  expectedEven.setIdentity();
  Matrix4d expectedOdd=new Matrix4d(r180);
  assertEquals(expectedEven,axes.getRepeatTransform(0));
  assertEquals(expectedOdd,axes.getRepeatTransform(1));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(2));
  assertEquals(expectedOdd,axes.getRepeatTransform(3));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(4));
  assertEquals(expectedOdd,axes.getRepeatTransform(5));
  expectedEven.mul(r90);
  expectedOdd.mul(r180,expectedEven);
  assertEquals(expectedEven,axes.getRepeatTransform(6));
  assertEquals(expectedOdd,axes.getRepeatTransform(7));
  List<List<Integer>> relation=Arrays.asList(Arrays.asList(0,1,2,3,4,5,6,7),Arrays.asList(2,3,4,5,6,7,0,1));
  assertEquals(relation,axes.getRepeatRelation(0));
  relation=Arrays.asList(Arrays.asList(0,1),Arrays.asList(1,0));
  assertEquals(relation,axes.getRepeatRelation(1));
  relation=Arrays.asList(Arrays.asList(2,3),Arrays.asList(3,2));
  assertEquals(relation,axes.getRepeatRelation(1,2));
  try {
    axes.getRepeatRelation(2);
    fail("String_Node_Str");
  }
 catch (  IndexOutOfBoundsException e) {
  }
  try {
    axes.getRepeatRelation(1,1);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  relation=Arrays.asList(Arrays.asList(0,2,4,6),Arrays.asList(1,3,5,7));
  assertEquals(relation,axes.getRepeatsCyclicForm(0));
  relation=Arrays.asList(Arrays.asList(0,1));
  assertEquals(relation,axes.getRepeatsCyclicForm(1));
  relation=Arrays.asList(Arrays.asList(2,3));
  assertEquals(relation,axes.getRepeatsCyclicForm(1,2));
  try {
    axes.getRepeatsCyclicForm(2);
    fail("String_Node_Str");
  }
 catch (  IndexOutOfBoundsException e) {
  }
  try {
    axes.getRepeatsCyclicForm(1,1);
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException e) {
  }
  Point3d[] repeats=new Point3d[]{new Point3d(1,1,1),new Point3d(1,-1,-1),new Point3d(-1,1,1),new Point3d(1,1,-1),new Point3d(-1,-1,1),new Point3d(-1,1,-1),new Point3d(1,-1,1),new Point3d(-1,-1,-1)};
  for (int i=0; i < 8; i++) {
    Matrix4d m=axes.getRepeatTransform(i);
    m.invert();
    Point3d x=new Point3d(repeats[0]);
    m.transform(x);
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ repeats[0]+ "String_Node_Str"+ x+ "String_Node_Str"+ repeats[i],x.epsilonEquals(repeats[i],1e-5));
  }
  for (int i=0; i < 8; i++) {
    Matrix4d m=axes.getRepeatTransform(i);
    Point3d x=new Point3d(repeats[i]);
    m.transform(x);
    assertTrue("String_Node_Str" + i + "String_Node_Str"+ repeats[i]+ "String_Node_Str"+ x+ "String_Node_Str",x.epsilonEquals(repeats[0],1e-5));
  }
  Point3d x;
  List<Axis> symmetryAxes=axes.getSymmetryAxes();
  assertEquals(5,symmetryAxes.size());
  int axisNum=0;
  x=new Point3d(repeats[2]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[2]),round(x),round(repeats[0])),x.epsilonEquals(repeats[0],1e-5));
  assertEquals(0,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[1]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[1]),round(x),round(repeats[0])),x.epsilonEquals(repeats[0],1e-5));
  assertEquals(0,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[3]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[3]),round(x),round(repeats[2])),x.epsilonEquals(repeats[2],1e-5));
  assertEquals(2,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[5]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[5]),round(x),round(repeats[4])),x.epsilonEquals(repeats[4],1e-5));
  assertEquals(4,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
  x=new Point3d(repeats[7]);
  symmetryAxes.get(axisNum).getOperator().transform(x);
  assertTrue(String.format("String_Node_Str",axisNum,round(repeats[7]),round(x),round(repeats[6])),x.epsilonEquals(repeats[6],1e-5));
  assertEquals(6,symmetryAxes.get(axisNum).getFirstRepeat());
  axisNum++;
}