forked from oskopek/javaanpr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue oskopek#1: added unit tests for recognized plate.
- Loading branch information
1 parent
b80b810
commit 75e9eb0
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/test/java/net/sf/javaanpr/intelligence/RecognizedPlateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2013 JavaANPR contributors | ||
* Copyright 2006 Ondrej Martinsky | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.osedu.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" | ||
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package net.sf.javaanpr.intelligence; | ||
|
||
import net.sf.javaanpr.recognizer.RecognizedChar; | ||
import net.sf.javaanpr.recognizer.RecognizedPattern; | ||
import org.junit.Test; | ||
|
||
import java.util.Vector; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class RecognizedPlateTest { | ||
|
||
private RecognizedPlate getRecognizedPlateWithThreeRecognizedChars() { | ||
RecognizedPlate recognizedPlate = new RecognizedPlate(); | ||
RecognizedChar recognizedChar1 = new RecognizedChar(); | ||
recognizedChar1.addPattern(new RecognizedPattern('A', 1.0f)); | ||
recognizedChar1.sort(false); | ||
RecognizedChar recognizedChar2 = new RecognizedChar(); | ||
recognizedChar2.addPattern(new RecognizedPattern('B', 2.0f)); | ||
recognizedChar2.addPattern(new RecognizedPattern('C', 3.0f)); | ||
recognizedChar2.sort(false); | ||
RecognizedChar recognizedChar3 = new RecognizedChar(); | ||
recognizedChar3.addPattern(new RecognizedPattern('D', 4.0f)); | ||
recognizedChar3.sort(false); | ||
recognizedPlate.addChar(recognizedChar1); | ||
recognizedPlate.addChar(recognizedChar2); | ||
recognizedPlate.addChar(recognizedChar3); | ||
return recognizedPlate; | ||
} | ||
|
||
@Test | ||
public void testCanAddAndGetChars() { | ||
RecognizedPlate recognizedPlate = getRecognizedPlateWithThreeRecognizedChars(); | ||
assertThat(recognizedPlate.getChar(0).getPattern(0).getChar(), is('A')); | ||
assertThat(recognizedPlate.getChar(1).getPattern(0).getChar(), is('B')); | ||
assertThat(recognizedPlate.getChar(1).getPattern(1).getChar(), is('C')); | ||
assertThat(recognizedPlate.getChar(2).getPattern(0).getChar(), is('D')); | ||
} | ||
|
||
@Test | ||
public void testCanAddAndGetAllChars() { | ||
RecognizedPlate recognizedPlate = getRecognizedPlateWithThreeRecognizedChars(); | ||
Vector<RecognizedChar> recognizedChars = recognizedPlate.getChars(); | ||
assertThat(recognizedChars.get(0).getPattern(0).getChar(), is('A')); | ||
assertThat(recognizedChars.get(1).getPattern(0).getChar(), is('B')); | ||
assertThat(recognizedChars.get(1).getPattern(1).getChar(), is('C')); | ||
assertThat(recognizedChars.get(2).getPattern(0).getChar(), is('D')); | ||
} | ||
|
||
@Test | ||
public void testCanGetStringFromChars() { | ||
RecognizedPlate recognizedPlate = getRecognizedPlateWithThreeRecognizedChars(); | ||
assertThat(recognizedPlate.getString(), is("ABD")); | ||
} | ||
} |