BitMatrixTestCase.java (zxing-zxing-3.4.1) | : | BitMatrixTestCase.java (zxing-zxing-3.5.0) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
package com.google.zxing.common; | package com.google.zxing.common; | |||
import org.junit.Assert; | import org.junit.Assert; | |||
import org.junit.Test; | import org.junit.Test; | |||
import java.util.Arrays; | ||||
/** | /** | |||
* @author Sean Owen | * @author Sean Owen | |||
* @author dswitkin@google.com (Daniel Switkin) | * @author dswitkin@google.com (Daniel Switkin) | |||
*/ | */ | |||
public final class BitMatrixTestCase extends Assert { | public final class BitMatrixTestCase extends Assert { | |||
private static final int[] BIT_MATRIX_POINTS = { 1, 2, 2, 0, 3, 1 }; | private static final int[] BIT_MATRIX_POINTS = { 1, 2, 2, 0, 3, 1 }; | |||
@Test | @Test | |||
public void testGetSet() { | public void testGetSet() { | |||
skipping to change at line 161 | skipping to change at line 163 | |||
for (int x = 0; x < 102; x++) { | for (int x = 0; x < 102; x++) { | |||
boolean on = (x & 0x03) == 0; | boolean on = (x & 0x03) == 0; | |||
assertEquals(on, array.get(x)); | assertEquals(on, array.get(x)); | |||
assertEquals(on, array2.get(x)); | assertEquals(on, array2.get(x)); | |||
assertEquals(on, array3.get(x)); | assertEquals(on, array3.get(x)); | |||
} | } | |||
} | } | |||
@Test | @Test | |||
public void testRotate90Simple() { | ||||
BitMatrix matrix = new BitMatrix(3, 3); | ||||
matrix.set(0, 0); | ||||
matrix.set(0, 1); | ||||
matrix.set(1, 2); | ||||
matrix.set(2, 1); | ||||
matrix.rotate90(); | ||||
assertTrue(matrix.get(0, 2)); | ||||
assertTrue(matrix.get(1, 2)); | ||||
assertTrue(matrix.get(2, 1)); | ||||
assertTrue(matrix.get(1, 0)); | ||||
} | ||||
@Test | ||||
public void testRotate180Simple() { | public void testRotate180Simple() { | |||
BitMatrix matrix = new BitMatrix(3, 3); | BitMatrix matrix = new BitMatrix(3, 3); | |||
matrix.set(0, 0); | matrix.set(0, 0); | |||
matrix.set(0, 1); | matrix.set(0, 1); | |||
matrix.set(1, 2); | matrix.set(1, 2); | |||
matrix.set(2, 1); | matrix.set(2, 1); | |||
matrix.rotate180(); | matrix.rotate180(); | |||
assertTrue(matrix.get(2, 2)); | assertTrue(matrix.get(2, 2)); | |||
skipping to change at line 214 | skipping to change at line 232 | |||
} catch (IllegalArgumentException ex) { | } catch (IllegalArgumentException ex) { | |||
// good | // good | |||
} | } | |||
assertEquals(emptyMatrix24, BitMatrix.parse(" \n \n \n \n", "x", " ")); | assertEquals(emptyMatrix24, BitMatrix.parse(" \n \n \n \n", "x", " ")); | |||
assertEquals(centerMatrix, BitMatrix.parse(centerMatrix.toString("x", "."), "x", ".")); | assertEquals(centerMatrix, BitMatrix.parse(centerMatrix.toString("x", "."), "x", ".")); | |||
} | } | |||
@Test | @Test | |||
public void testParseBoolean() { | ||||
BitMatrix emptyMatrix = new BitMatrix(3, 3); | ||||
BitMatrix fullMatrix = new BitMatrix(3, 3); | ||||
fullMatrix.setRegion(0, 0, 3, 3); | ||||
BitMatrix centerMatrix = new BitMatrix(3, 3); | ||||
centerMatrix.setRegion(1, 1, 1, 1); | ||||
BitMatrix emptyMatrix24 = new BitMatrix(2, 4); | ||||
boolean[][] matrix = new boolean[3][3]; | ||||
assertEquals(emptyMatrix, BitMatrix.parse(matrix)); | ||||
matrix[1][1] = true; | ||||
assertEquals(centerMatrix, BitMatrix.parse(matrix)); | ||||
for (boolean[] arr : matrix) { | ||||
Arrays.fill(arr, true); | ||||
} | ||||
assertEquals(fullMatrix, BitMatrix.parse(matrix)); | ||||
} | ||||
@Test | ||||
public void testUnset() { | public void testUnset() { | |||
BitMatrix emptyMatrix = new BitMatrix(3, 3); | BitMatrix emptyMatrix = new BitMatrix(3, 3); | |||
BitMatrix matrix = emptyMatrix.clone(); | BitMatrix matrix = emptyMatrix.clone(); | |||
matrix.set(1, 1); | matrix.set(1, 1); | |||
assertNotEquals(emptyMatrix, matrix); | assertNotEquals(emptyMatrix, matrix); | |||
matrix.unset(1, 1); | matrix.unset(1, 1); | |||
assertEquals(emptyMatrix, matrix); | assertEquals(emptyMatrix, matrix); | |||
matrix.unset(1, 1); | matrix.unset(1, 1); | |||
assertEquals(emptyMatrix, matrix); | assertEquals(emptyMatrix, matrix); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 37 lines changed or added |