nus-yam/ex-repair huggingface dataset:
Program: 92584
Project: 92584
Buggy source:
/** 
 * Test of parse method, of class PCLParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  PCLParser parser=new PCLParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.type);
      System.out.println(attribute.name);
    }
    assertEquals(6694,data.size());
    assertEquals(16,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-0.43,x[0][0],1E-7);
    assertEquals(-0.47,x[0][1],1E-7);
    assertEquals(-0.39,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[6693]);
    assertEquals(0.03,x[6693][13],1E-7);
    assertEquals(-0.53,x[6693][14],1E-7);
    assertEquals(0.3,x[6693][15],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}

Fixed version (ground truth):
/** 
 * Test of parse method, of class PCLParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  PCLParser parser=new PCLParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.getType());
      System.out.println(attribute.getName());
    }
    assertEquals(6694,data.size());
    assertEquals(16,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-0.43,x[0][0],1E-7);
    assertEquals(-0.47,x[0][1],1E-7);
    assertEquals(-0.39,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[6693]);
    assertEquals(0.03,x[6693][13],1E-7);
    assertEquals(-0.53,x[6693][14],1E-7);
    assertEquals(0.3,x[6693][15],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}
Program: 92585
Project: 92585
Buggy source:
/** 
 * Test of parse method, of class RESParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  RESParser parser=new RESParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.type);
      System.out.println(attribute.name + "String_Node_Str" + attribute.description);
    }
    assertEquals(7129,data.size());
    assertEquals(35,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-214,x[0][0],1E-7);
    assertEquals(-342,x[0][1],1E-7);
    assertEquals(-87,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[7128]);
    assertEquals(16,x[7128][32],1E-7);
    assertEquals(-73,x[7128][33],1E-7);
    assertEquals(-60,x[7128][34],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}

Fixed version (ground truth):
/** 
 * Test of parse method, of class RESParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  RESParser parser=new RESParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.getType());
      System.out.println(attribute.getName() + "String_Node_Str" + attribute.getDescription());
    }
    assertEquals(7129,data.size());
    assertEquals(35,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-214,x[0][0],1E-7);
    assertEquals(-342,x[0][1],1E-7);
    assertEquals(-87,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[7128]);
    assertEquals(16,x[7128][32],1E-7);
    assertEquals(-73,x[7128][33],1E-7);
    assertEquals(-60,x[7128][34],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}
Program: 92586
Project: 92586
Buggy source:
/** 
 * Test of parse method, of class TXTParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  TXTParser parser=new TXTParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.type);
      System.out.println(attribute.name);
    }
    assertEquals(6694,data.size());
    assertEquals(16,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-0.43,x[0][0],1E-7);
    assertEquals(-0.47,x[0][1],1E-7);
    assertEquals(-0.39,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[6693]);
    assertEquals(0.03,x[6693][13],1E-7);
    assertEquals(-0.53,x[6693][14],1E-7);
    assertEquals(0.3,x[6693][15],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}

Fixed version (ground truth):
/** 
 * Test of parse method, of class TXTParser.
 */
@Test public void testParse() throws Exception {
  System.out.println("String_Node_Str");
  TXTParser parser=new TXTParser();
  try {
    AttributeDataset data=parser.parse("String_Node_Str",smile.data.parser.IOUtils.getDataFile("String_Node_Str"));
    double[][] x=data.toArray(new double[data.size()][]);
    String[] id=data.toArray(new String[data.size()]);
    for (    Attribute attribute : data.attributes()) {
      assertEquals(Attribute.Type.NUMERIC,attribute.getType());
      System.out.println(attribute.getName());
    }
    assertEquals(6694,data.size());
    assertEquals(16,data.attributes().length);
    assertEquals("String_Node_Str",id[0]);
    assertEquals(-0.43,x[0][0],1E-7);
    assertEquals(-0.47,x[0][1],1E-7);
    assertEquals(-0.39,x[0][2],1E-7);
    assertEquals("String_Node_Str",id[6693]);
    assertEquals(0.03,x[6693][13],1E-7);
    assertEquals(-0.53,x[6693][14],1E-7);
    assertEquals(0.3,x[6693][15],1E-7);
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}
Program: 92587
Project: 92587
Buggy source:
@Override public Neighbor<double[],E>[] knn(double[] q,int k){
  if (k < 1) {
    throw new IllegalArgumentException("String_Node_Str" + k);
  }
  Set<Integer> candidates=obtainCandidates(q);
  Neighbor<double[],E> neighbor=new Neighbor<double[],E>(null,null,0,Double.MAX_VALUE);
  @SuppressWarnings("String_Node_Str") Neighbor<double[],E>[] neighbors=(Neighbor<double[],E>[])java.lang.reflect.Array.newInstance(neighbor.getClass(),k);
  HeapSelect<Neighbor<double[],E>> heap=new HeapSelect<Neighbor<double[],E>>(neighbors);
  for (int i=0; i < k; i++) {
    heap.add(neighbor);
  }
  int hit=0;
  for (  int index : candidates) {
    double[] key=keys.get(index);
    if (q == key && identicalExcluded) {
      continue;
    }
    double distance=Math.distance(q,key);
    if (distance < heap.peek().distance) {
      heap.add(new Neighbor<double[],E>(key,data.get(index),index,distance));
      hit++;
    }
  }
  heap.sort();
  if (hit < k) {
    @SuppressWarnings("String_Node_Str") Neighbor<double[],E>[] n2=(Neighbor<double[],E>[])java.lang.reflect.Array.newInstance(neighbor.getClass(),hit);
    for (int i=0; i < hit; i++) {
      n2[i]=neighbors[i + 1];
    }
    neighbors=n2;
  }
  return neighbors;
}

Fixed version (ground truth):
@Override public Neighbor<double[],E>[] knn(double[] q,int k){
  if (k < 1) {
    throw new IllegalArgumentException("String_Node_Str" + k);
  }
  Set<Integer> candidates=obtainCandidates(q);
  Neighbor<double[],E> neighbor=new Neighbor<double[],E>(null,null,0,Double.MAX_VALUE);
  @SuppressWarnings("String_Node_Str") Neighbor<double[],E>[] neighbors=(Neighbor<double[],E>[])java.lang.reflect.Array.newInstance(neighbor.getClass(),k);
  HeapSelect<Neighbor<double[],E>> heap=new HeapSelect<Neighbor<double[],E>>(neighbors);
  for (int i=0; i < k; i++) {
    heap.add(neighbor);
  }
  int hit=0;
  for (  int index : candidates) {
    double[] key=keys.get(index);
    if (q == key && identicalExcluded) {
      continue;
    }
    double distance=Math.distance(q,key);
    if (distance < heap.peek().distance) {
      heap.add(new Neighbor<double[],E>(key,data.get(index),index,distance));
      hit++;
    }
  }
  heap.sort();
  if (hit < k) {
    @SuppressWarnings("String_Node_Str") Neighbor<double[],E>[] n2=(Neighbor<double[],E>[])java.lang.reflect.Array.newInstance(neighbor.getClass(),hit);
    int start=k - hit;
    for (int i=0; i < hit; i++) {
      n2[i]=neighbors[i + start];
    }
    neighbors=n2;
  }
  return neighbors;
}
Program: 92589
Project: 92589
Buggy source:
@Override protected boolean onStateChange(int[] stateSet){
  boolean ret=false;
  if (mIconColor != null) {
    updateIconColor();
    ret=true;
  }
  if (mTint != null && mTintMode != null) {
    mTintFilter=updateTintFilter(mTint,mTintMode);
    invalidateSelf();
    ret=true;
  }
  return ret;
}

Fixed version (ground truth):
@Override protected boolean onStateChange(int[] stateSet){
  boolean ret=false;
  if (mIconColor != null && mIconColor.isStateful()) {
    updateIconColor();
    ret=true;
  }
  if (mTint != null && mTintMode != null) {
    mTintFilter=updateTintFilter(mTint,mTintMode);
    invalidateSelf();
    ret=true;
  }
  return ret;
}
Program: 92590
Project: 92590
Buggy source:
public IconicsTextView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
}

Fixed version (ground truth):
public IconicsTextView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  if (!isInEditMode()) {
    applyAttr(context,attrs,defStyle);
  }
}
Program: 92592
Project: 92592
Buggy source:
private void setAttributes(){
  if (mColor != 0) {
    mIcon.color(mColor);
  }
  if (mSize != -1) {
    mIcon.sizePx(mSize);
  }
  if (mSize != -1) {
    mIcon.paddingPx(mPadding);
  }
  if (mContourColor != 0) {
    mIcon.contourColor(mContourColor);
  }
  if (mContourWidth != -1) {
    mIcon.contourWidthPx(mContourWidth);
  }
  if (mBackgroundColor != 0) {
    mIcon.backgroundColor(mBackgroundColor);
  }
  if (mCornerRadius != -1) {
    mIcon.roundedCornersPx(mCornerRadius);
  }
}

Fixed version (ground truth):
private void setAttributes(){
  if (mColor != 0) {
    mIcon.color(mColor);
  }
  if (mSize != -1) {
    mIcon.sizePx(mSize);
  }
  if (mPadding != -1) {
    mIcon.paddingPx(mPadding);
  }
  if (mContourColor != 0) {
    mIcon.contourColor(mContourColor);
  }
  if (mContourWidth != -1) {
    mIcon.contourWidthPx(mContourWidth);
  }
  if (mBackgroundColor != 0) {
    mIcon.backgroundColor(mBackgroundColor);
  }
  if (mCornerRadius != -1) {
    mIcon.roundedCornersPx(mCornerRadius);
  }
}
Program: 92593
Project: 92593
Buggy source:
/** 
 * a helper class to resolve the correct R Class for the package
 * @param packageName
 * @return
 */
private static Class resolveRClass(String packageName){
  try {
    return Class.forName(packageName + "String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    e.printStackTrace();
  }
  try {
    return Class.forName(packageName.replace("String_Node_Str","String_Node_Str") + "String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    e.printStackTrace();
  }
  try {
    return Class.forName(packageName.replace("String_Node_Str","String_Node_Str") + "String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * a helper class to resolve the correct R Class for the package
 * @param packageName
 * @return
 */
private static Class resolveRClass(String packageName){
  do {
    try {
      return Class.forName(packageName + "String_Node_Str");
    }
 catch (    ClassNotFoundException e) {
      packageName=packageName.contains("String_Node_Str") ? packageName.substring(0,packageName.lastIndexOf('.')) : "String_Node_Str";
    }
  }
 while (!TextUtils.isEmpty(packageName));
  return null;
}
Program: 92594
Project: 92594
Buggy source:
public static String[] getFields(Context ctx){
  Class rClass=resolveRClass(ctx.getPackageName());
  if (rClass != null) {
    for (    Class c : rClass.getClasses()) {
      if (c.getName().endsWith("String_Node_Str")) {
        return getDefinedFonts(ctx,c.getFields());
      }
    }
  }
  return new String[0];
}

Fixed version (ground truth):
/** 
 * a helper to get the string fields from the R class
 * @param ctx
 * @return
 */
public static String[] getFields(Context ctx){
  Class rStringClass=resolveRClass(ctx.getPackageName());
  if (rStringClass != null) {
    return getDefinedFonts(ctx,rStringClass.getFields());
  }
  return new String[0];
}
Program: 92595
Project: 92595
Buggy source:
public IconicsImageView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  if (!isInEditMode()) {
    final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.IconicsImageView,defStyle,0);
    String icon=a.getString(R.styleable.IconicsImageView_iiv_icon);
    if (icon == null) {
      return;
    }
    mColor=a.getColor(R.styleable.IconicsImageView_iiv_color,0);
    mSize=a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_size,-1);
    mPadding=a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_padding,-1);
    mIcon=new IconicsDrawable(context,icon);
    if (mColor != 0) {
      mIcon.color(mColor);
    }
    if (mSize != -1) {
      mIcon.sizePx(mSize);
    }
    if (mSize != -1) {
      mIcon.paddingPx(mPadding);
    }
    a.recycle();
    setImageDrawable(mIcon);
    setScaleType(ScaleType.MATRIX);
  }
}

Fixed version (ground truth):
public IconicsImageView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  if (!isInEditMode()) {
    final TypedArray a=context.obtainStyledAttributes(attrs,R.styleable.IconicsImageView,defStyle,0);
    String icon=a.getString(R.styleable.IconicsImageView_iiv_icon);
    if (icon == null) {
      return;
    }
    mColor=a.getColor(R.styleable.IconicsImageView_iiv_color,0);
    mSize=a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_size,-1);
    mPadding=a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_padding,-1);
    mIcon=new IconicsDrawable(context,icon);
    if (mColor != 0) {
      mIcon.color(mColor);
    }
    if (mSize != -1) {
      mIcon.sizePx(mSize);
    }
    if (mSize != -1) {
      mIcon.paddingPx(mPadding);
    }
    a.recycle();
    setImageDrawable(mIcon);
    setScaleType(ScaleType.CENTER_INSIDE);
  }
}
Program: 92596
Project: 92596
Buggy source:
/** 
 * Set the color of the drawable.
 * @param color The color, usually from android.graphics.Color or 0xFF012345.
 * @return The current IconExtDrawable for chaining.
 */
public IconicsDrawable color(int color){
  mIconPaint.setAlpha(Color.alpha(color));
  mIconPaint.setColor(color);
  invalidateSelf();
  return this;
}

Fixed version (ground truth):
/** 
 * Set the color of the drawable.
 * @param color The color, usually from android.graphics.Color or 0xFF012345.
 * @return The current IconExtDrawable for chaining.
 */
public IconicsDrawable color(int color){
  setAlpha(Color.alpha(color));
  mIconPaint.setColor(color);
  invalidateSelf();
  return this;
}
Program: 92597
Project: 92597
Buggy source:
/** 
 * Set the color of the drawable.
 * @param color The color, usually from android.graphics.Color or 0xFF012345.
 * @return The current IconExtDrawable for chaining.
 */
public IconicsDrawable color(int color){
  mIconPaint.setColor(color);
  setAlpha(Color.alpha(color));
  invalidateSelf();
  return this;
}

Fixed version (ground truth):
/** 
 * Set the color of the drawable.
 * @param color The color, usually from android.graphics.Color or 0xFF012345.
 * @return The current IconExtDrawable for chaining.
 */
public IconicsDrawable color(int color){
  int red=Color.red(color);
  int green=Color.green(color);
  int blue=Color.blue(color);
  mIconPaint.setColor(Color.rgb(red,green,blue));
  setAlpha(Color.alpha(color));
  invalidateSelf();
  return this;
}
Program: 92598
Project: 92598
Buggy source:
@Override public void setAlpha(int alpha){
  mIconPaint.setAlpha(alpha);
  mAlpha=alpha;
}

Fixed version (ground truth):
@Override public void setAlpha(int alpha){
  mAlpha=alpha;
}
Program: 92599
Project: 92599
Buggy source:
private static int partition(int[] a,int l,int r){
  int pivot=a[r];
  while (l < r) {
    while (a[l] < pivot) {
      l++;
    }
    while (a[r] > pivot) {
      r--;
    }
    if (l <= r) {
      int temp=a[l];
      a[l]=a[r];
      a[r]=temp;
    }
  }
  return l;
}

Fixed version (ground truth):
private int partition(int[] numbers,int left,int right){
  int pivot=numbers[right];
  while (left < right) {
    while (numbers[left] < pivot) {
      left++;
    }
    while (numbers[right] > pivot) {
      right--;
    }
    if (left <= right) {
      int temp=numbers[left];
      numbers[left]=numbers[right];
      numbers[right]=temp;
    }
  }
  return left;
}
Program: 92600
Project: 92600
Buggy source:
@Override public void sort(int[] numbers){
  validateInput(numbers);
  this.numbers=numbers;
  number=numbers.length;
  quickSort(numbers,0,number - 1);
}

Fixed version (ground truth):
/** 
 * Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. Developed by Tony Hoare in 1959 and published in 1961, it is still a commonly used algorithm for sorting. When implemented well, it can be about two or three times faster than its main competitors, merge sort and heapsort. Quicksort is a comparison sort, meaning that it can sort items of any type for which a "less-than" relation (formally, a total order) is defined. In efficient implementations it is not a stable sort, meaning that the relative order of equal sort items is not preserved. Quicksort can operate in-place on an array, requiring small additional amounts of memory to perform the sorting. Mathematical analysis of quicksort shows that, on average, the algorithm takes O(n log n) comparisons to sort n items. In the worst case, it makes O(n2) comparisons, though this behavior is rare.
 */
@Override public void sort(int[] numbers){
  validateInput(numbers);
  quickSort(numbers,0,numbers.length - 1);
}
Program: 92601
Project: 92601
Buggy source:
public static void quickSort(int[] a,int left,int right){
  if (left < right) {
    int pi=partition(a,left,right);
    quickSort(a,left,pi - 1);
    quickSort(a,pi,right);
  }
}

Fixed version (ground truth):
private void quickSort(int[] numbers,int left,int right){
  if (left < right) {
    int pivotIndex=partition(numbers,left,right);
    quickSort(numbers,left,pivotIndex - 1);
    quickSort(numbers,pivotIndex,right);
  }
}
Program: 92602
Project: 92602
Buggy source:
/** 
 * Algorithm implementation based on a sorting algorithm named "Bubble Sorting" modified to work with this problem requirements. Using this sorting algorithm we get a complexity order in time terms equals to O(N^2) where N is the number of elements in the array. In space terms, the complexity order of this algorithm is O(1).
 */
public void moveSorting(int[] array){
  validateArray(array);
  boolean swap=true;
  while (swap) {
    swap=false;
    for (int i=0; i < array.length - 1; i++) {
      if ((array[i] < array[i + 1] && array[i + 1] > 0)) {
        swap(array,i,i + 1);
        swap=true;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Algorithm implementation based on a sorting algorithm named "Bubble Sorting" modified to work with this problem requirements. Using this sorting algorithm we get a complexity order in time terms equals to O(N^2) where N is the number of elements in the array. In space terms, the complexity order of this algorithm is O(1).
 */
public void moveSorting(int[] array){
  validateArray(array);
  boolean swap=true;
  while (swap) {
    swap=false;
    for (int i=0; i < array.length - 1; i++) {
      if (array[i] == 0 && array[i + 1] != 0) {
        swap(array,i,i + 1);
        swap=true;
      }
    }
  }
}
Program: 92603
Project: 92603
Buggy source:
/** 
 * Add implementation based on an additional data structure, one queue which implementation is a LinkedList. We we are going to do is add elements of the tree to the queue and one by one evaluate it adding more binary nodes to the queue if exist. The complexity order in time terms is O(N) where N is the number of elements in the tree. The complexity order in space terms is O(N) where N is the number of elements in the tree because we are going to store every node in a queue.
 */
public List<BinaryNode> getUsingQueue(BinaryNode root){
  validateBinaryNode(root);
  List<BinaryNode> result=new LinkedList<BinaryNode>();
  Queue<BinaryNode> queue=new LinkedList<BinaryNode>();
  queue.add(root);
  while (!queue.isEmpty()) {
    BinaryNode binaryNode=queue.remove();
    result.add(binaryNode);
    if (binaryNode.getLeft() != null)     queue.add(binaryNode.getLeft());
    if (binaryNode.getRight() != null)     queue.add(binaryNode.getRight());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Add implementation based on an additional data structure, one queue which implementation is a LinkedList. What we are going to do is add elements of the tree to the queue and one by one evaluate it adding more binary nodes to the queue if exist. The complexity order in time terms is O(N) where N is the number of elements in the tree. The complexity order in space terms is O(N) where N is the number of elements in the tree because we are going to store every node in a queue.
 */
public List<BinaryNode> getUsingQueue(BinaryNode root){
  validateBinaryNode(root);
  List<BinaryNode> result=new LinkedList<BinaryNode>();
  Queue<BinaryNode> queue=new LinkedList<BinaryNode>();
  queue.add(root);
  while (!queue.isEmpty()) {
    BinaryNode binaryNode=queue.remove();
    result.add(binaryNode);
    if (binaryNode.getLeft() != null)     queue.add(binaryNode.getLeft());
    if (binaryNode.getRight() != null)     queue.add(binaryNode.getRight());
  }
  return result;
}
Program: 92605
Project: 92605
Buggy source:
@Test public void shouldRewriteRowAndColumnsWithZeros(){
  int[][] matrix={{1,1,0},{1,0,1},{1,1,1}};
  rewriteMatrix.rewrite(matrix);
  int[][] expectedMatrix={{0,0,0},{1,0,0},{1,0,0}};
  assertArrayEquals(expectedMatrix,matrix);
}

Fixed version (ground truth):
@Test public void shouldRewriteRowAndColumnsWithZeros(){
  int[][] matrix={{1,1,0},{1,0,1},{1,1,1}};
  rewriteMatrix.rewrite(matrix);
  int[][] expectedMatrix={{0,0,0},{0,0,0},{1,0,0}};
  assertArrayEquals(expectedMatrix,matrix);
}
Program: 92606
Project: 92606
Buggy source:
private void validateInputData(int[] moneys,int billAmount){
  if (moneys == null || moneys.length == 0 || billAmount <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void validateInputData(int[] moneys,int billAmount){
  if (moneys == null || moneys.length == 0 || billAmount <= 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
}
Program: 92607
Project: 92607
Buggy source:
public long calculate(String number){
  return 0;
}

Fixed version (ground truth):
public long calculate(String number){
  if (number == null || number.indexOf("String_Node_Str") == -1) {
    throw new IllegalArgumentException("String_Node_Str" + number);
  }
  String[] splittedNumber=number.split("String_Node_Str");
  double first=Double.parseDouble(splittedNumber[0]);
  int sign=splittedNumber[1].charAt(0) == '+' ? 1 : -1;
  int pow=Integer.parseInt(splittedNumber[1].substring(1,splittedNumber[1].length()));
  Double result=sign * first * Math.pow(10,pow);
  return result.longValue();
}
Program: 92608
Project: 92608
Buggy source:
@Test public void shouldTakeIntoAccountNegativeNumbers(){
  String number="String_Node_Str";
  long result=cientificNotation.calculate(number);
  assertEquals(-9100000000L,result);
}

Fixed version (ground truth):
@Test public void shouldTakeIntoAccountNegativeNumbers(){
  String number="String_Node_Str";
  long result=cientificNotation.calculate(number);
  assertEquals(-9180000000L,result);
}
Program: 92609
Project: 92609
Buggy source:
@Test public void shouldReturnTheValueOfTheNumber(){
  String number="String_Node_Str";
  long result=cientificNotation.calculate(number);
  assertEquals(9100000000L,result);
}

Fixed version (ground truth):
@Test public void shouldReturnTheValueOfTheNumber(){
  String number="String_Node_Str";
  long result=cientificNotation.calculate(number);
  assertEquals(9180000000L,result);
}
Program: 92610
Project: 92610
Buggy source:
@Test public void shouldFindLCAWhenIsAFatherOfBothNodes(){
  BinaryNode<Integer> root=new BinaryNode<Integer>(1);
  BinaryNode<Integer> n2=new BinaryNode<Integer>(2);
  BinaryNode<Integer> n3=new BinaryNode<Integer>(3);
  BinaryNode<Integer> n4=new BinaryNode<Integer>(4);
  BinaryNode<Integer> n5=new BinaryNode<Integer>(5);
  BinaryNode<Integer> n6=new BinaryNode<Integer>(6);
  root.setLeft(n2);
  root.setRight(n3);
  n2.setLeft(n4);
  n2.setRight(n5);
  n4.setLeft(n6);
  BinaryNode<Integer> result=lca.get(root,n5,n6);
  assertEquals(n4,result);
}

Fixed version (ground truth):
@Test public void shouldFindLCAWhenIsAFatherOfBothNodes(){
  BinaryNode<Integer> root=new BinaryNode<Integer>(1);
  BinaryNode<Integer> n2=new BinaryNode<Integer>(2);
  BinaryNode<Integer> n3=new BinaryNode<Integer>(3);
  BinaryNode<Integer> n4=new BinaryNode<Integer>(4);
  BinaryNode<Integer> n5=new BinaryNode<Integer>(5);
  BinaryNode<Integer> n6=new BinaryNode<Integer>(6);
  root.setLeft(n2);
  root.setRight(n3);
  n2.setLeft(n4);
  n2.setRight(n5);
  n4.setLeft(n6);
  BinaryNode result=lca.getRecursive(root,n5,n6);
  assertEquals(n2,result);
}
Program: 92611
Project: 92611
Buggy source:
@Test public void shouldFindLCAWhenTheLCAIsOneOfTheNodesPassedAsInput(){
  BinaryNode<Integer> root=new BinaryNode<Integer>(1);
  BinaryNode<Integer> n2=new BinaryNode<Integer>(2);
  BinaryNode<Integer> n3=new BinaryNode<Integer>(3);
  BinaryNode<Integer> n4=new BinaryNode<Integer>(4);
  BinaryNode<Integer> n5=new BinaryNode<Integer>(5);
  BinaryNode<Integer> n6=new BinaryNode<Integer>(6);
  root.setLeft(n2);
  root.setRight(n3);
  n2.setLeft(n4);
  n2.setRight(n5);
  n4.setLeft(n6);
  BinaryNode<Integer> result=lca.get(root,root,n2);
  assertEquals(n4,result);
}

Fixed version (ground truth):
@Test public void shouldFindLCAWhenTheLCAIsOneOfTheNodesPassedAsInput(){
  BinaryNode<Integer> root=new BinaryNode<Integer>(1);
  BinaryNode<Integer> n2=new BinaryNode<Integer>(2);
  BinaryNode<Integer> n3=new BinaryNode<Integer>(3);
  BinaryNode<Integer> n4=new BinaryNode<Integer>(4);
  BinaryNode<Integer> n5=new BinaryNode<Integer>(5);
  BinaryNode<Integer> n6=new BinaryNode<Integer>(6);
  root.setLeft(n2);
  root.setRight(n3);
  n2.setLeft(n4);
  n2.setRight(n5);
  n4.setLeft(n6);
  BinaryNode result=lca.getRecursive(root,root,n2);
  assertEquals(root,result);
}
Program: 92612
Project: 92612
Buggy source:
@Test(expected=IllegalArgumentException.class) public void shouldNotAcceptNullElements(){
  lca.get(null,null,null);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void shouldNotAcceptNullElements(){
  lca.getRecursive(null,null,null);
}
Program: 92613
Project: 92613
Buggy source:
@Test public void fourDividedByTwoEqualsToTwo(){
  int dividend=4;
  int divider=2;
  float result=divideUsingSubtraction.divide(dividend,divider);
  assertEquals(2,result,DELTA);
}

Fixed version (ground truth):
@Test public void fourDividedByTwoEqualsToTwo(){
  int dividend=4;
  int divider=2;
  float result=divideUsingSubtraction.divideIterative(dividend,divider);
  assertEquals(2,result,DELTA);
}
Program: 92614
Project: 92614
Buggy source:
@Test public void fiveDividedByTwoEqualsToTwoPointFive(){
  int dividend=5;
  int divider=2;
  float result=divideUsingSubtraction.divide(dividend,divider);
  assertEquals(2.5,result,DELTA);
}

Fixed version (ground truth):
@Test public void fiveDividedByTwoEqualsToTwoPointFive(){
  int dividend=5;
  int divider=2;
  float result=divideUsingSubtraction.divideIterative(dividend,divider);
  assertEquals(2.5,result,DELTA);
}
Program: 92615
Project: 92615
Buggy source:
@Test(expected=IllegalArgumentException.class) public void anyNumberDividedByZeroIsNotDefined(){
  int dividend=100;
  int divider=0;
  divideUsingSubtraction.divide(dividend,divider);
}

Fixed version (ground truth):
@Test(expected=IllegalArgumentException.class) public void anyNumberDividedByZeroIsNotDefined(){
  int dividend=100;
  int divider=0;
  divideUsingSubtraction.divideIterative(dividend,divider);
}
Program: 92616
Project: 92616
Buggy source:
@Test public void sixtyDividedByTwelveEqualsToFive(){
  int dividend=60;
  int divider=12;
  float result=divideUsingSubtraction.divide(dividend,divider);
  assertEquals(5,result,DELTA);
}

Fixed version (ground truth):
@Test public void sixtyDividedByTwelveEqualsToFive(){
  int dividend=60;
  int divider=12;
  float result=divideUsingSubtraction.divideIterative(dividend,divider);
  assertEquals(5,result,DELTA);
}
Program: 92618
Project: 92618
Buggy source:
@Override public void onClick(View v){
  View myView=((RevealFrameLayout)mCardsGroup.getChildAt(0)).getChildAt(0);
  int cx=myView.getRight() - 100;
  int cy=myView.getBottom() - 100;
  int finalRadius=Math.max(myView.getWidth(),myView.getHeight()) + 100;
  ObjectAnimator animator=(ObjectAnimator)ViewAnimationUtils.createCircularReveal(myView,cx,cy,0,finalRadius);
  animator.setInterpolator(new AccelerateInterpolator());
  animator.setDuration(500);
  animator.setAutoCancel(true);
  animator.start();
}

Fixed version (ground truth):
@Override public void onClick(View v){
  View myView=((RevealFrameLayout)mCardsGroup.getChildAt(0)).getChildAt(0);
  int cx=myView.getRight() - 100;
  int cy=myView.getBottom() - 100;
  int finalRadius=Math.max(myView.getWidth(),myView.getHeight()) + 100;
  Animator animator=ViewAnimationUtils.createCircularReveal(myView,cx,cy,0,finalRadius);
  animator.setInterpolator(new AccelerateInterpolator());
  animator.setDuration(500);
  if (Animator.LOLLIPOP) {
    android.animation.ObjectAnimator a=(android.animation.ObjectAnimator)animator.getNativeAnimator();
    a.setAutoCancel(true);
  }
 else {
    ObjectAnimator a=(ObjectAnimator)animator.getSupportAnimator();
    a.setAutoCancel(true);
  }
  animator.start();
}
Program: 92620
Project: 92620
Buggy source:
public RevealFrameLayout(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  mRevealPath=new Path();
}

Fixed version (ground truth):
public RevealFrameLayout(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  if (FEATURES_HONEYCOMB && !FEATURES_KITKAT) {
    setLayerType(LAYER_TYPE_SOFTWARE,null);
  }
  mRevealPath=new Path();
}
Program: 92622
Project: 92622
Buggy source:
public static long removeTimezone(long timestamp){
  TimeZone tz=getTimezone();
  long now=new Date(timestamp).getTime();
  return now + tz.getOffset(now);
}

Fixed version (ground truth):
public static long removeTimezone(long timestamp){
  TimeZone tz=getTimezone();
  return timestamp + tz.getOffset(timestamp);
}
Program: 92623
Project: 92623
Buggy source:
public static long applyTimezone(long localTimestamp){
  TimeZone tz=getTimezone();
  long now=new Date(localTimestamp).getTime();
  return now - tz.getOffset(now);
}

Fixed version (ground truth):
public static long applyTimezone(long localTimestamp){
  TimeZone tz=getTimezone();
  return localTimestamp - tz.getOffset(localTimestamp - tz.getOffset(localTimestamp));
}
Program: 92624
Project: 92624
Buggy source:
public long timestamp(int year,int month,int day){
  GregorianCalendar cal=DateUtils.getStartOfTodayCalendar();
  cal.set(year,month,day);
  return cal.getTimeInMillis();
}

Fixed version (ground truth):
public long timestamp(int year,int month,int day,int hourOfDay,int minute,int second){
  GregorianCalendar cal=DateUtils.getStartOfTodayCalendar();
  cal.set(year,month,day,hourOfDay,minute,second);
  return cal.getTimeInMillis();
}
Program: 92625
Project: 92625
Buggy source:
private void drawColumn(Canvas canvas,RectF rect,GregorianCalendar date){
  Integer values[]=frequency.get(new Timestamp(date));
  float rowHeight=rect.height() / 8.0f;
  prevRect.set(rect);
  Integer[] localeWeekdayList=DateUtils.getLocaleWeekdayList();
  for (int j=0; j < localeWeekdayList.length; j++) {
    rect.set(0,0,baseSize,baseSize);
    rect.offset(prevRect.left,prevRect.top + baseSize * j);
    int i=DateUtils.javaWeekdayToLoopWeekday(localeWeekdayList[j]);
    if (values != null)     drawMarker(canvas,rect,values[i]);
    rect.offset(0,rowHeight);
  }
  drawFooter(canvas,rect,date);
}

Fixed version (ground truth):
private void drawColumn(Canvas canvas,RectF rect,GregorianCalendar date){
  Integer values[]=frequency.get(new Timestamp(date));
  float rowHeight=rect.height() / 8.0f;
  prevRect.set(rect);
  Integer[] localeWeekdayList=DateUtils.getLocaleWeekdayList();
  for (int j=0; j < localeWeekdayList.length; j++) {
    rect.set(0,0,baseSize,baseSize);
    rect.offset(prevRect.left,prevRect.top + baseSize * j);
    int i=localeWeekdayList[j] % 7;
    if (values != null)     drawMarker(canvas,rect,values[i]);
    rect.offset(0,rowHeight);
  }
  drawFooter(canvas,rect,date);
}
Program: 92626
Project: 92626
Buggy source:
@Test public void test_getValues_withValidInterval(){
  long from=today - 15 * dayLength;
  long to=today - 5 * dayLength;
  int[] expectedValues={CHECKED_EXPLICITLY,CHECKED_IMPLICITLY,CHECKED_IMPLICITLY,CHECKED_EXPLICITLY,CHECKED_EXPLICITLY,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED};
  int[] actualValues=nonDailyHabit.getCheckmarks().getValues(new Timestamp(from),new Timestamp(to));
  assertThat(actualValues,equalTo(expectedValues));
}

Fixed version (ground truth):
@Test public void test_getValues_withValidInterval(){
  Timestamp from=today.minus(15);
  Timestamp to=today.minus(5);
  int[] expectedValues={CHECKED_EXPLICITLY,CHECKED_IMPLICITLY,CHECKED_IMPLICITLY,CHECKED_EXPLICITLY,CHECKED_EXPLICITLY,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED,UNCHECKED};
  int[] actualValues=nonDailyHabit.getCheckmarks().getValues(from,to);
  assertThat(actualValues,equalTo(expectedValues));
}
Program: 92627
Project: 92627
Buggy source:
@Override public void setUp() throws Exception {
  super.setUp();
  nonDailyHabit=fixtures.createShortHabit();
  habitList.add(nonDailyHabit);
  emptyHabit=fixtures.createEmptyHabit();
  habitList.add(emptyHabit);
  numericalHabit=fixtures.createNumericalHabit();
  habitList.add(numericalHabit);
}

Fixed version (ground truth):
@Override public void setUp() throws Exception {
  super.setUp();
  nonDailyHabit=fixtures.createShortHabit();
  habitList.add(nonDailyHabit);
  emptyHabit=fixtures.createEmptyHabit();
  habitList.add(emptyHabit);
  numericalHabit=fixtures.createNumericalHabit();
  habitList.add(numericalHabit);
  today=DateUtils.getToday();
}
Program: 92628
Project: 92628
Buggy source:
@Test public void testOnStartup_firstLaunch(){
  long today=DateUtils.getStartOfToday();
  when(prefs.isFirstRun()).thenReturn(true);
  behavior.onStartup();
  verify(prefs).setFirstRun(false);
  verify(prefs).updateLastHint(-1,today);
  verify(screen).showIntroScreen();
}

Fixed version (ground truth):
@Test public void testOnStartup_firstLaunch(){
  Timestamp today=DateUtils.getToday();
  when(prefs.isFirstRun()).thenReturn(true);
  behavior.onStartup();
  verify(prefs).setFirstRun(false);
  verify(prefs).updateLastHint(-1,today);
  verify(screen).showIntroScreen();
}
Program: 92629
Project: 92629
Buggy source:
@Test public void testFormatHeaderDate(){
  long timestamp=timestamp(2015,DECEMBER,31);
  GregorianCalendar date=DateUtils.getCalendar(timestamp);
  String formatted=DateUtils.formatHeaderDate(date);
  assertThat(formatted,equalTo("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testFormatHeaderDate(){
  long timestamp=timestamp(2015,DECEMBER,31);
  GregorianCalendar date=new Timestamp(timestamp).toCalendar();
  String formatted=DateUtils.formatHeaderDate(date);
  assertThat(formatted,equalTo("String_Node_Str"));
}
Program: 92630
Project: 92630
Buggy source:
@Override public void onEdit(@NonNull Habit habit,long timestamp){
  int oldValue=habit.getCheckmarks().getTodayValue();
  screen.showNumberPicker(oldValue,newValue -> {
    commandRunner.execute(new CreateRepetitionCommand(habit,timestamp,newValue),habit.getId());
  }
);
}

Fixed version (ground truth):
@Override public void onEdit(@NonNull Habit habit,long timestamp){
  int oldValue=habit.getCheckmarks().getValues(timestamp,timestamp)[0];
  screen.showNumberPicker(oldValue,newValue -> {
    commandRunner.execute(new CreateRepetitionCommand(habit,timestamp,newValue),habit.getId());
  }
);
}
Program: 92631
Project: 92631
Buggy source:
public void showNumberPicker(int initialValue,@NonNull NumberPickerCallback callback){
  LayoutInflater inflater=activity.getLayoutInflater();
  View view=inflater.inflate(R.layout.number_picker_dialog,null);
  final NumberPicker picker=(NumberPicker)view.findViewById(R.id.picker);
  picker.setMinValue(0);
  picker.setMaxValue(Integer.MAX_VALUE);
  picker.setValue(initialValue);
  picker.setWrapSelectorWheel(false);
  AlertDialog.Builder builder=new AlertDialog.Builder(activity);
  builder.setView(view).setTitle(R.string.change_value).setPositiveButton(android.R.string.ok,(dialog,which) -> {
    callback.onNumberPicked(picker.getValue());
  }
);
  AlertDialog dialog=builder.create();
  dialog.show();
  int width=(int)dpToPixels(activity,200);
  int height=(int)dpToPixels(activity,275);
  dialog.getWindow().setLayout(width,height);
}

Fixed version (ground truth):
public void showNumberPicker(int initialValue,@NonNull NumberPickerCallback callback){
  LayoutInflater inflater=activity.getLayoutInflater();
  View view=inflater.inflate(R.layout.number_picker_dialog,null);
  final NumberPicker picker=(NumberPicker)view.findViewById(R.id.picker);
  picker.setMinValue(0);
  picker.setMaxValue(Integer.MAX_VALUE);
  picker.setValue(initialValue);
  picker.setWrapSelectorWheel(false);
  AlertDialog dialog=new AlertDialog.Builder(activity).setView(view).setTitle(R.string.change_value).setPositiveButton(android.R.string.ok,(d,which) -> {
    picker.clearFocus();
    callback.onNumberPicked(picker.getValue());
  }
).create();
  InterfaceUtils.setupEditorAction(picker,(v,actionId,event) -> {
    if (actionId == IME_ACTION_DONE)     dialog.getButton(BUTTON_POSITIVE).performClick();
    return false;
  }
);
  dialog.show();
  Window window=dialog.getWindow();
  if (window != null) {
    int width=(int)dpToPixels(activity,200);
    int height=(int)dpToPixels(activity,275);
    window.setLayout(width,height);
  }
}
Program: 92632
Project: 92632
Buggy source:
@Override public void onRestoreInstanceState(Parcelable state){
  BundleSavedState bss=(BundleSavedState)state;
  int x=bss.bundle.getInt("String_Node_Str");
  int y=bss.bundle.getInt("String_Node_Str");
  dataOffset=bss.bundle.getInt("String_Node_Str");
  scroller.startScroll(0,0,x,y,0);
  scroller.computeScrollOffset();
  super.onRestoreInstanceState(bss.getSuperState());
}

Fixed version (ground truth):
@Override public void onRestoreInstanceState(Parcelable state){
  BundleSavedState bss=(BundleSavedState)state;
  int x=bss.bundle.getInt("String_Node_Str");
  int y=bss.bundle.getInt("String_Node_Str");
  direction=bss.bundle.getInt("String_Node_Str");
  dataOffset=bss.bundle.getInt("String_Node_Str");
  maxDataOffset=bss.bundle.getInt("String_Node_Str");
  scroller.startScroll(0,0,x,y,0);
  scroller.computeScrollOffset();
  super.onRestoreInstanceState(bss.getSuperState());
}
Program: 92633
Project: 92633
Buggy source:
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  scroller.fling(scroller.getCurrX(),scroller.getCurrY(),(int)velocityX / 2,0,0,100000,0,0);
  invalidate();
  scrollAnimator.setDuration(scroller.getDuration());
  scrollAnimator.start();
  return false;
}

Fixed version (ground truth):
@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
  scroller.fling(scroller.getCurrX(),scroller.getCurrY(),direction * ((int)velocityX) / 2,0,0,getMaxX(),0,0);
  invalidate();
  scrollAnimator.setDuration(scroller.getDuration());
  scrollAnimator.start();
  return false;
}
Program: 92634
Project: 92634
Buggy source:
@Override public boolean onScroll(MotionEvent e1,MotionEvent e2,float dx,float dy){
  if (scrollerBucketSize == 0)   return false;
  if (Math.abs(dx) > Math.abs(dy)) {
    ViewParent parent=getParent();
    if (parent != null)     parent.requestDisallowInterceptTouchEvent(true);
  }
  scroller.startScroll(scroller.getCurrX(),scroller.getCurrY(),(int)-dx,(int)dy,0);
  scroller.computeScrollOffset();
  updateDataOffset();
  return true;
}

Fixed version (ground truth):
@Override public boolean onScroll(MotionEvent e1,MotionEvent e2,float dx,float dy){
  if (scrollerBucketSize == 0)   return false;
  if (Math.abs(dx) > Math.abs(dy)) {
    ViewParent parent=getParent();
    if (parent != null)     parent.requestDisallowInterceptTouchEvent(true);
  }
  dx=-direction * dx;
  dx=Math.min(dx,getMaxX() - scroller.getCurrX());
  scroller.startScroll(scroller.getCurrX(),scroller.getCurrY(),(int)dx,(int)dy,0);
  scroller.computeScrollOffset();
  updateDataOffset();
  return true;
}
Program: 92635
Project: 92635
Buggy source:
@Override public Parcelable onSaveInstanceState(){
  Parcelable superState=super.onSaveInstanceState();
  Bundle bundle=new Bundle();
  bundle.putInt("String_Node_Str",scroller.getCurrX());
  bundle.putInt("String_Node_Str",scroller.getCurrY());
  bundle.putInt("String_Node_Str",dataOffset);
  return new BundleSavedState(superState,bundle);
}

Fixed version (ground truth):
@Override public Parcelable onSaveInstanceState(){
  Parcelable superState=super.onSaveInstanceState();
  Bundle bundle=new Bundle();
  bundle.putInt("String_Node_Str",scroller.getCurrX());
  bundle.putInt("String_Node_Str",scroller.getCurrY());
  bundle.putInt("String_Node_Str",dataOffset);
  bundle.putInt("String_Node_Str",direction);
  bundle.putInt("String_Node_Str",maxDataOffset);
  return new BundleSavedState(superState,bundle);
}
Program: 92636
Project: 92636
Buggy source:
private void updateDataOffset(){
  int newDataOffset=Math.max(0,scroller.getCurrX() / scrollerBucketSize);
  if (newDataOffset != dataOffset) {
    dataOffset=newDataOffset;
    scrollController.onDataOffsetChanged(dataOffset);
    postInvalidate();
  }
}

Fixed version (ground truth):
private void updateDataOffset(){
  int newDataOffset=scroller.getCurrX() / scrollerBucketSize;
  newDataOffset=Math.max(0,newDataOffset);
  newDataOffset=Math.min(maxDataOffset,newDataOffset);
  if (newDataOffset != dataOffset) {
    dataOffset=newDataOffset;
    scrollController.onDataOffsetChanged(dataOffset);
    postInvalidate();
  }
}
Program: 92637
Project: 92637
Buggy source:
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  int count=getCheckmarkCount();
  header.setButtonCount(count);
  listView.setCheckmarkCount(count);
  super.onSizeChanged(w,h,oldw,oldh);
}

Fixed version (ground truth):
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  int count=getCheckmarkCount();
  header.setButtonCount(count);
  header.setMaxDataOffset(Math.max(MAX_CHECKMARK_COUNT - count,0));
  listView.setCheckmarkCount(count);
  super.onSizeChanged(w,h,oldw,oldh);
}
Program: 92638
Project: 92638
Buggy source:
public HeaderView(Context context,AttributeSet attrs){
  super(context,attrs);
  if (isInEditMode()) {
    setButtonCount(5);
  }
  StyledResources res=new StyledResources(context);
  setScrollerBucketSize((int)dpToPixels(context,42));
  paint=new TextPaint();
  paint.setColor(Color.BLACK);
  paint.setAntiAlias(true);
  paint.setTextSize(getResources().getDimension(R.dimen.tinyTextSize));
  paint.setTextAlign(Paint.Align.CENTER);
  paint.setTypeface(Typeface.DEFAULT_BOLD);
  paint.setColor(res.getColor(R.attr.mediumContrastTextColor));
  rect=new RectF();
  Context appContext=context.getApplicationContext();
  if (appContext instanceof HabitsApplication) {
    HabitsApplication app=(HabitsApplication)appContext;
    prefs=app.getComponent().getPreferences();
  }
  if (context instanceof ListHabitsActivity) {
    ListHabitsActivity activity=(ListHabitsActivity)context;
    midnightTimer=activity.getListHabitsComponent().getMidnightTimer();
  }
}

Fixed version (ground truth):
public HeaderView(Context context,AttributeSet attrs){
  super(context,attrs);
  if (isInEditMode()) {
    setButtonCount(5);
  }
  Context appContext=context.getApplicationContext();
  if (appContext instanceof HabitsApplication) {
    HabitsApplication app=(HabitsApplication)appContext;
    prefs=app.getComponent().getPreferences();
  }
  if (context instanceof ListHabitsActivity) {
    ListHabitsActivity activity=(ListHabitsActivity)context;
    midnightTimer=activity.getListHabitsComponent().getMidnightTimer();
  }
  Resources res=context.getResources();
  setScrollerBucketSize((int)res.getDimension(R.dimen.checkmarkWidth));
  setDirection(shouldReverseCheckmarks() ? 1 : -1);
  StyledResources sr=new StyledResources(context);
  paint=new TextPaint();
  paint.setColor(Color.BLACK);
  paint.setAntiAlias(true);
  paint.setTextSize(getResources().getDimension(R.dimen.tinyTextSize));
  paint.setTextAlign(Paint.Align.CENTER);
  paint.setTypeface(Typeface.DEFAULT_BOLD);
  paint.setColor(sr.getColor(R.attr.mediumContrastTextColor));
  rect=new RectF();
}
Program: 92639
Project: 92639
Buggy source:
@Override public void onCheckmarkOrderChanged(){
  postInvalidate();
}

Fixed version (ground truth):
@Override public void onCheckmarkOrderChanged(){
  setDirection(shouldReverseCheckmarks() ? 1 : -1);
  postInvalidate();
}
Program: 92640
Project: 92640
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  GregorianCalendar day=DateUtils.getStartOfTodayCalendar();
  Resources res=getContext().getResources();
  float width=res.getDimension(R.dimen.checkmarkWidth);
  float height=res.getDimension(R.dimen.checkmarkHeight);
  rect.set(0,0,width,height);
  rect.offset(canvas.getWidth(),0);
  day.add(GregorianCalendar.DAY_OF_MONTH,-getDataOffset());
  float em=paint.measureText("String_Node_Str");
  for (int i=0; i < buttonCount; i++) {
    rect.offset(-width,0);
    String text=DateUtils.formatHeaderDate(day).toUpperCase();
    String[] lines=text.split("String_Node_Str");
    int y1=(int)(rect.centerY() - 0.5 * em);
    int y2=(int)(rect.centerY() + em);
    canvas.drawText(lines[0],rect.centerX(),y1,paint);
    canvas.drawText(lines[1],rect.centerX(),y2,paint);
    day.add(GregorianCalendar.DAY_OF_MONTH,-1);
  }
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  GregorianCalendar day=DateUtils.getStartOfTodayCalendar();
  Resources res=getContext().getResources();
  float width=res.getDimension(R.dimen.checkmarkWidth);
  float height=res.getDimension(R.dimen.checkmarkHeight);
  boolean reverse=shouldReverseCheckmarks();
  day.add(GregorianCalendar.DAY_OF_MONTH,-getDataOffset());
  float em=paint.measureText("String_Node_Str");
  for (int i=0; i < buttonCount; i++) {
    rect.set(0,0,width,height);
    rect.offset(canvas.getWidth(),0);
    if (reverse)     rect.offset(-(i + 1) * width,0);
 else     rect.offset((i - buttonCount) * width,0);
    String text=DateUtils.formatHeaderDate(day).toUpperCase();
    String[] lines=text.split("String_Node_Str");
    int y1=(int)(rect.centerY() - 0.25 * em);
    int y2=(int)(rect.centerY() + 1.25 * em);
    canvas.drawText(lines[0],rect.centerX(),y1,paint);
    canvas.drawText(lines[1],rect.centerX(),y2,paint);
    day.add(GregorianCalendar.DAY_OF_MONTH,-1);
  }
}