jaroslav@390: /** jaroslav@390: * Back 2 Browser Bytecode Translator jaroslav@390: * Copyright (C) 2012 Jaroslav Tulach jaroslav@390: * jaroslav@390: * This program is free software: you can redistribute it and/or modify jaroslav@390: * it under the terms of the GNU General Public License as published by jaroslav@390: * the Free Software Foundation, version 2 of the License. jaroslav@390: * jaroslav@390: * This program is distributed in the hope that it will be useful, jaroslav@390: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@390: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@390: * GNU General Public License for more details. jaroslav@390: * jaroslav@390: * You should have received a copy of the GNU General Public License jaroslav@390: * along with this program. Look for COPYING file in the top folder. jaroslav@390: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@390: */ jaroslav@390: package org.apidesign.bck2brwsr.tck; jaroslav@390: jaroslav@390: import org.apidesign.bck2brwsr.vmtest.Compare; jaroslav@390: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@390: import org.testng.annotations.Factory; jaroslav@390: jaroslav@390: /** jaroslav@390: * jaroslav@390: * @author Jaroslav Tulach jaroslav@390: */ jaroslav@390: public class CompareIntArrayTest { jaroslav@390: @Compare public int integerArraySum() { jaroslav@390: int[] arr = createArray(); jaroslav@390: return sumIntArr(arr); jaroslav@390: } jaroslav@390: jaroslav@390: @Compare public int countZeros() { jaroslav@390: int zeros = 0; jaroslav@390: for (Integer i : createArray()) { jaroslav@390: if (i == 0) { jaroslav@390: zeros++; jaroslav@390: } jaroslav@390: } jaroslav@390: return zeros; jaroslav@390: } jaroslav@390: jaroslav@390: private static int sumIntArr(int[] arr) { jaroslav@390: int sum = 0; jaroslav@390: for (int i = 0; i < arr.length; i++) { jaroslav@390: sum += arr[i]; jaroslav@390: } jaroslav@390: return sum; jaroslav@390: } jaroslav@390: jaroslav@390: @Factory jaroslav@390: public static Object[] create() { jaroslav@390: return VMTest.create(CompareIntArrayTest.class); jaroslav@390: } jaroslav@390: jaroslav@390: private int[] createArray() { jaroslav@390: int[] arr = new int[10]; jaroslav@390: arr[5] = 3; jaroslav@390: arr[7] = 8; jaroslav@390: return arr; jaroslav@390: } jaroslav@390: }