At last update to JUnit 4.x

git-svn-id: https://zxing.googlecode.com/svn/trunk@1611 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-09-30 22:26:48 +00:00
parent c2d41376c3
commit 8f2ddd96e7
59 changed files with 550 additions and 406 deletions

View file

@ -111,7 +111,7 @@
<classpath>
<pathelement location="core.jar"/>
<pathelement location="../javase/javase.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="lib/junit-4.8.2.jar"/>
</classpath>
</javac>
</target>
@ -143,7 +143,7 @@
<pathelement location="core.jar"/>
<pathelement location="build-test"/>
<pathelement location="../javase/javase.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="lib/junit-4.8.2.jar"/>
</classpath>
<assertions>
<enable/>
@ -165,7 +165,7 @@
<pathelement location="core.jar"/>
<pathelement location="build-test"/>
<pathelement location="../javase/javase.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="lib/junit-4.8.2.jar"/>
</classpath>
<assertions>
<enable/>

BIN
core/lib/junit-4.8.2.jar Normal file

Binary file not shown.

View file

@ -1,260 +1,123 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>Common Public License - v 1.0</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Common Public License - v 1.0</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" VLINK="#800000">
<P ALIGN="CENTER"><B>Common Public License - v 1.0</B>
<P><B></B><FONT SIZE="3"></FONT>
<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
AGREEMENT.</FONT>
<P><FONT SIZE="3"></FONT><FONT SIZE="2">THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.</FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
<P><FONT SIZE="2"><B>1. DEFINITIONS</B></FONT>
<P><FONT SIZE="2">"Contribution" means:</FONT>
<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this
Agreement, and<BR CLEAR="LEFT">
b) in the case of each subsequent Contributor:</FONT></UL>
<UL><FONT SIZE="2">a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and<BR CLEAR="LEFT">
b) in the case of each subsequent Contributor:</FONT></UL>
<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
<UL><FONT SIZE="2">i) changes to the Program, and</FONT></UL>
<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
<UL><FONT SIZE="2">ii) additions to the Program;</FONT></UL>
<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that
particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the
Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions
do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with
the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
<UL><FONT SIZE="2">where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. </FONT><FONT SIZE="2">A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. </FONT><FONT SIZE="2">Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. </FONT></UL>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">"Contributor" means any person or entity that distributes the Program.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by
the use or sale of its Contribution alone or when combined with the Program. </FONT>
<P><FONT SIZE="2">"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. </FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this
Agreement.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">"Program" means the Contributions distributed in accordance with this Agreement.</FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all
Contributors.</FONT>
<P><FONT SIZE="2">"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.</FONT>
<P><FONT SIZE="2"><B></B></FONT>
<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
<P><FONT SIZE="2"><B>2. GRANT OF RIGHTS</B></FONT>
<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each
Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license
to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly
display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative
works, in source code and object code form.</FONT></UL>
<UL><FONT SIZE="2"></FONT><FONT SIZE="2">a) </FONT><FONT SIZE="2">Subject to the terms of this Agreement, each Contributor hereby grants</FONT><FONT SIZE="2"> Recipient a non-exclusive, worldwide, royalty-free copyright license to</FONT><FONT SIZE="2" COLOR="#FF0000"> </FONT><FONT SIZE="2">reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.</FONT></UL>
<UL><FONT SIZE="2"></FONT></UL>
<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby
grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT
SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise
transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall
apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the
Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The
patent license shall not apply to any other combinations which include the Contribution. No hardware per se is
licensed hereunder. </FONT></UL>
<UL><FONT SIZE="2"></FONT><FONT SIZE="2">b) Subject to the terms of this Agreement, each Contributor hereby grants </FONT><FONT SIZE="2">Recipient a non-exclusive, worldwide,</FONT><FONT SIZE="2" COLOR="#008000"> </FONT><FONT SIZE="2">royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. </FONT></UL>
<UL><FONT SIZE="2"></FONT></UL>
<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set
forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other
intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims
brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to
exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any
other intellectual property rights needed, if any. For example, if a third party patent license is required to allow
Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the
Program.</FONT></UL>
<UL><FONT SIZE="2">c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.</FONT></UL>
<UL><FONT SIZE="2"></FONT></UL>
<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its
Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
<UL><FONT SIZE="2">d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. </FONT></UL>
<UL><FONT SIZE="2"></FONT></UL>
<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
<P><FONT SIZE="2"><B>3. REQUIREMENTS</B></FONT>
<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:</FONT>
<P><FONT SIZE="2"><B></B>A Contributor may choose to distribute the Program in object code form under its own license
agreement, provided that:</FONT>
<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
<UL><FONT SIZE="2">a) it complies with the terms and conditions of this Agreement; and</FONT></UL>
<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
<UL><FONT SIZE="2">b) its license agreement:</FONT></UL>
<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and
conditions, express and implied, including warranties or conditions of title and non-infringement, and implied
warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
<UL><FONT SIZE="2">i) effectively disclaims</FONT><FONT SIZE="2"> on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; </FONT></UL>
<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct,
indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
<UL><FONT SIZE="2">ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; </FONT></UL>
<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by
that Contributor alone and not by any other party; and</FONT></UL>
<UL><FONT SIZE="2">iii)</FONT><FONT SIZE="2"> states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and</FONT></UL>
<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees
how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT
SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
<UL><FONT SIZE="2">iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.</FONT><FONT SIZE="2" COLOR="#0000FF"> </FONT><FONT SIZE="2" COLOR="#FF0000"></FONT></UL>
<UL><FONT SIZE="2" COLOR="#FF0000"></FONT><FONT SIZE="2"></FONT></UL>
<P><FONT SIZE="2">When the Program is made available in source code form:</FONT>
<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
<UL><FONT SIZE="2">a) it must be made available under this Agreement; and </FONT></UL>
<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
<UL><FONT SIZE="2">b) a copy of this Agreement must be included with each copy of the Program. </FONT></UL>
<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT>
<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any
copyright notices contained within the Program. </FONT>
<P><FONT SIZE="2" COLOR="#0000FF"><STRIKE></STRIKE></FONT><FONT SIZE="2">Contributors may not remove or alter any copyright notices contained within the Program. </FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that
reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
<P><FONT SIZE="2">Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. </FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users,
business partners and the like. While this license is intended to facilitate the commercial use of the Program, the
Contributor who includes the Program in a commercial product offering should do so in a manner which does not create
potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product
offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor
("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims,
lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by
the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a
commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any
actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a)
promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to
control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The
Indemnified Contributor may participate in any such claim at its own expense.</FONT>
<P><FONT SIZE="2"><B>4. COMMERCIAL DISTRIBUTION</B></FONT>
<P><FONT SIZE="2">Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.</FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That
Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers
warranties related to Product X, those performance claims and warranties are such Commercial Contributor's
responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other
Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay
any damages as a result, the Commercial Contributor must pay those damages.</FONT>
<P><FONT SIZE="2">For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2" COLOR="#0000FF"></FONT>
<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient
is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT
SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this
Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with
applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or
interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2" COLOR="#0000FF"></FONT><FONT SIZE="2"><B>5. NO WARRANTY</B></FONT>
<P><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is</FONT><FONT SIZE="2"> solely responsible for determining the appropriateness of using and distributing </FONT><FONT SIZE="2">the Program</FONT><FONT SIZE="2"> and assumes all risks associated with its exercise of rights under this Agreement</FONT><FONT SIZE="2">, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, </FONT><FONT SIZE="2">programs or equipment, and unavailability or interruption of operations</FONT><FONT SIZE="2">. </FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"><B>6. DISCLAIMER OF LIABILITY</B></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES </FONT><FONT SIZE="2">(INCLUDING WITHOUT LIMITATION LOST PROFITS),</FONT><FONT SIZE="2"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable
law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without
further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such
provision valid and enforceable.</FONT>
<P><FONT SIZE="2"><B>7. GENERAL</B></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.</FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to
software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor
to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if
Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit)
alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes
such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date
such litigation is filed. </FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. </FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the
material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after
becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to
cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under
this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT
SIZE="2"></FONT>
<P><FONT SIZE="2">All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. </FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in
order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The
Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this
Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify
this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement
Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a
distinguishing version number. The Program (including Contributions) may always be distributed subject to the version
of the Agreement under which it was received. In addition, after a new version of the Agreement is published,
Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT
SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the
intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by
implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not
expressly granted under this Agreement are reserved.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2">Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to </FONT><FONT SIZE="2">publish new versions (including revisions) of this Agreement from time to </FONT><FONT SIZE="2">time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. </FONT><FONT SIZE="2">Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new </FONT><FONT SIZE="2">version. </FONT><FONT SIZE="2">Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, </FONT><FONT SIZE="2">by implication, estoppel or otherwise</FONT><FONT SIZE="2">.</FONT><FONT SIZE="2"> All rights in the Program not expressly granted under this Agreement are reserved.</FONT>
<P><FONT SIZE="2"></FONT>
<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of
the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one
year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
<P><FONT SIZE="2">This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.</FONT>
<P><FONT SIZE="2"></FONT><FONT SIZE="2"></FONT>
<P><FONT SIZE="2"></FONT>
</BODY>

Binary file not shown.

View file

@ -128,11 +128,11 @@ public final class RSSExpandedReader extends AbstractRSSReader{
ExpandedPair nextPair = retrieveNextPair(row, this.pairs, rowNumber);
this.pairs.addElement(nextPair);
if(nextPair.mayBeLast()){
if(checkChecksum()) {
if (nextPair.mayBeLast()) {
if (checkChecksum()) {
return this.pairs;
}
if(nextPair.mustBeLast()) {
if (nextPair.mustBeLast()) {
throw NotFoundException.getNotFoundInstance();
}
}

View file

@ -162,8 +162,8 @@ public final class AllPositiveBlackBoxTester {
long now = System.currentTimeMillis();
AbstractBlackBoxTestCase.SummaryResults results = new AbstractBlackBoxTestCase.SummaryResults();
for (int x = 0; x < TESTS.length; x++) {
results.add(TESTS[x].testBlackBoxCountingResults(false));
for (AbstractBlackBoxTestCase test : TESTS) {
results.add(test.testBlackBoxCountingResults(false));
}
// This threaded version can't be used yet because BlackPointEstimator (and possibly other code)

View file

@ -18,7 +18,8 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
@ -27,8 +28,9 @@ import java.util.Arrays;
*
* @author Sean Owen
*/
public final class AddressBookParsedResultTestCase extends TestCase {
public final class AddressBookParsedResultTestCase extends Assert {
@Test
public void testAddressBookDocomo() {
doTest("MECARD:N:Sean Owen;;", null, new String[] {"Sean Owen"}, null, null, null, null, null, null, null, null);
doTest("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;;",
@ -36,22 +38,26 @@ public final class AddressBookParsedResultTestCase extends TestCase {
"google.com", null, "ZXing Team");
}
@Test
public void testAddressBookAU() {
doTest("MEMORY:foo\r\nNAME1:Sean\r\nTEL1:+12125551212\r\n",
null, new String[] {"Sean"}, null, null, null, new String[] {"+12125551212"}, null, null, null, "foo");
}
@Test
public void testVCard() {
doTest("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, null, null, null, null, null, null);
}
@Test
public void testBizcard() {
doTest("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12125551212;E:srowen@example.org;",
null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, new String[] {"srowen@example.org"},
new String[] {"+12125551212"}, "Google", null, null, null);
}
@Test
public void testSeveralAddresses() {
doTest("MECARD:N:Foo Bar;ORG:Company;TEL:5555555555;EMAIL:foo.bar@xyz.com;ADR:City, 10001;" +
"ADR:City, 10001;NOTE:This is the memo.;;",
@ -60,6 +66,7 @@ public final class AddressBookParsedResultTestCase extends TestCase {
new String[] {"5555555555" }, "Company", null, null, "This is the memo.");
}
@Test
public void testQuotedPrintable() {
doTest("BEGIN:VCARD\r\nADR;HOME;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;;" +
"=35=38=20=4C=79=6E=62=72=6F=6F=6B=0D=0A=43=\r\n" +

View file

@ -18,15 +18,17 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link CalendarParsedResult}.
*
* @author Sean Owen
*/
public final class CalendarParsedResultTestCase extends TestCase {
public final class CalendarParsedResultTestCase extends Assert {
@Test
public void testStartEnd() {
doTest(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
@ -36,6 +38,7 @@ public final class CalendarParsedResultTestCase extends TestCase {
null, null, null, "20080504T123456Z", "20080505T234555Z", null);
}
@Test
public void testStart() {
doTest(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
@ -44,6 +47,7 @@ public final class CalendarParsedResultTestCase extends TestCase {
null, null, null, "20080504T123456Z", "20080504T123456Z", null);
}
@Test
public void testSummary() {
doTest(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
@ -53,6 +57,7 @@ public final class CalendarParsedResultTestCase extends TestCase {
null, "foo", null, "20080504T123456Z", "20080504T123456Z", null);
}
@Test
public void testLocation() {
doTest(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
@ -62,6 +67,7 @@ public final class CalendarParsedResultTestCase extends TestCase {
null, null, "Miami", "20080504T123456Z", "20080504T123456Z", null);
}
@Test
public void testDescription() {
doTest(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +

View file

@ -18,20 +18,23 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link EmailAddressParsedResult}.
*
* @author Sean Owen
*/
public final class EmailAddressParsedResultTestCase extends TestCase {
public final class EmailAddressParsedResultTestCase extends Assert {
@Test
public void testEmailAddress() {
doTest("srowen@example.org", "srowen@example.org", null, null);
doTest("mailto:srowen@example.org", "srowen@example.org", null, null);
}
@Test
public void testEmailDocomo() {
doTest("MATMSG:TO:srowen@example.org;;", "srowen@example.org", null, null);
doTest("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org", "Stuff", null);
@ -39,6 +42,7 @@ public final class EmailAddressParsedResultTestCase extends TestCase {
"Stuff", "This is some text");
}
@Test
public void testSMTP() {
doTest("smtp:srowen@example.org", "srowen@example.org", null, null);
doTest("SMTP:srowen@example.org", "srowen@example.org", null, null);

View file

@ -28,17 +28,18 @@ package com.google.zxing.client.result;
import java.util.Hashtable;
import junit.framework.TestCase;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Antonio Manuel Benjumea Conde, Servinform, S.A.
* @author Agustín Delgado, Servinform, S.A.
*/
public final class ExpandedProductParsedResultTestCase extends TestCase {
public final class ExpandedProductParsedResultTestCase extends Assert {
@Test
public void test_RSSExpanded() {
String text = "(01)66546(13)001205(3932)4455(3102)6544(123)544654";
String productID = "66546";
@ -58,8 +59,7 @@ public final class ExpandedProductParsedResultTestCase extends TestCase {
uncommonAIs.put("123", "544654");
Result result = new Result(text, null, null, BarcodeFormat.RSS_EXPANDED);
ExpandedProductParsedResult o = ExpandedProductResultParser
.parse(result);
ExpandedProductParsedResult o = ExpandedProductResultParser.parse(result);
assertEquals(productID, o.getProductID());
assertEquals(sscc, o.getSscc());
assertEquals(lotNumber, o.getLotNumber());

View file

@ -18,15 +18,19 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link com.google.zxing.client.result.GeoParsedResult}.
*
* @author Sean Owen
*/
public final class GeoParsedResultTestCase extends TestCase {
public final class GeoParsedResultTestCase extends Assert {
private static final double EPSILON = 0.0000000001;
@Test
public void testGeo() {
doTest("geo:1,2", 1.0, 2.0, 0.0, null);
doTest("geo:80.33,-32.3344,3.35", 80.33, -32.3344, 3.35, null);
@ -43,9 +47,10 @@ public final class GeoParsedResultTestCase extends TestCase {
ParsedResult result = ResultParser.parseResult(fakeResult);
assertSame(ParsedResultType.GEO, result.getType());
GeoParsedResult geoResult = (GeoParsedResult) result;
assertEquals(latitude, geoResult.getLatitude());
assertEquals(longitude, geoResult.getLongitude());
assertEquals(altitude, geoResult.getAltitude());
assertEquals(latitude, geoResult.getLatitude(), EPSILON);
assertEquals(longitude, geoResult.getLongitude(), EPSILON);
assertEquals(altitude, geoResult.getAltitude(), EPSILON);
assertEquals(query, geoResult.getQuery());
}
}

View file

@ -18,15 +18,17 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link ISBNParsedResult}.
*
* @author Sean Owen
*/
public final class ISBNParsedResultTestCase extends TestCase {
public final class ISBNParsedResultTestCase extends Assert {
@Test
public void testISBN() {
doTest("9784567890123");
}

View file

@ -18,7 +18,8 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link ParsedResult}.
@ -26,8 +27,9 @@ import junit.framework.TestCase;
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class ParsedReaderResultTestCase extends TestCase {
public final class ParsedReaderResultTestCase extends Assert {
@Test
public void testTextType() {
doTestResult("", "", ParsedResultType.TEXT);
doTestResult("foo", "foo", ParsedResultType.TEXT);
@ -40,6 +42,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
ParsedResultType.TEXT);
}
@Test
public void testBookmarkType() {
doTestResult("MEBKM:URL:google.com;;", "http://google.com", ParsedResultType.URI);
doTestResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com",
@ -50,6 +53,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("MEBKM:URL:HTTPS://google.com;;", "https://google.com", ParsedResultType.URI);
}
@Test
public void testURLTOType() {
doTestResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI);
doTestResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI);
@ -57,6 +61,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("URLTO::http://bar.com", "http://bar.com", ParsedResultType.URI);
}
@Test
public void testEmailType() {
doTestResult("MATMSG:TO:srowen@example.org;;",
"srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
@ -70,6 +75,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
"TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedResultType.TEXT);
}
@Test
public void testEmailAddressType() {
doTestResult("srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
doTestResult("mailto:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS);
@ -79,6 +85,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("Let's meet @ 2", "Let's meet @ 2", ParsedResultType.TEXT);
}
@Test
public void testAddressBookType() {
doTestResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212",
@ -99,27 +106,32 @@ public final class ParsedReaderResultTestCase extends TestCase {
ParsedResultType.TEXT);
}
@Test
public void testAddressBookAUType() {
doTestResult("MEMORY:\r\n", "", ParsedResultType.ADDRESSBOOK);
doTestResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedResultType.ADDRESSBOOK);
doTestResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedResultType.ADDRESSBOOK);
}
@Test
public void testBizcard() {
doTestResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;",
"Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedResultType.ADDRESSBOOK);
}
@Test
public void testUPCA() {
doTestResult("123456789012", "123456789012", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("1234567890123", "1234567890123", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("12345678901", "12345678901", ParsedResultType.TEXT);
}
@Test
public void testUPCE() {
doTestResult("01234565", "01234565", ParsedResultType.PRODUCT, BarcodeFormat.UPC_E);
}
@Test
public void testEAN() {
doTestResult("00393157", "00393157", ParsedResultType.PRODUCT, BarcodeFormat.EAN_8);
doTestResult("00393158", "00393158", ParsedResultType.TEXT);
@ -127,6 +139,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("5051140178490", "5051140178490", ParsedResultType.TEXT);
}
@Test
public void testISBN() {
doTestResult("9784567890123", "9784567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13);
doTestResult("9794567890123", "9794567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13);
@ -134,26 +147,24 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("97945678901", "97945678901", ParsedResultType.TEXT);
}
@Test
public void testURI() {
doTestResult("http://google.com", "http://google.com", ParsedResultType.URI);
doTestResult("google.com", "http://google.com", ParsedResultType.URI);
doTestResult("https://google.com", "https://google.com", ParsedResultType.URI);
doTestResult("HTTP://google.com", "http://google.com", ParsedResultType.URI);
doTestResult("http://google.com/foobar", "http://google.com/foobar", ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar",
ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI);
doTestResult("google.com:443", "http://google.com:443", ParsedResultType.URI);
doTestResult("google.com:443/", "http://google.com:443/", ParsedResultType.URI);
doTestResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI);
doTestResult("http://google.com:443/foobar", "http://google.com:443/foobar",
ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar",
ParsedResultType.URI);
doTestResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI);
doTestResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedResultType.URI);
doTestResult("gopher://google.com/obsolete", "gopher://google.com/obsolete",
ParsedResultType.URI);
doTestResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedResultType.URI);
}
@Test
public void testGeo() {
doTestResult("geo:1,2", "1.0, 2.0", ParsedResultType.GEO);
doTestResult("GEO:1,2", "1.0, 2.0", ParsedResultType.GEO);
@ -163,6 +174,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("geography", "geography", ParsedResultType.TEXT);
}
@Test
public void testTel() {
doTestResult("tel:+15551212", "+15551212", ParsedResultType.TEL);
doTestResult("TEL:+15551212", "+15551212", ParsedResultType.TEL);
@ -173,6 +185,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("telephone", "telephone", ParsedResultType.TEXT);
}
@Test
public void testVCard() {
doTestResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
@ -184,6 +197,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("BEGIN:VCARD", "", ParsedResultType.ADDRESSBOOK);
}
@Test
public void testVEvent() {
// UTC times
doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
@ -218,6 +232,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("BEGIN:VEVENT", "begin:VEVENT", ParsedResultType.URI);
}
@Test
public void testSMS() {
doTestResult("sms:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("SMS:+15551212", "+15551212", ParsedResultType.SMS);
@ -226,6 +241,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
}
@Test
public void testSMSTO() {
doTestResult("SMSTO:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("smsto:+15551212", "+15551212", ParsedResultType.SMS);
@ -241,6 +257,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
ParsedResultType.SMS);
}
@Test
public void testMMS() {
doTestResult("mms:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("MMS:+15551212", "+15551212", ParsedResultType.SMS);
@ -249,6 +266,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
doTestResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS);
}
@Test
public void testMMSTO() {
doTestResult("MMSTO:+15551212", "+15551212", ParsedResultType.SMS);
doTestResult("mmsto:+15551212", "+15551212", ParsedResultType.SMS);
@ -262,6 +280,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
}
/*
@Test
public void testNDEFText() {
doTestResult(new byte[] {(byte)0xD1,(byte)0x01,(byte)0x05,(byte)0x54,
(byte)0x02,(byte)0x65,(byte)0x6E,(byte)0x68,
@ -269,6 +288,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
ParsedResultType.TEXT);
}
@Test
public void testNDEFURI() {
doTestResult(new byte[] {(byte)0xD1,(byte)0x01,(byte)0x08,(byte)0x55,
(byte)0x01,(byte)0x6E,(byte)0x66,(byte)0x63,
@ -276,6 +296,7 @@ public final class ParsedReaderResultTestCase extends TestCase {
ParsedResultType.URI);
}
@Test
public void testNDEFSmartPoster() {
doTestResult(new byte[] {(byte)0xD1,(byte)0x02,(byte)0x2F,(byte)0x53,
(byte)0x70,(byte)0x91,(byte)0x01,(byte)0x0E,

View file

@ -18,15 +18,17 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link ProductParsedResult}.
*
* @author Sean Owen
*/
public final class ProductParsedResultTestCase extends TestCase {
public final class ProductParsedResultTestCase extends Assert {
@Test
public void testProduct() {
doTest("123456789012", "123456789012", BarcodeFormat.UPC_A);
doTest("00393157", "00393157", BarcodeFormat.EAN_8);

View file

@ -18,7 +18,8 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
@ -27,14 +28,16 @@ import java.util.Arrays;
*
* @author Sean Owen
*/
public final class SMSMMSParsedResultTestCase extends TestCase {
public final class SMSMMSParsedResultTestCase extends Assert {
@Test
public void testSMS() {
doTest("sms:+15551212", "+15551212", null, null, null);
doTest("sms:+15551212?subject=foo&body=bar", "+15551212", "foo", "bar", null);
doTest("sms:+15551212;via=999333", "+15551212", null, null, "999333");
}
@Test
public void testMMS() {
doTest("mms:+15551212", "+15551212", null, null, null);
doTest("mms:+15551212?subject=foo&body=bar", "+15551212", "foo", "bar", null);

View file

@ -18,15 +18,17 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link TelParsedResult}.
*
* @author Sean Owen
*/
public final class TelParsedResultTestCase extends TestCase {
public final class TelParsedResultTestCase extends Assert {
@Test
public void testTel() {
doTest("tel:+15551212", "+15551212", null);
doTest("tel:2125551212", "2125551212", null);

View file

@ -18,21 +18,24 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link URIParsedResult}.
*
* @author Sean Owen
*/
public final class URIParsedResultTestCase extends TestCase {
public final class URIParsedResultTestCase extends Assert {
@Test
public void testBookmarkDocomo() {
doTest("MEBKM:URL:google.com;;", "http://google.com", null);
doTest("MEBKM:URL:http://google.com;;", "http://google.com", null);
doTest("MEBKM:URL:google.com;TITLE:Google;", "http://google.com", "Google");
}
@Test
public void testURI() {
doTest("google.com", "http://google.com", null);
doTest("http://google.com", "http://google.com", null);
@ -43,12 +46,14 @@ public final class URIParsedResultTestCase extends TestCase {
null);
}
@Test
public void testURLTO() {
doTest("urlto::bar.com", "http://bar.com", null);
doTest("urlto::http://bar.com", "http://bar.com", null);
doTest("urlto:foo:bar.com", "http://bar.com", "foo");
}
@Test
public void testGarbage() {
String text = "Da65cV1g^>%^f0bAbPn1CJB6lV7ZY8hs0Sm:DXU0cd]GyEeWBz8]bUHLB";
Result fakeResult = new Result(text, null, null, BarcodeFormat.QR_CODE);
@ -57,6 +62,7 @@ public final class URIParsedResultTestCase extends TestCase {
assertEquals(text, result.getDisplayResult());
}
@Test
public void testIsPossiblyMalicious() {
doTestIsPossiblyMalicious("http://google.com", false);
doTestIsPossiblyMalicious("http://google.com@evil.com", true);

View file

@ -18,21 +18,21 @@ package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import junit.framework.TestCase;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link WifiParsedResult}.
*
* @author Vikram Aggarwal
*/
public final class WifiParsedResultTestCase extends TestCase {
public final class WifiParsedResultTestCase extends Assert {
public void testNoPassword() {
doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", "", "");
doTest("WIFI:S:No Password;P:;T:;;", "No Password", "", "");
}
@Test
public void testWep() {
doTest("WIFI:S:TenChars;P:0123456789;T:WEP;;", "TenChars", "0123456789", "WEP");
doTest("WIFI:S:TenChars;P:abcde56789;T:WEP;;", "TenChars", "abcde56789", "WEP");
@ -47,7 +47,10 @@ public final class WifiParsedResultTestCase extends TestCase {
// TODO(vikrama) Need a test for SB as well.
}
// Put in checks for the length of the password for wep.
/**
* Put in checks for the length of the password for wep.
*/
@Test
public void testWpa() {
doTest("WIFI:S:TenChars;P:wow;T:WPA;;", "TenChars", "wow", "WPA");
doTest("WIFI:S:TenChars;P:space is silent;T:WPA;;", "TenChars", "space is silent", "WPA");
@ -59,8 +62,9 @@ public final class WifiParsedResultTestCase extends TestCase {
doTest("WIFI:S:TenChars;P:hello\\:there;T:WEP;;", "TenChars", "hello:there", "WEP");
}
// Given the string contents for the barcode, check that it matches
// our expectations
/**
* Given the string contents for the barcode, check that it matches our expectations
*/
private static void doTest(String contents,
String ssid,
String password,

View file

@ -25,7 +25,8 @@ import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.geom.AffineTransform;
@ -49,7 +50,7 @@ import java.util.Properties;
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
public abstract class AbstractBlackBoxTestCase extends TestCase {
public abstract class AbstractBlackBoxTestCase extends Assert {
protected static final Hashtable<DecodeHintType, Object> TRY_HARDER_HINT;
static {
@ -161,6 +162,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase {
// This workaround is used because AbstractNegativeBlackBoxTestCase overrides this method but does
// not return SummaryResults.
@Test
public void testBlackBox() throws IOException {
testBlackBoxCountingResults(true);
}

View file

@ -22,6 +22,7 @@ import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -69,6 +70,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
}
@Override
@Test
public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty());

View file

@ -16,13 +16,15 @@
package com.google.zxing.common;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class BitArrayTestCase extends TestCase {
public final class BitArrayTestCase extends Assert {
@Test
public void testGetSet() {
BitArray array = new BitArray(33);
for (int i = 0; i < 33; i++) {
@ -32,6 +34,7 @@ public final class BitArrayTestCase extends TestCase {
}
}
@Test
public void testSetBulk() {
BitArray array = new BitArray(64);
array.setBulk(32, 0xFFFF0000);
@ -43,6 +46,7 @@ public final class BitArrayTestCase extends TestCase {
}
}
@Test
public void testClear() {
BitArray array = new BitArray(32);
for (int i = 0; i < 32; i++) {
@ -54,6 +58,7 @@ public final class BitArrayTestCase extends TestCase {
}
}
@Test
public void testGetArray() {
BitArray array = new BitArray(64);
array.set(0);
@ -63,6 +68,7 @@ public final class BitArrayTestCase extends TestCase {
assertEquals(Integer.MIN_VALUE, ints[1]);
}
@Test
public void testIsRange() {
BitArray array = new BitArray(64);
assertTrue(array.isRange(0, 64, false));

View file

@ -16,14 +16,16 @@
package com.google.zxing.common;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class BitMatrixTestCase extends TestCase {
public final class BitMatrixTestCase extends Assert {
@Test
public void testGetSet() {
BitMatrix matrix = new BitMatrix(33);
assertEquals(33, matrix.getHeight());
@ -41,6 +43,7 @@ public final class BitMatrixTestCase extends TestCase {
}
}
@Test
public void testSetRegion() {
BitMatrix matrix = new BitMatrix(5);
matrix.setRegion(1, 1, 3, 3);
@ -51,6 +54,7 @@ public final class BitMatrixTestCase extends TestCase {
}
}
@Test
public void testRectangularMatrix() {
BitMatrix matrix = new BitMatrix(75, 20);
assertEquals(75, matrix.getWidth());
@ -77,6 +81,7 @@ public final class BitMatrixTestCase extends TestCase {
assertFalse(matrix.get(51, 3));
}
@Test
public void testRectangularSetRegion() {
BitMatrix matrix = new BitMatrix(320, 240);
assertEquals(320, matrix.getWidth());
@ -91,6 +96,7 @@ public final class BitMatrixTestCase extends TestCase {
}
}
@Test
public void testGetRow() {
BitMatrix matrix = new BitMatrix(102, 5);
for (int x = 0; x < 102; x++) {

View file

@ -16,13 +16,15 @@
package com.google.zxing.common;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class BitSourceTestCase extends TestCase {
public final class BitSourceTestCase extends Assert {
@Test
public void testSource() {
byte[] bytes = {(byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5};
BitSource source = new BitSource(bytes);

View file

@ -16,7 +16,8 @@
package com.google.zxing.common;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.Random;
import java.util.Vector;
@ -24,8 +25,9 @@ import java.util.Vector;
/**
* @author Sean Owen
*/
public final class CollectionsTestCase extends TestCase {
public final class CollectionsTestCase extends Assert {
@Test
public void testSort() {
Random r = new Random(0xDEADBEEFL);
Vector<Integer> v = new Vector<Integer>(100);

View file

@ -16,15 +16,17 @@
package com.google.zxing.common;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class PerspectiveTransformTestCase extends TestCase {
public final class PerspectiveTransformTestCase extends Assert {
private static final float EPSILON = 0.0001f;
@Test
public void testSquareToQuadrilateral() {
PerspectiveTransform pt = PerspectiveTransform.squareToQuadrilateral(
2.0f, 3.0f, 10.0f, 4.0f, 16.0f, 15.0f, 4.0f, 9.0f);
@ -36,6 +38,7 @@ public final class PerspectiveTransformTestCase extends TestCase {
assertPointEquals(48.0f, 42.42857f, 1.5f, 1.5f, pt);
}
@Test
public void testQuadrilateralToQuadrilateral() {
PerspectiveTransform pt = PerspectiveTransform.quadrilateralToQuadrilateral(
2.0f, 3.0f, 10.0f, 4.0f, 16.0f, 15.0f, 4.0f, 9.0f,
@ -48,7 +51,11 @@ public final class PerspectiveTransformTestCase extends TestCase {
assertPointEquals(328.09116f, 334.16385f, 50.0f, 50.0f, pt);
}
private static void assertPointEquals(float expectedX, float expectedY, float sourceX, float sourceY, PerspectiveTransform pt) {
private static void assertPointEquals(float expectedX,
float expectedY,
float sourceX,
float sourceY,
PerspectiveTransform pt) {
float[] points = {sourceX, sourceY};
pt.transformPoints(points);
assertEquals(expectedX, points[0], EPSILON);

View file

@ -16,7 +16,7 @@
package com.google.zxing.common.reedsolomon;
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.BitSet;
import java.util.Random;
@ -24,7 +24,7 @@ import java.util.Random;
/**
* @author Sean Owen
*/
abstract class AbstractReedSolomonTestCase extends TestCase {
abstract class AbstractReedSolomonTestCase extends Assert {
static void corrupt(int[] received, int howMany, Random random) {
BitSet corrupted = new BitSet(received.length);

View file

@ -16,6 +16,8 @@
package com.google.zxing.common.reedsolomon;
import org.junit.Test;
import java.util.Random;
/**
@ -31,6 +33,7 @@ public final class ReedSolomonDecoderDataMatrixTestCase extends AbstractReedSolo
private final ReedSolomonDecoder dmRSDecoder = new ReedSolomonDecoder(GF256.DATA_MATRIX_FIELD);
@Test
public void testNoError() throws ReedSolomonException {
int[] received = new int[DM_CODE_TEST_WITH_EC.length];
System.arraycopy(DM_CODE_TEST_WITH_EC, 0, received, 0, received.length);
@ -38,6 +41,7 @@ public final class ReedSolomonDecoderDataMatrixTestCase extends AbstractReedSolo
checkQRRSDecode(received);
}
@Test
public void testOneError() throws ReedSolomonException {
int[] received = new int[DM_CODE_TEST_WITH_EC.length];
Random random = getRandom();
@ -48,16 +52,18 @@ public final class ReedSolomonDecoderDataMatrixTestCase extends AbstractReedSolo
}
}
@Test
public void testMaxErrors() throws ReedSolomonException {
int[] received = new int[DM_CODE_TEST_WITH_EC.length];
Random random = getRandom();
for (int i = 0; i < DM_CODE_TEST.length; i++) { // # iterations is kind of arbitrary
for (int test : DM_CODE_TEST) { // # iterations is kind of arbitrary
System.arraycopy(DM_CODE_TEST_WITH_EC, 0, received, 0, received.length);
corrupt(received, DM_CODE_CORRECTABLE, random);
checkQRRSDecode(received);
}
}
@Test
public void testTooManyErrors() {
int[] received = new int[DM_CODE_TEST_WITH_EC.length];
System.arraycopy(DM_CODE_TEST_WITH_EC, 0, received, 0, received.length);

View file

@ -16,6 +16,8 @@
package com.google.zxing.common.reedsolomon;
import org.junit.Test;
import java.util.Random;
/**
@ -36,6 +38,7 @@ public final class ReedSolomonDecoderQRCodeTestCase extends AbstractReedSolomonT
private final ReedSolomonDecoder qrRSDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);
@Test
public void testNoError() throws ReedSolomonException {
int[] received = new int[QR_CODE_TEST_WITH_EC.length];
System.arraycopy(QR_CODE_TEST_WITH_EC, 0, received, 0, received.length);
@ -43,6 +46,7 @@ public final class ReedSolomonDecoderQRCodeTestCase extends AbstractReedSolomonT
checkQRRSDecode(received);
}
@Test
public void testOneError() throws ReedSolomonException {
int[] received = new int[QR_CODE_TEST_WITH_EC.length];
Random random = getRandom();
@ -53,16 +57,18 @@ public final class ReedSolomonDecoderQRCodeTestCase extends AbstractReedSolomonT
}
}
@Test
public void testMaxErrors() throws ReedSolomonException {
int[] received = new int[QR_CODE_TEST_WITH_EC.length];
Random random = getRandom();
for (int i = 0; i < QR_CODE_TEST.length; i++) { // # iterations is kind of arbitrary
for (int test : QR_CODE_TEST) { // # iterations is kind of arbitrary
System.arraycopy(QR_CODE_TEST_WITH_EC, 0, received, 0, received.length);
corrupt(received, QR_CODE_CORRECTABLE, random);
checkQRRSDecode(received);
}
}
@Test
public void testTooManyErrors() {
int[] received = new int[QR_CODE_TEST_WITH_EC.length];
System.arraycopy(QR_CODE_TEST_WITH_EC, 0, received, 0, received.length);

View file

@ -16,6 +16,8 @@
package com.google.zxing.common.reedsolomon;
import org.junit.Test;
import java.util.Random;
/**
@ -26,6 +28,7 @@ public final class ReedSolomonEncoderQRCodeTestCase extends AbstractReedSolomonT
/**
* Tests example given in ISO 18004, Annex I
*/
@Test
public void testISO18004Example() {
int[] dataBytes = {
0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11,
@ -36,6 +39,7 @@ public final class ReedSolomonEncoderQRCodeTestCase extends AbstractReedSolomonT
doTestQRCodeEncoding(dataBytes, expectedECBytes);
}
@Test
public void testQRCodeVersusDecoder() throws Exception {
Random random = getRandom();
ReedSolomonEncoder encoder = new ReedSolomonEncoder(GF256.QR_CODE_FIELD);

View file

@ -16,13 +16,15 @@
package com.google.zxing.datamatrix.decoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author bbrown@google.com (Brian Brown)
*/
public final class DecodedBitStreamParserTestCase extends TestCase{
public final class DecodedBitStreamParserTestCase extends Assert {
@Test
public void testAsciiStandardDecode() throws Exception {
// ASCII characters 0-127 are encoded as the value + 1
byte[] bytes = {(byte) ('a' + 1), (byte) ('b' + 1), (byte) ('c' + 1),
@ -30,7 +32,8 @@ public final class DecodedBitStreamParserTestCase extends TestCase{
String decodedString = DecodedBitStreamParser.decode(bytes).getText();
assertEquals("abcABC", decodedString);
}
@Test
public void testAsciiDoubleDigitDecode() throws Exception{
// ASCII double digit (00 - 99) Numeric Value + 130
byte[] bytes = {(byte) 130 , (byte) ( 1 + 130),

View file

@ -19,13 +19,15 @@ package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Ari Pollak
*/
public final class EAN13WriterTestCase extends TestCase {
public final class EAN13WriterTestCase extends Assert {
@Test
public void testEncode() throws WriterException {
String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0);

View file

@ -19,20 +19,20 @@ package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Ari Pollak
*/
public final class EAN8WriterTestCase extends TestCase {
public final class EAN8WriterTestCase extends Assert {
@Test
public void testEncode() throws WriterException {
String testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000";
BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i,
testStr.charAt(i) == '1',
result.get(i, 0));
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));
}
}

View file

@ -16,15 +16,17 @@
package com.google.zxing.oned;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link EANManufacturerOrgSupport}.
*
* @author Sean Owen
*/
public final class EANManufacturerOrgSupportTest extends TestCase {
public final class EANManufacturerOrgSupportTest extends Assert {
@Test
public void testLookup() {
EANManufacturerOrgSupport support = new EANManufacturerOrgSupport();
assertNull(support.lookupCountryIdentifier("472000"));

View file

@ -78,6 +78,7 @@ public final class BinaryUtil {
return buildBitArrayFromString(sb.toString());
}
/*
public static int extractNumericValueFromBitArray(BitArray information, int pos, int bits) {
if(bits > 32) {
throw new IllegalArgumentException("extractNumberValueFromBitArray can't handle more than 32 bits");
@ -92,4 +93,5 @@ public final class BinaryUtil {
numeric.reverse();
return numeric.bits[0];
}
*/
}

View file

@ -28,13 +28,15 @@ package com.google.zxing.oned.rss.expanded;
import com.google.zxing.common.BitArray;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
public final class BinaryUtilTest extends TestCase{
public final class BinaryUtilTest extends Assert {
@Test
public void testBuildBitArrayFromString(){
String data = " ..X..X.. ..XXX... XXXXXXXX ........";
@ -58,10 +60,9 @@ public final class BinaryUtilTest extends TestCase{
assertEquals(data, binary.toString());
}
@Test
public void testBuildBitArrayFromStringWithoutSpaces(){
String data;
data = " ..X..X.. ..XXX... XXXXXXXX ........";
String data = " ..X..X.. ..XXX... XXXXXXXX ........";
checkWithoutSpaces(data);
data = " XXX..X..";

View file

@ -31,15 +31,17 @@ import java.util.Vector;
import com.google.zxing.common.BitArray;
import com.google.zxing.oned.rss.DataCharacter;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class BitArrayBuilderTest extends TestCase {
public final class BitArrayBuilderTest extends Assert {
public void testBuildBitArray1(){
@Test
public void testBuildBitArray1() {
int [][] pairValues = {
{ 19 },
{ 673, 16 }
@ -50,13 +52,13 @@ public final class BitArrayBuilderTest extends TestCase {
checkBinary(pairValues, expected);
}
private void checkBinary(int[][] pairValues, String expected) {
private static void checkBinary(int[][] pairValues, String expected) {
BitArray binary = buildBitArray(pairValues);
assertEquals(expected, binary.toString());
}
private static BitArray buildBitArray(int[][] pairValues) {
Vector pairs = new Vector();
Vector<ExpandedPair> pairs = new Vector<ExpandedPair>();
for(int i = 0; i < pairValues.length; ++i){
int [] pair = pairValues[i];
@ -80,7 +82,6 @@ public final class BitArrayBuilderTest extends TestCase {
pairs.add(expandedPair);
}
BitArray binary = BitArrayBuilder.buildBitArray(pairs);
return binary;
return BitArrayBuilder.buildBitArray(pairs);
}
}

View file

@ -29,14 +29,16 @@ package com.google.zxing.oned.rss.expanded;
import com.google.zxing.common.BitArray;
import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class ExpandedInformationDecoderTest extends TestCase {
public final class ExpandedInformationDecoderTest extends Assert {
@Test
public void testNoAi() throws Exception {
BitArray information = BinaryUtil.buildBitArrayFromString(" .......X ..XX..X. X.X....X .......X ....");

View file

@ -33,21 +33,22 @@ import java.util.Vector;
import javax.imageio.ImageIO;
import junit.framework.TestCase;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.NotFoundException;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class RSSExpandedImage2binaryTestCase extends TestCase {
public final class RSSExpandedImage2binaryTestCase extends Assert {
public void testDecodeRow2binary_1() throws Exception{
@Test
public void testDecodeRow2binary_1() throws Exception {
// (11)100224(17)110224(3102)000100
String path = "test/data/blackbox/rssexpanded-1/1.jpg";
String expected = " ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X...";
@ -55,7 +56,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_2() throws Exception{
@Test
public void testDecodeRow2binary_2() throws Exception {
// (01)90012345678908(3103)001750
String path = "test/data/blackbox/rssexpanded-1/2.jpg";
String expected = " ..X..... ......X. .XXX.X.X .X...XX. XXXXX.XX XX.X.... .XX.XX.X .XX.";
@ -64,7 +66,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
}
public void testDecodeRow2binary_3() throws Exception{
@Test
public void testDecodeRow2binary_3() throws Exception {
// (10)12A
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
String expected = " .......X ..XX..X. X.X....X .......X ....";
@ -72,7 +75,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_4() throws Exception{
@Test
public void testDecodeRow2binary_4() throws Exception {
// (01)98898765432106(3202)012345(15)991231
String path = "test/data/blackbox/rssexpanded-1/4.jpg";
String expected = " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX";
@ -80,7 +84,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_5() throws Exception{
@Test
public void testDecodeRow2binary_5() throws Exception {
// (01)90614141000015(3202)000150
String path = "test/data/blackbox/rssexpanded-1/5.jpg";
String expected = " ..X.X... .XXXX.X. XX..XXXX ....XX.. X....... ....X... ....X..X .XX.";
@ -88,7 +93,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_10() throws Exception{
@Test
public void testDecodeRow2binary_10() throws Exception {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012
String path = "test/data/blackbox/rssexpanded-1/10.png";
String expected = " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X.";
@ -96,7 +102,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_11() throws Exception{
@Test
public void testDecodeRow2binary_11() throws Exception {
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456
String expected = " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ....";
String path = "test/data/blackbox/rssexpanded-1/11.png";
@ -104,7 +111,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_12() throws Exception{
@Test
public void testDecodeRow2binary_12() throws Exception {
// (01)98898765432106(3103)001750
String expected = " ..X..XX. XXXX..XX X.XX.XX. .X....XX XXX..XX. X..X.... .XX.XX.X .XX.";
@ -113,7 +121,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_13() throws Exception{
@Test
public void testDecodeRow2binary_13() throws Exception {
// (01)90012345678908(3922)795
String expected = " ..XX..X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.X.XXXX .X..X..X ......X.";
@ -122,7 +131,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_14() throws Exception{
@Test
public void testDecodeRow2binary_14() throws Exception {
// (01)90012345678908(3932)0401234
String expected = " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X...";
@ -131,7 +141,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_15() throws Exception{
@Test
public void testDecodeRow2binary_15() throws Exception {
// (01)90012345678908(3102)001750(11)100312
String expected = " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -140,7 +151,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_16() throws Exception{
@Test
public void testDecodeRow2binary_16() throws Exception {
// (01)90012345678908(3202)001750(11)100312
String expected = " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -149,7 +161,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_17() throws Exception{
@Test
public void testDecodeRow2binary_17() throws Exception {
// (01)90012345678908(3102)001750(13)100312
String expected = " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -158,7 +171,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_18() throws Exception{
@Test
public void testDecodeRow2binary_18() throws Exception {
// (01)90012345678908(3202)001750(13)100312
String expected = " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -167,7 +181,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_19() throws Exception{
@Test
public void testDecodeRow2binary_19() throws Exception {
// (01)90012345678908(3102)001750(15)100312
String expected = " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -176,7 +191,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_20() throws Exception{
@Test
public void testDecodeRow2binary_20() throws Exception {
// (01)90012345678908(3202)001750(15)100312
String expected = " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -185,7 +201,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_21() throws Exception{
@Test
public void testDecodeRow2binary_21() throws Exception {
// (01)90012345678908(3102)001750(17)100312
String expected = " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -194,7 +211,8 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
public void testDecodeRow2binary_22() throws Exception{
@Test
public void testDecodeRow2binary_22() throws Exception {
// (01)90012345678908(3202)001750(17)100312
String expected = " ..XXXXXX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..";
@ -203,8 +221,7 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
assertCorrectImage2binary(path, expected);
}
private static void assertCorrectImage2binary(String path,
String expected) throws IOException, NotFoundException {
private static void assertCorrectImage2binary(String path, String expected) throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
BufferedImage image = ImageIO.read(new File(path));
@ -212,7 +229,7 @@ public final class RSSExpandedImage2binaryTestCase extends TestCase {
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
Vector pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row);
Vector<ExpandedPair> pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row);
BitArray binary = BitArrayBuilder.buildBitArray(pairs);
assertEquals(expected, binary.toString());
}

View file

@ -33,12 +33,14 @@ package com.google.zxing.oned.rss.expanded;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.result.ExpandedProductParsedResult;
@ -47,23 +49,27 @@ import com.google.zxing.client.result.ResultParser;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class RSSExpandedImage2resultTestCase extends TestCase {
public final class RSSExpandedImage2resultTestCase extends Assert {
public void testDecodeRow2result_2() throws Exception{
@Test
public void testDecodeRow2result_2() throws Exception {
// (01)90012345678908(3103)001750
String path = "test/data/blackbox/rssexpanded-1/2.jpg";
ExpandedProductParsedResult expected = new ExpandedProductParsedResult("90012345678908", "-", "-", "-", "-", "-", "-", "001750", ExpandedProductParsedResult.KILOGRAM, "3", "-", "-", "-", new Hashtable());
ExpandedProductParsedResult expected =
new ExpandedProductParsedResult("90012345678908", "-", "-", "-", "-", "-", "-", "001750", ExpandedProductParsedResult.KILOGRAM, "3", "-", "-", "-", new Hashtable());
assertCorrectImage2result(path, expected);
}
private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected) throws Exception {
private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected)
throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
BufferedImage image = ImageIO.read(new File(path));
@ -73,7 +79,7 @@ public final class RSSExpandedImage2resultTestCase extends TestCase {
Result theResult = rssExpandedReader.decodeRow(rowNumber, row, new Hashtable());
assertEquals(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());
assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());
ParsedResult result = ResultParser.parseResult(theResult);

View file

@ -28,215 +28,244 @@ package com.google.zxing.oned.rss.expanded;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import javax.imageio.ImageIO;
import junit.framework.TestCase;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class RSSExpandedImage2stringTestCase extends TestCase {
public final class RSSExpandedImage2stringTestCase extends Assert {
public void testDecodeRow2string_1() throws Exception{
@Test
public void testDecodeRow2string_1() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/1.jpg";
String expected = "(11)100224(17)110224(3102)000100";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_2() throws Exception{
@Test
public void testDecodeRow2string_2() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/2.jpg";
String expected = "(01)90012345678908(3103)001750";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_3() throws Exception{
@Test
public void testDecodeRow2string_3() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
String expected = "(10)12A";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_4() throws Exception{
@Test
public void testDecodeRow2string_4() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/4.jpg";
String expected = "(01)98898765432106(3202)012345(15)991231";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_5() throws Exception{
@Test
public void testDecodeRow2string_5() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/5.jpg";
String expected = "(01)90614141000015(3202)000150";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_7() throws Exception{
@Test
public void testDecodeRow2string_7() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/7.png";
String expected = "(10)567(11)010101";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_10() throws Exception{
@Test
public void testDecodeRow2string_10() throws Exception {
String path = "test/data/blackbox/rssexpanded-1/10.png";
String expected = "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_11() throws Exception{
@Test
public void testDecodeRow2string_11() throws Exception {
String expected = "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456";
String path = "test/data/blackbox/rssexpanded-1/11.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_12() throws Exception{
@Test
public void testDecodeRow2string_12() throws Exception {
String expected = "(01)98898765432106(3103)001750";
String path = "test/data/blackbox/rssexpanded-1/12.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_13() throws Exception{
@Test
public void testDecodeRow2string_13() throws Exception {
String expected = "(01)90012345678908(3922)795";
String path = "test/data/blackbox/rssexpanded-1/13.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_14() throws Exception{
@Test
public void testDecodeRow2string_14() throws Exception {
String expected = "(01)90012345678908(3932)0401234";
String path = "test/data/blackbox/rssexpanded-1/14.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_15() throws Exception{
@Test
public void testDecodeRow2string_15() throws Exception {
String expected = "(01)90012345678908(3102)001750(11)100312";
String path = "test/data/blackbox/rssexpanded-1/15.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_16() throws Exception{
@Test
public void testDecodeRow2string_16() throws Exception {
String expected = "(01)90012345678908(3202)001750(11)100312";
String path = "test/data/blackbox/rssexpanded-1/16.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_17() throws Exception{
@Test
public void testDecodeRow2string_17() throws Exception {
String expected = "(01)90012345678908(3102)001750(13)100312";
String path = "test/data/blackbox/rssexpanded-1/17.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_18() throws Exception{
@Test
public void testDecodeRow2string_18() throws Exception {
String expected = "(01)90012345678908(3202)001750(13)100312";
String path = "test/data/blackbox/rssexpanded-1/18.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_19() throws Exception{
@Test
public void testDecodeRow2string_19() throws Exception {
String expected = "(01)90012345678908(3102)001750(15)100312";
String path = "test/data/blackbox/rssexpanded-1/19.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_20() throws Exception{
@Test
public void testDecodeRow2string_20() throws Exception {
String expected = "(01)90012345678908(3202)001750(15)100312";
String path = "test/data/blackbox/rssexpanded-1/20.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_21() throws Exception{
@Test
public void testDecodeRow2string_21() throws Exception {
String expected = "(01)90012345678908(3102)001750(17)100312";
String path = "test/data/blackbox/rssexpanded-1/21.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_22() throws Exception{
@Test
public void testDecodeRow2string_22() throws Exception {
String expected = "(01)90012345678908(3202)001750(17)100312";
String path = "test/data/blackbox/rssexpanded-1/22.jpg";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_25() throws Exception{
@Test
public void testDecodeRow2string_25() throws Exception {
String expected = "(10)123";
String path = "test/data/blackbox/rssexpanded-1/25.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_26() throws Exception{
@Test
public void testDecodeRow2string_26() throws Exception {
String expected = "(10)5678(11)010101";
String path = "test/data/blackbox/rssexpanded-1/26.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_27() throws Exception{
@Test
public void testDecodeRow2string_27() throws Exception {
String expected = "(10)1098-1234";
String path = "test/data/blackbox/rssexpanded-1/27.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_28() throws Exception{
@Test
public void testDecodeRow2string_28() throws Exception {
String expected = "(10)1098/1234";
String path = "test/data/blackbox/rssexpanded-1/28.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_29() throws Exception{
@Test
public void testDecodeRow2string_29() throws Exception {
String expected = "(10)1098.1234";
String path = "test/data/blackbox/rssexpanded-1/29.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_30() throws Exception{
@Test
public void testDecodeRow2string_30() throws Exception {
String expected = "(10)1098*1234";
String path = "test/data/blackbox/rssexpanded-1/30.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_31() throws Exception{
@Test
public void testDecodeRow2string_31() throws Exception {
String expected = "(10)1098,1234";
String path = "test/data/blackbox/rssexpanded-1/31.png";
assertCorrectImage2string(path, expected);
}
public void testDecodeRow2string_32() throws Exception{
@Test
public void testDecodeRow2string_32() throws Exception {
String expected = "(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012";
String path = "test/data/blackbox/rssexpanded-1/32.png";
assertCorrectImage2string(path, expected);
}
private static void assertCorrectImage2string(String path, String expected) throws Exception {
private static void assertCorrectImage2string(String path, String expected) throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
BufferedImage image = ImageIO.read(new File(path));
@ -246,7 +275,7 @@ public final class RSSExpandedImage2stringTestCase extends TestCase {
Result result = rssExpandedReader.decodeRow(rowNumber, row, new Hashtable());
assertEquals(BarcodeFormat.RSS_EXPANDED, result.getBarcodeFormat());
assertSame(BarcodeFormat.RSS_EXPANDED, result.getBarcodeFormat());
assertEquals(expected, result.getText());
}

View file

@ -40,15 +40,17 @@ import com.google.zxing.common.GlobalHistogramBinarizer;
import com.google.zxing.oned.rss.DataCharacter;
import com.google.zxing.oned.rss.FinderPattern;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public final class RSSExpandedInternalTestCase extends TestCase {
public final class RSSExpandedInternalTestCase extends Assert {
public void testFindFinderPatterns() throws Exception{
@Test
public void testFindFinderPatterns() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/2.jpg";
@ -82,7 +84,8 @@ public final class RSSExpandedInternalTestCase extends TestCase {
}
}
public void testRetrieveNextPairPatterns() throws Exception{
@Test
public void testRetrieveNextPairPatterns() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
@ -103,7 +106,8 @@ public final class RSSExpandedInternalTestCase extends TestCase {
assertTrue(pair2.mayBeLast());
}
public void testDecodeCheckCharacter() throws Exception{
@Test
public void testDecodeCheckCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.jpg";
@ -120,7 +124,8 @@ public final class RSSExpandedInternalTestCase extends TestCase {
assertEquals(98, dataCharacter.getValue());
}
public void testDecodeDataCharacter() throws Exception{
@Test
public void testDecodeDataCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.jpg";

View file

@ -27,6 +27,7 @@
package com.google.zxing.oned.rss.expanded.decoders;
import com.google.zxing.NotFoundException;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
@ -34,7 +35,8 @@ import com.google.zxing.NotFoundException;
public class AI01_3103_DecoderTest extends AbstractDecoderTest {
private static final String header = "..X..";
@Test
public void test01_3103_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
String expected = "(01)90012345678908(3103)001750";
@ -42,13 +44,15 @@ public class AI01_3103_DecoderTest extends AbstractDecoderTest {
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_3103_2() throws Exception {
String data = header + compressedGtin_900000000000008 + compressed15bitWeight_0;
String expected = "(01)90000000000003(3103)000000";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_3103_invalid() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + "..";

View file

@ -26,12 +26,16 @@
package com.google.zxing.oned.rss.expanded.decoders;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
public class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
private static final String header = "..X.X";
@Test
public void test01_3202_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
String expected = "(01)90012345678908(3202)001750";
@ -39,6 +43,7 @@ public class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_3203_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_11750;
String expected = "(01)90012345678908(3203)001750";

View file

@ -26,6 +26,8 @@
package com.google.zxing.oned.rss.expanded.decoders;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
@ -39,63 +41,72 @@ public class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
private static final String header_320x_15 = "..XXXX.X";
private static final String header_310x_17 = "..XXXXX.";
private static final String header_320x_17 = "..XXXXXX";
@Test
public void test01_310X_1X_endDate() throws Exception {
String data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_End;
String expected = "(01)90012345678908(3100)001750";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_310X_11_1() throws Exception {
String data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(11)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_320X_11_1() throws Exception {
String data = header_320x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(11)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_310X_13_1() throws Exception {
String data = header_310x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(13)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_320X_13_1() throws Exception {
String data = header_320x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(13)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_310X_15_1() throws Exception {
String data = header_310x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(15)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_320X_15_1() throws Exception {
String data = header_320x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(15)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_310X_17_1() throws Exception {
String data = header_310x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(17)100312";
assertCorrectBinaryString(data, expected);
}
@Test
public void test01_320X_17_1() throws Exception {
String data = header_320x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(17)100312";

View file

@ -30,12 +30,12 @@ import com.google.zxing.NotFoundException;
import com.google.zxing.common.BitArray;
import com.google.zxing.oned.rss.expanded.BinaryUtil;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
public abstract class AbstractDecoderTest extends TestCase {
public abstract class AbstractDecoderTest extends Assert {
protected static final String numeric_10 = "..X..XX";
protected static final String numeric_12 = "..X.X.X";

View file

@ -26,48 +26,56 @@
package com.google.zxing.oned.rss.expanded.decoders;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/
public class AnyAIDecoderTest extends AbstractDecoderTest {
private static final String header = ".....";
@Test
public void testAnyAIDecoder_1() throws Exception {
String data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2numeric + numeric_12;
String expected = "(10)12A12";
assertCorrectBinaryString(data, expected);
}
@Test
public void testAnyAIDecoder_2() throws Exception {
String data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2isoiec646 + i646_B;
String expected = "(10)12AB";
assertCorrectBinaryString(data, expected);
}
@Test
public void testAnyAIDecoder_3() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha2isoiec646 + i646_B + i646_C + isoiec646_2alpha + alpha_A + alpha2numeric + numeric_10;
String expected = "(10)BCA10";
assertCorrectBinaryString(data, expected);
}
@Test
public void testAnyAIDecoder_numericFNC1_secondDigit() throws Exception {
String data = header + numeric_10 + numeric_1FNC1;
String expected = "(10)1";
assertCorrectBinaryString(data, expected);
}
@Test
public void testAnyAIDecoder_alphaFNC1() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha_A + alpha_FNC1;
String expected = "(10)A";
assertCorrectBinaryString(data, expected);
}
@Test
public void testAnyAIDecoder_646FNC1() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha_A + isoiec646_2alpha + i646_B + i646_FNC1;
String expected = "(10)AB";

View file

@ -27,24 +27,27 @@
package com.google.zxing.oned.rss.expanded.decoders;
import com.google.zxing.NotFoundException;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
*/
public class FieldParserTest extends TestCase{
public class FieldParserTest extends Assert {
private static void checkFields(String expected) throws NotFoundException {
String field = expected.replace("(", "").replace(")","");
String actual = FieldParser.parseFieldsInGeneralPurpose(field);
assertEquals(expected, actual);
}
@Test
public void testParseField() throws Exception{
checkFields("(15)991231(3103)001750(10)12A");
}
@Test
public void testParseField2() throws Exception{
checkFields("(15)991231(15)991231(3103)001750(10)12A");
}

View file

@ -21,20 +21,20 @@ import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Hashtable;
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported and expanded from C++
*/
public final class QRCodeWriterTestCase extends TestCase {
public final class QRCodeWriterTestCase extends Assert {
private static final String BASE_IMAGE_PATH = "test/data/golden/qrcode/";
@ -74,6 +74,7 @@ public final class QRCodeWriterTestCase extends TestCase {
return matrix;
}
@Test
public void testQRCodeWriter() throws WriterException {
// The QR should be multiplied up to fit, with extra padding if necessary
int bigEnough = 256;
@ -123,7 +124,8 @@ public final class QRCodeWriterTestCase extends TestCase {
// Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls
// and cell phones. We expect pixel-perfect results, because the error correction level is known,
// and the pixel dimensions matches exactly.
// and the pixel dimensions matches exactly.
@Test
public void testRegressionTest() throws WriterException {
compareToGoldenFile("http://www.google.com/", ErrorCorrectionLevel.M, 99,
"renderer-test-01.png");

View file

@ -17,13 +17,15 @@
package com.google.zxing.qrcode.decoder;
import com.google.zxing.common.BitMatrix;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class DataMaskTestCase extends TestCase {
public final class DataMaskTestCase extends Assert {
@Test
public void testMask0() {
testMaskAcrossDimensions(0, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -32,6 +34,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask1() {
testMaskAcrossDimensions(1, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -40,6 +43,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask2() {
testMaskAcrossDimensions(2, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -48,6 +52,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask3() {
testMaskAcrossDimensions(3, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -56,6 +61,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask4() {
testMaskAcrossDimensions(4, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -64,6 +70,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask5() {
testMaskAcrossDimensions(5, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -72,6 +79,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask6() {
testMaskAcrossDimensions(6, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -80,6 +88,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
@Test
public void testMask7() {
testMaskAcrossDimensions(7, new MaskCondition() {
public boolean isMasked(int i, int j) {
@ -88,8 +97,7 @@ public final class DataMaskTestCase extends TestCase {
});
}
private void testMaskAcrossDimensions(int reference,
MaskCondition condition) {
private static void testMaskAcrossDimensions(int reference, MaskCondition condition) {
DataMask mask = DataMask.forReference(reference);
for (int version = 1; version <= 40; version++) {
int dimension = 17 + 4 * version;
@ -97,7 +105,7 @@ public final class DataMaskTestCase extends TestCase {
}
}
private void testMask(DataMask mask, int dimension, MaskCondition condition) {
private static void testMask(DataMask mask, int dimension, MaskCondition condition) {
BitMatrix bits = new BitMatrix(dimension);
mask.unmaskBitMatrix(bits, dimension);
for (int i = 0; i < dimension; i++) {

View file

@ -17,15 +17,17 @@
package com.google.zxing.qrcode.decoder;
import com.google.zxing.common.BitSourceBuilder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests {@link com.google.zxing.qrcode.decoder.DecodedBitStreamParser}.
*
* @author Sean Owen
*/
public final class DecodedBitStreamParserTestCase extends TestCase {
public final class DecodedBitStreamParserTestCase extends Assert {
@Test
public void testSimpleByteMode() throws Exception {
BitSourceBuilder builder = new BitSourceBuilder();
builder.write(0x04, 4); // Byte mode
@ -38,6 +40,7 @@ public final class DecodedBitStreamParserTestCase extends TestCase {
assertEquals("\u00f1\u00f2\u00f3", result);
}
@Test
public void testSimpleSJIS() throws Exception {
BitSourceBuilder builder = new BitSourceBuilder();
builder.write(0x04, 4); // Byte mode
@ -51,6 +54,7 @@ public final class DecodedBitStreamParserTestCase extends TestCase {
assertEquals("\uff61\uff62\uff63\uff90", result);
}
@Test
public void testECI() throws Exception {
BitSourceBuilder builder = new BitSourceBuilder();
builder.write(0x07, 4); // ECI mode

View file

@ -16,18 +16,20 @@
package com.google.zxing.qrcode.decoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class ErrorCorrectionLevelTestCase extends TestCase {
public final class ErrorCorrectionLevelTestCase extends Assert {
@Test
public void testForBits() {
assertEquals(ErrorCorrectionLevel.M, ErrorCorrectionLevel.forBits(0));
assertEquals(ErrorCorrectionLevel.L, ErrorCorrectionLevel.forBits(1));
assertEquals(ErrorCorrectionLevel.H, ErrorCorrectionLevel.forBits(2));
assertEquals(ErrorCorrectionLevel.Q, ErrorCorrectionLevel.forBits(3));
assertSame(ErrorCorrectionLevel.M, ErrorCorrectionLevel.forBits(0));
assertSame(ErrorCorrectionLevel.L, ErrorCorrectionLevel.forBits(1));
assertSame(ErrorCorrectionLevel.H, ErrorCorrectionLevel.forBits(2));
assertSame(ErrorCorrectionLevel.Q, ErrorCorrectionLevel.forBits(3));
try {
ErrorCorrectionLevel.forBits(4);
fail("Should have thrown an exception");

View file

@ -16,16 +16,18 @@
package com.google.zxing.qrcode.decoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class FormatInformationTestCase extends TestCase {
public final class FormatInformationTestCase extends Assert {
private static final int MASKED_TEST_FORMAT_INFO = 0x2BED;
private static final int UNMASKED_TEST_FORMAT_INFO = MASKED_TEST_FORMAT_INFO ^ 0x5412;
@Test
public void testBitsDiffering() {
assertEquals(0, FormatInformation.numBitsDiffering(1, 1));
assertEquals(1, FormatInformation.numBitsDiffering(0, 2));
@ -33,6 +35,7 @@ public final class FormatInformationTestCase extends TestCase {
assertEquals(32, FormatInformation.numBitsDiffering(-1, 0));
}
@Test
public void testDecode() {
// Normal case
FormatInformation expected =
@ -44,6 +47,7 @@ public final class FormatInformationTestCase extends TestCase {
FormatInformation.decodeFormatInformation(UNMASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO));
}
@Test
public void testDecodeWithBitDifference() {
FormatInformation expected =
FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO);
@ -58,6 +62,7 @@ public final class FormatInformationTestCase extends TestCase {
MASKED_TEST_FORMAT_INFO ^ 0x0F, MASKED_TEST_FORMAT_INFO ^ 0x0F));
}
@Test
public void testDecodeWithMisread() {
FormatInformation expected =
FormatInformation.decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO);

View file

@ -16,19 +16,21 @@
package com.google.zxing.qrcode.decoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class ModeTestCase extends TestCase {
public final class ModeTestCase extends Assert {
@Test
public void testForBits() {
assertEquals(Mode.TERMINATOR, Mode.forBits(0x00));
assertEquals(Mode.NUMERIC, Mode.forBits(0x01));
assertEquals(Mode.ALPHANUMERIC, Mode.forBits(0x02));
assertEquals(Mode.BYTE, Mode.forBits(0x04));
assertEquals(Mode.KANJI, Mode.forBits(0x08));
assertSame(Mode.TERMINATOR, Mode.forBits(0x00));
assertSame(Mode.NUMERIC, Mode.forBits(0x01));
assertSame(Mode.ALPHANUMERIC, Mode.forBits(0x02));
assertSame(Mode.BYTE, Mode.forBits(0x04));
assertSame(Mode.KANJI, Mode.forBits(0x08));
try {
Mode.forBits(0x10);
fail("Should have thrown an exception");
@ -37,6 +39,7 @@ public final class ModeTestCase extends TestCase {
}
}
@Test
public void testCharacterCount() {
// Spot check a few values
assertEquals(10, Mode.NUMERIC.getCharacterCountBits(Version.getVersionForNumber(5)));

View file

@ -16,13 +16,15 @@
package com.google.zxing.qrcode.decoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Sean Owen
*/
public final class VersionTestCase extends TestCase {
public final class VersionTestCase extends Assert {
@Test
public void testVersionForNumber() {
try {
Version.getVersionForNumber(0);
@ -50,12 +52,14 @@ public final class VersionTestCase extends TestCase {
assertNotNull(version.buildFunctionPattern());
}
@Test
public void testGetProvisionalVersionForDimension() throws Exception {
for (int i = 1; i <= 40; i++) {
assertEquals(i, Version.getProvisionalVersionForDimension(4*i + 17).getVersionNumber());
}
}
@Test
public void testDecodeVersionInformation() {
// Spot check
assertEquals(7, Version.decodeVersionInformation(0x07C94).getVersionNumber());

View file

@ -17,13 +17,14 @@
package com.google.zxing.qrcode.encoder;
import com.google.zxing.common.BitArray;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
*/
public class BitVectorTestCase extends TestCase {
public class BitVectorTestCase extends Assert {
private static long getUnsignedInt(BitArray v, int index) {
long result = 0L;
@ -35,6 +36,7 @@ public class BitVectorTestCase extends TestCase {
return result;
}
@Test
public void testAppendBit() {
BitArray v = new BitArray();
assertEquals(0, v.getSizeInBytes());
@ -80,6 +82,7 @@ public class BitVectorTestCase extends TestCase {
assertEquals(0xaa800000L, getUnsignedInt(v, 0));
}
@Test
public void testAppendBits() {
{
BitArray v = new BitArray();
@ -101,6 +104,7 @@ public class BitVectorTestCase extends TestCase {
}
}
@Test
public void testNumBytes() {
BitArray v = new BitArray();
assertEquals(0, v.getSizeInBytes());
@ -116,6 +120,7 @@ public class BitVectorTestCase extends TestCase {
assertEquals(3, v.getSizeInBytes());
}
@Test
public void testAppendBitVector() {
BitArray v1 = new BitArray();
v1.appendBits(0xbe, 8);
@ -126,6 +131,7 @@ public class BitVectorTestCase extends TestCase {
assertEquals(" X.XXXXX. XXX.XXXX", v1.toString());
}
@Test
public void testXOR() {
{
BitArray v1 = new BitArray();
@ -145,6 +151,7 @@ public class BitVectorTestCase extends TestCase {
}
}
@Test
public void testAt() {
BitArray v = new BitArray();
v.appendBits(0xdead, 16); // 1101 1110 1010 1101
@ -169,6 +176,7 @@ public class BitVectorTestCase extends TestCase {
assertTrue(v.get(15));
}
@Test
public void testToString() {
BitArray v = new BitArray();
v.appendBits(0xdead, 16); // 1101 1110 1010 1101

View file

@ -20,7 +20,8 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitArray;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Mode;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
@ -28,8 +29,9 @@ import java.io.UnsupportedEncodingException;
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author mysen@google.com (Chris Mysen) - ported from C++
*/
public final class EncoderTestCase extends TestCase {
public final class EncoderTestCase extends Assert {
@Test
public void testGetAlphanumericCode() {
// The first ten code points are numbers.
for (int i = 0; i < 10; ++i) {
@ -58,6 +60,7 @@ public final class EncoderTestCase extends TestCase {
assertEquals(-1, Encoder.getAlphanumericCode('\0'));
}
@Test
public void testChooseMode() throws WriterException {
// Numeric mode.
assertSame(Mode.NUMERIC, Encoder.chooseMode("0"));
@ -85,6 +88,7 @@ public final class EncoderTestCase extends TestCase {
assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(new byte[]{0xe, 0x4, 0x9, 0x5, 0x9, 0x61})));
}
@Test
public void testEncode() throws WriterException {
QRCode qrCode = new QRCode();
Encoder.encode("ABCDEF", ErrorCorrectionLevel.H, qrCode);
@ -126,12 +130,14 @@ public final class EncoderTestCase extends TestCase {
assertEquals(expected, qrCode.toString());
}
@Test
public void testAppendModeInfo() {
BitArray bits = new BitArray();
Encoder.appendModeInfo(Mode.NUMERIC, bits);
assertEquals(" ...X", bits.toString());
}
@Test
public void testAppendLengthInfo() throws WriterException {
{
BitArray bits = new BitArray();
@ -167,6 +173,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testAppendBytes() throws WriterException {
{
// Should use appendNumericBytes.
@ -206,6 +213,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testTerminateBits() throws WriterException {
{
BitArray v = new BitArray();
@ -248,6 +256,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testGetNumDataBytesAndNumECBytesForBlockID() throws WriterException {
int[] numDataBytes = new int[1];
int[] numEcBytes = new int[1];
@ -284,6 +293,7 @@ public final class EncoderTestCase extends TestCase {
assertEquals(30, numEcBytes[0]);
}
@Test
public void testInterleaveWithECBytes() throws WriterException {
{
byte[] dataBytes = {32, 65, (byte)205, 69, 41, (byte)220, 46, (byte)128, (byte)236};
@ -350,6 +360,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testAppendNumericBytes() {
{
// 1 = 01 = 0001 in 4 bits.
@ -383,6 +394,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testAppendAlphanumericBytes() throws WriterException {
{
// A = 10 = 0xa = 001010 in 6 bits
@ -419,6 +431,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testAppend8BitBytes() throws WriterException {
{
// 0x61, 0x62, 0x63
@ -435,6 +448,7 @@ public final class EncoderTestCase extends TestCase {
}
// Numbers are from page 21 of JISX0510:2004
@Test
public void testAppendKanjiBytes() throws WriterException {
BitArray bits = new BitArray();
Encoder.appendKanjiBytes(shiftJISString(new byte[] {(byte)0x93,0x5f}), bits);
@ -445,6 +459,7 @@ public final class EncoderTestCase extends TestCase {
// Numbers are from http://www.swetake.com/qr/qr3.html and
// http://www.swetake.com/qr/qr9.html
@Test
public void testGenerateECBytes() {
{
byte[] dataBytes = {32, 65, (byte)205, 69, 41, (byte)220, 46, (byte)128, (byte)236};
@ -483,6 +498,7 @@ public final class EncoderTestCase extends TestCase {
}
}
@Test
public void testBugInBitVectorNumBytes() throws WriterException {
// There was a bug in BitVector.sizeInBytes() that caused it to return a
// smaller-by-one value (ex. 1465 instead of 1466) if the number of bits

View file

@ -16,14 +16,17 @@
package com.google.zxing.qrcode.encoder;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author mysen@google.com (Chris Mysen) - ported from C++
*/
public final class MaskUtilTestCase extends TestCase {
public final class MaskUtilTestCase extends Assert {
@Test
public void testApplyMaskPenaltyRule1() {
{
ByteMatrix matrix = new ByteMatrix(4, 1);
@ -59,6 +62,7 @@ public final class MaskUtilTestCase extends TestCase {
}
}
@Test
public void testApplyMaskPenaltyRule2() {
{
ByteMatrix matrix = new ByteMatrix(1, 1);
@ -97,6 +101,7 @@ public final class MaskUtilTestCase extends TestCase {
}
}
@Test
public void testApplyMaskPenaltyRule3() {
{
// Horizontal 00001011101.
@ -164,6 +169,7 @@ public final class MaskUtilTestCase extends TestCase {
}
}
@Test
public void testApplyMaskPenaltyRule4() {
{
// Dark cell ratio = 0%
@ -205,6 +211,7 @@ public final class MaskUtilTestCase extends TestCase {
}
// See mask patterns on the page 43 of JISX0510:2004.
@Test
public void testGetDataMaskBit() {
int[][] mask0 = {
{1, 0, 1, 0, 1, 0},

View file

@ -19,13 +19,14 @@ package com.google.zxing.qrcode.encoder;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitArray;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author mysen@google.com (Chris Mysen) - ported from C++
*/
public final class MatrixUtilTestCase extends TestCase {
public final class MatrixUtilTestCase extends Assert {
public void testtoString() {
ByteMatrix array = new ByteMatrix(3, 3);
array.set(0, 0, 0);
@ -41,6 +42,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(expected, array.toString());
}
@Test
public void testClearMatrix() {
ByteMatrix matrix = new ByteMatrix(2, 2);
MatrixUtil.clearMatrix(matrix);
@ -50,6 +52,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(-1, matrix.get(1, 1));
}
@Test
public void testEmbedBasicPatterns() throws WriterException {
{
// Version 1.
@ -116,6 +119,7 @@ public final class MatrixUtilTestCase extends TestCase {
}
}
@Test
public void testEmbedTypeInfo() throws WriterException {
// Type info bits = 100000011001110.
String expected =
@ -146,6 +150,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(expected, matrix.toString());
}
@Test
public void testEmbedVersionInfo() throws WriterException {
// Version info bits = 000111 110010 010100
String expected =
@ -178,6 +183,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(expected, matrix.toString());
}
@Test
public void testEmbedDataBits() throws WriterException {
// Cells other than basic patterns should be filled with zero.
String expected =
@ -210,6 +216,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(expected, matrix.toString());
}
@Test
public void testBuildMatrix() throws WriterException {
// From http://www.swetake.com/qr/qr7.html
String expected =
@ -249,6 +256,7 @@ public final class MatrixUtilTestCase extends TestCase {
matrix);
}
@Test
public void testFindMSBSet() {
assertEquals(0, MatrixUtil.findMSBSet(0));
assertEquals(1, MatrixUtil.findMSBSet(1));
@ -256,6 +264,7 @@ public final class MatrixUtilTestCase extends TestCase {
assertEquals(32, MatrixUtil.findMSBSet(0x80000000));
}
@Test
public void testCalculateBCHCode() {
// Encoding of type information.
// From Appendix C in JISX0510:2004 (p 65)
@ -278,6 +287,7 @@ public final class MatrixUtilTestCase extends TestCase {
// We don't test a lot of cases in this function since we've already
// tested them in TEST(calculateBCHCode).
@Test
public void testMakeVersionInfoBits() throws WriterException {
// From Appendix D in JISX0510:2004 (p 68)
BitArray bits = new BitArray();
@ -287,6 +297,7 @@ public final class MatrixUtilTestCase extends TestCase {
// We don't test a lot of cases in this function since we've already
// tested them in TEST(calculateBCHCode).
@Test
public void testMakeTypeInfoInfoBits() throws WriterException {
// From Appendix C in JISX0510:2004 (p 65)
BitArray bits = new BitArray();

View file

@ -18,13 +18,16 @@ package com.google.zxing.qrcode.encoder;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Mode;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author mysen@google.com (Chris Mysen) - ported from C++
*/
public final class QRCodeTestCase extends TestCase {
public final class QRCodeTestCase extends Assert {
@Test
public void test() {
QRCode qrCode = new QRCode();
// Initially the QR Code should be invalid.
@ -42,8 +45,8 @@ public final class QRCodeTestCase extends TestCase {
qrCode.setNumECBytes(130);
qrCode.setNumRSBlocks(5);
assertEquals(Mode.BYTE, qrCode.getMode());
assertEquals(ErrorCorrectionLevel.H, qrCode.getECLevel());
assertSame(Mode.BYTE, qrCode.getMode());
assertSame(ErrorCorrectionLevel.H, qrCode.getECLevel());
assertEquals(7, qrCode.getVersion());
assertEquals(45, qrCode.getMatrixWidth());
assertEquals(3, qrCode.getMaskPattern());
@ -79,6 +82,7 @@ public final class QRCodeTestCase extends TestCase {
}
}
@Test
public void testToString() {
{
QRCode qrCode = new QRCode();
@ -154,6 +158,7 @@ public final class QRCodeTestCase extends TestCase {
}
}
@Test
public void testIsValidMaskPattern() {
assertFalse(QRCode.isValidMaskPattern(-1));
assertTrue(QRCode.isValidMaskPattern(0));