pax_global_header00006660000000000000000000000064124302056320014507gustar00rootroot0000000000000052 comment=f58d3821531dfafd5f51d56f01a13b7b376b4845 fest-assert-2.0M10/000077500000000000000000000000001243020563200140665ustar00rootroot00000000000000fest-assert-2.0M10/.gitignore000066400000000000000000000002651243020563200160610ustar00rootroot00000000000000#Maven build result directory /target #IntelliJ project files /.idea /*.iml #Eclipse project files /.settings /.classpath /.project #Other /clover.license /actual.txt /expected.txt fest-assert-2.0M10/LICENSE.txt000066400000000000000000000261361243020563200157210ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) 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. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. fest-assert-2.0M10/README.md000066400000000000000000000025201243020563200153440ustar00rootroot00000000000000FEST-Assert provides a fluent interface for assertions. Example: ``` int removed = employees.removeFired(); assertThat(removed).isZero(); List newEmployees = employees.hired(TODAY); assertThat(newEmployees).hasSize(6) .contains(frodo, sam); assertThat(yoda).isInstanceOf(Jedi.class) .isEqualTo(foundJedi) .isNotEqualTo(foundSith); ``` The 2.x branch is an attempt to learn from mistakes made in the the 1.x release, in terms of readability and extensibility. FEST's assertions are incredibly easy to write: just type **```assertThat```** followed the actual value and a dot, and any Java IDE will show you all the assertions available for the type of the object to verify. No more confusion about the order of the "expected" and "actual" values. Our assertions are very readable as well: they read very close to plain English, making it easier for non-technical people to read test code. For more details please visit : * **[FEST-Assert's wiki](https://github.com/alexruiz/fest-assert-2.x/wiki)** for the most up to date documentation. Many thanks to Cloudbees for their FOSS program that allows FEST to have a **[Jenkins CI server](https://fest.ci.cloudbees.com/#)**! ![cloudbees](/alexruiz/fest-assert-2.x/raw/master/src/site/resources/images/built-on-Dev@Cloud-Cloudbees.png) fest-assert-2.0M10/pom.xml000066400000000000000000000040571243020563200154110ustar00rootroot00000000000000 4.0.0 fest-assert-core 2.0M10 FEST Fluent Assertions (Core) 'Flexible' or 'fluent' assertions for testing 2007 http://fest.easytesting.org/assert org.easytesting fest 1.0.15 Easy Testing Group http://groups.google.com/group/easytesting http://groups.google.com/group/easytesting http://groups.google.com/group/easytesting scm:git:git@github.com:alexruiz/fest-assert-2.x.git scm:git:git://github.com/alexruiz/fest-assert-2.x.git https://github.com/alexruiz/fest-assert-2.x github https://github.com/alexruiz/fest-assert-2.x/issues org.easytesting fest-util 1.2.5 compile org.easytesting fest-test 2.1.0 test org.mockito mockito-all 1.9.0 test junit junit test fest-assert-2.0M10/release-notes.txt000066400000000000000000000152171243020563200174030ustar00rootroot00000000000000For the next release -------------------- next version release notes (WIP) ------------------- 2.0M9 release notes ------------------- bugfix release, fix incompatibility with fest-reflect, you can use 2.0M9 along with fest-reflect 1.4.1 both depending on fest-util 1.2.4 github #138 : containsExactly() throws ArrayIndexOutOfBoundsException github #131 : ObjectArrayAssert.containsExactly() works wrong 2.0M8 release notes ------------------- Breaking changes : Remove dependency on AWT : AWT assertions moved to a new module Use java 6 instead of java 5 New features : github#79 : String assertions are available on (small) file by calling contentOf(File) method (Olivier Michallat) github#73 : new assertion ListAssert.has(Condition, Index) (Bo Gotthardt) github#97 : new assertion ListAssert.is(Condition, Index) (Bo Gotthardt) github#50 : new assertion StringAssert.containsOnlyOnce (Pauline Iogna) Improvement : github#87 : Fail.failBecauseExpectedExceptionWasNotThrown now takes a Throwable instead of an Exception github#86 : tests : org.fest.assertions.internal contain too much classes github#82 : tests : org.fest.assertions.api contain too much classes (Olivier Michallat) github#91 : tests : move fail tests in a "fail" subpackage github#106 : provide better extensibility by exposing assertion WritableAssertionInfo github#74 : ObjectAssert lenient equals assertions now takes inherited fields into account Bug : github#92 : Fix BinaryDiff_diff_File_byteArray_Test test that was failing on windows github#104 : containsExactly does not work with SortedSet Refactoring Move creation of ArrayLists into a Lists class Move creation of Sets to Sets class Move Iterable-related methods out of the Collections Iterables : Rename 'isEmpty' to 'isNullOrEmpty' Move back factory of primitive arrays from fest-util back to fest-assert 2.0M7 release notes ------------------- New features : github#43 : New File assertion : hasContent(String content) and hasBinaryContent(byte[] expected) (Olivier Michallat) github#48 : Add hasTime assertion to DateAssert (Nicolas Francois and Guillaume Girou) github#71 : New File assertions : canRead(), canWrite() (Olivier Demeijer) Improvement : github#12 : overridingErrorMessage should be ported in 2.0 github#54 : ObjectArrayAssert methods should use T parameter instead of Object github#70 : Properties.from should use Iterable (Florent Biville) github#73 : Maven build should assure that we build a java 5 compatible version github#58 : Properties: add ofType() method to improve API fluency Bug : github#75 : ShouldHaveEqualContent unexpected MissingFormatArgumentException. github#85 : ShouldHaveTime_create_Test test fails because of time zone dependency. 2.0M6 release notes ------------------- New features : github#29 : MapAssert should have containsKey(), containsValue() and counterparts (Nicolas Francois) github#31 : Move isInstanceOf and friends to AbstractAssert (Nicolas Francois) github#32 : add class related assertions : hasSameClassAs, doesNotHaveSameClassAs, isExactlyInstanceOf, isOfAnyClassIn and counterparts (Nicolas Francois) github#35 : Port containsExactly to Fest 2.0 (was in Fest 1.x) (Nicolas Francois) github#42 : Move hasSameSize to EnumerableAssert to make it available in *ArrayAssert (Nicolas Francois) Improvement : github#52 : Remove final on methods to provide better extensibility (FEST-475) github#56 : Date assert error message improvement Bug : Fix some error compilation only occuring with oracle jdk 1.7.0_05, error being having two static import with same name. github#56 : containsOnly does not handle null elements 2.0M5 release notes ------------------- New features : - github#34 : Add generic type to MapAssert (Nicolas Francois) - github#22 : add base assertion isEqualsToByComparingFields (Nicolas Francois) - github#23 : Filters now support null value (Joel Costigliola) - FEST-358 : New numbers assertions : isNotPositive / isNotNegative (Nicolas Francois) - FEST-476 : Improve error message when comparing numbers with offset (Joel Costigliola) Improvement : - github#22 : Use multiline error message to ease comparing actual and expected (Joel Costigliola) - Make assertions more type safe (work in progress) (Mikhail Mazursky) Bug : - github#26 : fix Lenient Equals By Ignoring Fields (Nicolas Francois) 2.0M4 release notes ------------------- - Improve type safety (Mikhail Mazursky) - Refactor custom comparators : introducing customElementComparator for group assertions (Mikhail Mazursky) - github#20 : new group assertions : containsAll(Iterable) (Joel Costigliola) - github#16 : new BigDecimalAssert assertions : isEqualTo(String) and isEqualByComparingTo(String) (Joel Costigliola) 2.0M3 release notes ------------------- - FEST-404 : Filter API on iterable/array - FEST-470 : Lenient Equals (allows specifying on which properties equality should be performed) - FEST-447 : Increase ComparableAssert API flexibility - FEST-478 : Add support for parametrized types in AbstractAssert - FEST-221 : Array and Iterable new assertion : hasSameSizeAs - FEST-481 : isIn() and isNotIn() assertions should take Iterable instead of Collection - github#17 : DateAssert isNotBetween error message must be improved - github#13 : Improve error messages 2.0M2 release notes ------------------- - github#9 : Allow custom assertions to have access to their description using descriptionText() 2.0M1 release notes ------------------- - Date assertions : 28 assertions ! - Using a custom comparator instead of equals() to compare objects in assertions - Assertions class now exposes all assertions related API : assertThat, fail API, entry for Map assertions and anyOf condition - Richer conditions : has, are, areAtLeast, areAtMost, ... - OR assertions with anyOf conditions - isEqualTo assertion error message improvement - Iterable assertions - InputStream assertions - 3 new exception assertions : hasMessageStartingWith, hasMessageContaining, hasMessageEndingWith - When an assertion fails, the exception stack is filtered to avoidshowing fest stack trace elements - New List and array assertion : isSorted - isGreaterThan, isLessThan, isGreaterThanOrEqualTo and isLessThanOrEqualTo work now with primitive wrappers - Fail API : fail() method removed - Fail API learned failBecauseExceptionWasNotThrown(exception class) - New collection/array assertions : containsNull, doesNotContainNull - New collection assertions : isSubsetOf Jira release note : http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=11920&version=18363 1.4 -> 2.0 Migration guide -------------------------- Migration steps are detailed in Fest Assertions github wiki : https://github.com/alexruiz/fest-assert-2.x/wiki/Migrating-from-fest-assert-1.4 fest-assert-2.0M10/src/000077500000000000000000000000001243020563200146555ustar00rootroot00000000000000fest-assert-2.0M10/src/formatters/000077500000000000000000000000001243020563200170435ustar00rootroot00000000000000fest-assert-2.0M10/src/formatters/fest-eclipse-formatter.xml000066400000000000000000000743151243020563200241630ustar00rootroot00000000000000 fest-assert-2.0M10/src/formatters/fest-idea-formatter.xml000066400000000000000000000031301243020563200234240ustar00rootroot00000000000000 fest-assert-2.0M10/src/formatters/intellij-codestyle.jar000066400000000000000000000027631243020563200233540ustar00rootroot00000000000000PK ӽ@ templates/PK ӽ@fileTemplates/PK ӽ@fileTemplates/internal/PK ӽ@fileTemplates/j2ee/PK ӽ@fileTemplates/code/PK ӽ@fileTemplates/includes/PK `@ codestyles/PKǰ@ #codestyles/FEST.xmlUM0W [Zd@&b]7DH!6RR{of0C@W/~Wowz9 LDW^] $Z0FBD1ČobM 3`!T SdO!{"0zc/Y(YrQ`1&kIJ{sH(R+±#)Bvs\a ")+TeR}87B5̲ cӸ.|c1@}ʈ + oi>DC-QwWDB79G*ܶu F. 䚙iSBomcM@&i{]7+B`ó9hv'PK ذ@IntelliJ IDEA Global SettingsPK ӽ@ templates/PK ӽ@(fileTemplates/PK ӽ@TfileTemplates/internal/PK ӽ@fileTemplates/j2ee/PK ӽ@fileTemplates/code/PK ӽ@fileTemplates/includes/PK `@ codestyles/PKǰ@ #Icodestyles/FEST.xmlPK ذ@]IntelliJ IDEA Global SettingsPK Efest-assert-2.0M10/src/main/000077500000000000000000000000001243020563200156015ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/000077500000000000000000000000001243020563200165225ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/000077500000000000000000000000001243020563200173115ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/000077500000000000000000000000001243020563200202525ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/000077500000000000000000000000001243020563200224445ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/api/000077500000000000000000000000001243020563200232155ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/api/AbstractAssert.java000066400000000000000000000214201243020563200270040ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.lang.String.format; import java.util.Comparator; import org.fest.assertions.core.Assert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.WritableAssertionInfo; import org.fest.assertions.description.Description; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Base class for all assertions. * * @param the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" * for more details. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public abstract class AbstractAssert, A> implements Assert { @VisibleForTesting Objects objects = Objects.instance(); @VisibleForTesting Conditions conditions = Conditions.instance(); @VisibleForTesting final WritableAssertionInfo info; // visibility is protected to allow us write custom assertions that need access to actual @VisibleForTesting protected final A actual; protected final S myself; // we prefer not to use Class selfType because it would force inherited // constructor to cast with a compiler warning // let's keep compiler warning internal to fest (when we can) and not expose them to our end users. @SuppressWarnings("unchecked") protected AbstractAssert(A actual, Class selfType) { myself = (S) selfType.cast(this); this.actual = actual; info = new WritableAssertionInfo(); } /** * Exposes the {@link WritableAssertionInfo} used in the current assertion for better extensibility.
When writing * your own assertion class, you can use the returned {@link WritableAssertionInfo} to change the error message and * still keep the description set by the assertion user. * * @return the {@link WritableAssertionInfo} used in the current assertion */ protected WritableAssertionInfo getWritableAssertionInfo() { return info; } /** {@inheritDoc} */ public S as(String description) { return describedAs(description); } /** {@inheritDoc} */ public S as(Description description) { return describedAs(description); } /** {@inheritDoc} */ public S describedAs(String description) { info.description(description); return myself; } /** {@inheritDoc} */ public S describedAs(Description description) { info.description(description); return myself; } /** {@inheritDoc} */ public S isEqualTo(A expected) { objects.assertEqual(info, actual, expected); return myself; } /** {@inheritDoc} */ public S isNotEqualTo(A other) { objects.assertNotEqual(info, actual, other); return myself; } /** {@inheritDoc} */ public void isNull() { objects.assertNull(info, actual); } /** {@inheritDoc} */ public S isNotNull() { objects.assertNotNull(info, actual); return myself; } /** {@inheritDoc} */ public S isSameAs(A expected) { objects.assertSame(info, actual, expected); return myself; } /** {@inheritDoc} */ public S isNotSameAs(A other) { objects.assertNotSame(info, actual, other); return myself; } /** {@inheritDoc} */ public S isIn(A... values) { objects.assertIsIn(info, actual, values); return myself; } /** {@inheritDoc} */ public S isNotIn(A... values) { objects.assertIsNotIn(info, actual, values); return myself; } /** {@inheritDoc} */ public S isIn(Iterable values) { objects.assertIsIn(info, actual, values); return myself; } /** {@inheritDoc} */ public S isNotIn(Iterable values) { objects.assertIsNotIn(info, actual, values); return myself; } /** {@inheritDoc} */ public S is(Condition condition) { conditions.assertIs(info, actual, condition); return myself; } /** {@inheritDoc} */ public S isNot(Condition condition) { conditions.assertIsNot(info, actual, condition); return myself; } /** {@inheritDoc} */ public S has(Condition condition) { conditions.assertHas(info, actual, condition); return myself; } /** {@inheritDoc} */ public S doesNotHave(Condition condition) { conditions.assertDoesNotHave(info, actual, condition); return myself; } /** {@inheritDoc} */ public S isInstanceOf(Class type) { objects.assertIsInstanceOf(info, actual, type); return myself; } /** {@inheritDoc} */ public S isInstanceOfAny(Class... types) { objects.assertIsInstanceOfAny(info, actual, types); return myself; } /** {@inheritDoc} */ public S isNotInstanceOf(Class type) { objects.assertIsNotInstanceOf(info, actual, type); return myself; } /** {@inheritDoc} */ public S isNotInstanceOfAny(Class... types) { objects.assertIsNotInstanceOfAny(info, actual, types); return myself; } /** {@inheritDoc} */ public S hasSameClassAs(Object other) { objects.assertHasSameClassAs(info, actual, other); return myself; } /** {@inheritDoc} */ public S doesNotHaveSameClassAs(Object other) { objects.assertDoesNotHaveSameClassAs(info, actual, other); return myself; } /** {@inheritDoc} */ public S isExactlyInstanceOf(Class type) { objects.assertIsExactlyInstanceOf(info, actual, type); return myself; } /** {@inheritDoc} */ public S isNotExactlyInstanceOf(Class type) { objects.assertIsNotExactlyInstanceOf(info, actual, type); return myself; } /** {@inheritDoc} */ public S isOfAnyClassIn(Class... types) { objects.assertIsOfAnyClassIn(info, actual, types); return myself; } /** {@inheritDoc} */ public S isNotOfAnyClassIn(Class... types) { objects.assertIsNotOfAnyClassIn(info, actual, types); return myself; } /** * The description of this assertion set with {@link #describedAs(String)} or {@link #describedAs(Description)}. * * @return the description String representation of this assertion. */ public String descriptionText() { return info.descriptionText(); } /** * Overrides Fest default error message by the given one, the new error message can be built using * {@link String#format(String, Object...)}, hence the presence of args parameter. *

* Example : * *

   * assertThat(player.isRookie()).overridingErrorMessage("Expecting Player <%s> to be a rookie but was not.", player)
   *     .isTrue();
   * 
* * @param newErrorMessage the error message that will replace the default one provided by Fest. * @param args the args used to fill error message as in {@link String#format(String, Object...)}. * @return this assertion object. * @throws exception see {@link String#format(String, Object...)} exception clause. */ public S overridingErrorMessage(String newErrorMessage, Object... args) { info.overridingErrorMessage(format(newErrorMessage, args)); return myself; } /** {@inheritDoc} */ public S usingComparator(Comparator customComparator) { // using a specific strategy to compare actual with other objects. this.objects = new Objects(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public S usingDefaultComparator() { // fall back to default strategy to compare actual with other objects. this.objects = Objects.instance(); return myself; } /** {@inheritDoc} */ @Override public final boolean equals(Object obj) { throw new UnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo'"); } /** * Always returns 1. * * @return 1. */ @Override public final int hashCode() { return 1; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/AbstractComparableAssert.java000066400000000000000000000052101243020563200307710ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ComparableAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Base class for all implementations of {@link ComparableAssert}. * @param the "self" type of this assertion class. Please read "
Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Mikhail Mazursky */ public abstract class AbstractComparableAssert, A extends Comparable> extends AbstractAssert implements ComparableAssert { @VisibleForTesting Comparables comparables = Comparables.instance(); protected AbstractComparableAssert(A actual, Class selfType) { super(actual, selfType); } /** {@inheritDoc} */ public S isLessThan(A other) { comparables.assertLessThan(info, actual, other); return myself; } /** {@inheritDoc} */ public S isLessThanOrEqualTo(A other) { comparables.assertLessThanOrEqualTo(info, actual, other); return myself; } /** {@inheritDoc} */ public S isGreaterThan(A other) { comparables.assertGreaterThan(info, actual, other); return myself; } /** {@inheritDoc} */ public S isGreaterThanOrEqualTo(A other) { comparables.assertGreaterThanOrEqualTo(info, actual, other); return myself; } @Override public S usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.comparables = new Comparables(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public S usingDefaultComparator() { super.usingDefaultComparator(); this.comparables = Comparables.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/AbstractIterableAssert.java000066400000000000000000000175511243020563200304660ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Collection; import java.util.Comparator; import org.fest.assertions.core.Condition; import org.fest.assertions.core.ObjectEnumerableAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Base class for implementations of {@link ObjectEnumerableAssert} whose actual value type is * {@link Collection}. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Mathieu Baechler * @author Joel Costigliola * @author Maciej Jaskowski * @author Nicolas François * @author Mikhail Mazursky */ public abstract class AbstractIterableAssert, A extends Iterable, T> extends AbstractAssert implements ObjectEnumerableAssert { @VisibleForTesting Iterables iterables = Iterables.instance(); protected AbstractIterableAssert(A actual, Class selfType) { super(actual, selfType); } /** {@inheritDoc} */ public void isNullOrEmpty() { iterables.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { iterables.assertEmpty(info, actual); } /** {@inheritDoc} */ public S isNotEmpty() { iterables.assertNotEmpty(info, actual); return myself; } /** {@inheritDoc} */ public S hasSize(int expected) { iterables.assertHasSize(info, actual, expected); return myself; } /** {@inheritDoc} */ public S hasSameSizeAs(Object[] other) { iterables.assertHasSameSizeAs(info, actual, other); return myself; } /** {@inheritDoc} */ public S hasSameSizeAs(Iterable other) { iterables.assertHasSameSizeAs(info, actual, other); return myself; } /** {@inheritDoc} */ public S contains(T... values) { iterables.assertContains(info, actual, values); return myself; } /** {@inheritDoc} */ public S containsOnly(T... values) { iterables.assertContainsOnly(info, actual, values); return myself; } /** {@inheritDoc} */ public S containsExactly(T... values) { iterables.assertContainsExactly(info, actual, values); return myself; } /** * Verifies that all the elements of the actual {@code Iterable} are present in the given {@code Iterable}. * @param values the {@code Iterable} that should contain all actual elements. * @return this assertion object. * @throws AssertionError if the actual {@code Iterable} is {@code null}. * @throws NullPointerException if the given {@code Iterable} is {@code null}. * @throws AssertionError if the actual {@code Iterable} is not subset of set {@code Iterable}. */ public S isSubsetOf(Iterable values) { iterables.assertIsSubsetOf(info, actual, values); return myself; } /** {@inheritDoc} */ public S containsSequence(T... sequence) { iterables.assertContainsSequence(info, actual, sequence); return myself; } /** {@inheritDoc} */ public S doesNotContain(T... values) { iterables.assertDoesNotContain(info, actual, values); return myself; } /** {@inheritDoc} */ public S doesNotHaveDuplicates() { iterables.assertDoesNotHaveDuplicates(info, actual); return myself; } /** {@inheritDoc} */ public S startsWith(T... sequence) { iterables.assertStartsWith(info, actual, sequence); return myself; } /** {@inheritDoc} */ public S endsWith(T... sequence) { iterables.assertEndsWith(info, actual, sequence); return myself; } /** {@inheritDoc} */ public S containsNull() { iterables.assertContainsNull(info, actual); return myself; } /** {@inheritDoc} */ public S doesNotContainNull() { iterables.assertDoesNotContainNull(info, actual); return myself; } /** {@inheritDoc} */ public S are(Condition condition) { iterables.assertAre(info, actual, condition); return myself; } /** {@inheritDoc} */ public S areNot(Condition condition) { iterables.assertAreNot(info, actual, condition); return myself; } /** {@inheritDoc} */ public S have(Condition condition) { iterables.assertHave(info, actual, condition); return myself; } /** {@inheritDoc} */ public S doNotHave(Condition condition) { iterables.assertDoNotHave(info, actual, condition); return myself; } /** {@inheritDoc} */ public S areAtLeast(int times, Condition condition) { iterables.assertAreAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S areNotAtLeast(int times, Condition condition) { iterables.assertAreNotAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S areAtMost(int times, Condition condition) { iterables.assertAreAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S areNotAtMost(int times, Condition condition) { iterables.assertAreNotAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S areExactly(int times, Condition condition) { iterables.assertAreExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S areNotExactly(int times, Condition condition) { iterables.assertAreNotExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S haveAtLeast(int times, Condition condition) { iterables.assertHaveAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S doNotHaveAtLeast(int times, Condition condition) { iterables.assertDoNotHaveAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S haveAtMost(int times, Condition condition) { iterables.assertHaveAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S doNotHaveAtMost(int times, Condition condition) { iterables.assertDoNotHaveAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S haveExactly(int times, Condition condition) { iterables.assertHaveExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S doNotHaveExactly(int times, Condition condition) { iterables.assertDoNotHaveExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public S containsAll(Iterable iterable) { iterables.assertContainsAll(info, actual, iterable); return myself; } /** {@inheritDoc} */ public S usingElementComparator(Comparator customComparator) { this.iterables = new Iterables(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public S usingDefaultElementComparator() { this.iterables = Iterables.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/AbstractUnevenComparableAssert.java000066400000000000000000000034741243020563200321640ustar00rootroot00000000000000/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import org.fest.assertions.core.UnevenComparableAssert; /** * Base class for all implementations of {@link UnevenComparableAssert}. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Mikhail Mazursky */ public abstract class AbstractUnevenComparableAssert, A extends Comparable> extends AbstractComparableAssert implements UnevenComparableAssert { protected AbstractUnevenComparableAssert(A actual, Class selfType) { super(actual, selfType); } /** {@inheritDoc} */ public S isEqualByComparingTo(A expected) { comparables.assertEqualByComparison(info, actual, expected); return myself; } /** {@inheritDoc} */ public S isNotEqualByComparingTo(A other) { comparables.assertNotEqualByComparison(info, actual, other); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/Assertions.java000066400000000000000000000617651243020563200262310ustar00rootroot00000000000000/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.io.File; import java.io.InputStream; import java.math.BigDecimal; import java.nio.charset.Charset; import java.util.Date; import java.util.List; import java.util.Map; import org.fest.assertions.api.filter.Filters; import org.fest.assertions.condition.AllOf; import org.fest.assertions.condition.AnyOf; import org.fest.assertions.condition.DoesNotHave; import org.fest.assertions.condition.Not; import org.fest.assertions.core.Condition; import org.fest.assertions.data.Index; import org.fest.assertions.data.MapEntry; import org.fest.assertions.data.Offset; import org.fest.assertions.groups.Properties; import org.fest.util.Files; import org.fest.util.FilesException; /** * Entry point for assertion methods for different data types. Each method in this class is a static factory for the type-specific * assertion objects. The purpose of this class is to make test code more readable. *

* For example: * *

 * int removed = employees.removeFired();
 * {@link Assertions#assertThat(int) assertThat}(removed).{@link IntegerAssert#isZero isZero}();
 *
 * List<Employee> newEmployees = employees.hired(TODAY);
 * {@link Assertions#assertThat(Iterable) assertThat}(newEmployees).{@link IterableAssert#hasSize(int) hasSize}(6);
 * 
*

* * @author Alex Ruiz * @author Yvonne Wang * @author David DIDIER * @author Ted Young * @author Joel Costigliola * @author Matthieu Baechler * @author Mikhail Mazursky * @author Nicolas François */ public class Assertions { /** * Creates a new instance of {@link BigDecimalAssert}. * @param actual the actual value. * @return the created assertion object. */ public static BigDecimalAssert assertThat(BigDecimal actual) { return new BigDecimalAssert(actual); } /** * Creates a new instance of {@link BooleanAssert}. * @param actual the actual value. * @return the created assertion object. */ public static BooleanAssert assertThat(boolean actual) { return new BooleanAssert(actual); } /** * Creates a new instance of {@link BooleanAssert}. * @param actual the actual value. * @return the created assertion object. */ public static BooleanAssert assertThat(Boolean actual) { return new BooleanAssert(actual); } /** * Creates a new instance of {@link BooleanArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static BooleanArrayAssert assertThat(boolean[] actual) { return new BooleanArrayAssert(actual); } /** * Creates a new instance of {@link ByteAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ByteAssert assertThat(byte actual) { return new ByteAssert(actual); } /** * Creates a new instance of {@link ByteAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ByteAssert assertThat(Byte actual) { return new ByteAssert(actual); } /** * Creates a new instance of {@link ByteArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ByteArrayAssert assertThat(byte[] actual) { return new ByteArrayAssert(actual); } /** * Creates a new instance of {@link CharacterAssert}. * @param actual the actual value. * @return the created assertion object. */ public static CharacterAssert assertThat(char actual) { return new CharacterAssert(actual); } /** * Creates a new instance of {@link CharArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static CharArrayAssert assertThat(char[] actual) { return new CharArrayAssert(actual); } /** * Creates a new instance of {@link CharacterAssert}. * @param actual the actual value. * @return the created assertion object. */ public static CharacterAssert assertThat(Character actual) { return new CharacterAssert(actual); } /** * Creates a new instance of {@link IterableAssert}. * @param actual the actual value. * @return the created assertion object. */ public static IterableAssert assertThat(Iterable actual) { return new IterableAssert(actual); } /** * Creates a new instance of {@link DoubleAssert}. * @param actual the actual value. * @return the created assertion object. */ public static DoubleAssert assertThat(double actual) { return new DoubleAssert(actual); } /** * Creates a new instance of {@link DoubleAssert}. * @param actual the actual value. * @return the created assertion object. */ public static DoubleAssert assertThat(Double actual) { return new DoubleAssert(actual); } /** * Creates a new instance of {@link DoubleArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static DoubleArrayAssert assertThat(double[] actual) { return new DoubleArrayAssert(actual); } /** * Creates a new instance of {@link FileAssert}. * @param actual the actual value. * @return the created assertion object. */ public static FileAssert assertThat(File actual) { return new FileAssert(actual); } /** * Creates a new instance of {@link InputStreamAssert}. * @param actual the actual value. * @return the created assertion object. */ public static InputStreamAssert assertThat(InputStream actual) { return new InputStreamAssert(actual); } /** * Creates a new instance of {@link FloatAssert}. * @param actual the actual value. * @return the created assertion object. */ public static FloatAssert assertThat(float actual) { return new FloatAssert(actual); } /** * Creates a new instance of {@link FloatAssert}. * @param actual the actual value. * @return the created assertion object. */ public static FloatAssert assertThat(Float actual) { return new FloatAssert(actual); } /** * Creates a new instance of {@link FloatArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static FloatArrayAssert assertThat(float[] actual) { return new FloatArrayAssert(actual); } /** * Creates a new instance of {@link IntegerAssert}. * @param actual the actual value. * @return the created assertion object. */ public static IntegerAssert assertThat(int actual) { return new IntegerAssert(actual); } /** * Creates a new instance of {@link IntArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static IntArrayAssert assertThat(int[] actual) { return new IntArrayAssert(actual); } /** * Creates a new instance of {@link IntegerAssert}. * @param actual the actual value. * @return the created assertion object. */ public static IntegerAssert assertThat(Integer actual) { return new IntegerAssert(actual); } /** * Creates a new instance of {@link ListAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ListAssert assertThat(List actual) { return new ListAssert(actual); } /** * Creates a new instance of {@link LongAssert}. * @param actual the actual value. * @return the created assertion object. */ public static LongAssert assertThat(long actual) { return new LongAssert(actual); } /** * Creates a new instance of {@link LongAssert}. * @param actual the actual value. * @return the created assertion object. */ public static LongAssert assertThat(Long actual) { return new LongAssert(actual); } /** * Creates a new instance of {@link LongArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static LongArrayAssert assertThat(long[] actual) { return new LongArrayAssert(actual); } /** * Creates a new instance of {@link ObjectAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ObjectAssert assertThat(T actual) { return new ObjectAssert(actual); } /** * Creates a new instance of {@link ObjectArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ObjectArrayAssert assertThat(T[] actual) { return new ObjectArrayAssert(actual); } /** * Creates a new instance of {@link MapAssert}. * @param actual the actual value. * @return the created assertion object. */ public static MapAssert assertThat(Map actual) { return new MapAssert(actual); } /** * Creates a new instance of {@link ShortAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ShortAssert assertThat(short actual) { return new ShortAssert(actual); } /** * Creates a new instance of {@link ShortAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ShortAssert assertThat(Short actual) { return new ShortAssert(actual); } /** * Creates a new instance of {@link ShortArrayAssert}. * @param actual the actual value. * @return the created assertion object. */ public static ShortArrayAssert assertThat(short[] actual) { return new ShortArrayAssert(actual); } /** * Creates a new instance of {@link StringAssert}. * @param actual the actual value. * @return the created assertion object. */ public static StringAssert assertThat(String actual) { return new StringAssert(actual); } /** * Creates a new instance of {@link DateAssert}. * @param actual the actual value. * @return the created assertion object. */ public static DateAssert assertThat(Date actual) { return new DateAssert(actual); } /** * Creates a new instance of {@link ThrowableAssert}. * @param actual the actual value. * @return the created assertion Throwable. */ public static ThrowableAssert assertThat(Throwable actual) { return new ThrowableAssert(actual); } // ------------------------------------------------------------------------------------------------- // fail methods : not assertions but here to have a single entry point to all Fest Assert features. // ------------------------------------------------------------------------------------------------- /** * Only delegate to {@link Fail#setRemoveFestRelatedElementsFromStackTrace(boolean)} so that Assertions offers a full feature * entry point to all Fest Assert features (but you can use {@link Fail} if you prefer). */ public static void setRemoveFestRelatedElementsFromStackTrace(boolean removeFestRelatedElementsFromStackTrace) { Fail.setRemoveFestRelatedElementsFromStackTrace(removeFestRelatedElementsFromStackTrace); } /** * Only delegate to {@link Fail#fail(String)} so that Assertions offers a full feature entry point to all Fest Assert features * (but you can use Fail if you prefer). */ public static void fail(String failureMessage) { Fail.fail(failureMessage); } /** * Only delegate to {@link Fail#fail(String, Throwable)} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use Fail if you prefer). */ public static void fail(String failureMessage, Throwable realCause) { Fail.fail(failureMessage, realCause); } /** * Only delegate to {@link Fail#failBecauseExceptionWasNotThrown(Class)} so that Assertions offers a full feature entry point to * all Fest Assert features (but you can use Fail if you prefer). */ public static void failBecauseExceptionWasNotThrown(Class exceptionClass) { Fail.failBecauseExceptionWasNotThrown(exceptionClass); } // ------------------------------------------------------------------------------------------------------ // properties methods : not assertions but here to have a single entry point to all Fest Assert features. // ------------------------------------------------------------------------------------------------------ /** * Only delegate to {@link Properties#extractProperty(String)} so that Assertions offers a full feature entry point to all Fest * Assert features (but you can use {@link Properties} if you prefer). *

* Typical usage is to chain extractProperty with from method, see examples below : * *

   * // extract simple property values having a java standard type (here String)
   * assertThat(extractProperty("name", String.class).from(fellowshipOfTheRing))
   *           .contains("Boromir", "Gandalf", "Frodo", "Legolas")
   *           .doesNotContain("Sauron", "Elrond");
   *                                                              
   * // extracting property works also with user's types (here Race)
   * assertThat(extractProperty("race", String.class).from(fellowshipOfTheRing))
   *           .contains(HOBBIT, ELF)
   *           .doesNotContain(ORC);
   * 
   * // extract nested property on Race
   * assertThat(extractProperty("race.name", String.class).from(fellowshipOfTheRing))
   *           .contains("Hobbit", "Elf")
   *           .doesNotContain("Orc");
   * 
*/ public static Properties extractProperty(String propertyName, Class propertyType) { return Properties.extractProperty(propertyName, propertyType); } /** * Only delegate to {@link Properties#extractProperty(String)} so that Assertions offers a full feature entry point to all Fest * Assert features (but you can use {@link Properties} if you prefer). *

* Typical usage is to chain extractProperty with from method, see examples below : * *

   * // extract simple property values, as no type has been defined the extracted property will be considered as Object 
   * // to define the real property type (here String) use extractProperty("name", String.class) instead. 
   * assertThat(extractProperty("name").from(fellowshipOfTheRing))
   *           .contains("Boromir", "Gandalf", "Frodo", "Legolas")
   *           .doesNotContain("Sauron", "Elrond");
   *                                                              
   * // extracting property works also with user's types (here Race), even though it will be considered as Object
   * // to define the real property type (here String) use extractProperty("name", Race.class) instead. 
   * assertThat(extractProperty("race").from(fellowshipOfTheRing)).contains(HOBBIT, ELF).doesNotContain(ORC);
   * 
   * // extract nested property on Race
   * assertThat(extractProperty("race.name").from(fellowshipOfTheRing)).contains("Hobbit", "Elf").doesNotContain("Orc");
   * 
*/ public static Properties extractProperty(String propertyName) { return Properties.extractProperty(propertyName); } // ------------------------------------------------------------------------------------------------------ // Data utility methods : not assertions but here to have a single entry point to all Fest Assert features. // ------------------------------------------------------------------------------------------------------ /** * Only delegate to {@link MapEntry#entry(Object, Object)} so that Assertions offers a full feature entry point to all Fest * Assert features (but you can use {@link MapEntry} if you prefer). *

* Typical usage is to call entry in MapAssert contains assertion, see examples below : * *

   * assertThat(ringBearers).contains(entry(oneRing, frodo), entry(nenya, galadriel));
   * 
*/ public static MapEntry entry(Object key, Object value) { return MapEntry.entry(key, value); } /** * Only delegate to {@link Index#atIndex(int)} so that Assertions offers a full feature entry point to all Fest Assert features * (but you can use {@link Index} if you prefer). *

* Typical usage : * *

   * List elvesRings = newArrayList(vilya, nenya, narya);
   * assertThat(elvesRings).contains(vilya, atIndex(0)).contains(nenya, atIndex(1)).contains(narya, atIndex(2));
   * 
*/ public static Index atIndex(int index) { return Index.atIndex(index); } /** * Only delegate to {@link Offset#offset(Double)} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use {@link Offset} if you prefer). *

* Typical usage : * *

   * assertThat(8.1).isEqualTo(8.0, offset(0.1));
   * 
*/ public static Offset offset(Double value) { return Offset.offset(value); } /** * Only delegate to {@link Offset#offset(Float)} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use {@link Offset} if you prefer). *

* Typical usage : * *

   * assertThat(8.2f).isEqualTo(8.0f, offset(0.2f));
   * 
*/ public static Offset offset(Float value) { return Offset.offset(value); } // ------------------------------------------------------------------------------------------------------ // Condition methods : not assertions but here to have a single entry point to all Fest Assert features. // ------------------------------------------------------------------------------------------------------ /** * Creates a new {@link AllOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given array is {@code null}. * @throws NullPointerException if any of the elements in the given array is {@code null}. */ public static Condition allOf(Condition... conditions) { return AllOf.allOf(conditions); } /** * Creates a new {@link AllOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given iterable is {@code null}. * @throws NullPointerException if any of the elements in the given iterable is {@code null}. */ public static Condition allOf(Iterable> conditions) { return AllOf.allOf(conditions); } /** * Only delegate to {@link AnyOf#anyOf(Condition...)} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use {@link AnyOf} if you prefer). *

* Typical usage (jedi and sith are {@link Condition}) : * *

   * assertThat("Vader").is(anyOf(jedi, sith));
   * 
*/ public static Condition anyOf(Condition... conditions) { return AnyOf.anyOf(conditions); } /** * Creates a new {@link AnyOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given iterable is {@code null}. * @throws NullPointerException if any of the elements in the given iterable is {@code null}. */ public static Condition anyOf(Iterable> conditions) { return AnyOf.anyOf(conditions); } /** * Creates a new {@link DoesNotHave}. * * @param condition the condition to inverse. * @return The Not condition created. */ public static DoesNotHave doesNotHave(Condition condition) { return DoesNotHave.doesNotHave(condition); } /** * Creates a new {@link Not}. * * @param condition the condition to inverse. * @return The Not condition created. */ public static Not not(Condition condition) { return Not.not(condition); } // -------------------------------------------------------------------------------------------------- // Filter methods : not assertions but here to have a single entry point to all Fest Assert features. // -------------------------------------------------------------------------------------------------- /** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use {@link Filters} if you prefer). *

* Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. *

* Typical usage with {@link Condition} : * *

   * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);
* and with filter language based on java bean property : * *
   * assertThat(filter(players).with("pointsPerGame").greaterThan(20)
   *                           .and("assistsPerGame").greaterThan(7)
   *                           .get()).containsOnly(james, rose);
*/ public static Filters filter(E[] array) { return Filters.filter(array); } /** * Only delegate to {@link Filters#filter(Object[])} so that Assertions offers a full feature entry point to all Fest Assert * features (but you can use {@link Filters} if you prefer). *

* Note that the given {@link Iterable} is not modified, the filters are performed on a copy. *

* Typical usage with {@link Condition} : * *

   * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);
* and with filter language based on java bean property : * *
   * assertThat(filter(players).with("pointsPerGame").greaterThan(20)
   *                           .and("assistsPerGame").greaterThan(7)
   *                           .get()).containsOnly(james, rose);
*/ public static Filters filter(Iterable iterableToFilter) { return Filters.filter(iterableToFilter); } // -------------------------------------------------------------------------------------------------- // File methods : not assertions but here to have a single entry point to all Fest Assert features. // -------------------------------------------------------------------------------------------------- /** * Loads the text content of a file, so that it can be passed to {@link #assertThat(String)}. *

* Note that this will load the entire file in memory; for larger files, there might be a more efficient alternative with * {@link #assertThat(File)}. *

* @param file the file. * @param charset the character set to use. * @return the content of the file. * @throws NullPointerException if the given charset is {@code null}. * @throws FilesException if an I/O exception occurs. */ public static String contentOf(File file, Charset charset) { return Files.contentOf(file, charset); } /** * Loads the text content of a file, so that it can be passed to {@link #assertThat(String)}. *

* Note that this will load the entire file in memory; for larger files, there might be a more efficient alternative with * {@link #assertThat(File)}. *

* @param file the file. * @param charsetName the name of the character set to use. * @return the content of the file. * @throws IllegalArgumentException if the given character set is not supported on this platform. * @throws FilesException if an I/O exception occurs. */ public static String contentOf(File file, String charsetName) { return Files.contentOf(file, charsetName); } /** * Loads the text content of a file with the default character set, so that it can be passed to {@link #assertThat(String)}. *

* Note that this will load the entire file in memory; for larger files, there might be a more efficient alternative with * {@link #assertThat(File)}. *

* @param file the file. * @return the content of the file. * @throws FilesException if an I/O exception occurs. */ public static String contentOf(File file) { return Files.contentOf(file, Charset.defaultCharset()); } /** Creates a new {@link Assertions}. */ protected Assertions() {} } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/BigDecimalAssert.java000066400000000000000000000064741243020563200272350ustar00rootroot00000000000000/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import java.math.BigDecimal; import java.util.Comparator; import org.fest.assertions.core.NumberAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@link BigDecimal}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(BigDecimal)}. *

* * @author David DIDIER * @author Ted M. Young * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky */ public class BigDecimalAssert extends AbstractUnevenComparableAssert implements NumberAssert { @VisibleForTesting BigDecimals bigDecimals = BigDecimals.instance(); protected BigDecimalAssert(BigDecimal actual) { super(actual, BigDecimalAssert.class); } /** {@inheritDoc} */ public BigDecimalAssert isZero() { bigDecimals.assertIsZero(info, actual); return myself; } /** {@inheritDoc} */ public BigDecimalAssert isNotZero() { bigDecimals.assertIsNotZero(info, actual); return myself; } /** {@inheritDoc} */ public BigDecimalAssert isPositive() { bigDecimals.assertIsPositive(info, actual); return myself; } /** {@inheritDoc} */ public BigDecimalAssert isNegative() { bigDecimals.assertIsNegative(info, actual); return myself; } /** {@inheritDoc} */ public BigDecimalAssert isNotPositive() { bigDecimals.assertIsNotPositive(info, actual); return this; } /** {@inheritDoc} */ public BigDecimalAssert isNotNegative() { bigDecimals.assertIsNotNegative(info, actual); return this; } /** * Same as {@link AbstractAssert#isEqualTo(Object) isEqualTo(BigDecimal)} but takes care of converting given String to * {@link BigDecimal} for you. */ public BigDecimalAssert isEqualTo(String expected) { return super.isEqualTo(new BigDecimal(expected)); } /** * Same as {@link AbstractUnevenComparableAssert#isEqualByComparingTo(Comparable) isEqualByComparingTo(BigDecimal)} but takes * care of converting given String to {@link BigDecimal} for you. */ public BigDecimalAssert isEqualByComparingTo(String expected) { return super.isEqualByComparingTo(new BigDecimal(expected)); } @Override public BigDecimalAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.bigDecimals = new BigDecimals(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public BigDecimalAssert usingDefaultComparator() { super.usingDefaultComparator(); this.bigDecimals = BigDecimals.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/BooleanArrayAssert.java000066400000000000000000000224231243020563200276230ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.BooleanArrays; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code boolean}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(boolean[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class BooleanArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting BooleanArrays arrays = BooleanArrays.instance(); protected BooleanArrayAssert(boolean[] actual) { super(actual, BooleanArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public BooleanArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public BooleanArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public BooleanArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public BooleanArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public BooleanArrayAssert contains(boolean... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public BooleanArrayAssert containsOnly(boolean... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public BooleanArrayAssert containsSequence(boolean... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public BooleanArrayAssert contains(boolean value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public BooleanArrayAssert doesNotContain(boolean... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public BooleanArrayAssert doesNotContain(boolean value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public BooleanArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(boolean...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public BooleanArrayAssert startsWith(boolean... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(boolean...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public BooleanArrayAssert endsWith(boolean... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public BooleanArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public BooleanArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public BooleanArrayAssert usingElementComparator(Comparator customComparator) { throw new UnsupportedOperationException("custom element Comparator is not supported for Boolean array comparison"); } /** {@inheritDoc} */ public BooleanArrayAssert usingDefaultElementComparator() { throw new UnsupportedOperationException("custom element Comparator is not supported for Boolean array comparison"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/BooleanAssert.java000066400000000000000000000062031243020563200266220ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.internal.Booleans; import org.fest.util.VisibleForTesting; /** * Assertion methods for bytes. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Boolean)} or * {@link Assertions#assertThat(boolean)}. *

* * @author Alex Ruiz * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Mikhail Mazursky */ public class BooleanAssert extends AbstractAssert { @VisibleForTesting Booleans booleans = Booleans.instance(); protected BooleanAssert(Boolean actual) { super(actual, BooleanAssert.class); } /** * Verifies that the actual value is {@code true}. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not {@code true}. */ public BooleanAssert isTrue() { return isEqualTo(true); } /** * Verifies that the actual value is {@code false}. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not {@code false}. */ public BooleanAssert isFalse() { return isEqualTo(false); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public BooleanAssert isEqualTo(boolean expected) { booleans.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public BooleanAssert isNotEqualTo(boolean other) { booleans.assertNotEqual(info, actual, other); return this; } @Override public BooleanAssert usingComparator(Comparator customComparator) { throw new UnsupportedOperationException("custom Comparator is not supported for Boolean comparison"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ByteArrayAssert.java000066400000000000000000000221021243020563200271410ustar00rootroot00000000000000/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code byte}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(byte[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class ByteArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting ByteArrays arrays = ByteArrays.instance(); protected ByteArrayAssert(byte[] actual) { super(actual, ByteArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public ByteArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public ByteArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public ByteArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public ByteArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public ByteArrayAssert contains(byte... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public ByteArrayAssert containsOnly(byte... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public ByteArrayAssert containsSequence(byte... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public ByteArrayAssert contains(byte value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public ByteArrayAssert doesNotContain(byte... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public ByteArrayAssert doesNotContain(byte value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public ByteArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(byte...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public ByteArrayAssert startsWith(byte... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(byte...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public ByteArrayAssert endsWith(byte... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public ByteArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public ByteArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public ByteArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new ByteArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public ByteArrayAssert usingDefaultElementComparator() { this.arrays = ByteArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ByteAssert.java000066400000000000000000000126041243020563200261500ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.NumberAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for bytes. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Byte)} or * {@link Assertions#assertThat(byte)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class ByteAssert extends AbstractComparableAssert implements NumberAssert { @VisibleForTesting Bytes bytes = Bytes.instance(); protected ByteAssert(Byte actual) { super(actual, ByteAssert.class); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public ByteAssert isEqualTo(byte expected) { bytes.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public ByteAssert isNotEqualTo(byte other) { bytes.assertNotEqual(info, actual, other); return this; } /** {@inheritDoc} */ public ByteAssert isZero() { bytes.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public ByteAssert isNotZero() { bytes.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public ByteAssert isPositive() { bytes.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public ByteAssert isNegative() { bytes.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public ByteAssert isNotNegative() { bytes.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public ByteAssert isNotPositive() { bytes.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public ByteAssert isLessThan(byte other) { bytes.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public ByteAssert isLessThanOrEqualTo(byte other) { bytes.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public ByteAssert isGreaterThan(byte other) { bytes.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public ByteAssert isGreaterThanOrEqualTo(byte other) { bytes.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public ByteAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.bytes = new Bytes(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public ByteAssert usingDefaultComparator() { super.usingDefaultComparator(); this.bytes = Bytes.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/CharArrayAssert.java000066400000000000000000000221261243020563200271210ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code char}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(char[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class CharArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting CharArrays arrays = CharArrays.instance(); protected CharArrayAssert(char[] actual) { super(actual, CharArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public CharArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public CharArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public CharArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public CharArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public CharArrayAssert contains(char... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public CharArrayAssert containsOnly(char... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public CharArrayAssert containsSequence(char... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public CharArrayAssert contains(char value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public CharArrayAssert doesNotContain(char... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public CharArrayAssert doesNotContain(char value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public CharArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(char...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public CharArrayAssert startsWith(char... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(char...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public CharArrayAssert endsWith(char... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public CharArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public CharArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public CharArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new CharArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public CharArrayAssert usingDefaultElementComparator() { this.arrays = CharArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/CharacterAssert.java000066400000000000000000000127041243020563200271420ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for characters. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Character)} or * {@link Assertions#assertThat(char)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky */ public class CharacterAssert extends AbstractComparableAssert { @VisibleForTesting Characters characters = Characters.instance(); protected CharacterAssert(Character actual) { super(actual, CharacterAssert.class); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public CharacterAssert isEqualTo(char expected) { characters.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public CharacterAssert isNotEqualTo(char other) { characters.assertNotEqual(info, actual, other); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public CharacterAssert isLessThan(char other) { characters.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public CharacterAssert isLessThanOrEqualTo(char other) { characters.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public CharacterAssert isGreaterThan(char other) { characters.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public CharacterAssert isGreaterThanOrEqualTo(char other) { characters.assertGreaterThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is a lowercase character. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not a lowercase character. */ public CharacterAssert isLowerCase() { characters.assertLowerCase(info, actual); return this; } /** * Verifies that the actual value is a uppercase character. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not a uppercase character. */ public CharacterAssert isUpperCase() { characters.assertUpperCase(info, actual); return this; } @Override public CharacterAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.characters = new Characters(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public CharacterAssert usingDefaultComparator() { super.usingDefaultComparator(); this.characters = Characters.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/DateAssert.java000066400000000000000000001267541243020563200261360ustar00rootroot00000000000000package org.fest.assertions.api; import static org.fest.util.Dates.ISO_DATE_FORMAT; import java.text.DateFormat; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Comparator; import java.util.Date; import java.util.concurrent.TimeUnit; import org.fest.assertions.core.Assert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * * Assertions for {@code Date}s. *

* To create a new instance of this class invoke {@link Assertions#assertThat(Date)}. *

* Note that assertions with date parameter comes with two flavor, one is obviously a {@link Date} and the other is a String * representing a Date.
* For the latter, the default format follows ISO 8901 : "yyyy-MM-dd", user can override it with a custom format by calling * {@link #withDateFormat(DateFormat)}.
* The user custom format will then be used for all next Date assertions (i.e not limited to the current assertion) in the test * suite.
* To turn back to default format, simply call {@link #withIsoDateFormat()}. * * @author Tomasz Nurkiewicz (thanks for giving assertions idea) * @author Joel Costigliola * @author Mikhail Mazursky */ public class DateAssert extends AbstractAssert { @VisibleForTesting Dates dates = Dates.instance(); /** * Used in String based Date assertions - like {@link #isAfter(String)} - to convert input date represented as string to Date.
* The format used can be overriden by invoking {@link #withDateFormat(DateFormat)} */ @VisibleForTesting static DateFormat dateFormat = ISO_DATE_FORMAT; /** * Creates a new {@link DateAssert}. * @param actual the target to verify. */ protected DateAssert(Date actual) { super(actual, DateAssert.class); } /** * Same assertion as {@link AbstractAssert#isEqualTo(Object) isEqualTo(Date date)} but given Date is represented as String * either with ISO date format (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual and given Date represented as String are not equal. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isEqualTo(String dateAsString) { return isEqualTo(parse(dateAsString)); } /** * Same assertion as {@link AbstractAssert#isNotEqualTo(Object) isNotEqualTo(Date date)} but given Date is represented as String * either with ISO date format (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual and given Date represented as String are equal. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isNotEqualTo(String dateAsString) { return isNotEqualTo(parse(dateAsString)); } /** * Same assertion as {@link Assert#isIn(Object...)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is not in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isIn(String... datesAsString) { Date[] dates = new Date[datesAsString.length]; for (int i = 0; i < datesAsString.length; i++) { dates[i] = parse(datesAsString[i]); } return isIn(dates); } /** * Same assertion as {@link Assert#isIn(Iterable)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}).
* Method signature could not be isIn(Collection<String>) because it would be same signature as * isIn(Collection<Date>) since java collection type are erased at runtime. * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is not in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isInWithStringDateCollection(Collection datesAsString) { Collection dates = new ArrayList(datesAsString.size()); for (String dateAsString : datesAsString) { dates.add(parse(dateAsString)); } return isIn(dates); } /** * Same assertion as {@link Assert#isNotIn(Object...)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isNotIn(String... datesAsString) { Date[] dates = new Date[datesAsString.length]; for (int i = 0; i < datesAsString.length; i++) { dates[i] = parse(datesAsString[i]); } return isNotIn(dates); } /** * Same assertion as {@link Assert#isNotIn(Iterable)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}).
* Method signature could not be isNotIn(Collection<String>) because it would be same signature as * isNotIn(Collection<Date>) since java collection type are erased at runtime. * @param datesAsString the given Dates represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if actual is in given Dates represented as String. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isNotInWithStringDateCollection(Collection datesAsString) { Collection dates = new ArrayList(datesAsString.size()); for (String dateAsString : datesAsString) { dates.add(parse(dateAsString)); } return isNotIn(dates); } /** * Verifies that the actual {@code Date} is strictly before the given one. * @param other the given Date. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly before the given one. */ public DateAssert isBefore(Date other) { dates.assertIsBefore(info, actual, other); return this; } /** * Same assertion as {@link #isBefore(Date)} but given Date is represented as String either with ISO date format (yyyy-MM-dd) or * user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly before the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isBefore(String dateAsString) { return isBefore(parse(dateAsString)); } /** * Verifies that the actual {@code Date} is before or equals to the given one. * @param other the given Date. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not before or equals to the given one. */ public DateAssert isBeforeOrEqualsTo(Date other) { dates.assertIsBeforeOrEqualsTo(info, actual, other); return this; } /** * Same assertion as {@link #isBeforeOrEqualsTo(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not before or equals to the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isBeforeOrEqualsTo(String dateAsString) { return isBeforeOrEqualsTo(parse(dateAsString)); } /** * Verifies that the actual {@code Date} is strictly after the given one. * @param other the given Date. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly after the given one. */ public DateAssert isAfter(Date other) { dates.assertIsAfter(info, actual, other); return this; } /** * Same assertion as {@link #isAfter(Date)} but given Date is represented as String either with ISO date format (yyyy-MM-dd) or * user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly after the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isAfter(String dateAsString) { return isAfter(parse(dateAsString)); } /** * Verifies that the actual {@code Date} is after or equals to the given one. * @param other the given Date. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not after or equals to the given one. */ public DateAssert isAfterOrEqualsTo(Date other) { dates.assertIsAfterOrEqualsTo(info, actual, other); return this; } /** * Same assertion as {@link #isAfterOrEqualsTo(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if given date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not after or equals to the given Date represented as String. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isAfterOrEqualsTo(String dateAsString) { return isAfterOrEqualsTo(parse(dateAsString)); } /** * Verifies that the actual {@code Date} is in [start, end[ period (start included, end excluded). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in [start, end[ period. */ public DateAssert isBetween(Date start, Date end) { return isBetween(start, end, true, false); } /** * Same assertion as {@link #isBetween(Date, Date)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start Date as String is {@code null}. * @throws NullPointerException if end Date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not in [start, end[ period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isBetween(String start, String end) { return isBetween(parse(start), parse(end)); } /** * Verifies that the actual {@code Date} is in the given period defined by start and end dates.
* To include start in the period set inclusiveStart parameter to true.
* To include end in the period set inclusiveEnd parameter to true.
* @param start the period start, expected not to be null. * @param end the period end, expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return this assertion object. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in (start, end) period. */ public DateAssert isBetween(Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { dates.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); return this; } /** * Same assertion as {@link #isBetween(Date, Date, boolean, boolean)} but given Dates are represented as String either with ISO * date format (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param start the period start, expected not to be null. * @param end the period end, expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return this assertion object. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start Date as String is {@code null}. * @throws NullPointerException if end Date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not in (start, end) period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isBetween(String start, String end, boolean inclusiveStart, boolean inclusiveEnd) { dates.assertIsBetween(info, actual, parse(start), parse(end), inclusiveStart, inclusiveEnd); return this; } /** * Verifies that the actual {@code Date} is not in the given period defined by start and end dates.
* To include start in the period set inclusiveStart parameter to true.
* To include end in the period set inclusiveEnd parameter to true.
* @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return this assertion object. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in (start, end) period. */ public DateAssert isNotBetween(Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { dates.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); return this; } /** * Same assertion as {@link #isNotBetween(Date, Date, boolean, boolean)} but given Dates are represented as String either with * ISO date format (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return this assertion object. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start Date as String is {@code null}. * @throws NullPointerException if end Date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is not in (start, end) period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isNotBetween(String start, String end, boolean inclusiveStart, boolean inclusiveEnd) { return isNotBetween(parse(start), parse(end), inclusiveStart, inclusiveEnd); } /** * Verifies that the actual {@code Date} is not in [start, end[ period * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is in [start, end[ period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isNotBetween(Date start, Date end) { return isNotBetween(start, end, true, false); } /** * Same assertion as {@link #isNotBetween(Date, Date)} but given Dates are represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param start the period start (inclusive), expected not to be null. * @param end the period end (exclusive), expected not to be null. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws NullPointerException if start Date as String is {@code null}. * @throws NullPointerException if end Date as String is {@code null}. * @throws AssertionError if the actual {@code Date} is in [start, end[ period. * @throws AssertionError if one of the given date as String could not be converted to a Date. */ public DateAssert isNotBetween(String start, String end) { return isNotBetween(parse(start), parse(end), true, false); } /** * Verifies that the actual {@code Date} is strictly in the past. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in the past. */ public DateAssert isInThePast() { dates.assertIsInThePast(info, actual); return this; } /** * Verifies that the actual {@code Date} is today, that is matching current year, month and day (no check on hour, minute, * second, milliseconds). * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not today. */ public DateAssert isToday() { dates.assertIsToday(info, actual); return this; } /** * Verifies that the actual {@code Date} is strictly in the future. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in the future. */ public DateAssert isInTheFuture() { dates.assertIsInTheFuture(info, actual); return this; } /** * Verifies that the actual {@code Date} is strictly before the given year. * @param year the year to compare actual year to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} year is after or equals to the given year. */ public DateAssert isBeforeYear(int year) { dates.assertIsBeforeYear(info, actual, year); return this; } /** * Verifies that the actual {@code Date} is strictly after the given year. * @param year the year to compare actual year to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} year is before or equals to the given year. */ public DateAssert isAfterYear(int year) { dates.assertIsAfterYear(info, actual, year); return this; } /** * Verifies that the actual {@code Date} year is equal to the given year. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param year the year to compare actual year to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} year is not equal to the given year. */ public DateAssert isWithinYear(int year) { dates.assertIsWithinYear(info, actual, year); return this; } /** * Verifies that the actual {@code Date} month is equal to the given month, month value starting at 1 (January=1, * February=2, ...). *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param month the month to compare actual month to, month value starting at 1 (January=1, February=2, ...). * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} month is not equal to the given month. */ public DateAssert isWithinMonth(int month) { dates.assertIsWithinMonth(info, actual, month); return this; } /** * Verifies that the actual {@code Date} day of month is equal to the given day of month. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param dayOfMonth the day of month to compare actual day of month to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} month is not equal to the given day of month. */ public DateAssert isWithinDayOfMonth(int dayOfMonth) { dates.assertIsWithinDayOfMonth(info, actual, dayOfMonth); return this; } /** * Verifies that the actual {@code Date} day of week is equal to the given day of week (see {@link Calendar#DAY_OF_WEEK} for * valid values). *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param dayOfWeek the day of week to compare actual day of week to, see {@link Calendar#DAY_OF_WEEK} for valid values * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not equal to the given day of week. */ public DateAssert isWithinDayOfWeek(int dayOfWeek) { dates.assertIsWithinDayOfWeek(info, actual, dayOfWeek); return this; } /** * Verifies that the actual {@code Date} hour od day is equal to the given hour of day (24-hour clock). *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param hourOfDay the hour of day to compare actual hour of day to (24-hour clock) * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} hour is not equal to the given hour. */ public DateAssert isWithinHourOfDay(int hourOfDay) { dates.assertIsWithinHourOfDay(info, actual, hourOfDay); return this; } /** * Verifies that the actual {@code Date} minute is equal to the given minute. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param minute the minute to compare actual minute to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} minute is not equal to the given minute. */ public DateAssert isWithinMinute(int minute) { dates.assertIsWithinMinute(info, actual, minute); return this; } /** * Verifies that the actual {@code Date} second is equal to the given second. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param second the second to compare actual second to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} second is not equal to the given second. */ public DateAssert isWithinSecond(int second) { dates.assertIsWithinSecond(info, actual, second); return this; } /** * Verifies that the actual {@code Date} millisecond is equal to the given millisecond. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param millisecond the millisecond to compare actual millisecond to * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} millisecond is not equal to the given millisecond. */ public DateAssert isWithinMillisecond(int millisecond) { dates.assertIsWithinMillisecond(info, actual, millisecond); return this; } /** * Verifies that actual and given {@code Date} are in the same year. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same year. */ public DateAssert isInSameYearAs(Date other) { dates.assertIsInSameYearAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameYearAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given Date represented as String are not in the same year. * @throws AssertionError if the given date as String could not be converted to a Date. */ public DateAssert isInSameYearAs(String dateAsString) { return isInSameYearAs(parse(dateAsString)); } /** * Verifies that actual and given {@code Date} are chronologically in the same month (and thus in the same year). *

* If you want to compare month only (without year), use : assertThat(myDate).isWithinMonth(monthOf(otherDate))
* See {@link org.fest.util.Dates#monthOf(Date)} to get the month of a given Date. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same month. */ public DateAssert isInSameMonthAs(Date other) { dates.assertIsInSameMonthAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameMonthAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same month. */ public DateAssert isInSameMonthAs(String dateAsString) { return isInSameMonthAs(parse(dateAsString)); } /** * Verifies that actual and given {@code Date} are chronologically in the same day of month (and thus in the same month and * year). *

* If you want to compare day of month only (without month and year), you could write : * assertThat(myDate).isWithinDayOfMonth(dayOfMonthOf(otherDate))
* see {@link org.fest.util.Dates#dayOfMonthOf(Date)} to get the day of month of a given Date. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same day of month. */ public DateAssert isInSameDayAs(Date other) { dates.assertIsInSameDayAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameDayAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same day of month. */ public DateAssert isInSameDayAs(String dateAsString) { return isInSameDayAs(parse(dateAsString)); } /** * Verifies that actual and given {@code Date} are chronologically in the same hour (and thus in the same day, month and year). *

* If you want to compare hour only (without day, month and year), you could write : * assertThat(myDate).isWithinHour(hourOfDayOf(otherDate))
* see {@link org.fest.util.Dates#hourOfDay(Date)} to get the hour of a given Date. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same hour. */ public DateAssert isInSameHourAs(Date other) { dates.assertIsInSameHourAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameHourAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same hour. */ public DateAssert isInSameHourAs(String dateAsString) { return isInSameHourAs(parse(dateAsString)); } /** * Verifies that actual and given {@code Date} are chronologically in the same minute (and thus in the same hour, day, month and * year). *

* If you want to compare minute only (without hour, day, month and year), you could write : * assertThat(myDate).isWithinMinute(minuteOf(otherDate))
* see {@link org.fest.util.Dates#minuteOf(Date)} to get the minute of a given Date. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same minute. */ public DateAssert isInSameMinuteAs(Date other) { dates.assertIsInSameMinuteAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameMinuteAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same minute. */ public DateAssert isInSameMinuteAs(String dateAsString) { return isInSameMinuteAs(parse(dateAsString)); } /** * Verifies that actual and given {@code Date} are chronologically in the same second (and thus in the same minute, hour, day, * month and year). *

* If you want to compare second only (without minute, hour, day, month and year), you could write : * assertThat(myDate).isWithinSecond(secondOf(otherDate))
* see {@link org.fest.util.Dates#secondOf(Date)} to get the second of a given Date. *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * * @param other the given {@code Date} to compare actual {@code Date} to. * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same second. */ public DateAssert isInSameSecondAs(Date other) { dates.assertIsInSameSecondAs(info, actual, other); return this; } /** * Same assertion as {@link #isInSameSecondAs(Date)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same second. */ public DateAssert isInSameSecondAs(String dateAsString) { return isInSameSecondAs(parse(dateAsString)); } /** * Verifies that the actual {@code Date} is close to the other date by less than delta (expressed in milliseconds), if * difference is equals to delta it's ok. *

* One can use handy {@link TimeUnit} to convert a duration in milliseconds, for example you can express a delta of 5 seconds * with TimeUnit.SECONDS.toMillis(5). *

* Note that using a custom comparator has no effect on this assertion (see {@link #usingComparator(Comparator)}. * @param other the date to compare actual to * @param deltaInMilliseconds the delta used for date comparison, expressed in milliseconds * @return this assertion object. * @throws NullPointerException if {@code Date} parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not close to the given date by less than delta. */ public DateAssert isCloseTo(Date other, long deltaInMilliseconds) { dates.assertIsCloseTo(info, actual, other, deltaInMilliseconds); return this; } /** * Same assertion as {@link #isCloseTo(Date, long)} but given Date is represented as String either with ISO date format * (yyyy-MM-dd) or user custom date format (set with method {@link #withDateFormat(DateFormat)}). * @param dateAsString the given Date represented as String in default or custom date format. * @param deltaInMilliseconds the delta used for date comparison, expressed in milliseconds * @return this assertion object. * @throws NullPointerException if dateAsString parameter is {@code null}. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not close to the given date by less than delta. */ public DateAssert isCloseTo(String dateAsString, long deltaInMilliseconds) { return isCloseTo(parse(dateAsString), deltaInMilliseconds); } /** * Verifies that the actual {@code Date} has the same time as the given timestamp. *

* Both time or timestamp express a number of milliseconds since January 1, 1970, 00:00:00 GMT. * @param timestamp the timestamp to compare actual time to. * @return this assertion object. * @throws AssertionError if the actual {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} time is not equal to the given timestamp. * @see Date#getTime() */ public DateAssert hasTime(long timestamp) { dates.assertHasTime(info, actual, timestamp); return this; } /** * For String based Date assertions like {@link #isBefore(String)}, given String is expected to follow the default Date format, * that is ISO 8601 format : "yyyy-MM-dd". *

* With this method, user can specify its own date format, replacing the current date format for all future Date assertions in * the test suite (i.e. not only the current assertions) since custom DateFormat is stored in a static field. *

* To revert to default format simply call {@link #withIsoDateFormat()}. * * @param userCustomDateFormat the new Date format used for String based Date assertions. * @return this assertion object. */ public DateAssert withDateFormat(DateFormat userCustomDateFormat) { useDateFormat(userCustomDateFormat); return this; } /** * For String based Date assertions like {@link #isBefore(String)}, given String is expected to follow the default Date format, * that is ISO 8601 format : "yyyy-MM-dd". *

* With this method, user can specify its own date format, replacing the current date format for all future Date assertions in * the test suite (i.e. not only the current assertions) since custom DateFormat is stored in a static field. *

* To revert to default format simply call {@link #useIsoDateFormat()} (static method) or {@link #withIsoDateFormat()}. * * @param userCustomDateFormat the new Date format used for String based Date assertions. */ public static void useDateFormat(DateFormat userCustomDateFormat) { if (userCustomDateFormat == null) throw new NullPointerException("The given date format should not be null"); dateFormat = userCustomDateFormat; } /** * Use ISO 8601 date format ("yyyy-MM-dd") for String based Date assertions. * @return this assertion object. */ public DateAssert withIsoDateFormat() { useIsoDateFormat(); return this; } /** * Use ISO 8601 date format ("yyyy-MM-dd") for String based Date assertions. */ public static void useIsoDateFormat() { dateFormat = ISO_DATE_FORMAT; } /** * Utillity method to parse a Date with {@link #dateFormat}, note that it is thread safe.
* Returns null if dateAsString parameter is null. * @param dateAsString the string to parse as a Date with {@link #dateFormat} * @return the corrresponding Date, null if dateAsString parameter is null. * @throws AssertionError if the string can't be parsed as a Date */ private static Date parse(String dateAsString) { if (dateAsString == null) { return null; } try { // synchronized is used because SimpleDateFormat which is not thread safe (sigh). synchronized (dateFormat) { return dateFormat.parse(dateAsString); } } catch (ParseException e) { throw Failures.instance().failure("Failed to parse " + dateAsString + " with date format " + dateFormat); } } @Override public DateAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.dates = new Dates(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public DateAssert usingDefaultComparator() { super.usingDefaultComparator(); this.dates = Dates.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/DoubleArrayAssert.java000066400000000000000000000222361243020563200274600ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code double}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(double[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class DoubleArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting DoubleArrays arrays = DoubleArrays.instance(); protected DoubleArrayAssert(double[] actual) { super(actual, DoubleArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public DoubleArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public DoubleArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public DoubleArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public DoubleArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public DoubleArrayAssert contains(double... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public DoubleArrayAssert containsOnly(double... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public DoubleArrayAssert containsSequence(double... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public DoubleArrayAssert contains(double value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public DoubleArrayAssert doesNotContain(double... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public DoubleArrayAssert doesNotContain(double value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public DoubleArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(double...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public DoubleArrayAssert startsWith(double... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(double...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public DoubleArrayAssert endsWith(double... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public DoubleArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public DoubleArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public DoubleArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new DoubleArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public DoubleArrayAssert usingDefaultElementComparator() { this.arrays = DoubleArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/DoubleAssert.java000066400000000000000000000151721243020563200264620ustar00rootroot00000000000000/* * Created on Oct 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.FloatingPointNumberAssert; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for doubles. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Double)} or * {@link Assertions#assertThat(double)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Alex Ruiz * @author Ansgar Konermann * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class DoubleAssert extends AbstractComparableAssert implements FloatingPointNumberAssert { @VisibleForTesting Doubles doubles = Doubles.instance(); protected DoubleAssert(Double actual) { super(actual, DoubleAssert.class); } /** {@inheritDoc} */ public DoubleAssert isNaN() { doubles.assertIsNaN(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isNotNaN() { doubles.assertIsNotNaN(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isZero() { doubles.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isNotZero() { doubles.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isPositive() { doubles.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isNegative() { doubles.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isNotNegative() { doubles.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public DoubleAssert isNotPositive() { doubles.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public DoubleAssert isEqualTo(double expected) { doubles.assertEqual(info, actual, expected); return this; } /** {@inheritDoc} */ public DoubleAssert isEqualTo(Double expected, Offset offset) { doubles.assertEqual(info, actual, expected, offset); return this; } /** * Verifies that the actual value is equal to the given one, within a positive offset. * @param expected the given value to compare the actual value to. * @param offset the given positive offset. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public DoubleAssert isEqualTo(double expected, Offset offset) { doubles.assertEqual(info, actual, expected, offset); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public DoubleAssert isNotEqualTo(double other) { doubles.assertNotEqual(info, actual, other); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public DoubleAssert isLessThan(double other) { doubles.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public DoubleAssert isLessThanOrEqualTo(double other) { doubles.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public DoubleAssert isGreaterThan(double other) { doubles.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public DoubleAssert isGreaterThanOrEqualTo(double other) { doubles.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public DoubleAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.doubles = new Doubles(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public DoubleAssert usingDefaultComparator() { super.usingDefaultComparator(); this.doubles = Doubles.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/Fail.java000066400000000000000000000055411243020563200247400ustar00rootroot00000000000000/* * Created on Mar 19, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.api; import static java.lang.String.format; import org.fest.assertions.internal.Failures; /** * Common failures. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public final class Fail { /** * Sets wether we remove elements related to Fest from assertion error stack trace. * @param removeFestRelatedElementsFromStackTrace flag. */ public static void setRemoveFestRelatedElementsFromStackTrace(boolean removeFestRelatedElementsFromStackTrace) { Failures.instance().setRemoveFestRelatedElementsFromStackTrace(removeFestRelatedElementsFromStackTrace); } /** * Fails with the given message. * @param failureMessage error message. * @throws AssertionError with the given message. */ public static void fail(String failureMessage) { throw Failures.instance().failure(failureMessage); } /** * Throws an {@link AssertionError} with the given message and with the {@link Throwable} that caused the failure. * @param failureMessage the description of the failed assertion. It can be {@code null}. * @param realCause cause of the error. * @throws AssertionError with the given message and with the {@link Throwable} that caused the failure. */ public static void fail(String failureMessage, Throwable realCause) { AssertionError error = Failures.instance().failure(failureMessage); error.initCause(realCause); throw error; } /** * Throws an {@link AssertionError} with a message explaining that a {@link Throwable} of given class was expected to be thrown * but had not been. * @param throwableClass the Throwable class that was expected to be thrown. * @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had * not been. */ public static void failBecauseExceptionWasNotThrown(Class throwableClass) { throw Failures.instance().failure(format("Expected %s to be thrown", throwableClass.getSimpleName())); } /** * This constructor is protected to make it possible to subclass this class. Since all its methods are static, there is no point * on creating a new instance of it. */ protected Fail() {} } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/FileAssert.java000066400000000000000000000211701243020563200261220ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 <<<<<<< HEAD * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. ======= * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2011-2012 the original author or authors. >>>>>>> refs/heads/github-71 */ package org.fest.assertions.api; import java.io.File; import java.nio.charset.Charset; import org.fest.assertions.internal.Files; import org.fest.util.FilesException; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@link File}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(File)}. *

* * @author David DIDIER * @author Yvonne Wang * @author Alex Ruiz * @author Olivier Michallat * @author Olivier Demeijer */ public class FileAssert extends AbstractAssert { @VisibleForTesting Files files = Files.instance(); @VisibleForTesting Charset charset = Charset.defaultCharset(); protected FileAssert(File actual) { super(actual, FileAssert.class); } /** * Verifies that the actual {@code File} exists, regardless it's a file or directory. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} does not exist. */ public FileAssert exists() { files.assertExists(info, actual); return this; } /** * Verifies that the actual {@code File} does not exist. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} exists. */ public FileAssert doesNotExist() { files.assertDoesNotExist(info, actual); return this; } /** * Verifies that the actual {@code File} is an existing file. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an existing file. */ public FileAssert isFile() { files.assertIsFile(info, actual); return this; } /** * Verifies that the actual {@code File} is an existing directory. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an existing file. */ public FileAssert isDirectory() { files.assertIsDirectory(info, actual); return this; } /** * Verifies that the actual {@code File} is an absolute path. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an absolute path. */ public FileAssert isAbsolute() { files.assertIsAbsolute(info, actual); return this; } /** * Verifies that the actual {@code File} is a relative path. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not a relative path. */ public FileAssert isRelative() { files.assertIsRelative(info, actual); return this; } /** * Verifies that the content of the actual {@code File} is equal to the content of the given one. * @param expected the given {@code File} to compare the actual {@code File} to. * @return {@code this} assertion object. * @throws NullPointerException if the given {@code File} is {@code null}. * @throws IllegalArgumentException if the given {@code File} is not an existing file. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the content of the actual {@code File} is not equal to the content of the given one. */ public FileAssert hasContentEqualTo(File expected) { files.assertEqualContent(info, actual, expected); return this; } /** * Verifies that the binary content of the actual {@code File} is exactly equal to the given one. * @param expected the expected binary content to compare the actual {@code File}'s content to. * @return {@code this} assertion object. * @throws NullPointerException if the given content is {@code null}. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the content of the actual {@code File} is not equal to the given binary content. */ public FileAssert hasBinaryContent(byte[] expected) { files.assertHasBinaryContent(info, actual, expected); return this; } /** * Specifies the name of the charset to use for text-based assertions on the file's contents. * * @param charsetName the name of the charset to use. * @return {@code this} assertion object. * @throws IllegalArgumentException if the given encoding is not supported on this platform. */ public FileAssert usingCharset(String charsetName) { if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(String.format("Charset:<'%s'> is not supported on this system", charsetName)); return usingCharset(Charset.forName(charsetName)); } /** * Specifies the charset to use for text-based assertions on the file's contents. * * @param charset the charset to use. * @return {@code this} assertion object. * @throws NullPointerException if the given charset is {@code null}. */ public FileAssert usingCharset(Charset charset) { if (charset == null) throw new NullPointerException("The charset should not be null"); this.charset = charset; return this; } /** * Verifies that the text content of the actual {@code File} is exactly equal to the given one.
* The charset to use when reading the file should be provided with {@link #usingCharset(Charset)} or * {@link #usingCharset(String)} prior to calling this method; if not, the platform's default charset (as returned by * {@link Charset#defaultCharset()}) will be used. * @param expected the expected text content to compare the actual {@code File}'s content to. * @return {@code this} assertion object. * @throws NullPointerException if the given content is {@code null}. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the content of the actual {@code File} is not equal to the given binary content. */ public FileAssert hasContent(String expected) { files.assertHasContent(info, actual, expected, charset); return this; } /** * * Verifies that the actual {@code File} can be modified by the application. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} can not be modified by the application. */ public FileAssert canWrite() { files.assertCanWrite(info, actual); return this; } /** * * Verifies that the actual {@code File} can be read by the application. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code File} is {@code null}. * @throws AssertionError if the actual {@code File} can not be read by the application. */ public FileAssert canRead() { files.assertCanRead(info, actual); return this; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/FloatArrayAssert.java000066400000000000000000000221571243020563200273150ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code float}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(float[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class FloatArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting FloatArrays arrays = FloatArrays.instance(); protected FloatArrayAssert(float[] actual) { super(actual, FloatArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public FloatArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public FloatArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public FloatArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public FloatArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public FloatArrayAssert contains(float... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public FloatArrayAssert containsOnly(float... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public FloatArrayAssert containsSequence(float... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public FloatArrayAssert contains(float value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public FloatArrayAssert doesNotContain(float... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public FloatArrayAssert doesNotContain(float value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public FloatArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(float...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public FloatArrayAssert startsWith(float... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(float...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public FloatArrayAssert endsWith(float... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public FloatArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public FloatArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public FloatArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new FloatArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public FloatArrayAssert usingDefaultElementComparator() { this.arrays = FloatArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/FloatAssert.java000066400000000000000000000150061243020563200263110ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.FloatingPointNumberAssert; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for floats. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Float)} or * {@link Assertions#assertThat(float)}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Ansgar Konermann * @author Mikhail Mazursky * @author Nicolas François */ public class FloatAssert extends AbstractComparableAssert implements FloatingPointNumberAssert { @VisibleForTesting Floats floats = Floats.instance(); protected FloatAssert(Float actual) { super(actual, FloatAssert.class); } /** {@inheritDoc} */ public FloatAssert isNaN() { floats.assertIsNaN(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isNotNaN() { floats.assertIsNotNaN(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isZero() { floats.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isNotZero() { floats.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isPositive() { floats.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isNegative() { floats.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isNotNegative() { floats.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public FloatAssert isNotPositive() { floats.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public FloatAssert isEqualTo(float expected) { floats.assertEqual(info, actual, expected); return this; } /** {@inheritDoc} */ public FloatAssert isEqualTo(Float expected, Offset offset) { floats.assertEqual(info, actual, expected, offset); return this; } /** * Verifies that the actual value is equal to the given one, within a positive offset. * @param expected the given value to compare the actual value to. * @param offset the given positive offset. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public FloatAssert isEqualTo(float expected, Offset offset) { floats.assertEqual(info, actual, expected, offset); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public FloatAssert isNotEqualTo(float other) { floats.assertNotEqual(info, actual, other); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public FloatAssert isLessThan(float other) { floats.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public FloatAssert isLessThanOrEqualTo(float other) { floats.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public FloatAssert isGreaterThan(float other) { floats.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public FloatAssert isGreaterThanOrEqualTo(float other) { floats.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public FloatAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.floats = new Floats(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public FloatAssert usingDefaultComparator() { super.usingDefaultComparator(); this.floats = Floats.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/InputStreamAssert.java000066400000000000000000000026651243020563200275260ustar00rootroot00000000000000package org.fest.assertions.api; import java.io.InputStream; import org.fest.assertions.internal.InputStreams; import org.fest.assertions.internal.InputStreamsException; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@link InputStream}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(InputStream)}. *

* @author Matthieu Baechler */ public class InputStreamAssert extends AbstractAssert { @VisibleForTesting InputStreams inputStreams = InputStreams.instance(); public InputStreamAssert(InputStream actual) { super(actual, InputStreamAssert.class); } /** * Verifies that the content of the actual {@code InputStream} is equal to the content of the given one. * * @param expected the given {@code InputStream} to compare the actual {@code InputStream} to. * @return {@code this} assertion object. * @throws NullPointerException if the given {@code InputStream} is {@code null}. * @throws AssertionError if the actual {@code InputStream} is {@code null}. * @throws AssertionError if the content of the actual {@code InputStream} is not equal to the content of the given one. * @throws InputStreamsException if an I/O error occurs. */ public InputStreamAssert hasContentEqualTo(InputStream expected) { inputStreams.assertEqualContent(info, actual, expected); return this; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/IntArrayAssert.java000066400000000000000000000220451243020563200267760ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code int}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(int[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class IntArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting IntArrays arrays = IntArrays.instance(); protected IntArrayAssert(int[] actual) { super(actual, IntArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public IntArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public IntArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public IntArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public IntArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public IntArrayAssert contains(int... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public IntArrayAssert containsOnly(int... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public IntArrayAssert containsSequence(int... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public IntArrayAssert contains(int value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public IntArrayAssert doesNotContain(int... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public IntArrayAssert doesNotContain(int value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public IntArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(int...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public IntArrayAssert startsWith(int... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(int...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public IntArrayAssert endsWith(int... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public IntArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public IntArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public IntArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new IntArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public IntArrayAssert usingDefaultElementComparator() { this.arrays = IntArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/IntegerAssert.java000066400000000000000000000130331243020563200266370ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.NumberAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for integers. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Integer)} or * {@link Assertions#assertThat(int)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class IntegerAssert extends AbstractComparableAssert implements NumberAssert { @VisibleForTesting Integers integers = Integers.instance(); protected IntegerAssert(Integer actual) { super(actual, IntegerAssert.class); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public IntegerAssert isEqualTo(int expected) { integers.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public IntegerAssert isNotEqualTo(int other) { integers.assertNotEqual(info, actual, other); return this; } /** {@inheritDoc} */ public IntegerAssert isZero() { integers.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public IntegerAssert isNotZero() { integers.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public IntegerAssert isPositive() { integers.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public IntegerAssert isNegative() { integers.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public IntegerAssert isNotNegative() { integers.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public IntegerAssert isNotPositive() { integers.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public IntegerAssert isLessThan(int other) { integers.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public IntegerAssert isLessThanOrEqualTo(int other) { integers.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public IntegerAssert isGreaterThan(int other) { integers.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public IntegerAssert isGreaterThanOrEqualTo(int other) { integers.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public IntegerAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.integers = new Integers(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public IntegerAssert usingDefaultComparator() { super.usingDefaultComparator(); this.integers = Integers.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/IterableAssert.java000066400000000000000000000023161243020563200267730ustar00rootroot00000000000000/* * Created on Jul 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * Assertion methods for {@link Iterable}. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Iterable)}. *

* @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Matthieu Baechler * @author Joel Costigliola * @author Mikhail Mazursky */ public class IterableAssert extends AbstractIterableAssert, Iterable, T> { protected IterableAssert(Iterable actual) { super(actual, IterableAssert.class); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ListAssert.java000066400000000000000000000150371243020563200261630ustar00rootroot00000000000000/* * Created on Oct 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import java.util.List; import org.fest.assertions.core.Condition; import org.fest.assertions.core.IndexedObjectEnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@link List}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(List)}. *

* @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky */ // TODO inherits from IterableAssert and remove AbstractIterableAssert ? public class ListAssert extends AbstractIterableAssert, List, T> implements IndexedObjectEnumerableAssert, T> { @VisibleForTesting Lists lists = Lists.instance(); protected ListAssert(List actual) { super(actual, ListAssert.class); } /** {@inheritDoc} */ public ListAssert contains(T value, Index index) { lists.assertContains(info, actual, value, index); return this; } /** {@inheritDoc} */ public ListAssert doesNotContain(T value, Index index) { lists.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual object at the given index in the actual group satisfies the given condition. * @param condition the given condition. * @param index the index where the object should be stored in the actual group. * @return this assertion object. * @throws AssertionError if the given {@code List} is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * {@code List}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the value in the given {@code List} at the given index does not satisfy the given {@code Condition} * . */ public ListAssert has(Condition condition, Index index) { lists.assertHas(info, actual, condition, index); return this; } /** * Verifies that the actual object at the given index in the actual group satisfies the given condition. * @param condition the given condition. * @param index the index where the object should be stored in the actual group. * @return this assertion object. * @throws AssertionError if the given {@code List} is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * {@code List}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the value in the given {@code List} at the given index does not satisfy the given {@code Condition} * . */ public ListAssert is(Condition condition, Index index) { lists.assertIs(info, actual, condition, index); return this; } /** * Verifies that the actual list is sorted into ascending order according to the natural ordering of its elements. *

* All list elements must implement the {@link Comparable} interface and must be mutually comparable (that is, e1.compareTo(e2) * must not throw a ClassCastException for any elements e1 and e2 in the list), examples : *

    *
  • a list composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
  • *
  • a list composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
  • *
  • a list composed of {True, "abc", False} is NOT ok because elements are not mutually comparable
  • *
* Empty lists are considered sorted.
Unique element lists are considered sorted unless the element type is not Comparable. * * @return {@code this} assertion object. * * @throws AssertionError if the actual list is not sorted into ascending order according to the natural ordering of its * elements. * @throws AssertionError if the actual list is null. * @throws AssertionError if the actual list element type does not implement {@link Comparable}. * @throws AssertionError if the actual list elements are not mutually {@link Comparable}. */ public ListAssert isSorted() { lists.assertIsSorted(info, actual); return this; } /** * Verifies that the actual list is sorted according to the given comparator.
Empty lists are considered sorted whatever * the comparator is.
One element lists are considered sorted if element is compatible with comparator. * * @param comparator the {@link Comparator} used to compare list elements * * @return {@code this} assertion object. * * @throws AssertionError if the actual list is not sorted according to the given comparator. * @throws AssertionError if the actual list is null. * @throws NullPointerException if the given comparator is null. * @throws AssertionError if the actual list elements are not mutually comparable according to given Comparator. */ public ListAssert isSortedAccordingTo(Comparator comparator) { lists.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } @Override public ListAssert usingElementComparator(Comparator customComparator) { super.usingElementComparator(customComparator); this.lists = new Lists(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public ListAssert usingDefaultElementComparator() { super.usingDefaultElementComparator(); this.lists = Lists.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/LongArrayAssert.java000066400000000000000000000221021243020563200271350ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code long}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(long[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class LongArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting LongArrays arrays = LongArrays.instance(); protected LongArrayAssert(long[] actual) { super(actual, LongArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public LongArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public LongArrayAssert contains(long... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public LongArrayAssert containsOnly(long... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public LongArrayAssert containsSequence(long... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public LongArrayAssert contains(long value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public LongArrayAssert doesNotContain(long... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public LongArrayAssert doesNotContain(long value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public LongArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(long...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public LongArrayAssert startsWith(long... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(long...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public LongArrayAssert endsWith(long... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public LongArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public LongArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public LongArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new LongArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public LongArrayAssert usingDefaultElementComparator() { this.arrays = LongArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/LongAssert.java000066400000000000000000000126411243020563200261450ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.NumberAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for longs. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Long)} or * {@link Assertions#assertThat(long)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class LongAssert extends AbstractComparableAssert implements NumberAssert { @VisibleForTesting Longs longs = Longs.instance(); protected LongAssert(Long actual) { super(actual, LongAssert.class); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public LongAssert isEqualTo(long expected) { longs.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public LongAssert isNotEqualTo(long other) { longs.assertNotEqual(info, actual, other); return this; } /** {@inheritDoc} */ public LongAssert isZero() { longs.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public LongAssert isNotZero() { longs.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public LongAssert isPositive() { longs.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public LongAssert isNegative() { longs.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public LongAssert isNotNegative() { longs.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public LongAssert isNotPositive() { longs.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public LongAssert isLessThan(long other) { longs.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public LongAssert isLessThanOrEqualTo(long other) { longs.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public LongAssert isGreaterThan(long other) { longs.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public LongAssert isGreaterThanOrEqualTo(long other) { longs.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public LongAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.longs = new Longs(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public LongAssert usingDefaultComparator() { super.usingDefaultComparator(); this.longs = Longs.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/MapAssert.java000066400000000000000000000125611243020563200257640ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import java.util.Map; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.MapEntry; import org.fest.assertions.internal.Maps; import org.fest.util.VisibleForTesting; /** * Assertions for {@link Map}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(Map)}. *

* * @author David DIDIER * @author Yvonne Wang * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class MapAssert extends AbstractAssert, Map> implements EnumerableAssert, MapEntry> { @VisibleForTesting Maps maps = Maps.instance(); protected MapAssert(Map actual) { super(actual, MapAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { maps.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { maps.assertEmpty(info, actual); } /** {@inheritDoc} */ public MapAssert isNotEmpty() { maps.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public MapAssert hasSize(int expected) { maps.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public MapAssert hasSameSizeAs(Object[] other) { maps.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public MapAssert hasSameSizeAs(Iterable other) { maps.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual map contains the given entries, in any order. * @param entries the given entries. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws NullPointerException if any of the entries in the given array is {@code null}. * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map does not contain the given entries. */ public MapAssert contains(MapEntry... entries) { maps.assertContains(info, actual, entries); return this; } /** * Verifies that the actual map does not contain the given entries. * @param entries the given entries. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map contains any of the given entries. */ public MapAssert doesNotContain(MapEntry... entries) { maps.assertDoesNotContain(info, actual, entries); return this; } /** * Verifies that the actual map contains the given key. * @param key the given key * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map does not contain the given key. */ public MapAssert containsKey(K key) { maps.assertContainsKey(info, actual, key); return this; } /** * Verifies that the actual map does not contain the given key. * @param key the given key * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map contains the given key. */ public MapAssert doesNotContainKey(K key) { maps.assertDoesNotContainKey(info, actual, key); return this; } /** * Verifies that the actual map contains the given value. * @param value the value to look for. * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map does not contain the given value. */ public MapAssert containsValue(V value) { maps.assertContainsValue(info, actual, value); return this; } /** * Verifies that the actual map does not contain the given value. * @param value the value that should not be in actual map. * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map contains the given value. */ public MapAssert doesNotContainValue(V value) { maps.assertDoesNotContainValue(info, actual, value); return this; } /** {@inheritDoc} */ public MapAssert usingElementComparator(Comparator customComparator) { throw new UnsupportedOperationException("custom element Comparator is not supported for MapEntry comparison"); } /** {@inheritDoc} */ public MapAssert usingDefaultElementComparator() { throw new UnsupportedOperationException("custom element Comparator is not supported for MapEntry comparison"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ObjectArrayAssert.java000066400000000000000000000201231243020563200274450ustar00rootroot00000000000000/* * Created on Jul 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.IndexedObjectEnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of objects. *

* To create an instance of this class, invoke {@link Assertions#assertThat(T[])}. *

* @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert extends AbstractAssert, T[]> implements IndexedObjectEnumerableAssert, T>, ArraySortedAssert, T> { @VisibleForTesting ObjectArrays arrays = ObjectArrays.instance(); protected ObjectArrayAssert(T[] actual) { super(actual, ObjectArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public ObjectArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public ObjectArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public ObjectArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public ObjectArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public ObjectArrayAssert contains(T... values) { arrays.assertContains(info, actual, values); return this; } /** {@inheritDoc} */ public ObjectArrayAssert containsOnly(T... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** {@inheritDoc} */ public ObjectArrayAssert containsExactly(T... values) { objects.assertEqual(info, actual, values); return this; }; /** {@inheritDoc} */ public ObjectArrayAssert containsSequence(T... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** {@inheritDoc} */ public ObjectArrayAssert contains(T value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** {@inheritDoc} */ public ObjectArrayAssert doesNotContain(T value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** {@inheritDoc} */ public ObjectArrayAssert doesNotContain(T... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** {@inheritDoc} */ public ObjectArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** {@inheritDoc} */ public ObjectArrayAssert startsWith(T... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public ObjectArrayAssert endsWith(T... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public ObjectArrayAssert containsNull() { arrays.assertContainsNull(info, actual); return this; } /** {@inheritDoc} */ public ObjectArrayAssert doesNotContainNull() { arrays.assertDoesNotContainNull(info, actual); return this; } /** {@inheritDoc} */ public ObjectArrayAssert are(Condition condition) { arrays.assertAre(info, actual, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areNot(Condition condition) { arrays.assertAreNot(info, actual, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert have(Condition condition) { arrays.assertHave(info, actual, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert doNotHave(Condition condition) { arrays.assertDoNotHave(info, actual, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areAtLeast(int times, Condition condition) { arrays.assertAreAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areNotAtLeast(int times, Condition condition) { arrays.assertAreNotAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areAtMost(int times, Condition condition) { arrays.assertAreAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areNotAtMost(int times, Condition condition) { arrays.assertAreNotAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areExactly(int times, Condition condition) { arrays.assertAreExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert areNotExactly(int times, Condition condition) { arrays.assertAreNotExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert haveAtLeast(int times, Condition condition) { arrays.assertHaveAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert doNotHaveAtLeast(int times, Condition condition) { arrays.assertDoNotHaveAtLeast(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert haveAtMost(int times, Condition condition) { arrays.assertHaveAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert doNotHaveAtMost(int times, Condition condition) { arrays.assertDoNotHaveAtMost(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert haveExactly(int times, Condition condition) { arrays.assertHaveExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert doNotHaveExactly(int times, Condition condition) { arrays.assertDoNotHaveExactly(info, actual, times, condition); return myself; } /** {@inheritDoc} */ public ObjectArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public ObjectArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public ObjectArrayAssert containsAll(Iterable iterable) { arrays.assertContainsAll(info, actual, iterable); return this; } public ObjectArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new ObjectArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } public ObjectArrayAssert usingDefaultElementComparator() { this.arrays = ObjectArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ObjectAssert.java000066400000000000000000000154451243020563200264610ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import org.fest.util.IntrospectionError; /** * Assertion methods for {@code Object}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(Object)}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectAssert extends AbstractAssert, T> { protected ObjectAssert(T actual) { super(actual, ObjectAssert.class); } /** * Assert that the actual object is lenient equals to given one by comparing only actual and not null other * fields (including inherited fields). *

* It means that if an actual field is not null and the corresponding field in other is null, field will be ignored by * lenient comparison, but the inverse will make assertion fail (null field in actual, not null in other). * *

   * Example: 
   * 
   * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT); 
   * TolkienCharacter mysteriousHobbit = new TolkienCharacter(null, 33, HOBBIT); 
   * 
   * // Null fields in other/expected object are ignored, the mysteriousHobbit has null name thus name is ignored
   * assertThat(frodo).isLenientEqualsToByIgnoringNullFields(mysteriousHobbit); //=> OK
   * 
   * // ... but the lenient equality is not reversible !
   * assertThat(mysteriousHobbit).isLenientEqualsToByIgnoringNullFields(frodo); //=> FAIL
   * 
   * 
* * @param other the object to compare {@code actual} to. * @throws NullPointerException if the actual type is {@code null}. * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. */ public ObjectAssert isLenientEqualsToByIgnoringNullFields(T other) { objects.assertIsLenientEqualsToByIgnoringNullFields(info, actual, other); return this; } /** * Assert that the actual object is lenient equals to given one by only comparing actual and other on the given * "accepted" fields only ("accepted" fields can be inherited fields). *

* Example: * *

   * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);
   * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT);
   * 
   * // frodo and sam both are hobbits, so they are lenient equals on race
   * assertThat(frodo).isLenientEqualsToByAcceptingFields(sam, "race"); // => OK
   * 
   * // ... but not when accepting name and race
   * assertThat(frodo).isLenientEqualsToByAcceptingFields(sam, "name", "race"); // => FAIL
   * 
   * 
* * @param other the object to compare {@code actual} to. * @param fields accepted fields for lenient equality. * @throws NullPointerException if the actual type is {@code null}. * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. * @throws IntrospectionError if a field does not exist in actual. */ public ObjectAssert isLenientEqualsToByAcceptingFields(T other, String... fields) { objects.assertIsLenientEqualsToByAcceptingFields(info, actual, other, fields); return this; } /** * Assert that the actual object is lenient equals to given one by comparing actual and other fields (including * inherited fields) except the given "ignored" fields. * *
   * Example: 
   * 
   * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT); 
   * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT); 
   * 
   * // frodo and sam both are lenient equals ignoring name and age since only remaining property is race and frodo and sam both are HOBBIT
   * assertThat(frodo).isLenientEqualsToByIgnoringFields(sam, "name", "age"); //=> OK
   * 
   * // ... but they are not lenient equals if only age is ignored because their names differ.
   * assertThat(frodo).isLenientEqualsToByIgnoringFields(sam, "age"); //=> FAIL
   * 
   * 
* * @param other the object to compare {@code actual} to. * @param fields ignored fields for lenient equality. * @throws NullPointerException if the actual type is {@code null}. * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. */ public ObjectAssert isLenientEqualsToByIgnoringFields(T other, String... fields) { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other, fields); return this; } /** * Assert that the actual object is equals fields by fields to another object, inherited fields are taken into * account. *

* This can be handy if equals implementation of objects to compare does not suit you. * *

   * Example: 
   * 
   * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT); 
   * TolkienCharacter frodoClone = new TolkienCharacter("Frodo", 33, HOBBIT); 
   * 
   * // Fail if equals has not been overriden in TolkienCharacter as equals default implementation only compares references 
   * assertThat(frodo).isEqualsTo(frodoClone); // Fail if equals has not been overriden in TolkienCharacter 
   * 
   * // frodo and frodoClone are equals by comparing fields
   * assertThat(frodo).isEqualsToByComparingFields(frodoClone); // OK
   * 
   * 
* * @param other the object to compare {@code actual} to. * @throws NullPointerException if the actual type is {@code null}. * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if the actual and the given object are not equals fields by fields. * @throws AssertionError if the other object is not an instance of the actual type. */ public ObjectAssert isEqualsToByComparingFields(T other) { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other); return this; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ShortArrayAssert.java000066400000000000000000000221571243020563200273470ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for arrays of {@code short}s. *

* To create an instance of this class, invoke {@link Assertions#assertThat(short[])}. *

* * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class ShortArrayAssert extends AbstractAssert implements EnumerableAssert, ArraySortedAssert { @VisibleForTesting ShortArrays arrays = ShortArrays.instance(); protected ShortArrayAssert(short[] actual) { super(actual, ShortArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public ShortArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public ShortArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public ShortArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public ShortArrayAssert hasSameSizeAs(Iterable other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public ShortArrayAssert contains(short... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some or none of * the given values, or the actual array contains more values than the given ones. */ public ShortArrayAssert containsOnly(short... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between them. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public ShortArrayAssert containsSequence(short... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public ShortArrayAssert contains(short value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public ShortArrayAssert doesNotContain(short... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public ShortArrayAssert doesNotContain(short value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public ShortArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(short...)}, but it also verifies that the first element in the sequence is also first * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public ShortArrayAssert startsWith(short... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to * {@link #containsSequence(short...)}, but it also verifies that the last element in the sequence is also last * element of the actual array. * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public ShortArrayAssert endsWith(short... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public ShortArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public ShortArrayAssert isSortedAccordingTo(Comparator comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public ShortArrayAssert usingElementComparator(Comparator customComparator) { this.arrays = new ShortArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public ShortArrayAssert usingDefaultElementComparator() { this.arrays = ShortArrays.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ShortAssert.java000066400000000000000000000126661243020563200263540ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import org.fest.assertions.core.NumberAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for shorts. *

* To create an instance of this class, invoke {@link Assertions#assertThat(Short)} or * {@link Assertions#assertThat(short)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Ansgar Konermann * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class ShortAssert extends AbstractComparableAssert implements NumberAssert { @VisibleForTesting Shorts shorts = Shorts.instance(); protected ShortAssert(Short actual) { super(actual, ShortAssert.class); } /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ public ShortAssert isEqualTo(short expected) { shorts.assertEqual(info, actual, expected); return this; } /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ public ShortAssert isNotEqualTo(short other) { shorts.assertNotEqual(info, actual, other); return this; } /** {@inheritDoc} */ public ShortAssert isZero() { shorts.assertIsZero(info, actual); return this; } /** {@inheritDoc} */ public ShortAssert isNotZero() { shorts.assertIsNotZero(info, actual); return this; } /** {@inheritDoc} */ public ShortAssert isPositive() { shorts.assertIsPositive(info, actual); return this; } /** {@inheritDoc} */ public ShortAssert isNegative() { shorts.assertIsNegative(info, actual); return this; } /** {@inheritDoc} */ public ShortAssert isNotNegative() { shorts.assertIsNotNegative(info, actual); return this; } /** {@inheritDoc} */ public ShortAssert isNotPositive() { shorts.assertIsNotPositive(info, actual); return this; } /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ public ShortAssert isLessThan(short other) { shorts.assertLessThan(info, actual, other); return this; } /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ public ShortAssert isLessThanOrEqualTo(short other) { shorts.assertLessThanOrEqualTo(info, actual, other); return this; } /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ public ShortAssert isGreaterThan(short other) { shorts.assertGreaterThan(info, actual, other); return this; } /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ public ShortAssert isGreaterThanOrEqualTo(short other) { shorts.assertGreaterThanOrEqualTo(info, actual, other); return this; } @Override public ShortAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.shorts = new Shorts(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public ShortAssert usingDefaultComparator() { super.usingDefaultComparator(); this.shorts = Shorts.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/StringAssert.java000066400000000000000000000222471243020563200265170ustar00rootroot00000000000000/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Comparator; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.fest.assertions.core.EnumerableAssert; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@code String}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(String)}. *

* * @author Yvonne Wang * @author David DIDIER * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas Francois */ public class StringAssert extends AbstractAssert implements EnumerableAssert { @VisibleForTesting Strings strings = Strings.instance(); protected StringAssert(String actual) { super(actual, StringAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { strings.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { strings.assertEmpty(info, actual); } /** {@inheritDoc} */ public StringAssert isNotEmpty() { strings.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public StringAssert hasSize(int expected) { strings.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public StringAssert hasSameSizeAs(Object[] other) { strings.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public StringAssert hasSameSizeAs(Iterable other) { strings.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual {@code String} is equal to the given one, ignoring case considerations. * @param expected the given {@code String} to compare the actual {@code String} to. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code String} is not equal to the given one. */ public StringAssert isEqualToIgnoringCase(String expected) { strings.assertEqualsIgnoringCase(info, actual, expected); return this; } /** * Verifies that the actual {@code String} contains only once the given sequence. * * @param sequence the sequence to search for. * @return {@code this} assertion object. * @throws AssertionError if the actual {@code String} does not contain the given one, or contain it multiple times. */ public StringAssert containsOnlyOnce(String sequence) { strings.assertContainsOnlyOnce(info, actual, sequence); return this; } /** * Verifies that the actual {@code String} contains the given sequence. * * @param sequence the sequence to search for. * @return {@code this} assertion object. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not contain the given one. */ public StringAssert contains(String sequence) { strings.assertContains(info, actual, sequence); return this; } /** * Verifies that the actual {@code String} contains the given sequence, ignoring case considerations. * @param sequence the sequence to search for. * @return {@code this} assertion object. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not contain the given one. */ public StringAssert containsIgnoringCase(String sequence) { strings.assertContainsIgnoringCase(info, actual, sequence); return this; } /** * Verifies that the actual {@code String} does not contain the given sequence. * @param sequence the sequence to search for. * @return {@code this} assertion object. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} contains the given one. */ public StringAssert doesNotContain(String sequence) { strings.assertDoesNotContain(info, actual, sequence); return this; } /** * Verifies that the actual {@code String} starts with the given prefix. * @param prefix the given prefix. * @return {@code this} assertion object. * @throws NullPointerException if the given prefix is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not start with the given prefix. */ public StringAssert startsWith(String prefix) { strings.assertStartsWith(info, actual, prefix); return this; } /** * Verifies that the actual {@code String} ends with the given suffix. * @param suffix the given suffix. * @return {@code this} assertion object. * @throws NullPointerException if the given suffix is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not end with the given suffix. */ public StringAssert endsWith(String suffix) { strings.assertEndsWith(info, actual, suffix); return this; } /** * Verifies that the actual {@code String} matches the given regular expression. * @param regex the regular expression to which the actual {@code String} is to be matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws PatternSyntaxException if the regular expression's syntax is invalid. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not match the given regular expression. */ public StringAssert matches(String regex) { strings.assertMatches(info, actual, regex); return this; } /** * Verifies that the actual {@code String} does not match the given regular expression. * @param regex the regular expression to which the actual {@code String} is to be matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws PatternSyntaxException if the regular expression's syntax is invalid. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} matches the given regular expression. */ public StringAssert doesNotMatch(String regex) { strings.assertDoesNotMatch(info, actual, regex); return this; } /** * Verifies that the actual {@code String} matches the given regular expression. * @param pattern the regular expression to which the actual {@code String} is to be matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws AssertionError if the actual {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not match the given regular expression. */ public StringAssert matches(Pattern pattern) { strings.assertMatches(info, actual, pattern); return this; } /** * Verifies that the actual {@code String} does not match the given regular expression. * @param pattern the regular expression to which the actual {@code String} is to be matched. * @return {@code this} assertion object. * @throws NullPointerException if the given pattern is {@code null}. * @throws AssertionError if the actual {@code String} does not match the given regular expression. */ public StringAssert doesNotMatch(Pattern pattern) { strings.assertDoesNotMatch(info, actual, pattern); return this; } /** {@inheritDoc} */ public StringAssert usingElementComparator(Comparator customComparator) { // TODO maybe use Comparator throw new UnsupportedOperationException("custom element Comparator is not supported for String comparison"); } /** {@inheritDoc} */ public StringAssert usingDefaultElementComparator() { throw new UnsupportedOperationException("custom element Comparator is not supported for String comparison"); } @Override public StringAssert usingComparator(Comparator customComparator) { super.usingComparator(customComparator); this.strings = new Strings(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } @Override public StringAssert usingDefaultComparator() { super.usingDefaultComparator(); this.strings = Strings.instance(); return myself; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/ThrowableAssert.java000066400000000000000000000077261243020563200272050ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this Throwable except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import org.fest.assertions.internal.Throwables; import org.fest.util.VisibleForTesting; /** * Assertion methods for {@link Throwable}s. *

* To create a new instance of this class, invoke {@link Assertions#assertThat(Throwable)}. *

* * @author David DIDIER * @author Alex Ruiz * @author Joel Costigliola */ public class ThrowableAssert extends AbstractAssert { @VisibleForTesting Throwables throwables = Throwables.instance(); protected ThrowableAssert(Throwable actual) { super(actual, ThrowableAssert.class); } /** * Verifies that the message of the actual {@code Throwable} is equal to the given one. * @param message the expected message. * @return this assertion object. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} is not equal to the given one. */ public ThrowableAssert hasMessage(String message) { throwables.assertHasMessage(info, actual, message); return this; } /** * Verifies that the actual {@code Throwable} does not have a cause. * @return this assertion object. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has a cause. */ public ThrowableAssert hasNoCause() { throwables.assertHasNoCause(info, actual); return this; } /** * Verifies that the message of the actual {@code Throwable} starts with the given description. * @param description the description expected to start the actual {@code Throwable}'s message. * @return this assertion object. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not start with the given description. */ public ThrowableAssert hasMessageStartingWith(String description) { throwables.assertHasMessageStartingWith(info, actual, description); return this; } /** * Verifies that the message of the actual {@code Throwable} contains with the given description. * @param description the description expected to be contained in the actual {@code Throwable}'s message. * @return this assertion object. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not contain the given description. */ public ThrowableAssert hasMessageContaining(String description) { throwables.assertHasMessageContaining(info, actual, description); return this; } /** * Verifies that the message of the actual {@code Throwable} ends with the given description. * @param description the description expected to end the actual {@code Throwable}'s message. * @return this assertion object. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not end with the given description. */ public ThrowableAssert hasMessageEndingWith(String description) { throwables.assertHasMessageEndingWith(info, actual, description); return this; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/api/filter/000077500000000000000000000000001243020563200245025ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/api/filter/Filters.java000066400000000000000000000405711243020563200267640ustar00rootroot00000000000000/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.filter; import static org.fest.util.Lists.newArrayList; import static org.fest.util.Objects.areEqual; import java.util.ArrayList; import java.util.List; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.PropertySupport; import org.fest.util.IntrospectionError; import org.fest.util.VisibleForTesting; /** * Filters the elements of a given {@link Iterable} or array according to the specified filter criteria. *

* Filter criteria can be expressed either by a {@link Condition} or a pseudo filter language on elements properties. *

* Note that the given {@link Iterable} or array is not modified, the filters are performed on a copy. *

* With {@link Condition} : * *

 * List<Player> players = ...; 
 *   
 * Condition<Player> potentialMVP = new Condition<Player>("is a possible MVP"){
 *   public boolean matches(Player player) {
 *     return player.getPointsPerGame() > 20 && player.getAssistsPerGame() > 7;
 *   };
 * };
 * 
 * // use filter static method to build Filters
 * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose)
 * 
* * With pseudo filter language on element properties : * *
 * assertThat(filter(players).with("pointsPerGame").greaterThan(20)
 *                           .and("assistsPerGame").greaterThan(7)
 *                           .get()).containsOnly(james, rose);
* * @param the type of element of group to filter. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class Filters { // initialIterable is never modified, it represents the group before any filters have been performed @VisibleForTesting final Iterable initialIterable; Iterable filteredIterable; private PropertySupport propertySupport = PropertySupport.instance(); /** * The name of the property used for filtering. */ private String propertyNameToFilterOn; /** * Creates a new {@link Filters} with the {@link Iterable} to filter. *

* Chain this call to express filter criteria either by a {@link Condition} or a pseudo filter language on elements properties. *

* Note that the given {@link Iterable} is not modified, the filters are performed on a copy. *

* - With {@link Condition} : * *

   * List<Player> players = ...; 
   *   
   * Condition<Player> potentialMVP = new Condition<Player>("is a possible MVP"){
   *   public boolean matches(Player player) {
   *     return player.getPointsPerGame() > 20 && player.getAssistsPerGame() > 7;
   *   };
   * };
   * 
   * // use filter static method to build Filters
   * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose)
   * 
* * - With pseudo filter language on element properties : * *
   * assertThat(filter(players).with("pointsPerGame").greaterThan(20)
   *                           .and("assistsPerGame").greaterThan(7).get())
   *                           .containsOnly(james, rose);
* * @param iterable the {@code Iterable} to filter. * @throws NullPointerException if the given iterable is {@code null}. * @return the created {@link Filters}. */ public static Filters filter(Iterable iterable) { if (iterable == null) throw new NullPointerException("The iterable to filter should not be null"); return new Filters(iterable); } /** * Creates a new {@link Filters} with the array to filter. *

* Chain this call to express filter criteria either by a {@link Condition} or a pseudo filter language on elements properties. *

* Note that the given array is not modified, the filters are performed on an {@link Iterable} copy of the array. *

* With {@link Condition} : * *

   * List<Player> players = ...; 
   *   
   * Condition<Player> potentialMVP = new Condition<Player>("is a possible MVP"){
   *   public boolean matches(Player player) {
   *     return player.getPointsPerGame() > 20 && player.getAssistsPerGame() > 7;
   *   };
   * };
   * 
   * // use filter static method to build Filters
   * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);
   * 
* * With pseudo filter language on element properties : * *
   * assertThat(filter(players).with("pointsPerGame").greaterThan(20)
   *                           .and("assistsPerGame").greaterThan(7)
   *                           .get()).containsOnly(james, rose);
* @param array the array to filter. * @throws NullPointerException if the given array is {@code null}. * @return the created {@link Filters}. */ public static Filters filter(E[] array) { if (array == null) throw new NullPointerException("The array to filter should not be null"); return new Filters(array); } @VisibleForTesting Filters(Iterable iterable) { this.initialIterable = iterable; // copy list to avoid modifying iterable this.filteredIterable = newArrayList(iterable); } @VisibleForTesting Filters(E[] array) { List iterable = new ArrayList(array.length); for (int i = 0; i < array.length; i++) { iterable.add(array[i]); } this.initialIterable = iterable; // copy list to avoid modifying iterable this.filteredIterable = newArrayList(iterable); } /** * Filter the underlying group, keeping only elements satisfying the given {@link Condition}.
* Same as {@link #having(Condition)} - pick the method you prefer to have the most readable code. * *
   * List<Player> players = ...; 
   *   
   * Condition<Player> potentialMVP = new Condition<Player>("is a possible MVP") {
   *   public boolean matches(Player player) {
   *     return player.getPointsPerGame() > 20 && player.getAssistsPerGame() > 7;
   *   };
   * };
   * 
   * // use filter static method to build Filters
   * assertThat(filter(players).being(potentialMVP).get()).containsOnly(james, rose);
* * @param condition the filter {@link Condition}. * @return this {@link Filters} to chain other filter operations. * @throws NullPointerException if the given condition is {@code null}. */ public Filters being(Condition condition) { if (condition == null) throw new NullPointerException("The filter condition should not be null"); return applyFilterCondition(condition); } /** * Filter the underlying group, keeping only elements satisfying the given {@link Condition}.
* Same as {@link #being(Condition)} - pick the method you prefer to have the most readable code. * *
   * List<Player> players = ...; 
   *   
   * Condition<Player> mvpStats = new Condition<Player>("is a possible MVP") {
   *   public boolean matches(Player player) {
   *     return player.getPointsPerGame() > 20 && player.getAssistsPerGame() > 7;
   *   };
   * };
   * 
   * // use filter static method to build Filters
   * assertThat(filter(players).having(mvpStats).get()).containsOnly(james, rose);
* * @param condition the filter {@link Condition}. * @return this {@link Filters} to chain other filter operations. * @throws NullPointerException if the given condition is {@code null}. */ public Filters having(Condition condition) { if (condition == null) throw new NullPointerException("The filter condition should not be null"); return applyFilterCondition(condition); } private Filters applyFilterCondition(Condition condition) { List newFilteredIterable = new ArrayList(); for (E element : filteredIterable) { if (condition.matches(element)) { newFilteredIterable.add(element); } } this.filteredIterable = newFilteredIterable; return this; } /** * Filter the underlying group, keeping only elements with a property equals to given value. *

* Let's, for example, filter Employees with name "Alex" : * *

   * filter(employees).with("name", "Alex").get();
   * 
* which is shortcut of : * *
   * filter(employees).with("name").equalsTo("Alex").get();
   * 
* * @param propertyName the name of the property whose value will compared to given value. It may be a nested property. * @param propertyValue the expected property value. * @return this {@link Filters} to chain other filter operations. * @throws IntrospectionError if an element in the given {@code Iterable} does not have a property with a given propertyName. * @throws NullPointerException if the given propertyName is {@code null}. */ public Filters with(String propertyName, Object propertyValue) { if (propertyName == null) throw new NullPointerException("The property name to filter on should not be null"); propertyNameToFilterOn = propertyName; return equalsTo(propertyValue); } /** * Sets the name of the property used for filtering, it may be a nested property like "adress.street.name". *

* The typical usage is to chain this call with a comparison method, for example : * *

   * filter(employees).with("name").equalsTo("Alex").get();
   * 
* * @param propertyName the name of the property used for filtering. It may be a nested property. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the given propertyName is {@code null}. */ public Filters with(String propertyName) { if (propertyName == null) throw new NullPointerException("The property name to filter on should not be null"); propertyNameToFilterOn = propertyName; return this; } /** * Alias of {@link #with(String)} for synthetic sugar to write things like :. * *
   * filter(employees).with("name").equalsTo("Alex").and("job").notEqualsTo("lawyer").get();
   * 
* * @param propertyName the name of the property used for filtering. It may be a nested property. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the given propertyName is {@code null}. */ public Filters and(String propertyName) { return with(propertyName); } /** * Filters the underlying iterable to keep object with property (specified by {@link #with(String)}) equals to given * value. *

* Typical usage : * *

   * filter(employees).with("name").equalsTo("Luke").get();
   * 
* * @param propertyValue the filter value. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the property name to filter on has not been set. */ public Filters equalsTo(Object propertyValue) { checkPropertyNameToFilterOnIsNotNull(); List newFilteredIterable = new ArrayList(); for (E element : filteredIterable) { // As we don't know the propertyValue class, we use Object.class Class propertyValueClass = propertyValue == null ? Object.class : propertyValue.getClass(); Object propertyValueOfCurrentElement = propertySupport.propertyValueOf(propertyNameToFilterOn, propertyValueClass, element); if (areEqual(propertyValueOfCurrentElement, propertyValue)) { newFilteredIterable.add(element); } } this.filteredIterable = newFilteredIterable; return this; } /** * Filters the underlying iterable to keep object with property (specified by {@link #with(String)}) not equals to given * value. *

* Typical usage : * *

   * filter(employees).with("name").notEqualsTo("Vader").get();
   * 
* * @param propertyValue the filter value. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the property name to filter on has not been set. */ public Filters notEqualsTo(Object propertyValue) { checkPropertyNameToFilterOnIsNotNull(); List newFilteredIterable = new ArrayList(); for (E element : filteredIterable) { Object propertyValueOfCurrentElement = propertySupport.propertyValueOf(propertyNameToFilterOn, propertyValue.getClass(), element); if (!areEqual(propertyValueOfCurrentElement, propertyValue)) { newFilteredIterable.add(element); } } this.filteredIterable = newFilteredIterable; return this; } private void checkPropertyNameToFilterOnIsNotNull() { if (propertyNameToFilterOn == null) throw new NullPointerException("The property name to filter on has not been set - no filtering is possible"); } /** * Filters the underlying iterable to keep object with property (specified by {@link #with(String)}) equals to one of the * given values. *

* Typical usage : * *

   * filter(players).with("team").in("Bulls", "Lakers").get();
   * 
* * @param propertyValues the filter values. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the property name to filter on has not been set. */ public Filters in(Object... propertyValues) { checkPropertyNameToFilterOnIsNotNull(); List newFilteredIterable = new ArrayList(); for (E element : filteredIterable) { Object propertyValueOfCurrentElement = propertySupport.propertyValueOf(propertyNameToFilterOn, propertyValues.getClass() .getComponentType(), element); if (isItemInArray(propertyValueOfCurrentElement, propertyValues)) { newFilteredIterable.add(element); } } this.filteredIterable = newFilteredIterable; return this; } /** * Filters the underlying iterable to keep object with property (specified by {@link #with(String)}) not in the given * values. *

* Typical usage : * *

   * filter(players).with("team").notIn("Heat", "Lakers").get();
   * 
* * @param propertyValues the filter values. * @return this {@link Filters} to chain other filter operation. * @throws NullPointerException if the property name to filter on has not been set. */ public Filters notIn(Object... propertyValues) { checkPropertyNameToFilterOnIsNotNull(); List newFilteredIterable = new ArrayList(); for (E element : filteredIterable) { Object propertyValueOfCurrentElement = propertySupport.propertyValueOf(propertyNameToFilterOn, propertyValues.getClass() .getComponentType(), element); if (!isItemInArray(propertyValueOfCurrentElement, propertyValues)) { newFilteredIterable.add(element); } } this.filteredIterable = newFilteredIterable; return this; } /** * Returns true if given item is in given array, false otherwise. * @param item the object to look for in arrayOfValues * @param arrayOfValues the array of values * @return true if given item is in given array, false otherwise. */ private static boolean isItemInArray(Object item, Object[] arrayOfValues) { for (Object value : arrayOfValues) if (areEqual(value, item)) return true; return false; } /** * Returns the resulting filtered Iterable<E> (even if the constructor parameter type was an array). * @return the Iterable<E> containing the filtered elements. */ public Iterable get() { return filteredIterable; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/000077500000000000000000000000001243020563200244325ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/AllOf.java000066400000000000000000000046111243020563200262740ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import org.fest.assertions.core.Condition; /** * Returns {@code true} if all of the joined conditions is satisfied. * @param the type of object this condition accepts. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class AllOf extends Join { /** * Creates a new {@link AllOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given array is {@code null}. * @throws NullPointerException if any of the elements in the given array is {@code null}. */ public static Condition allOf(Condition... conditions) { return new AllOf(conditions); } /** * Creates a new {@link AllOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given iterable is {@code null}. * @throws NullPointerException if any of the elements in the given iterable is {@code null}. */ public static Condition allOf(Iterable> conditions) { return new AllOf(conditions); } private AllOf(Condition... conditions) { super(conditions); } private AllOf(Iterable> conditions) { super(conditions); } /** {@inheritDoc} */ @Override public boolean matches(T value) { for (Condition condition : conditions) if (!condition.matches(value)) return false; return true; } @Override public String toString() { return String.format("all of:<%s>", conditions); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/AnyOf.java000066400000000000000000000046101243020563200263120ustar00rootroot00000000000000/* * Created on Feb 5, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import org.fest.assertions.core.Condition; /** * Returns {@code true} if any of the joined conditions is satisfied. * @param the type of object this condition accepts. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class AnyOf extends Join { /** * Creates a new {@link AnyOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given array is {@code null}. * @throws NullPointerException if any of the elements in the given array is {@code null}. */ public static Condition anyOf(Condition... conditions) { return new AnyOf(conditions); } /** * Creates a new {@link AnyOf} * @param the type of object the given condition accept. * @param conditions the conditions to evaluate. * @return the created {@code AnyOf}. * @throws NullPointerException if the given iterable is {@code null}. * @throws NullPointerException if any of the elements in the given iterable is {@code null}. */ public static Condition anyOf(Iterable> conditions) { return new AnyOf(conditions); } private AnyOf(Condition... conditions) { super(conditions); } private AnyOf(Iterable> conditions) { super(conditions); } /** {@inheritDoc} */ @Override public boolean matches(T value) { for (Condition condition : conditions) if (condition.matches(value)) return true; return false; } @Override public String toString() { return String.format("any of:<%s>", conditions); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/DoesNotHave.java000066400000000000000000000026561243020563200274650ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.condition; import org.fest.assertions.core.Condition; /** * Returns {@code true} if the condition is not satisfied. * * @author Nicolas François * @author Joel Costigliola * @author Mikhail Mazursky */ public class DoesNotHave extends Negative { /** * Creates a new {@link DoesNotHave}. * * @param condition the condition to inverse. * @return The Not condition created. */ public static DoesNotHave doesNotHave(Condition condition) { return new DoesNotHave(condition); } private DoesNotHave(Condition condition) { super(condition); } @Override public String toString() { return String.format("does not have :<%s>", condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/Join.java000066400000000000000000000054001243020563200261730ustar00rootroot00000000000000/* * Created on Feb 6, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static java.util.Collections.unmodifiableCollection; import java.util.*; import org.fest.assertions.core.Condition; import org.fest.util.VisibleForTesting; /** * Join of two or more {@link Condition}s. * @param the type of object this condition accepts. * * @author Yvonne Wang * @author Mikhail Mazursky */ public abstract class Join extends Condition { @VisibleForTesting final Collection> conditions; /** * Creates a new {@link Join}. * @param conditions the conditions to join. * @throws NullPointerException if the given array is {@code null}. * @throws NullPointerException if any of the elements in the given array is {@code null}. */ protected Join(Condition... conditions) { if (conditions == null) throw conditionsIsNull(); this.conditions = new ArrayList>(); for (Condition condition : conditions) this.conditions.add(notNull(condition)); } /** * Creates a new {@link Join}. * @param conditions the conditions to join. * @throws NullPointerException if the given iterable is {@code null}. * @throws NullPointerException if any of the elements in the given iterable is {@code null}. */ protected Join(Iterable> conditions) { if (conditions == null) throw conditionsIsNull(); this.conditions = new ArrayList>(); for (Condition condition : conditions) this.conditions.add(notNull(condition)); } private static NullPointerException conditionsIsNull() { return new NullPointerException("The given conditions should not be null"); } private static Condition notNull(Condition condition) { if (condition == null) throw new NullPointerException("The given conditions should not have null entries"); return condition; } /** * Returns the conditions to join. * @return the conditions to join. */ protected final Collection> conditions() { return unmodifiableCollection(conditions); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/Negative.java000066400000000000000000000022611243020563200270400ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.condition; import org.fest.assertions.core.Condition; import org.fest.util.VisibleForTesting; /** * Inverse the condition. * * @author Nicolas François * @author Mikhail Mazursky */ public abstract class Negative extends Condition { @VisibleForTesting final Condition condition; @Override public boolean matches(T value) { return !condition.matches(value); } protected Negative(Condition condition) { this.condition = condition; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/condition/Not.java000066400000000000000000000025271243020563200260430ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.condition; import org.fest.assertions.core.Condition; /** * Returns {@code true} if the condition is not satisfied. * * @author Nicolas François * @author Mikhail Mazursky */ public class Not extends Negative { /** * Creates a new {@link Not}. * * @param condition the condition to inverse. * @return The Not condition created. */ public static Not not(Condition condition) { return new Not(condition); } private Not(Condition condition) { super(condition); } @Override public String toString() { return String.format("not :<%s>", condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/000077500000000000000000000000001243020563200233745ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/core/ArraySortedAssert.java000066400000000000000000000075721243020563200276730ustar00rootroot00000000000000/* * Created on Jul 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import java.util.Comparator; /** * Assertions applicable to primitive arrays or arrays of elements either naturally {@link Comparable} or according to a given * {@link Comparator}. *

* Note that the contract defined here is can't be totally applied to List (that's why its name is not SortedAssert), the * differences being that we can't check that - for empty List - the list parameter is comparable or compatible with given * comparator due to type erasure. * * @param the "self" type of this assertion class that must be a array type (e.g. arrays, collections).
* Please read "Emulating 'self types' using Java Generics to * simplify fluent API implementation" for more details. * @param the array element type. * * @author Joel Costigliola * @author Mikhail Mazursky */ public interface ArraySortedAssert { /** * Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements. *

* All array elements must be primitive or implement the {@link Comparable} interface and must be mutually comparable (that is, * e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array), examples : *

    *
  • a array composed of {2, 4, 6} is ok because the element type is a primitive type.
  • *
  • a array composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
  • *
  • a array composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
  • *
  • a array composed of {True, "abc", False} is NOT ok because elements are not mutually comparable (even though each * element type implements Comparable)
  • *
* Empty or one element arrays are considered sorted (unless the array element type is not Comparable).

* * @return {@code this} assertion object. * * @throws AssertionError if the actual array is not sorted into ascending order according to the natural ordering of its * elements. * @throws AssertionError if the actual array is null. * @throws AssertionError if the actual array element type does not implement {@link Comparable}. * @throws AssertionError if the actual array elements are not mutually {@link Comparable}. */ S isSorted(); /** * Verifies that the actual array is sorted according to the given comparator.
Empty arrays are considered sorted whatever * the comparator is.
One element arrays are considered sorted if element is compatible with comparator, otherwise an * AssertionError is thrown. * * @param comparator the {@link Comparator} used to compare array elements * * @return {@code this} assertion object. * * @throws AssertionError if the actual array is not sorted according to the given comparator. * @throws AssertionError if the actual array is null. * @throws NullPointerException if the given comparator is null. * @throws AssertionError if the actual array elements are not mutually comparable according to given Comparator. */ S isSortedAccordingTo(Comparator comparator); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/Assert.java000066400000000000000000000246131243020563200255060ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import java.util.Comparator; /** * Base contract of all assertion objects: the minimum functionality that any assertion object should provide. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Nicolas François * @author Mikhail Mazursky */ public interface Assert extends Descriptable, ExtensionPoints { /** * Verifies that the actual value is equal to the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is not equal to the given one. */ S isEqualTo(A expected); /** * Verifies that the actual value is not equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is equal to the given one. */ S isNotEqualTo(A other); /** * Verifies that the actual value is {@code null}. * @throws AssertionError if the actual value is not {@code null}. */ void isNull(); /** * Verifies that the actual value is not {@code null}. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. */ S isNotNull(); /** * Verifies that the actual value is the same as the given one. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is not the same as the given one. */ S isSameAs(A expected); /** * Verifies that the actual value is not the same as the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is the same as the given one. */ S isNotSameAs(A other); /** * Verifies that the actual value is present in the given array of values. * @param values the given array to search the actual value in. * @return {@code this} assertion object. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws AssertionError if the actual value is not present in the given array. */ S isIn(A... values); /** * Verifies that the actual value is not present in the given array of values. * @param values the given array to search the actual value in. * @return {@code this} assertion object. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws AssertionError if the actual value is present in the given array. */ S isNotIn(A... values); /** * Verifies that the actual value is present in the given values. * @param values the given iterable to search the actual value in. * @return {@code this} assertion object. * @throws NullPointerException if the given collection is {@code null}. * @throws IllegalArgumentException if the given collection is empty. * @throws AssertionError if the actual value is not present in the given collection. */ S isIn(Iterable values); /** * Verifies that the actual value is not present in the given values. * @param values the given iterable to search the actual value in. * @return {@code this} assertion object. * @throws NullPointerException if the given collection is {@code null}. * @throws IllegalArgumentException if the given collection is empty. * @throws AssertionError if the actual value is present in the given collection. */ S isNotIn(Iterable values); /** * Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks. *

* Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison * strategy. *

* Examples : * *

   * // frodo and sam are instances of Character with Hobbit race (obviously :).
   * // raceComparator implements Comparator<Character> 
   * assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam); 
   * 
* * @param customComparator the comparator to use for incoming assertion checks. * @throws NullPointerException if the given comparator is {@code null}. * @return {@code this} assertion object. */ S usingComparator(Comparator customComparator); /** * Revert to standard comparison for incoming assertion checks. *

* This method should be used to disable a custom comparison strategy set by calling {@link #usingComparator(Comparator)}. * @return {@code this} assertion object. */ S usingDefaultComparator(); /** * Verifies that the actual value is an instance of the given type. * @param type the type to check the actual value against. * @return this assertion object. * @throws NullPointerException if the given type is {@code null}. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not an instance of the given type. */ S isInstanceOf(Class type); /** * Verifies that the actual value is an instance of any of the given types. * @param types the types to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not an instance of any of the given types. * @throws NullPointerException if the given array of types is {@code null}. * @throws NullPointerException if the given array of types contains {@code null}s. */ S isInstanceOfAny(Class... types); /** * Verifies that the actual value is not an instance of the given type. * @param type the type to check the actual value against. * @return this assertion object. * @throws NullPointerException if the given type is {@code null}. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is an instance of the given type. */ S isNotInstanceOf(Class type); /** * Verifies that the actual value is not an instance of any of the given types. * @param types the types to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is an instance of any of the given types. * @throws NullPointerException if the given array of types is {@code null}. * @throws NullPointerException if the given array of types contains {@code null}s. */ S isNotInstanceOfAny(Class... types); /** * Verifies that the actual value has the same class as the given object. * @param other the object to check type against. * @return this assertion object. * @throws AssertionError if the actual has not the same type has the given object. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ S hasSameClassAs(Object other); /** * Verifies that the actual value does not have the same class as the given object. * @param other the object to check type against. * @return this assertion object. * @throws AssertionError if the actual has the same type has the given object. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ S doesNotHaveSameClassAs(Object other); /** * Verifies that the actual value is exactly an instance of the given type. * @param type the type to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual is not exactly an instance of given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ S isExactlyInstanceOf(Class type); /** * Verifies that the actual value is not exactly an instance of given type. * @param type the type to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual is exactly a instance of given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ S isNotExactlyInstanceOf(Class type); /** * Verifies that the actual value type is in given types. * @param types the types to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual value type is not in given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given types is null. */ S isOfAnyClassIn(Class... types); /** * Verifies that the actual value type is not in given types. * @param types the types to check the actual value against. * @return this assertion object. * @throws AssertionError if the actual value type is in given types. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given types is null. */ S isNotOfAnyClassIn(Class... types); /** * Throws {@link UnsupportedOperationException} if called. It is easy to accidentally call * {@link #equals(Object)} instead of isEqualTo. * @throws UnsupportedOperationException if this method is called. */ @Override boolean equals(Object obj); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/AssertionInfo.java000066400000000000000000000023331243020563200270230ustar00rootroot00000000000000/* * Created on Aug 4, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import org.fest.assertions.description.Description; /** * Information about an assertion. * * @author Alex Ruiz * @author Yvonne Wang */ public interface AssertionInfo { /** * Returns the message that, if specified, will replace the default message of an assertion failure. * @return the message that, if specified, will replace the default message of an assertion failure. */ String overridingErrorMessage(); /** * Returns the description of an assertion. * @return the description of an assertion. */ Description description(); }fest-assert-2.0M10/src/main/java/org/fest/assertions/core/ComparableAssert.java000066400000000000000000000052431243020563200274720ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; /** * Assertion methods applicable to {@link Comparable}s. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Ted M. Young */ public interface ComparableAssert> { /** * Verifies that the actual value is less than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or greater than the given one. */ S isLessThan(A other); /** * Verifies that the actual value is less than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the given one. */ S isLessThanOrEqualTo(A other); /** * Verifies that the actual value is greater than the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to or less than the given one. */ S isGreaterThan(A other); /** * Verifies that the actual value is greater than or equal to the given one. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the given one. */ S isGreaterThanOrEqualTo(A other); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/Condition.java000066400000000000000000000055571243020563200262010ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.core.DescriptionValidations.checkIsNotNull; import org.fest.assertions.description.Description; import org.fest.util.VisibleForTesting; /** * A condition to be met by an object. * @param the type of object this condition accepts. * * @author Yvonne Wang * @author Alex Ruiz */ public abstract class Condition implements Descriptable> { @VisibleForTesting Description description; /** * Creates a new {@link Condition}. The default description of this condition will the simple name of the * condition's class. */ public Condition() { as(getClass().getSimpleName()); } /** * Creates a new {@link Condition}. * @param description the description of this condition. * @throws NullPointerException if the given description is {@code null}. */ public Condition(String description) { as(description); } /** * Creates a new {@link Condition}. * @param description the description of this condition. * @throws NullPointerException if the given description is {@code null}. */ public Condition(Description description) { as(description); } /** {@inheritDoc} */ public Condition describedAs(String newDescription) { return as(newDescription); } /** {@inheritDoc} */ public Condition as(String newDescription) { description = checkIsNotNull(newDescription); return this; } /** {@inheritDoc} */ public Condition describedAs(Description newDescription) { return as(newDescription); } /** {@inheritDoc} */ public Condition as(Description newDescription) { description = checkIsNotNull(newDescription); return this; } /** * Returns the description of this condition. * @return the description of this condition. */ public Description description() { return description; } /** * Verifies that the given value satisfies this condition. * @param value the value to verify. * @return {@code true} if the given value satisfies this condition; {@code false} otherwise. */ public abstract boolean matches(T value); @Override public String toString() { return description.value(); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/Descriptable.java000066400000000000000000000061231243020563200266420ustar00rootroot00000000000000/* * Created on Jul 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import org.fest.assertions.description.*; /** * An object that has a description. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * * @author Alex Ruiz * @author Yvonne Wang */ public interface Descriptable { /** * Sets the description of this object. * @param description the new description to set. * @return {@code this} object. * @throws NullPointerException if the description is {@code null}. * @see #describedAs(String) */ S as(String description); /** * Sets the description of this object. To remove or clear the description, pass a {@link EmptyTextDescription} as * argument. *

* This overloaded version of "describedAs" offers more flexibility than the one taking a {@code String} by allowing users to * pass their own implementation of a description. For example, a description that creates its value lazily, only when an * assertion failure occurs. *

* @param description the new description to set. * @return {@code this} object. * @throws NullPointerException if the description is {@code null}. * @see #describedAs(Description) */ S as(Description description); /** * Alias for {@link #as(String)} since "as" is a keyword in Groovy. * @param description the new description to set. * @return {@code this} object. * @throws NullPointerException if the description is {@code null}. */ S describedAs(String description); /** * Alias for {@link #as(String)} since "as" is a keyword in Groovy. To remove or clear the description, pass a {@link EmptyTextDescription} as argument. *

* This overloaded version of "describedAs" offers more flexibility than the one taking a {@code String} by allowing users to * pass their own implementation of a description. For example, a description that creates its value lazily, only when an * assertion failure occurs. *

* @param description the new description to set. * @return {@code this} object. * @throws NullPointerException if the description is {@code null}. */ S describedAs(Description description); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/DescriptionValidations.java000066400000000000000000000022661243020563200307260ustar00rootroot00000000000000/* * Created on Jul 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import org.fest.assertions.description.*; /** * @author Yvonne Wang * @author Alex Ruiz */ final class DescriptionValidations { static Description checkIsNotNull(String d) { if (d == null) throw bomb(); return new TextDescription(d); } static Description checkIsNotNull(Description d) { if (d == null) throw bomb(); return d; } private static RuntimeException bomb() { return new NullPointerException("The description to set should not be null"); } private DescriptionValidations() {} } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/EnumerableAssert.java000066400000000000000000000122151243020563200275010ustar00rootroot00000000000000/* * Created on Jul 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import java.util.Comparator; /** * Assertions applicable to groups of values that can be enumerated (e.g. arrays, collections or strings.) * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public interface EnumerableAssert, T> { /** * Verifies that the actual group of values is {@code null} or empty. * @throws AssertionError if the actual group of values is not {@code null} or not empty. */ void isNullOrEmpty(); /** * Verifies that the actual group of values is empty. * @throws AssertionError if the actual group of values is not empty. */ void isEmpty(); /** * Verifies that the actual group of values is not empty. * @return {@code this} assertion object. * @throws AssertionError if the actual group of values is empty. */ S isNotEmpty(); /** * Verifies that the number of values in the actual group is equal to the given one. * @param expected the expected number of values in the actual group. * @return {@code this} assertion object. * @throws AssertionError if the number of values of the actual group is not equal to the given one. */ S hasSize(int expected); /** * Verifies that the actual group has the same size as given {@link Iterable}. * @param other the {@code Iterable} to compare size with actual group. * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other {@code Iterable} is {@code null}. * @throws AssertionError if actual group and given {@code Iterable} don't have the same size. */ S hasSameSizeAs(Iterable other); /** * Verifies that the actual group has the same size as given array. * @param other the array to compare size with actual group. * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other array is {@code null}. * @throws AssertionError if actual group and given array don't have the same size. */ S hasSameSizeAs(Object[] other); /** * Use given custom comparator instead of relying on actual type A equals method to compare group elements for * incoming assertion checks. *

* Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison * strategy. *

* Examples : * *

   * // compares invoices by payee 
   * assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList).
   * 
   * // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator
   * assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice)
   * 
   * // as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy 
   * // based on Invoice's equal method to compare invoiceList elements to lowestInvoice.                                                      
   * assertThat(invoiceList).contains(lowestInvoice).
   * 
   * // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ...
   * assertThat(fellowshipOfTheRing).contains(gandalf)
   *                                .doesNotContain(sauron);
   * 
   * // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf.
   * assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator)
   *                                .contains(sauron);
   * 
* * @param customComparator the comparator to use for incoming assertion checks. * @throws NullPointerException if the given comparator is {@code null}. * @return {@code this} assertion object. */ S usingElementComparator(Comparator customComparator); /** * Revert to standard comparison for incoming assertion group element checks. *

* This method should be used to disable a custom comparison strategy set by calling {@link #usingElementComparator(Comparator)}. * @return {@code this} assertion object. */ S usingDefaultElementComparator(); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/ExtensionPoints.java000066400000000000000000000057121243020563200274150ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; /** * Mechanism for extending assertion classes. * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Mikhail Mazursky */ public interface ExtensionPoints { /** * Verifies that the actual value satisfies the given condition. This method is an alias for * {@link #has(Condition)}. * @param condition the given condition. * @return {@code this ExtensionPoints} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the actual value does not satisfy the given condition. * @see #is(Condition) */ S is(Condition condition); /** * Verifies that the actual value does not satisfy the given condition. This method is an alias for * {@link #doesNotHave(Condition)}. * @param condition the given condition. * @return {@code this ExtensionPoints} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the actual value satisfies the given condition. * @see #isNot(Condition) */ S isNot(Condition condition); /** * Verifies that the actual value satisfies the given condition. This method is an alias for {@link #is(Condition)} * . * @param condition the given condition. * @return {@code this ExtensionPoints} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the actual value does not satisfy the given condition. * @see #is(Condition) */ S has(Condition condition); /** * Verifies that the actual value does not satisfy the given condition. This method is an alias for * {@link #isNot(Condition)}. * @param condition the given condition. * @return {@code this ExtensionPoints} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the actual value satisfies the given condition. * @see #isNot(Condition) */ S doesNotHave(Condition condition); }fest-assert-2.0M10/src/main/java/org/fest/assertions/core/FloatingPointNumberAssert.java000066400000000000000000000040071243020563200313500ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import org.fest.assertions.data.Offset; /** * Assertion methods applicable to floating-point {@link Number}s. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Yvonne Wang */ public interface FloatingPointNumberAssert extends NumberAssert { /** * Verifies that the actual value is equal to the given one, within a positive offset. * @param expected the given value to compare the actual value to. * @param offset the given positive offset. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws NullPointerException if the expected number is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ FloatingPointNumberAssert isEqualTo(T expected, Offset offset); /** * Verifies that the actual value is equal to {@code NaN}. * @return this assertion object. * @throws AssertionError if the actual value is not equal to {@code NaN}. */ FloatingPointNumberAssert isNaN(); /** * Verifies that the actual value is not equal to {@code NaN}. * @return this assertion object. * @throws AssertionError if the actual value is equal to {@code NaN}. */ FloatingPointNumberAssert isNotNaN(); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/IndexedObjectEnumerableAssert.java000066400000000000000000000047621243020563200321410ustar00rootroot00000000000000/* * Created on Nov 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import org.fest.assertions.data.Index; /** * Assertions methods applicable to indexed groups of objects (e.g. arrays or lists.) * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of elements of the "actual" value. * * @author Alex Ruiz * @author Mikhail Mazursky */ public interface IndexedObjectEnumerableAssert, T> extends ObjectEnumerableAssert { /** * Verifies that the actual group contains the given object at the given index. * @param value the object to look for. * @param index the index where the object should be stored in the actual group. * @return this assertion object. * @throws AssertionError if the actual group is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the actual * group. * @throws AssertionError if the actual group does not contain the given object at the given index. */ S contains(T value, Index index); /** * Verifies that the actual group does not contain the given object at the given index. * @param value the object to look for. * @param index the index where the object should be stored in the actual group. * @return this assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual group contains the given object at the given index. */ S doesNotContain(T value, Index index); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/NumberAssert.java000066400000000000000000000051201243020563200266470ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; /** * Assertion methods applicable to {@link Number}s. * @param the type of the "actual" value. * * @author Alex Ruiz * @author Nicolas François */ public interface NumberAssert { /** * Verifies that the actual value is equal to zero. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to zero. */ NumberAssert isZero(); /** * Verifies that the actual value is not equal to zero. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to zero. */ NumberAssert isNotZero(); /** * Verifies that the actual value is positive. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not positive. */ NumberAssert isPositive(); /** * Verifies that the actual value is negative. * @return this assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not negative. */ NumberAssert isNegative(); /** * Verifies that the actual value is non negative (positive or equal zero). * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not non negative. */ NumberAssert isNotNegative(); /** * Verifies that the actual value is non positive (negative or equal zero). * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not non positive. */ NumberAssert isNotPositive(); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/ObjectEnumerableAssert.java000066400000000000000000000327751243020563200306450ustar00rootroot00000000000000/* * Created on Jul 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import java.util.HashSet; /** * Assertions methods applicable to groups of objects (e.g. arrays or collections.) * * @param the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" * for more details. * @param the type of elements of the "actual" value. * * @author Yvonne Wang * @author Alex Ruiz * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola * @author Nicolas François */ public interface ObjectEnumerableAssert, T> extends EnumerableAssert { /** * Verifies that the actual group contains the given values, in any order. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain the given values. */ S contains(T... values); /** * Verifies that the actual group contains only the given values and nothing else, in any order. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some * or none of the given values, or the actual group contains more values than the given ones. */ S containsOnly(T... values); /** * Verifies that the actual group contains only the given values and nothing else, in order.
* This assertion should only be used with Iterable that have a consistent iteration order (i.e. don't use it with * {@link HashSet}, prefer {@link #containsOnly(Object...)} in that case). *

* Example : * *

   * Iterable<Ring> elvesRings = newArrayList(vilya, nenya, narya);
   * 
   * // assertion will pass
   * assertThat(elvesRings).containsExactly(vilya, nenya, narya);
   * 
   * // assertion will fail as actual and expected orders differ.
   * assertThat(elvesRings).containsExactly(nenya, vilya, narya);
   * 
* * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group * contains some or none of the given values, or the actual group contains more values than the given ones * or values are not in same order. */ S containsExactly(T... values); /** * Verifies that the actual group contains the given sequence, without any other values between them. * * @param sequence the sequence of objects to look for. * @return this assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual group does not contain the given sequence. */ S containsSequence(T... sequence); /** * Verifies that the actual group does not contain the given values. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group contains any of the given values. */ S doesNotContain(T... values); /** * Verifies that the actual group does not contain duplicates. * * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group contains duplicates. */ S doesNotHaveDuplicates(); /** * Verifies that the actual group starts with the given sequence of objects, without any other objects between them. * Similar to {@link #containsSequence(Object...)}, but it also verifies that the first element in the * sequence is also first element of the actual group. * * @param sequence the sequence of objects to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not start with the given sequence of objects. */ S startsWith(T... sequence); /** * Verifies that the actual group ends with the given sequence of objects, without any other objects between them. * Similar to {@link #containsSequence(Object...)}, but it also verifies that the last element in the * sequence is also last element of the actual group. * * @param sequence the sequence of objects to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not end with the given sequence of objects. */ S endsWith(T... sequence); /** * Verifies that the actual group contains at least a null element. * * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain a null element. */ S containsNull(); /** * Verifies that the actual group does not contain null elements. * * @return {@code this} assertion object. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group contains a null element. */ S doesNotContainNull(); /** * Verifies that each element value satisfies the given condition * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element not satisfy the given condition. */ S are(Condition condition); /** * Verifies that each element value not satisfies the given condition * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element satisfy the given condition. */ S areNot(Condition condition); /** * Verifies that each element value satisfies the given condition * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element not satisfy the given condition. */ S have(Condition condition); /** * Verifies that each element value not satisfies the given condition * * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element satisfy the given condition. */ S doNotHave(Condition condition); /** * Verifies that there is at least n elements in the actual group satisfying the given condition. * * @param n the minimum number of times the condition should be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if an element can not be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is < n. */ S areAtLeast(int n, Condition condition); /** * Verifies that there is at least n elements in the actual group not satisfying the given * condition. * * @param n the number of times the condition should not be verified at least. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is < n. */ S areNotAtLeast(int n, Condition condition); /** * Verifies that there is at most n elements in the actual group satisfying the given condition. * * @param n the number of times the condition should be at most verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is > n. */ S areAtMost(int n, Condition condition); /** * Verifies that there is at most n elements in the actual group not satisfying the given * condition. * * @param n the number of times the condition should not be verified at most. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is > n. */ S areNotAtMost(int n, Condition condition); /** * Verifies that there is exactly n elements in the actual group satisfying the given condition. * * @param n the exact number of times the condition should be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is ≠ n. */ S areExactly(int n, Condition condition); /** * Verifies that there is exactly n elements in the actual group not satisfying the given * condition. * * @param n the exact number of times the condition should not be verified. * @param condition the given condition. * @return {@code this} object. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is ≠ n. */ S areNotExactly(int n, Condition condition); /** * This method is an alias for {@link #areAtLeast(int, Condition)}. */ S haveAtLeast(int n, Condition condition); /** * This method is an alias {@link #areNotAtLeast(int, Condition)}. */ S doNotHaveAtLeast(int n, Condition condition); /** * This method is an alias {@link #areAtMost(int, Condition)}. */ S haveAtMost(int n, Condition condition); /** * This method is an alias {@link #areNotAtMost(int, Condition)}. */ S doNotHaveAtMost(int n, Condition condition); /** * This method is an alias {@link #areExactly(int, Condition)}. */ S haveExactly(int n, Condition condition); /** * This method is an alias {@link #areNotExactly(int, Condition)}. */ S doNotHaveExactly(int n, Condition condition); /** * Verifies that the actual group contains all the elements of given {@code Iterable}, in any order. * * @param iterable the given {@code Iterable} we will get elements from. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain all the elements of given {@code Iterable}. */ S containsAll(Iterable iterable); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/UnevenComparableAssert.java000066400000000000000000000043271243020563200306550ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import java.math.BigDecimal; /** * Assertion methods applicable to {@link Comparable}s whose implementation of {@code compareTo} is not consistent * with their implementation of {@code equals} (e.g. {@link BigDecimal}.) * @param the "self" type of this assertion class. Please read "Emulating * 'self types' using Java Generics to simplify fluent API implementation" for more details. * @param the type of the "actual" value. * * @author Alex Ruiz */ public interface UnevenComparableAssert> extends ComparableAssert { /** * Verifies that the actual value is equal to the given one by invoking {@link Comparable#compareTo(Object)}. * @param expected the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the given one. */ S isEqualByComparingTo(T expected); /** * Verifies that the actual value is not equal to the given one by invoking {@link Comparable#compareTo(Object)}. * @param other the given value to compare the actual value to. * @return {@code this} assertion object. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the given one. */ S isNotEqualByComparingTo(T other); } fest-assert-2.0M10/src/main/java/org/fest/assertions/core/WritableAssertionInfo.java000066400000000000000000000056171243020563200305250ustar00rootroot00000000000000/* * Created on Jul 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static java.lang.String.format; import static org.fest.assertions.core.DescriptionValidations.checkIsNotNull; import static org.fest.util.Strings.quote; import org.fest.assertions.description.Description; import org.fest.assertions.description.EmptyTextDescription; /** * Writable information about an assertion. * * @author Alex Ruiz * @author Yvonne Wang */ public class WritableAssertionInfo implements AssertionInfo { private String overridingErrorMessage; private Description description; /** {@inheritDoc} */ public String overridingErrorMessage() { return overridingErrorMessage; } /** * Sets the message that will replace the default message of an assertion failure. * @param newErrorMessage the new message. It can be {@code null}. */ public void overridingErrorMessage(String newErrorMessage) { overridingErrorMessage = newErrorMessage; } /** {@inheritDoc} */ public Description description() { return description; } /** * Returns the text of this object's description, or {@code null} if such description is {@code null}. * @return the text of this object's description, or {@code null} if such description is {@code null}. */ public String descriptionText() { return description != null ? description.value() : null; } /** * Sets the description of an assertion. * @param newDescription the new description. * @throws NullPointerException if the given description is {@code null}. * @see #description(Description) */ public void description(String newDescription) { description = checkIsNotNull(newDescription); } /** * Sets the description of an assertion. To remove or clear the description, pass a {@link EmptyTextDescription} as * argument. * @param newDescription the new description. * @throws NullPointerException if the given description is {@code null}. */ public void description(Description newDescription) { description = checkIsNotNull(newDescription); } /** {@inheritDoc} */ @Override public String toString() { String format = "%s[overridingErrorMessage=%s, description=%s]"; return format(format, getClass().getSimpleName(), quote(overridingErrorMessage()), quote(descriptionText())); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/data/000077500000000000000000000000001243020563200233555ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/data/Index.java000066400000000000000000000034041243020563200252700ustar00rootroot00000000000000/* * Created on Oct 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static org.fest.util.Objects.HASH_CODE_PRIME; /** * A positive index. * * @author Alex Ruiz */ public class Index { public final int value; /** * Creates a new {@link Index}. * * @param value the value of the index. * @return the created {@code Index}. * @throws IllegalArgumentException if the given value is negative. */ public static Index atIndex(int value) { if (value < 0) { throw new IllegalArgumentException("The value of the index should not be negative"); } return new Index(value); } private Index(int value) { this.value = value; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } return value == ((Index) obj).value; } @Override public int hashCode() { int result = 1; result = HASH_CODE_PRIME * result + value; return result; } @Override public String toString() { return String.format("%s[value=%d]", getClass().getSimpleName(), value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/data/MapEntry.java000066400000000000000000000037431243020563200257660ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static org.fest.util.Objects.*; import static org.fest.util.Strings.quote; import java.util.Map; /** * Understands an entry in a {@link Map}. * * @author Yvonne Wang */ public class MapEntry { public final Object key; public final Object value; /** * Creates a new {@link MapEntry}. * * @param key the key of the entry to create. * @param value the value of the entry to create. * @return the created {@code MapEntry}. */ public static MapEntry entry(Object key, Object value) { return new MapEntry(key, value); } private MapEntry(Object key, Object value) { this.key = key; this.value = value; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } MapEntry other = (MapEntry) obj; return areEqual(key, other.key) && areEqual(value, other.value); } @Override public int hashCode() { int result = 1; result = HASH_CODE_PRIME * result + hashCodeFor(key); result = HASH_CODE_PRIME * result + hashCodeFor(value); return result; } @Override public String toString() { return String.format("%s[key=%s, value=%s]", getClass().getSimpleName(), quote(key), quote(value)); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/data/Offset.java000066400000000000000000000063031243020563200254500ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static org.fest.util.Objects.*; import static org.fest.util.Preconditions.checkNotNull; /** * A positive offset. * * @param the type of the offset value. * * @author Alex Ruiz * @author Yvonne Wang */ public class Offset { public final T value; /** * Creates a new {@link Offset}. * * @param value the value of the offset. * @return the created {@code Offset}. * @throws NullPointerException if the given value is {@code null}. * @throws IllegalArgumentException if the given value is negative. */ public static Offset offset(Double value) { checkNotNull(value); if (value.doubleValue() < 0d) { throw valueNotPositive(); } return new Offset(value); } /** * Creates a new {@link Offset}. * * @param value the value of the offset. * @return the created {@code Offset}. * @throws NullPointerException if the given value is {@code null}. * @throws IllegalArgumentException if the given value is negative. */ public static Offset offset(Float value) { checkNotNull(value); if (value.floatValue() < 0f) { throw valueNotPositive(); } return new Offset(value); } /** * Creates a new {@link Offset}. * * @param value the value of the offset. * @return the created {@code Offset}. * @throws NullPointerException if the given value is {@code null}. * @throws IllegalArgumentException if the given value is negative. */ public static Offset offset(Integer value) { checkNotNull(value); if (value.intValue() < 0) { throw valueNotPositive(); } return new Offset(value); } private static IllegalArgumentException valueNotPositive() { return new IllegalArgumentException("The value of the offset should be greater than zero"); } private Offset(T value) { this.value = value; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Offset other = (Offset) obj; return areEqual(value, other.value); } @Override public int hashCode() { int result = 1; result = HASH_CODE_PRIME * result + hashCodeFor(value); return result; } @Override public String toString() { return String.format("%s[value=%s]", getClass().getSimpleName(), value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/description/000077500000000000000000000000001243020563200247675ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/description/Description.java000066400000000000000000000017041243020563200301170ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.description; /** * The description of a value. * * @author Alex Ruiz * @author Yvonne Wang */ public abstract class Description { /** * @return the value of this description. */ public abstract String value(); @Override public String toString() { return value(); } }fest-assert-2.0M10/src/main/java/org/fest/assertions/description/EmptyTextDescription.java000066400000000000000000000020171243020563200320010ustar00rootroot00000000000000/* * Created on Jul 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.description; /** * A description containing empty text. * * @author Alex Ruiz * @author Yvonne Wang */ public class EmptyTextDescription extends TextDescription { private static final Description INSTANCE = new EmptyTextDescription(); public static Description emptyText() { return INSTANCE; } private EmptyTextDescription() { super(""); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/description/TextDescription.java000066400000000000000000000033371243020563200307700ustar00rootroot00000000000000/* * Created on Jul 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.description; import static org.fest.util.Objects.*; import static org.fest.util.Preconditions.checkNotNull; import org.fest.util.VisibleForTesting; /** * A text-based description. * * @author Yvonne Wang * @author Alex Ruiz */ public class TextDescription extends Description { @VisibleForTesting final String value; /** * Creates a new {@link TextDescription}. * * @param value the value of this description. * @throws NullPointerException if the given value is {@code null}. */ public TextDescription(String value) { checkNotNull(value); this.value = value; } @Override public String value() { return value; } @Override public int hashCode() { return HASH_CODE_PRIME * 1 + hashCodeFor(value); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } TextDescription other = (TextDescription) obj; return areEqual(value, other.value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/000077500000000000000000000000001243020563200235755ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/error/AbstractShouldHaveTextContent.java000066400000000000000000000032611243020563200323700ustar00rootroot00000000000000package org.fest.assertions.error; import static org.fest.util.SystemProperties.LINE_SEPARATOR; import java.util.List; import org.fest.assertions.description.Description; /** * * Base class for text content error. * * @author Joel Costigliola * */ public class AbstractShouldHaveTextContent extends BasicErrorMessageFactory { protected String diffs; public AbstractShouldHaveTextContent(String format, Object... arguments) { super(format, arguments); } @Override public String create(Description d) { // we append diffs here as we can't add in super constructor call, see why below. // // case 1 - append diffs to String passed in super : // super("file:<%s> and file:<%s> do not have equal content:" + diffs, actual, expected); // this leads to a MissingFormatArgumentException if diffs contains a format specifier (like %s) because the String will // finally be evaluated with String.format // // case 2 - add as format arg to the String passed in super : // super("file:<%s> and file:<%s> do not have equal content:"actual, expected, diffs); // this is better than case 1 but the diffs String will be quoted before the class to String.format as all String in Fest // error message. This is not what we want // // The solution is to keep diffs as an attribute and append it after String.format has been applied on the error message. return super.create(d) + diffs; } protected static String diffsAsString(List diffsList) { StringBuilder stringBuilder = new StringBuilder(); for (String diff : diffsList) stringBuilder.append(LINE_SEPARATOR).append(diff); return stringBuilder.toString(); } }fest-assert-2.0M10/src/main/java/org/fest/assertions/error/AssertionErrorFactory.java000066400000000000000000000021161243020563200307510ustar00rootroot00000000000000/* * Created on Aug 5, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.description.Description; /** * Factory of {@link AssertionError}s. * * @author Alex Ruiz * @author Yvonne Wang */ public interface AssertionErrorFactory { /** * Creates an {@link AssertionError}. * @param d the description of the failed assertion. * @return the created {@code AssertionError}. */ AssertionError newAssertionError(Description d); } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/BasicErrorMessageFactory.java000066400000000000000000000053521243020563200313350ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static java.lang.String.format; import static org.fest.util.Arrays.format; import static org.fest.util.Objects.*; import static org.fest.util.Strings.quote; import java.util.Arrays; import org.fest.assertions.description.Description; import org.fest.util.VisibleForTesting; /** * A factory of error messages typically shown when an assertion fails. * * @author Alex Ruiz */ public class BasicErrorMessageFactory implements ErrorMessageFactory { protected final String format; protected final Object[] arguments; @VisibleForTesting MessageFormatter formatter = MessageFormatter.instance(); /** * Creates a new {@link BasicErrorMessageFactory}. * @param format the format string. * @param arguments arguments referenced by the format specifiers in the format string. */ public BasicErrorMessageFactory(String format, Object... arguments) { this.format = format; this.arguments = arguments; } /** {@inheritDoc} */ public String create(Description d) { return formatter.format(d, format, arguments); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BasicErrorMessageFactory other = (BasicErrorMessageFactory) obj; if (!areEqual(format, other.format)) return false; // because it does not manage array recursively, don't use : Arrays.equals(arguments, other.arguments); // example if arguments[1] and other.arguments[1] are logically same arrays but not same object, it will return // false return areEqual(arguments, other.arguments); } @Override public int hashCode() { int result = 1; result = HASH_CODE_PRIME * result + hashCodeFor(format); result = HASH_CODE_PRIME * result + Arrays.hashCode(arguments); return result; } @Override public String toString() { return format("%s[format=%s, arguments=%s]", getClass().getSimpleName(), quote(format), format(arguments)); } } ConditionAndGroupGenericParameterTypeShouldBeTheSame.java000066400000000000000000000033271243020563200366510ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/error/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies type of elements of group and {@code Condition} A group of * elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky */ public class ConditionAndGroupGenericParameterTypeShouldBeTheSame extends BasicErrorMessageFactory { public ConditionAndGroupGenericParameterTypeShouldBeTheSame(Object actual, Condition condition) { super("expecting: <%s> have the same generic type as condition <%s>", actual, condition); } /** * Creates a new {@link ConditionAndGroupGenericParameterTypeShouldBeTheSame} * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeSameGenericBetweenIterableAndCondition(Object actual, Condition condition) { return new ConditionAndGroupGenericParameterTypeShouldBeTheSame(actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ConstructorInvoker.java000066400000000000000000000036511243020563200303300ustar00rootroot00000000000000/* * Created on Feb 15, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2011 the original author or authors. */ package org.fest.assertions.error; import java.lang.reflect.*; import java.security.*; /** * Access to constructors using Java reflection. * * @author Yvonne Wang * @author Alex Ruiz */ class ConstructorInvoker { Object newInstance(String className, Class[] parameterTypes, Object[] parameterValues) throws Exception { Class targetType = Class.forName(className); Constructor constructor = targetType.getConstructor(parameterTypes); boolean accessible = constructor.isAccessible(); try { setAccessible(constructor, true); return constructor.newInstance(parameterValues); } finally { try { setAccessible(constructor, accessible); } catch (RuntimeException e) {} } } private void setAccessible(AccessibleObject accessible, boolean value) { AccessController.doPrivileged(new SetAccessibleValueAction(accessible, value)); } private static class SetAccessibleValueAction implements PrivilegedAction { private final AccessibleObject accessible; private final boolean value; private SetAccessibleValueAction(AccessibleObject accessible, boolean value) { this.accessible = accessible; this.value = value; } public Void run() { accessible.setAccessible(value); return null; } } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/DescriptionFormatter.java000066400000000000000000000034111243020563200306060ustar00rootroot00000000000000/* * Created on Jan 11, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.util.Strings.isNullOrEmpty; import org.fest.assertions.description.Description; import org.fest.util.VisibleForTesting; /** * Formats the {@link Description}s to be included in assertion errors. * * @author Alex Ruiz */ public class DescriptionFormatter { private static final DescriptionFormatter INSTANCE = new DescriptionFormatter(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static DescriptionFormatter instance() { return INSTANCE; } @VisibleForTesting DescriptionFormatter() {} /** * Formats the given {@link Description} by surrounding its text value with square brackets and adding a space at * the end. * @param d the description to format. It can be {@code null}. * @return the formatted description, or an empty {@code String} if the the {@code Description} is {@code null}. */ public String format(Description d) { String s = (d != null) ? d.value() : null; if (isNullOrEmpty(s)) return ""; return String.format("[%s] ", s); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldBe.java000066400000000000000000000032651243020563200276500ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that each element of a group satisfies a {@code Condition} * A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky */ public class ElementsShouldBe extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldBe}. * @param actual the actual value in the failed assertion. * @param notSatisfies elements that not satisfies the condition * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldBe(Object actual, Object notSatisfies, Condition condition) { return new ElementsShouldBe(actual, notSatisfies, condition); } private ElementsShouldBe(Object actual, Object notSatisfies, Condition condition) { super("expecting elements:\n<%s>\n of \n<%s>\n to be <%s>", notSatisfies, actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldBeAtLeast.java000066400000000000000000000034051243020563200311220ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies at least n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldBeAtLeast extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldBeAtLeast}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldBeAtLeast(Object actual, int times, Condition condition) { return new ElementsShouldBeAtLeast(actual, times, condition); } private ElementsShouldBeAtLeast(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to be at least %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldBeAtMost.java000066400000000000000000000033761243020563200310030ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies at most n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldBeAtMost extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldBeAtMost}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldBeAtMost(Object actual, int times, Condition condition) { return new ElementsShouldBeAtMost(actual, times, condition); } private ElementsShouldBeAtMost(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to be at most %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldBeExactly.java000066400000000000000000000034061243020563200311770ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies exactly n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldBeExactly extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldBeExactly}. * @param actual the actual value in the failed assertion. * @param times exactly times the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldBeExactly(Object actual, int times, Condition condition) { return new ElementsShouldBeExactly(actual, times, condition); } private ElementsShouldBeExactly(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to be exactly %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldHave.java000066400000000000000000000033341243020563200302020ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that each element of a group satisfies a {@code Condition} * A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldHave extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldHave}. * @param actual the actual value in the failed assertion. * @param notSatisfies elements that not satisfies the condition * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldHave(Object actual, Object notSatisfies, Condition condition) { return new ElementsShouldHave(actual, notSatisfies, condition); } private ElementsShouldHave(Object actual, Object notSatisfies, Condition condition) { super("expecting elements:\n<%s>\n of \n<%s>\n to have <%s>", notSatisfies, actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldHaveAtLeast.java000066400000000000000000000034211243020563200314550ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies at least n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldHaveAtLeast extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldHaveAtLeast}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldHaveAtLeast(Object actual, int times, Condition condition) { return new ElementsShouldHaveAtLeast(actual, times, condition); } private ElementsShouldHaveAtLeast(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to have at least %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldHaveAtMost.java000066400000000000000000000034121243020563200313270ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies at most n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldHaveAtMost extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldHaveAtMost}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldHaveAtMost(Object actual, int times, Condition condition) { return new ElementsShouldHaveAtMost(actual, times, condition); } private ElementsShouldHaveAtMost(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to have at most %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldHaveExactly.java000066400000000000000000000034261243020563200315360ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies elements of a group satisfies exactly n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldHaveExactly extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldHaveExactly}. * @param actual the actual value in the failed assertion. * @param times exactly times the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldHaveExactly(Object actual, int times, Condition condition) { return new ElementsShouldHaveExactly(actual, times, condition); } private ElementsShouldHaveExactly(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n to have exactly %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotBe.java000066400000000000000000000033241243020563200303250ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies that each element of a group satisfies a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotBe extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotBe}. * @param actual the actual value in the failed assertion. * @param satisfies elements that satisfies the condition * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotBe(Object actual, Object satisfies, Condition condition) { return new ElementsShouldNotBe(actual, satisfies, condition); } private ElementsShouldNotBe(Object actual, Object satisfies, Condition condition) { super("expecting elements:\n<%s>\n of \n<%s>\n not to be <%s>", satisfies, actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotBeAtLeast.java000066400000000000000000000034341243020563200316050ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies at least n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotBeAtLeast extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotBeAtLeast}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotBeAtLeast(Object actual, int times, Condition condition) { return new ElementsShouldNotBeAtLeast(actual, times, condition); } private ElementsShouldNotBeAtLeast(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to be at least %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotBeAtMost.java000066400000000000000000000034311243020563200314540ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies at most n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotBeAtMost extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotBeAtMost}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotBeAtMost(Object actual, int times, Condition condition) { return new ElementsShouldNotBeAtMost(actual, times, condition); } private ElementsShouldNotBeAtMost(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to be at most %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotBeExactly.java000066400000000000000000000034411243020563200316570ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies exactly n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotBeExactly extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotBeExactly}. * @param actual the actual value in the failed assertion. * @param times exactly times the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotBeExactly(Object actual, int times, Condition condition) { return new ElementsShouldNotBeExactly(actual, times, condition); } private ElementsShouldNotBeExactly(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to be exactly %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotHave.java000066400000000000000000000033571243020563200306700ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that each element of a group satisfies a {@code Condition} * A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotHave extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotHave}. * @param actual the actual value in the failed assertion. * @param notSatisfies elements that not satisfies the condition * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotHave(Object actual, Object notSatisfies, Condition condition) { return new ElementsShouldNotHave(actual, notSatisfies, condition); } private ElementsShouldNotHave(Object actual, Object notSatisfies, Condition condition) { super("expecting elements:\n<%s>\n of \n<%s>\n not to have <%s>", notSatisfies, actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotHaveAtLeast.java000066400000000000000000000034501243020563200321400ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies at least n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotHaveAtLeast extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotHaveAtLeast}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotHaveAtLeast(Object actual, int times, Condition condition) { return new ElementsShouldNotHaveAtLeast(actual, times, condition); } private ElementsShouldNotHaveAtLeast(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to have at least %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotHaveAtMost.java000066400000000000000000000034451243020563200320160ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies at most n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotHaveAtMost extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotHaveAtMost}. * @param actual the actual value in the failed assertion. * @param times least time the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotHaveAtMost(Object actual, int times, Condition condition) { return new ElementsShouldNotHaveAtMost(actual, times, condition); } private ElementsShouldNotHaveAtMost(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to have at most %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ElementsShouldNotHaveExactly.java000066400000000000000000000034551243020563200322210ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that not verifies elements of a group satisfies exactly n times a * {@code Condition} A group of elements can be a collection, an array.
* * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ElementsShouldNotHaveExactly extends BasicErrorMessageFactory { /** * Creates a new {@link ElementsShouldNotHaveExactly}. * @param actual the actual value in the failed assertion. * @param times exactly times the condition should be verify. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory elementsShouldNotHaveExactly(Object actual, int times, Condition condition) { return new ElementsShouldNotHaveExactly(actual, times, condition); } private ElementsShouldNotHaveExactly(Object actual, int times, Condition condition) { super("expecting elements:\n<%s>\n not to have exactly %s times <%s>", actual, times, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ErrorMessageFactory.java000066400000000000000000000020221243020563200303620ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.description.Description; /** * Factory of error messages. * * @author Alex Ruiz */ public interface ErrorMessageFactory { /** * Creates a new error message as a result of a failed assertion. * @param d the description of the failed assertion. * @return the created error message. */ String create(Description d); }fest-assert-2.0M10/src/main/java/org/fest/assertions/error/MessageFormatter.java000066400000000000000000000054141243020563200277140ustar00rootroot00000000000000/* * Created on Sep 8, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.util.Preconditions.checkNotNull; import static org.fest.util.ToString.toStringOf; import org.fest.assertions.description.Description; import org.fest.assertions.internal.*; import org.fest.util.*; /** * Formats the messages to be included in assertion errors. * * @author Alex Ruiz */ public class MessageFormatter { private static final MessageFormatter INSTANCE = new MessageFormatter(); public static MessageFormatter instance() { return INSTANCE; } @VisibleForTesting DescriptionFormatter descriptionFormatter = DescriptionFormatter.instance(); @VisibleForTesting MessageFormatter() {} /** * Interprets a printf-style format {@code String} for failed assertion messages. It is similar to * {@link String#format(String, Object...)}, except for: *
    *
  1. the value of the given {@link Description} is used as the first argument referenced in the format * string
  2. *
  3. each of the arguments in the given array is converted to a {@code String} by invoking * {@link ToString#toStringOf(Object)}. *
* * @param d the description of the failed assertion, may be {@code null}. * @param format the format string. * @param args arguments referenced by the format specifiers in the format string. * @throws NullPointerException if the format string is {@code null}. * @return A formatted {@code String}. */ public String format(Description d, String format, Object... args) { checkNotNull(format); checkNotNull(args); return descriptionFormatter.format(d) + String.format(format, format(args)); } private Object[] format(Object[] args) { int argCount = args.length; String[] formatted = new String[argCount]; for (int i = 0; i < argCount; i++) { formatted[i] = asText(args[i]); } return formatted; } private String asText(Object o) { if (o instanceof ComparatorBasedComparisonStrategy) { return " according to " + o + " comparator"; } if (o instanceof StandardComparisonStrategy) { return ""; } return toStringOf(o); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBe.java000066400000000000000000000031431243020563200261460ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that a value satisfies a {@link Condition} * failed. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class ShouldBe extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBe}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBe(T actual, Condition condition) { return new ShouldBe(actual, condition); } private ShouldBe(Object actual, Condition condition) { super("expecting:\n<%s>\n to be:\n<%s>", actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeAbsolutePath.java000066400000000000000000000025641243020563200304700ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is an absolute path * failed. * * @author Yvonne Wang */ public class ShouldBeAbsolutePath extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeAbsolutePath}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAbsolutePath(File actual) { return new ShouldBeAbsolutePath(actual); } private ShouldBeAbsolutePath(File actual) { super("File:<%s> should be an absolute path", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeAfter.java000066400000000000000000000052631243020563200271350ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.util.Dates.parse; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is after another one failed. * * @author Joel Costigliola */ public class ShouldBeAfter extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeAfter}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAfter(Date actual, Date other, ComparisonStrategy comparisonStrategy) { return new ShouldBeAfter(actual, other, comparisonStrategy); } /** * Creates a new {@link ShouldBeAfter}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAfter(Date actual, Date other) { return new ShouldBeAfter(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeAfter}. * @param actual the actual value in the failed assertion. * @param year the year to compare the actual date's year to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAfter(Date actual, int year) { Date januaryTheFirstOfGivenYear = parse(year + "-01-01"); return new ShouldBeAfter(actual, januaryTheFirstOfGivenYear, StandardComparisonStrategy.instance()); } private ShouldBeAfter(Date actual, Date other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be strictly after:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeAfterOrEqualsTo.java000066400000000000000000000043631243020563200311140ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is after or equals to another one * failed. * * @author Joel Costigliola */ public class ShouldBeAfterOrEqualsTo extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeAfterOrEqualsTo}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAfterOrEqualsTo(Date actual, Date other, ComparisonStrategy comparisonStrategy) { return new ShouldBeAfterOrEqualsTo(actual, other, comparisonStrategy); } /** * Creates a new {@link ShouldBeAfterOrEqualsTo}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAfterOrEqualsTo(Date actual, Date other) { return new ShouldBeAfterOrEqualsTo(actual, other, StandardComparisonStrategy.instance()); } private ShouldBeAfterOrEqualsTo(Date actual, Date other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be after or equals to:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeAtIndex.java000066400000000000000000000024431243020563200274250ustar00rootroot00000000000000package org.fest.assertions.error; import java.util.List; import org.fest.assertions.core.Condition; import org.fest.assertions.data.Index; /** * Creates an error message indicating that an assertion that verifies a group of elements contains a value at a given index that * satisfies a {@link Condition} failed. * * @author Bo Gotthardt */ public class ShouldBeAtIndex extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeAtIndex}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @param index the index of the expected value. * @param found the value in {@code actual} stored under {@code index}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeAtIndex(List actual, Condition condition, Index index, T found) { return new ShouldBeAtIndex(actual, condition, index, found); } private ShouldBeAtIndex(List actual, Condition condition, Index index, T found) { super("expecting:<%s> at index <%s> to be:<%s> in:\n <%s>\n", found, index.value, condition, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeBefore.java000066400000000000000000000053001243020563200272660ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.util.Dates.parse; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is before another one failed. * * @author Joel Costigliola */ public class ShouldBeBefore extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeBefore}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBefore(Date actual, Date other, ComparisonStrategy comparisonStrategy) { return new ShouldBeBefore(actual, other, comparisonStrategy); } /** * Creates a new {@link ShouldBeBefore}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBefore(Date actual, Date other) { return new ShouldBeBefore(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeBefore}. * @param actual the actual value in the failed assertion. * @param year the year to compare the actual date's year to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBefore(Date actual, int year) { Date januaryTheFirstOfGivenYear = parse(year + "-01-01"); return new ShouldBeBefore(actual, januaryTheFirstOfGivenYear, StandardComparisonStrategy.instance()); } private ShouldBeBefore(Date actual, Date other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be strictly before:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeBeforeOrEqualsTo.java000066400000000000000000000043751243020563200312600ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is before or equals to another one * failed. * * @author Joel Costigliola */ public class ShouldBeBeforeOrEqualsTo extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeBeforeOrEqualsTo}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBeforeOrEqualsTo(Date actual, Date other, ComparisonStrategy comparisonStrategy) { return new ShouldBeBeforeOrEqualsTo(actual, other, comparisonStrategy); } /** * Creates a new {@link ShouldBeBeforeOrEqualsTo}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBeforeOrEqualsTo(Date actual, Date other) { return new ShouldBeBeforeOrEqualsTo(actual, other, StandardComparisonStrategy.instance()); } private ShouldBeBeforeOrEqualsTo(Date actual, Date other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be before or equals to:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeBetween.java000066400000000000000000000054551243020563200274700ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is between start - end dates (inclusive * or not) failed. * * @author Joel Costigliola */ public class ShouldBeBetween extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeBetween}. * @param actual the actual value in the failed assertion. * @param start the lower boundary of date period. * @param end the lower boundary of date period. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd, ComparisonStrategy comparisonStrategy) { return new ShouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, comparisonStrategy); } /** * Creates a new {@link ShouldBeBetween}. * @param actual the actual value in the failed assertion. * @param start the lower boundary of date period. * @param end the lower boundary of date period. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { return new ShouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, StandardComparisonStrategy.instance()); } private ShouldBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be in period %s%s, %s%s%s", actual, inclusiveStart ? '[' : ']', start, end, inclusiveEnd ? ']' : '[', comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeCloseTo.java000066400000000000000000000045441243020563200274450ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static java.lang.String.format; import static org.fest.util.Dates.formatAsDatetimeWithMs; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is close to another one from some delta * failed. * * @author Joel Costigliola */ public class ShouldBeCloseTo extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeCloseTo}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param deltaInMilliseconds the delta used for date comparison, expressed in milliseconds. * @param difference the difference in milliseconds between actual and other dates. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeCloseTo(Date actual, Date other, long deltaInMilliseconds, long difference) { return new ShouldBeCloseTo(actual, other, deltaInMilliseconds, difference); } private ShouldBeCloseTo(Date actual, Date other, long deltaInMilliseconds, long difference) { // format Date up to the given ms, because defaut format is the second, thus dates with a difference less than 1s // seems equal in the error message. // Use standard formatting to avoid calling ToString.toStringOf for long that adds a 'L' (like 100L) to // differentiate integer from long (here there is no ambiguity). super(format("expected '%s' to be close to '%s' by less than %sms but difference was of %sms", formatAsDatetimeWithMs(actual), formatAsDatetimeWithMs(other), deltaInMilliseconds, difference)); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeDirectory.java000066400000000000000000000025571243020563200300430ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is an existing directory * failed. * * @author Yvonne Wang */ public class ShouldBeDirectory extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeDirectory}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeDirectory(File actual) { return new ShouldBeDirectory(actual); } private ShouldBeDirectory(File actual) { super("File:<%s> should be an existing directory", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeEmpty.java000066400000000000000000000025471243020563200271740ustar00rootroot00000000000000/* * Created on Sep 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a group of elements is empty failed. A group of elements * can be a collection, an array or a {@code String}. * * @author Alex Ruiz */ public class ShouldBeEmpty extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeEmpty}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeEmpty(Object actual) { return new ShouldBeEmpty(actual); } private ShouldBeEmpty(Object actual) { super("expecting empty but was:<%s>", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeEqual.java000066400000000000000000000232161243020563200271410ustar00rootroot00000000000000/* * Created on Aug 5, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static java.lang.Integer.toHexString; import static org.fest.util.Arrays.array; import static org.fest.util.Objects.*; import static org.fest.util.ToString.toStringOf; import org.fest.assertions.description.Description; import org.fest.assertions.internal.*; import org.fest.util.VisibleForTesting; /** * Creates an {@link AssertionError} indicating that an assertion that verifies that two objects are equal failed. *

* The built {@link AssertionError}'s message differentiates {@link #actual} and {@link #expected} description if their string * representation are the same (e.g. 42 float and 42 double). It also mentions the comparator in case of a custom comparator is * used (instead of equals method). * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldBeEqual implements AssertionErrorFactory { private static final String EXPECTED_BUT_WAS_MESSAGE = "expected:\n<%s>\n but was:\n<%s>"; private static final String EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR = "Expecting actual:\n<%s>\n to be equal to \n<%s>\n%s but was not."; private static final Class[] MSG_ARG_TYPES = new Class[] { String.class, String.class, String.class }; @VisibleForTesting ConstructorInvoker constructorInvoker = new ConstructorInvoker(); @VisibleForTesting MessageFormatter messageFormatter = MessageFormatter.instance(); @VisibleForTesting DescriptionFormatter descriptionFormatter = DescriptionFormatter.instance(); protected final Object actual; protected final Object expected; private ComparisonStrategy comparisonStrategy; /** * Creates a new {@link ShouldBeEqual}. * @param actual the actual value in the failed assertion. * @param expected the expected value in the failed assertion. * @return the created {@code AssertionErrorFactory}. */ public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected) { return new ShouldBeEqual(actual, expected, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeEqual}. * @param actual the actual value in the failed assertion. * @param expected the expected value in the failed assertion. * @param comparisonStrategy the {@link ComparisonStrategy} used to compare actual with expected. * @return the created {@code AssertionErrorFactory}. */ public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { return new ShouldBeEqual(actual, expected, comparisonStrategy); } @VisibleForTesting ShouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { this.actual = actual; this.expected = expected; this.comparisonStrategy = comparisonStrategy; } /** * Creates an {@link AssertionError} indicating that an assertion that verifies that two objects are equal failed.
* The {@link AssertionError} message is built so that it differentiates {@link #actual} and {@link #expected} * description in case their string representation are the same (like 42 float and 42 double). *

* If JUnit 4 is in the classpath and the description is standard (no comparator was used and {@link #actual} and * {@link #expected} string representation were differents), this method will instead create a org.junit.ComparisonFailure that * highlights the difference(s) between the expected and actual objects. *

* {@link AssertionError} stack trace won't show Fest related elements if {@link Failures} is configured to filter them (see * {@link Failures#setRemoveFestRelatedElementsFromStackTrace(boolean)}). * * @param description the description of the failed assertion. * @return the created {@code AssertionError}. */ public AssertionError newAssertionError(Description description) { if (actualAndExpectedHaveSameStringRepresentation()) { // Example : actual = 42f and expected = 42d gives actual : "42" and expected : "42" and // JUnit 4 manages this case even worst, it will output something like : // "java.lang.String expected:java.lang.String<42.0> but was: java.lang.String<42.0>" // which does not solve the problem and makes things even more confusing since we lost the fact that 42 was a // float or a double, it is then better to built our own description, with the drawback of not using a // ComparisonFailure (which looks nice in eclipse) return Failures.instance().failure(defaultDetailedErrorMessage(description)); } // if comparison strategy was based on a custom comparator, we build the assertion error message, the result is // better than the JUnit ComparisonFailure we could build (that would not mention the comparator). if (isJUnitComparisonFailureRelevant()) { // try to build a JUnit ComparisonFailure that offers a nice IDE integration. AssertionError error = comparisonFailure(description); if (error != null) { return error; } } // No JUnit in the classpath => fall back to default error message. return Failures.instance().failure(defaultErrorMessage(description)); } /** * Tells {@link #newAssertionError(Description)} if it should try a build a {@link ComparisonFailure}.
* Returns true as we try in this class (may not be the case in subclasses). * @return true */ private boolean isJUnitComparisonFailureRelevant() { // to add comparator description, we can't rely on JUnit ComparisonFailure since it will ignore it. if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) return false; // we don't care to mention the strategy used => trying to build a JUnit comparison failure is relevant. return true; } private boolean actualAndExpectedHaveSameStringRepresentation() { return areEqual(toStringOf(actual), toStringOf(expected)); } /** * Builds and returns an error message from description using {@link #expected} and {@link #actual} basic representation. * @param description the {@link Description} used to build the returned error message * @return the error message from description using {@link #expected} and {@link #actual} basic representation. */ private String defaultErrorMessage(Description description) { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) return messageFormatter .format(description, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, actual, expected, comparisonStrategy); return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE, expected, actual); } /** * Builds and returns an error message from description using {@link #expectedDetailedToString()} and {@link #detailedActual()} * detailed representation. * @param description the {@link Description} used to build the returned error message * @return the error message from description using {@link #detailedExpected()} and {@link #detailedActual()} detailed * representation. */ private String defaultDetailedErrorMessage(Description description) { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, detailedActual(), detailedExpected(), comparisonStrategy); return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE, detailedExpected(), detailedActual()); } private AssertionError comparisonFailure(Description description) { try { AssertionError comparisonFailure = newComparisonFailure(descriptionFormatter.format(description).trim()); Failures.instance().removeFestRelatedElementsFromStackTraceIfNeeded(comparisonFailure); return comparisonFailure; } catch (Throwable e) { return null; } } private AssertionError newComparisonFailure(String description) throws Exception { Object o = constructorInvoker.newInstance("org.junit.ComparisonFailure", MSG_ARG_TYPES, msgArgs(description)); if (o instanceof AssertionError) return (AssertionError) o; return null; } private Object[] msgArgs(String description) { return array(description, toStringOf(expected), toStringOf(actual)); } private static String detailedToStringOf(Object obj) { return toStringOf(obj) + " (" + obj.getClass().getSimpleName() + "@" + toHexString(obj.hashCode()) + ")"; } private String detailedActual() { return detailedToStringOf(actual); } private String detailedExpected() { return detailedToStringOf(expected); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; if (getClass() != o.getClass()) return false; ShouldBeEqual other = (ShouldBeEqual) o; if (!areEqual(actual, other.actual)) return false; return areEqual(expected, other.expected); } @Override public int hashCode() { int result = 1; result = HASH_CODE_PRIME * result + hashCodeFor(actual); result = HASH_CODE_PRIME * result + hashCodeFor(expected); return result; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeEqualIgnoringCase.java000066400000000000000000000027621243020563200314350ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that two {@code String}s are equal, ignoring case * considerations, failed. * * @author Alex Ruiz */ public class ShouldBeEqualIgnoringCase extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeEqualIgnoringCase}. * @param actual the actual value in the failed assertion. * @param expected the expected value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeEqual(String actual, String expected) { return new ShouldBeEqualIgnoringCase(actual, expected); } private ShouldBeEqualIgnoringCase(String actual, String expected) { super("expecting:\n<%s>\n to be equal to:\n<%s>\n ignoring case considerations", actual, expected); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeEqualImages.java000066400000000000000000000032001243020563200302560ustar00rootroot00000000000000/* * Created on Jan 24, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.data.Offset; /** * Creates an error message that indicates an assertion that verifies that two images are equal failed. * * @author Yvonne Wang */ public class ShouldBeEqualImages extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeEqualImages}. * @param offset helps decide if the color of two pixels are similar: two pixels that are identical to the human eye may still * have slightly different color values. For example, by using an offset of 1 we can indicate that a blue value of 60 * is similar to a blue value of 61. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeEqualImages(Offset offset) { return new ShouldBeEqualImages(offset); } private ShouldBeEqualImages(Offset offset) { super("expecting images to be equal within offset:<%s>", offset.value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeEqualWithinOffset.java000066400000000000000000000036361243020563200314770ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.data.Offset; /** * Creates an error message indicating that an assertion that verifies that two numbers are equal within a positive offset failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeEqualWithinOffset extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeEqualWithinOffset}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param expected the expected value in the failed assertion. * @param offset the given positive offset. * @param difference the effective difference between actual and expected. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeEqual(T actual, T expected, Offset offset, T difference) { return new ShouldBeEqualWithinOffset(actual, expected, offset, difference); } private ShouldBeEqualWithinOffset(Number actual, Number expected, Offset offset, Number difference) { super("expecting <%s> to be close to <%s> within offset <%s> but offset was <%s>", actual, expected, offset.value, difference); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeExactlyInstanceOf.java000066400000000000000000000027551243020563200314620ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is exactly an instance of some type failed. * * @author Joel Costigliola */ public class ShouldBeExactlyInstanceOf extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeExactlyInstanceOf}. * @param actual the actual value in the failed assertion. * @param type the type {@code actual} is expected to be. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeExactlyInstance(Object actual, Class type) { return new ShouldBeExactlyInstanceOf(actual, type); } private ShouldBeExactlyInstanceOf(Object actual, Class type) { super("expected <%s> to have exactly the same type as:<%s> but was:<%s>", actual, type, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeExecutable.java000066400000000000000000000025051243020563200301510ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is executable * failed. * * @author Olivier Demeijer * */ public class ShouldBeExecutable extends BasicErrorMessageFactory { private ShouldBeExecutable(File actual) { super("File:<%s> should be executable", actual); } /** * Creates a new {@link ShouldBeExecutable}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeExecutable(File actual) { return new ShouldBeExecutable(actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeFile.java000066400000000000000000000025141243020563200267470ustar00rootroot00000000000000/* * Created on Jan 27, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is an existing file * failed. * * @author Yvonne Wang */ public class ShouldBeFile extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeFile}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeFile(File actual) { return new ShouldBeFile(actual); } private ShouldBeFile(File actual) { super("File:<%s> should be an existing file", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeGreater.java000066400000000000000000000046231243020563200274640ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is greater than another one failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeGreater extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeGreater}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeGreater(T actual, T other) { return new ShouldBeGreater(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeGreater}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeGreater(T actual, T other, ComparisonStrategy comparisonStrategy) { return new ShouldBeGreater(actual, other, comparisonStrategy); } private ShouldBeGreater(Comparable actual, Comparable other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be greater than:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeGreaterOrEqual.java000066400000000000000000000047371243020563200307630ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is greater than or equal to another one * failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeGreaterOrEqual extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeGreaterOrEqual}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeGreaterOrEqual(T actual, T other) { return new ShouldBeGreaterOrEqual(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeGreaterOrEqual}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeGreaterOrEqual(T actual, T other, ComparisonStrategy comparisonStrategy) { return new ShouldBeGreaterOrEqual(actual, other, comparisonStrategy); } private ShouldBeGreaterOrEqual(Comparable actual, Comparable other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be greater than or equal to:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeIn.java000066400000000000000000000041301243020563200264320ustar00rootroot00000000000000/* * Created on Feb 3, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is in a group of values (e.g. an array or * collection) failed. * * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldBeIn extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeIn}. * @param actual the actual value in the failed assertion. * @param values the group of values where {@code actual} is expected to be in. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeIn(Object actual, Object values, ComparisonStrategy comparisonStrategy) { return new ShouldBeIn(actual, values, comparisonStrategy); } /** * Creates a new {@link ShouldBeIn}. * @param actual the actual value in the failed assertion. * @param values the group of values where {@code actual} is expected to be in. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeIn(Object actual, Object values) { return new ShouldBeIn(actual, values, StandardComparisonStrategy.instance()); } private ShouldBeIn(Object actual, Object values, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to be in:\n<%s>\n%s", actual, values, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameDay.java000066400000000000000000000030331243020563200276770ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year, month and day of month * as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameDay extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameDay}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameDay(Date actual, Date other) { return new ShouldBeInSameDay(actual, other); } private ShouldBeInSameDay(Date actual, Date other) { super("expected <%s> to be on same year, month and day as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameHour.java000066400000000000000000000030541243020563200301020ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year, month, day of month * and hour as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameHour extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameHour}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameHour(Date actual, Date other) { return new ShouldBeInSameHour(actual, other); } private ShouldBeInSameHour(Date actual, Date other) { super("expected <%s> to be on same year, month, day and hour as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameMillisecond.java000066400000000000000000000035001243020563200314230ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.text.*; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year, month, day of month, * hour, minute, second adn millisecond as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameMillisecond extends BasicErrorMessageFactory { private static final DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SS"); /** * Creates a new {@link ShouldBeInSameMillisecond}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameMillisecond(Date actual, Date other) { return new ShouldBeInSameMillisecond(actual, other); } private ShouldBeInSameMillisecond(Date actual, Date other) { super("expected <" + dateformat.format(actual) + "> to be on same year, month, day, hour, minute, second " + "and millisecond as <" + dateformat.format(other) + ">"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameMinute.java000066400000000000000000000031061243020563200304240ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year, month, day of month, * hour and minute as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameMinute extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameMinute}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameMinute(Date actual, Date other) { return new ShouldBeInSameMinute(actual, other); } private ShouldBeInSameMinute(Date actual, Date other) { super("expected <%s> to be on same year, month, day, hour and minute as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameMonth.java000066400000000000000000000030221243020563200302450ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year and month as another * one failed. * * @author Joel Costigliola */ public class ShouldBeInSameMonth extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameMonth}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameMonth(Date actual, Date other) { return new ShouldBeInSameMonth(actual, other); } private ShouldBeInSameMonth(Date actual, Date other) { super("expected <%s> to be on same year and month as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameSecond.java000066400000000000000000000031261243020563200304000ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year, month, day of month, * hour, minute and second as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameSecond extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameSecond}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameSecond(Date actual, Date other) { return new ShouldBeInSameSecond(actual, other); } private ShouldBeInSameSecond(Date actual, Date other) { super("expected <%s> to be on same year, month, day, hour, minute and second as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInSameYear.java000066400000000000000000000027651243020563200300750ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in same year as another one failed. * * @author Joel Costigliola */ public class ShouldBeInSameYear extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInSameYear}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInSameYear(Date actual, Date other) { return new ShouldBeInSameYear(actual, other); } private ShouldBeInSameYear(Date actual, Date other) { super("expected <%s> to be on same year as <%s>", actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInTheFuture.java000066400000000000000000000037241243020563200302760ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in the future failed. * * @author Joel Costigliola */ public class ShouldBeInTheFuture extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInTheFuture}. * @param actual the actual value in the failed assertion. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInTheFuture(Date actual, ComparisonStrategy comparisonStrategy) { return new ShouldBeInTheFuture(actual, comparisonStrategy); } /** * Creates a new {@link ShouldBeInTheFuture}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInTheFuture(Date actual) { return new ShouldBeInTheFuture(actual, StandardComparisonStrategy.instance()); } private ShouldBeInTheFuture(Date actual, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be in the future%s but was not.", actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInThePast.java000066400000000000000000000037001243020563200277250ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is in the past failed. * * @author Joel Costigliola */ public class ShouldBeInThePast extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInThePast}. * @param actual the actual value in the failed assertion. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInThePast(Date actual, ComparisonStrategy comparisonStrategy) { return new ShouldBeInThePast(actual, comparisonStrategy); } /** * Creates a new {@link ShouldBeInThePast}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInThePast(Date actual) { return new ShouldBeInThePast(actual, StandardComparisonStrategy.instance()); } private ShouldBeInThePast(Date actual, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be in the past%s but was not.", actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInstance.java000066400000000000000000000041441243020563200276350ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is an instance of some type * failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeInstance extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInstance}. * * @param object the object value in the failed assertion. * @param type the type {@code object} is expected to belong to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInstance(Object object, Class type) { return new ShouldBeInstance(object, type); } /** * Creates a new {@link ShouldBeInstance} when object we want to check type is null. * * @param objectDescription the description of the null object we wanted to check type. * @param type the expected type. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInstanceButWasNull(String objectDescription, Class type) { return new ShouldBeInstance(objectDescription, type); } private ShouldBeInstance(Object object, Class type) { super("expected <%s> to be an instance of:\n<%s>\nbut was instance of:\n<%s>", object, type, object.getClass()); } private ShouldBeInstance(String objectDescription, Class type) { super("expected %s object to be an instance of:<%s> but was null", objectDescription, type); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeInstanceOfAny.java000066400000000000000000000030351243020563200305700ustar00rootroot00000000000000/* * Created on Dec 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is an instance of one or more types failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeInstanceOfAny extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeInstanceOfAny}. * @param actual the actual value in the failed assertion. * @param types contains the type or types {@code actual} is expected to belong to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeInstanceOfAny(Object actual, Class[] types) { return new ShouldBeInstanceOfAny(actual, types); } private ShouldBeInstanceOfAny(Object actual, Class[] types) { super("expected <%s> to be an instance of any of:\n<%s>\n but was instance of:<%s>", actual, types, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeLenientEqualByAccepting.java000066400000000000000000000046611243020563200325740ustar00rootroot00000000000000/* * Created on Apr 23, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import java.util.List; /** * Creates an {@link AssertionError} indicating that an assertion that verifies that two objects are lenient equal by * accepting fields failed. * * @author Nicolas François * @author Joel Costigliola */ public class ShouldBeLenientEqualByAccepting extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeLenientEqualByAccepting}. * @param actual the actual value in the failed assertion. * @param rejectedFields fields name not matching * @param expectedValues fields value not matching * @param acceptedFields fields on which is based the lenient equality * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeLenientEqualByAccepting(Object actual, List rejectedFields, List expectedValues, List acceptedFields) { if (rejectedFields.size() == 1) { return new ShouldBeLenientEqualByAccepting(actual, rejectedFields.get(0), expectedValues.get(0), acceptedFields); } else { return new ShouldBeLenientEqualByAccepting(actual, rejectedFields, expectedValues, acceptedFields); } } private ShouldBeLenientEqualByAccepting(Object actual, List rejectedFields, List expectedValue, List acceptedFields) { super("expected values:\n<%s>\n in fields:\n<%s>\n of <%s>.\nComparison was performed on fields <%s>", expectedValue, rejectedFields, actual, acceptedFields); } private ShouldBeLenientEqualByAccepting(Object actual, String rejectedField, Object rejectedValue, List acceptedFields) { super("expected value <%s> in field <%s> of <%s>.\nComparison was performed on fields <%s>", rejectedValue, rejectedField, actual, acceptedFields); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeLenientEqualByIgnoring.java000066400000000000000000000064001243020563200324440ustar00rootroot00000000000000/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import java.util.List; /** * Creates an {@link AssertionError} indicating that an assertion that verifies that two objects are lenient equal by * ignoring fields failed. * * @author Nicolas François * @author Joel Costigliola */ public class ShouldBeLenientEqualByIgnoring extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeLenientEqualByIgnoring}. * @param actual the actual value in the failed assertion. * @param rejectedFields fields name not matching * @param expectedValues fields value not matching * @param ignoredFields fields which are not base the lenient equality * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeLenientEqualByIgnoring(Object actual, List rejectedFields, List expectedValues, List ignoredFields) { if (rejectedFields.size() == 1) { if (ignoredFields.isEmpty()) { return new ShouldBeLenientEqualByIgnoring(actual, rejectedFields.get(0), expectedValues.get(0)); } else { return new ShouldBeLenientEqualByIgnoring(actual, rejectedFields.get(0), expectedValues.get(0), ignoredFields); } } else { if (ignoredFields.isEmpty()) { return new ShouldBeLenientEqualByIgnoring(actual, rejectedFields, expectedValues); } else { return new ShouldBeLenientEqualByIgnoring(actual, rejectedFields, expectedValues, ignoredFields); } } } private ShouldBeLenientEqualByIgnoring(Object actual, List rejectedFields, List expectedValues, List ignoredFields) { super("expected values:\n<%s>\n in fields:\n<%s>\n of <%s>.\nComparison was performed on all fields but <%s>", expectedValues, rejectedFields, actual, ignoredFields); } private ShouldBeLenientEqualByIgnoring(Object actual, String rejectedField, Object expectedValue, List ignoredFields) { super("expected value <%s> in field <%s> of <%s>.\nComparison was performed on all fields but <%s>", expectedValue, rejectedField, actual, ignoredFields); } private ShouldBeLenientEqualByIgnoring(Object actual, List rejectedFields, List expectedValue) { super("expected values:\n<%s>\n in fields:\n<%s>\n of <%s>.\nComparison was performed on all fields", expectedValue, rejectedFields, actual); } private ShouldBeLenientEqualByIgnoring(Object actual, String rejectedField, Object expectedValue) { super("expected value <%s> in field <%s> of <%s>.\nComparison was performed on all fields", expectedValue, rejectedField, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeLess.java000066400000000000000000000045651243020563200270060ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is less than another one failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeLess extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeLess}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeLess(T actual, T other) { return new ShouldBeLess(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeLess}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeLess(T actual, T other, ComparisonStrategy comparisonStrategy) { return new ShouldBeLess(actual, other, comparisonStrategy); } private ShouldBeLess(Comparable actual, Comparable other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be less than:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeLessOrEqual.java000066400000000000000000000047051243020563200302730ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is less than or equal to another one failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeLessOrEqual extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeLessOrEqual}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeLessOrEqual(T actual, T other) { return new ShouldBeLessOrEqual(actual, other, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldBeLessOrEqual}. * @param guarantees that the values used in this factory have the same type. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static > ErrorMessageFactory shouldBeLessOrEqual(T actual, T other, ComparisonStrategy comparisonStrategy) { return new ShouldBeLessOrEqual(actual, other, comparisonStrategy); } private ShouldBeLessOrEqual(Comparable actual, Comparable other, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be less than or equal to:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeLowerCase.java000066400000000000000000000025001243020563200277470ustar00rootroot00000000000000/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message that indicates an assertion that verifies that a character is lowercase failed. * * @author Yvonne Wang */ public class ShouldBeLowerCase extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeLowerCase}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeLowerCase(Character actual) { return new ShouldBeLowerCase(actual); } private ShouldBeLowerCase(Character actual) { super("expected:<%s> to be a lowercase character", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeNullOrEmpty.java000066400000000000000000000026361243020563200303270ustar00rootroot00000000000000/* * Created on Sep 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a group of elements is {@code null} or empty failed. A * group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldBeNullOrEmpty extends BasicErrorMessageFactory { /** * Creates a new instance of {@link ShouldBeNullOrEmpty}. * @param actual the actual value in the failed assertion. * @return the created of {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeNullOrEmpty(Object actual) { return new ShouldBeNullOrEmpty(actual); } private ShouldBeNullOrEmpty(Object actual) { super("expecting null or empty but was:<%s>", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeOfClassIn.java000066400000000000000000000027021243020563200277100ustar00rootroot00000000000000/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is of type in group of types failed. * * @author Nicolas François */ public class ShouldBeOfClassIn extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeOfClassIn}. * @param actual the actual value in the failed assertion. * @param types contains the types {@code actual} is expected to be in. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeOfClassIn(Object actual, Object types) { return new ShouldBeOfClassIn(actual, types); } private ShouldBeOfClassIn(Object actual, Object types) { super("expected <%s> should have type in <%s> but was:<%s>", actual, types, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeReadable.java000066400000000000000000000024671243020563200275760ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is readable * failed. * * @author Olivier Demeijer * */ public class ShouldBeReadable extends BasicErrorMessageFactory { private ShouldBeReadable(File actual) { super("File:<%s> should be readable", actual); } /** * Creates a new {@link ShouldBeReadable}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeReadable(File actual) { return new ShouldBeReadable(actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeRelativePath.java000066400000000000000000000025561243020563200304660ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is a relative path failed. * * @author Yvonne Wang */ public class ShouldBeRelativePath extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeRelativePath}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeRelativePath(File actual) { return new ShouldBeRelativePath(actual); } private ShouldBeRelativePath(File actual) { super("File:<%s> should be a relative path", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeSame.java000066400000000000000000000026701243020563200267600ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that two object refer to same object failed. * * @author Alex Ruiz */ public class ShouldBeSame extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeSame}. * @param actual the actual value in the failed assertion. * @param expected the expected value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeSame(Object actual, Object expected) { return new ShouldBeSame(actual, expected); } private ShouldBeSame(Object actual, Object expected) { super("expected:<%s> and actual:<%s> should refer to the same object", expected, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeSorted.java000066400000000000000000000067631243020563200273420ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.util.ArrayWrapperList.wrap; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; /** * Creates an error message indicating that an assertion that verifies a group of elements is sorted failed.
* A group of elements can be a collection or an array. * * @author Joel Costigliola */ public class ShouldBeSorted extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeSorted}. * @param i the index of elements whose not naturally ordered with the next. * @param group the actual group in the failed assertion (either collection or an array). * @return an instance of {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeSorted(int i, Object group) { List groupAsList = groupAsList(group); return new ShouldBeSorted("group is not sorted because element %s:<%s> is not less or equal than element %s:<%s>.\n" + "group was:\n" + "<%s>", i, groupAsList.get(i), i + 1, groupAsList.get(i + 1), groupAsList); } public static ErrorMessageFactory shouldBeSortedAccordingToGivenComparator(int i, Object group, Comparator comparator) { List arrayWrapper = groupAsList(group); return new ShouldBeSorted( "group is not sorted according to %s comparator because element %s:<%s> is not less or equal than element %s:<%s>.\n" + "group was:\n" + "<%s>", comparator, i, arrayWrapper.get(i), i + 1, arrayWrapper.get(i + 1), arrayWrapper); } public static ErrorMessageFactory shouldHaveMutuallyComparableElements(Object actual) { return new ShouldBeSorted("some elements are not mutually comparable in group:<%s>", actual); } public static ErrorMessageFactory shouldHaveComparableElementsAccordingToGivenComparator(Object actual, Comparator comparator) { return new ShouldBeSorted("some elements are not mutually comparable according to %s comparator in group:<%s>", comparator, actual); } private ShouldBeSorted(String format, Object... arguments) { super(format, arguments); } /** * Convert the given group (which is either an array or a Collection) to a List. * @param group the group to convert * @return the corresponding List * @throws IllegalArgumentException if group can't be converted to a List */ @SuppressWarnings("unchecked") private static List groupAsList(Object group) { if (group.getClass().isArray()) { return wrap(group); } else if (group instanceof Collection) { List asList = new ArrayList(); asList.addAll(((Collection) group)); return asList; } throw new IllegalArgumentException("Parameter should be an array or a collection but was " + group); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeSubsetOf.java000066400000000000000000000042351243020563200276240ustar00rootroot00000000000000/* * Created on Feb 18, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that an Iterable is a subset of an other set * Iterable failed. * * @author Maciej Jaskowski */ public class ShouldBeSubsetOf extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeSubsetOf} * @param actual the actual set * @param values the expected superset * @param comparisonStrategy the {@link ComparisonStrategy} used * @return the created {@link ErrorMessageFactory} */ public static ErrorMessageFactory shouldBeSubsetOf(Object actual, Object values, Iterable unexpected, ComparisonStrategy comparisonStrategy) { return new ShouldBeSubsetOf(actual, values, unexpected, comparisonStrategy); } /** * Creates a new {@link ShouldBeSubsetOf}. * @param actual the actual set * @param values the expected superset * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeSubsetOf(Object actual, Object values, Iterable unexpected) { return new ShouldBeSubsetOf(actual, values, unexpected, StandardComparisonStrategy.instance()); } private ShouldBeSubsetOf(Object actual, Object values, Iterable unexpected, ComparisonStrategy comparisonStrategy) { super("expecting%s:\n<%s>\n to be subset of\n<%s>\n but found those extra elements:\n<%s>", comparisonStrategy, actual, values, unexpected); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeToday.java000066400000000000000000000037031243020563200271510ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is today (matching only year, month and * day but not hours). * * @author Joel Costigliola */ public class ShouldBeToday extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeToday}. * @param actual the actual value in the failed assertion. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeToday(Date actual, ComparisonStrategy comparisonStrategy) { return new ShouldBeToday(actual, comparisonStrategy); } /** * Creates a new {@link ShouldBeToday}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeToday(Date actual) { return new ShouldBeToday(actual, StandardComparisonStrategy.instance()); } private ShouldBeToday(Date actual, ComparisonStrategy comparisonStrategy) { super("expected:<%s> to be today%s but was not.", actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeUpperCase.java000066400000000000000000000025001243020563200277520ustar00rootroot00000000000000/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message that indicates an assertion that verifies that a character is uppercase failed. * * @author Yvonne Wang */ public class ShouldBeUpperCase extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeUpperCase}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeUpperCase(Character actual) { return new ShouldBeUpperCase(actual); } private ShouldBeUpperCase(Character actual) { super("expected:<%s> to be a uppercase character", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeWithin.java000066400000000000000000000032661243020563200273370ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is within a year, month, day, ... * failed. * * @author Joel Costigliola */ public class ShouldBeWithin extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldBeWithin}. * @param actual the actual value in the failed assertion. * @param fieldDescription the fieldDescription of value : year, month, day, ... * @param fieldValue the field value used in the failed assertion to compare the actual date field value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeWithin(Date actual, String fieldDescription, int fieldValue) { return new ShouldBeWithin(actual, fieldDescription, fieldValue); } private ShouldBeWithin(Date actual, String fieldDescription, int fieldValue) { super("expected:<%s> to be to be on %s <%s>", actual, fieldDescription, fieldValue); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldBeWritable.java000066400000000000000000000024651243020563200276460ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} is writable * failed. * * @author Olivier Demeijer * */ public class ShouldBeWritable extends BasicErrorMessageFactory { private ShouldBeWritable(File actual) { super("File:<%s> should be writable", actual); } /** * Creates a new {@link ShouldBeWritable}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldBeWritable(File actual) { return new ShouldBeWritable(actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContain.java000066400000000000000000000050311243020563200272110ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements contains a given set of values failed. * A group of elements can be a collection, an array or a {@code String}.
* It also mention the {@link ComparisonStrategy} used. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContain extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContain}. * @param actual the actual value in the failed assertion. * @param expected values expected to be in {@code actual}. * @param notFound the values in {@code expected} not found in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContain(Object actual, Object expected, Object notFound, ComparisonStrategy comparisonStrategy) { return new ShouldContain(actual, expected, notFound, comparisonStrategy); } /** * Creates a new {@link ShouldContain}. * @param actual the actual value in the failed assertion. * @param expected values expected to be in {@code actual}. * @param notFound the values in {@code expected} not found in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContain(Object actual, Object expected, Object notFound) { return shouldContain(actual, expected, notFound, StandardComparisonStrategy.instance()); } private ShouldContain(Object actual, Object expected, Object notFound, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to contain:\n<%s>\n but could not find:\n<%s>\n%s", actual, expected, notFound, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainAtIndex.java000066400000000000000000000054261243020563200304760ustar00rootroot00000000000000/* * Created on Nov 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements contains a value at a given index * failed. A group of elements can be a collection, an array or a {@code String}.
* It also mention the {@link ComparisonStrategy} if the default one is not used. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContainAtIndex extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainAtIndex}. * @param actual the actual value in the failed assertion. * @param expected value expected to be in {@code actual}. * @param index the index of the expected value. * @param found the value in {@code actual} stored under {@code index}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainAtIndex(Object actual, Object expected, Index index, Object found, ComparisonStrategy comparisonStrategy) { return new ShouldContainAtIndex(actual, expected, index, found, comparisonStrategy); } /** * Creates a new {@link ShouldContainAtIndex}. * @param actual the actual value in the failed assertion. * @param expected value expected to be in {@code actual}. * @param index the index of the expected value. * @param found the value in {@code actual} stored under {@code index}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainAtIndex(Object actual, Object expected, Index index, Object found) { return new ShouldContainAtIndex(actual, expected, index, found, StandardComparisonStrategy.instance()); } private ShouldContainAtIndex(Object actual, Object expected, Index index, Object found, ComparisonStrategy comparisonStrategy) { super("expecting:<%s> at index <%s> but found <%s> in:\n <%s>\n%s", expected, index.value, found, actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainExactly.java000066400000000000000000000120371243020563200305470ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements contains exactly a given set * of values and nothing else failed, exactly meaning same elements in same order. A group of elements can be a * collection, an array or a {@code String}. * * @author Joel Costigliola */ public class ShouldContainExactly extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainExactly}. * * @param actual the actual value in the failed assertion. * @param expected values expected to be contained in {@code actual}. * @param notFound values in {@code expected} not found in {@code actual}. * @param notExpected values in {@code actual} that were not in {@code expected}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainExactly(Object actual, Object expected, Object notFound, Object notExpected, ComparisonStrategy comparisonStrategy) { return new ShouldContainExactly(actual, expected, notFound, notExpected, comparisonStrategy); } /** * Creates a new {@link ShouldContainExactly}. * * @param actual the actual value in the failed assertion. * @param expected values expected to be contained in {@code actual}. * @param notFound values in {@code expected} not found in {@code actual}. * @param notExpected values in {@code actual} that were not in {@code expected}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainExactly(Object actual, Object expected, Object notFound, Object notExpected) { return new ShouldContainExactly(actual, expected, notFound, notExpected, StandardComparisonStrategy.instance()); } private ShouldContainExactly(Object actual, Object expected, Object notFound, Object notExpected, ComparisonStrategy comparisonStrategy) { super( "expecting:\n<%s>\n to contain exactly (and in same order):\n<%s>\n but some elements were not found:\n<%s>\n and others were not expected:\n<%s>\n%s", actual, expected, notFound, notExpected, comparisonStrategy); } /** * Creates a new {@link ShouldContainExactly} for the case where actual and expected have the same * elements in different order according to the given {@link ComparisonStrategy}. * * @param actualElement the actual element at indexOfDifferentElements index. * @param expectedElement the expected element at indexOfDifferentElements index. * @param indexOfDifferentElements index where actual and expect differs. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainExactly(Object actualElement, Object expectedElement, int indexOfDifferentElements, ComparisonStrategy comparisonStrategy) { return new ShouldContainExactly(actualElement, expectedElement, indexOfDifferentElements, comparisonStrategy); } /** * Creates a new {@link ShouldContainExactly} for the case where actual and expected have the same * elements in different order. * * @param actualElement the actual element at indexOfDifferentElements index. * @param expectedElement the expected element at indexOfDifferentElements index. * @param indexOfDifferentElements index where actual and expect differs. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainExactly(Object actualElement, Object expectedElement, int indexOfDifferentElements) { return new ShouldContainExactly(actualElement, expectedElement, indexOfDifferentElements, StandardComparisonStrategy.instance()); } private ShouldContainExactly(Object actualElement, Object expectedElement, int indexOfDifferentElements, ComparisonStrategy comparisonStrategy) { super( "actual and expected have the same elements but not in the same order, at index %s actual element was :\n<%s>\n whereas expected element was :\n<%s>\n%s", indexOfDifferentElements, actualElement, expectedElement, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainKey.java000066400000000000000000000025231243020563200276650ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a map contains a key.. * * @author Nicolas François */ public class ShouldContainKey extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainKey}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainKey(Object actual, Object key) { return new ShouldContainKey(actual, key); } private ShouldContainKey(Object actual, Object key) { super("expecting:\n<%s>\n to contain key:\n<%s>", actual, key); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainNull.java000066400000000000000000000026221243020563200300470ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a group of elements contains a null element failed. A group * of elements can be a collection or an array. * * @author Joel Costigliola */ public class ShouldContainNull extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainNull}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainNull(Object actual) { return new ShouldContainNull(actual); } private ShouldContainNull(Object actual) { super("expecting:\n<%s>\n to contain a element", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainOnly.java000066400000000000000000000055771243020563200300720ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements contains only a given set of values and * nothing else failed. A group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldContainOnly extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainOnly}. * @param actual the actual value in the failed assertion. * @param expected values expected to be contained in {@code actual}. * @param notFound values in {@code expected} not found in {@code actual}. * @param notExpected values in {@code actual} that were not in {@code expected}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainOnly(Object actual, Object expected, Object notFound, Object notExpected, ComparisonStrategy comparisonStrategy) { return new ShouldContainOnly(actual, expected, notFound, notExpected, comparisonStrategy); } /** * Creates a new {@link ShouldContainOnly}. * @param actual the actual value in the failed assertion. * @param expected values expected to be contained in {@code actual}. * @param notFound values in {@code expected} not found in {@code actual}. * @param notExpected values in {@code actual} that were not in {@code expected}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainOnly(Object actual, Object expected, Object notFound, Object notExpected) { return new ShouldContainOnly(actual, expected, notFound, notExpected, StandardComparisonStrategy.instance()); } private ShouldContainOnly(Object actual, Object expected, Object notFound, Object notExpected, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to contain only:\n<%s>\n elements not found:\n<%s>\n and elements not expected:\n<%s>\n%s", actual, expected, notFound, notExpected, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainSequence.java000066400000000000000000000043761243020563200307150ustar00rootroot00000000000000/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a group of elements contains a sequence of values * failed. A group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContainSequence extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainSequence}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected to be in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainSequence(Object actual, Object sequence, ComparisonStrategy comparisonStrategy) { return new ShouldContainSequence(actual, sequence, comparisonStrategy); } /** * Creates a new {@link ShouldContainSequence}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected to be in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainSequence(Object actual, Object sequence) { return new ShouldContainSequence(actual, sequence, StandardComparisonStrategy.instance()); } private ShouldContainSequence(Object actual, Object sequence, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to contain sequence:\n<%s>\n%s", actual, sequence, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainString.java000066400000000000000000000053111243020563200304010ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@code String} contains another {@code String} * failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContainString extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainString}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected to be in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContain(String actual, String sequence) { return new ShouldContainString("expecting:<%s> to contain:<%s>%s", actual, sequence, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldContainString}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected to be in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContain(String actual, String sequence, ComparisonStrategy comparisonStrategy) { return new ShouldContainString("expecting:<%s> to contain:<%s>%s", actual, sequence, comparisonStrategy); } /** * Creates a new {@link ShouldContainString}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected to be in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainIgnoringCase(String actual, String sequence) { return new ShouldContainString("expecting:<%s> to contain:<%s> (ignoring case)", actual, sequence, StandardComparisonStrategy.instance()); } private ShouldContainString(String format, String actual, String sequence, ComparisonStrategy comparisonStrategy) { super(format, actual, sequence, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainStringOnlyOnce.java000066400000000000000000000045371243020563200320610ustar00rootroot00000000000000package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@code String} contains another {@code String} only * once failed. * * @author Pauline Iogna * @author Joel Costigliola */ public class ShouldContainStringOnlyOnce extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainStringOnlyOnce}. * * @param actual the actual value in the failed assertion. * @param sequence the String expected to be in {@code actual} only once. * @param occurences the number of occurences of sequence in actual. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainOnlyOnce(String actual, String sequence, int occurences, ComparisonStrategy comparisonStrategy) { if (occurences == 0) return new ShouldContainStringOnlyOnce(actual, sequence, comparisonStrategy); return new ShouldContainStringOnlyOnce(actual, sequence, occurences, comparisonStrategy); } /** * Creates a new {@link ShouldContainStringOnlyOnce}. * * @param actual the actual value in the failed assertion. * @param sequence the String expected to be in {@code actual} only once. * @param occurences the number of occurences of sequence in actual. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainOnlyOnce(String actual, String sequence, int occurences) { if (occurences == 0) return new ShouldContainStringOnlyOnce(actual, sequence, StandardComparisonStrategy.instance()); return new ShouldContainStringOnlyOnce(actual, sequence, occurences, StandardComparisonStrategy.instance()); } private ShouldContainStringOnlyOnce(String actual, String expected, int occurences, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to appear only once in:\n<%s>\n but it appeared %s times%s.", expected, actual, occurences, comparisonStrategy); } private ShouldContainStringOnlyOnce(String actual, String expected, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n to appear only once in:\n<%s>\n but it did not appear%s.", expected, actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldContainValue.java000066400000000000000000000025501243020563200302110ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a map contains a value. * * @author Nicolas François */ public class ShouldContainValue extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldContainValue}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldContainValue(Object actual, Object value) { return new ShouldContainValue(actual, value); } private ShouldContainValue(Object actual, Object value) { super("expecting:\n<%s>\n to contain value:\n<%s>", actual, value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldEndWith.java000066400000000000000000000043561243020563200271710ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a group of elements ends with a given value or * sequence of values failed. A group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldEndWith extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldEndWith}. * @param actual the actual value in the failed assertion. * @param expected the value or sequence of values that {@code actual} is expected to start with. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldEndWith(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { return new ShouldEndWith(actual, expected, comparisonStrategy); } /** * Creates a new {@link ShouldEndWith}. * @param actual the actual value in the failed assertion. * @param expected the value or sequence of values that {@code actual} is expected to start with. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldEndWith(Object actual, Object expected) { return new ShouldEndWith(actual, expected, StandardComparisonStrategy.instance()); } private ShouldEndWith(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { super("expecting\n<%s>\n to end with\n<%s>\n%s", actual, expected, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldExist.java000066400000000000000000000024561243020563200267220ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} exists failed. * * @author Yvonne Wang */ public class ShouldExist extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldExist}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldExist(File actual) { return new ShouldExist(actual); } private ShouldExist(File actual) { super("expecting file:<%s> to exist", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHave.java000066400000000000000000000031511243020563200265020ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that a value satisfies a {@link Condition} * failed. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class ShouldHave extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHave}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHave(T actual, Condition condition) { return new ShouldHave(actual, condition); } private ShouldHave(Object actual, Condition condition) { super("expecting:<%s> to have:<%s>", actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveAtIndex.java000066400000000000000000000024571243020563200277670ustar00rootroot00000000000000package org.fest.assertions.error; import org.fest.assertions.core.Condition; import org.fest.assertions.data.Index; import java.util.List; /** * Creates an error message indicating that an assertion that verifies a group of elements contains a value at a given * index that satisfies a {@link Condition} failed. * * @author Bo Gotthardt */ public class ShouldHaveAtIndex extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveAtIndex}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @param index the index of the expected value. * @param found the value in {@code actual} stored under {@code index}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveAtIndex(List actual, Condition condition, Index index, T found) { return new ShouldHaveAtIndex(actual, condition, index, found); } private ShouldHaveAtIndex(List actual, Condition condition, Index index, T found) { super("expecting:<%s> at index <%s> to have:<%s> in:\n <%s>\n", found, index.value, condition, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveBinaryContent.java000066400000000000000000000032511243020563200312030ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; import org.fest.assertions.internal.BinaryDiffResult; /** * Creates an error message indicating that an assertion that verifies that a file has a given binary content failed. * * @author Olivier Michallat */ public class ShouldHaveBinaryContent extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveBinaryContent}. * @param actual the actual file in the failed assertion. * @param diff the differences between {@code actual} and the given binary content. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveBinaryContent(File actual, BinaryDiffResult diff) { return new ShouldHaveBinaryContent(actual, diff); } private ShouldHaveBinaryContent(File actual, BinaryDiffResult diff) { super("file:<%s> does not have expected binary content: at offset <%s>, expected:\n<%s>\n but was:\n<%s>", actual, diff.offset, diff.expected, diff.actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveContent.java000066400000000000000000000033551243020563200300430ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; import java.nio.charset.Charset; import java.util.List; /** * Creates an error message indicating that an assertion that verifies that a file has a given text content failed. * * @author Olivier Michallat */ public class ShouldHaveContent extends AbstractShouldHaveTextContent { /** * Creates a new {@link ShouldHaveContent}. * @param actual the actual file in the failed assertion. * @param charset the charset that was used to read the file. * @param diffs the differences between {@code actual} and the expected text that was provided in the assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveContent(File actual, Charset charset, List diffs) { return new ShouldHaveContent(actual, charset, diffsAsString(diffs)); } private ShouldHaveContent(File actual, Charset charset, String diffs) { super("file:<%s> read with charset:<%s> does not have expected content:", actual, charset); this.diffs = diffs; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveEqualContent.java000066400000000000000000000050011243020563200310210ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; import java.io.InputStream; import java.util.List; /** * Creates an error message indicating that an assertion that verifies that two files/inputStreams have equal content failed. * * @author Yvonne Wang * @author Matthieu Baechler * @author Joel Costigliola */ public class ShouldHaveEqualContent extends AbstractShouldHaveTextContent { /** * Creates a new {@link ShouldHaveEqualContent}. * @param actual the actual file in the failed assertion. * @param expected the expected file in the failed assertion. * @param diffs the differences between {@code actual} and {@code expected}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveEqualContent(File actual, File expected, List diffs) { return new ShouldHaveEqualContent(actual, expected, diffsAsString(diffs)); } /** * Creates a new {@link ShouldHaveEqualContent}. * @param actual the actual InputStream in the failed assertion. * @param expected the expected Stream in the failed assertion. * @param diffs the differences between {@code actual} and {@code expected}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveEqualContent(InputStream actual, InputStream expected, List diffs) { return new ShouldHaveEqualContent(actual, expected, diffsAsString(diffs)); } private ShouldHaveEqualContent(File actual, File expected, String diffs) { super("file:<%s> and file:<%s> do not have equal content:", actual, expected); this.diffs = diffs; } private ShouldHaveEqualContent(InputStream actual, InputStream expected, String diffs) { super("InputStreams do not have equal content:", actual, expected); this.diffs = diffs; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveMessage.java000066400000000000000000000030201243020563200300020ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that a {@link Throwable} have certain message failed. * @author Joel Costigliola */ public class ShouldHaveMessage extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveMessage}. * @param actual the actual {@link Throwable} in the failed assertion. * @param expectedMessage the expected message of actual {@link Throwable}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveMessage(Throwable actual, String expectedMessage) { return new ShouldHaveMessage(actual, expectedMessage); } private ShouldHaveMessage(Throwable actual, String expectedMessage) { super("expected message:\n<%s>\n but was:\n<%s>", expectedMessage, actual.getMessage()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveNoCause.java000066400000000000000000000025071243020563200277640ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an {@link Throwable} has no cause failed. * * @author Joel Costigliola */ public class ShouldHaveNoCause extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveNoCause}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveNoCause(Throwable actual) { return new ShouldHaveNoCause(actual); } private ShouldHaveNoCause(Throwable actual) { super("expected exception without cause, but cause was:<%s>", actual.getCause()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveSameClass.java000066400000000000000000000027651243020563200303100ustar00rootroot00000000000000/* * Created on Jun 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object have same class as another instance failed. * * @author Nicolas François */ public class ShouldHaveSameClass extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveSameClass}. * @param actual the actual value in the failed assertion. * @param other the type {@code actual} is expected to be. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveSameClass(Object actual, Object other) { return new ShouldHaveSameClass(actual, other); } private ShouldHaveSameClass(Object actual, Object other) { super("expected <%s> to have the same class as:<%s>(<%s>) but was of class:<%s>", actual, other, other.getClass(), actual .getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveSameSizeAs.java000066400000000000000000000032051243020563200304270ustar00rootroot00000000000000/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that a value have certain size failed. * * @author Nicolas François */ public class ShouldHaveSameSizeAs extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveSameSizeAs}. * @param actual the actual value in the failed assertion. * @param actualSize the size of {@code actual}. * @param expectedSize the expected size. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveSameSizeAs(Object actual, Object actualSize, Object expectedSize) { return new ShouldHaveSameSizeAs(actual, actualSize, expectedSize); } private ShouldHaveSameSizeAs(Object actual, Object actualSize, Object expectedSize) { super("actual and expected should have same size but actual size is:<%s> while expected is:<%s>, actual was:<%s>", actualSize, expectedSize, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveSize.java000066400000000000000000000030241243020563200273340ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that a value have certain size failed. * * @author Alex Ruiz */ public class ShouldHaveSize extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveSize}. * @param actual the actual value in the failed assertion. * @param actualSize the size of {@code actual}. * @param expectedSize the expected size. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveSize(Object actual, Object actualSize, Object expectedSize) { return new ShouldHaveSize(actual, actualSize, expectedSize); } private ShouldHaveSize(Object actual, Object actualSize, Object expectedSize) { super("expected size:<%s> but was:<%s> in:<%s>", expectedSize, actualSize, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldHaveTime.java000066400000000000000000000031551243020563200273250ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; /** * Creates an error message indicating that an assertion that verifies that a date have a certain timestamp. * * @author Guillaume Girou * @author Nicolas François * @author Joel Costigliola */ public class ShouldHaveTime extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldHaveTime}. * @param actual the actual value in the failed assertion. * @param actualTimestamp the timestamp of {@code actual}. * @param expectedTimestamp the expected timestamp. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldHaveTime(Date actual, long expectedTimestamp) { return new ShouldHaveTime(actual, expectedTimestamp); } private ShouldHaveTime(Date actual, long expectedTimestamp) { super("expected <%s> to have time:\n<%s>\n but was:\n<%s>", actual, expectedTimestamp, actual.getTime()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldMatchPattern.java000066400000000000000000000025751243020563200302220ustar00rootroot00000000000000/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that a {@code String} matches a pattern failed. * * @author Alex Ruiz */ public class ShouldMatchPattern extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldMatchPattern}. * @param actual the actual value in the failed assertion. * @param pattern a regular expression pattern. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldMatch(String actual, String pattern) { return new ShouldMatchPattern(actual, pattern); } private ShouldMatchPattern(String actual, String pattern) { super("%s does not match the pattern %s", actual, pattern); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBe.java000066400000000000000000000031671243020563200266350ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that a value does not satisfy a * {@link Condition} failed. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class ShouldNotBe extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBe}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBe(T actual, Condition condition) { return new ShouldNotBe(actual, condition); } private ShouldNotBe(Object actual, Condition condition) { super("expecting:<%s> not to be:<%s>", actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeBetween.java000066400000000000000000000055151243020563200301460ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import java.util.Date; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@link Date} is not between start - end dates * (inclusive or not) failed. * * @author Joel Costigliola */ public class ShouldNotBeBetween extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeBetween}. * @param actual the actual value in the failed assertion. * @param start the lower boundary of date period. * @param end the lower boundary of date period. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd, ComparisonStrategy comparisonStrategy) { return new ShouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, comparisonStrategy); } /** * Creates a new {@link ShouldNotBeBetween}. * @param actual the actual value in the failed assertion. * @param start the lower boundary of date period. * @param end the lower boundary of date period. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { return new ShouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, StandardComparisonStrategy.instance()); } private ShouldNotBeBetween(Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd, ComparisonStrategy comparisonStrategy) { super("expected:<%s> not to be in period %s%s, %s%s%s", actual, inclusiveStart ? '[' : ']', start, end, inclusiveEnd ? ']' : '[', comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeEmpty.java000066400000000000000000000027561243020563200276570ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.description.Description; /** * Creates an error message indicating that an assertion that verifies a group of elements is not empty failed. A group of * elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz */ public class ShouldNotBeEmpty implements ErrorMessageFactory { private static final ShouldNotBeEmpty INSTANCE = new ShouldNotBeEmpty(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ErrorMessageFactory shouldNotBeEmpty() { return INSTANCE; } private ShouldNotBeEmpty() {} /** {@inheritDoc} */ public String create(Description d) { return MessageFormatter.instance().format(d, "expecting actual not to be empty"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeEqual.java000066400000000000000000000041631243020563200276220ustar00rootroot00000000000000/* * Created on Sep 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that two objects are not equal failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotBeEqual extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeEqual}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @param comparisonStrategy the {@link ComparisonStrategy} used to compare actual with expected. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeEqual(Object actual, Object other, ComparisonStrategy comparisonStrategy) { return new ShouldNotBeEqual(actual, other, comparisonStrategy); } /** * Creates a new {@link ShouldNotBeEqual}. * @param actual the actual value in the failed assertion. * @param other the value used in the failed assertion to compare the actual value to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeEqual(Object actual, Object other) { return new ShouldNotBeEqual(actual, other, StandardComparisonStrategy.instance()); } private ShouldNotBeEqual(Object actual, Object other, ComparisonStrategy comparisonStrategy) { super("<%s> should not be equal to:<%s>%s", actual, other, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeEqualImages.java000066400000000000000000000027071243020563200307520ustar00rootroot00000000000000/* * Created on Jan 24, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.description.Description; /** * Creates an error message that indicates an assertion that verifies that two images should not be {@code null} failed. * * @author Yvonne Wang */ public class ShouldNotBeEqualImages implements ErrorMessageFactory { private static final ShouldNotBeEqualImages INSTANCE = new ShouldNotBeEqualImages(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ErrorMessageFactory shouldNotBeEqualImages() { return INSTANCE; } private ShouldNotBeEqualImages() {} /** {@inheritDoc} */ public String create(Description d) { return MessageFormatter.instance().format(d, "expecting images not to be equal"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeExactlyInstanceOf.java000066400000000000000000000030071243020563200321320ustar00rootroot00000000000000/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is not exactly an instance of some type * failed. * * @author Joel Costigliola */ public class ShouldNotBeExactlyInstanceOf extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeExactlyInstanceOf}. * @param actual the actual value in the failed assertion. * @param type the type {@code actual} is expected to be. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeExactlyInstance(Object actual, Class type) { return new ShouldNotBeExactlyInstanceOf(actual, type); } private ShouldNotBeExactlyInstanceOf(Object actual, Class type) { super("expected <%s> to have not exactly the same type as:<%s> but was:<%s>", actual, type, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeIn.java000066400000000000000000000041701243020563200271170ustar00rootroot00000000000000/* * Created on Feb 4, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a value is not in a group of values (e.g. an array or * collection) failed. * * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldNotBeIn extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeIn}. * @param actual the actual value in the failed assertion. * @param values the group of values where {@code actual} is expected to be in. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeIn(Object actual, Object values, ComparisonStrategy comparisonStrategy) { return new ShouldNotBeIn(actual, values, comparisonStrategy); } /** * Creates a new {@link ShouldNotBeIn}. * @param actual the actual value in the failed assertion. * @param values the group of values where {@code actual} is expected to be in. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeIn(Object actual, Object values) { return new ShouldNotBeIn(actual, values, StandardComparisonStrategy.instance()); } private ShouldNotBeIn(Object actual, Object values, ComparisonStrategy comparisonStrategy) { super("expecting:\n<%s>\n not to be in:\n<%s>\n%s", actual, values, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeInstance.java000066400000000000000000000026541243020563200303220ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is not an instance of some type failed. * * @author Nicolas François */ public class ShouldNotBeInstance extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeInstance}. * @param actual the actual value in the failed assertion. * @param type the type {@code actual} is expected to belong to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeInstance(Object actual, Class type) { return new ShouldNotBeInstance(actual, type); } private ShouldNotBeInstance(Object actual, Class type) { super("expected <%s> not to be an instance of:<%s>", actual, type); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeInstanceOfAny.java000066400000000000000000000027601243020563200312550ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is not an instance of one or more types * failed. * * @author Nicolas François */ public class ShouldNotBeInstanceOfAny extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeInstanceOfAny}. * @param actual the actual value in the failed assertion. * @param types contains the type or types {@code actual} is expected to belong to. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeInstanceOfAny(Object actual, Class[] types) { return new ShouldNotBeInstanceOfAny(actual, types); } private ShouldNotBeInstanceOfAny(Object actual, Class[] types) { super("expected <%s> to be an instance of any of:\n<%s>", actual, types); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeNull.java000066400000000000000000000026361243020563200274700ustar00rootroot00000000000000/* * Created on Sep 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.description.Description; /** * Creates an error message that indicates an assertion that verifies that an object is not {@code null} failed. * * @author Alex Ruiz */ public class ShouldNotBeNull implements ErrorMessageFactory { private static final ShouldNotBeNull INSTANCE = new ShouldNotBeNull(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ErrorMessageFactory shouldNotBeNull() { return INSTANCE; } private ShouldNotBeNull() {} /** {@inheritDoc} */ public String create(Description d) { return MessageFormatter.instance().format(d, "expecting actual not to be null"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeOfClassIn.java000066400000000000000000000027351243020563200303770ustar00rootroot00000000000000/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object is not of type in group of types failed. * * @author Nicolas François */ public class ShouldNotBeOfClassIn extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeOfClassIn}. * @param actual the actual value in the failed assertion. * @param types contains the types {@code actual} is not expected to be in. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeOfClassIn(Object actual, Object types) { return new ShouldNotBeOfClassIn(actual, types); } private ShouldNotBeOfClassIn(Object actual, Object types) { super("expected <%s> should not have type in <%s> but was:<%s>", actual, types, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotBeSame.java000066400000000000000000000024421243020563200274360ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating an assertion that verifies that two objects do not refer to the same object failed. * * @author Yvonne Wang * @author Alex Ruiz */ public class ShouldNotBeSame extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotBeSame}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotBeSame(Object actual) { return new ShouldNotBeSame(actual); } private ShouldNotBeSame(Object actual) { super("expected not same:<%s>", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContain.java000066400000000000000000000047641243020563200277060ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements does not contain a given set of values * failed. A group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotContain extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContain}. * @param actual the actual value in the failed assertion. * @param expected values expected not to be contained in {@code actual}. * @param found the values in {@code expected} found in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContain(Object actual, Object expected, Object found, ComparisonStrategy comparisonStrategy) { return new ShouldNotContain(actual, expected, found, comparisonStrategy); } /** * Creates a new {@link ShouldNotContain}. * @param actual the actual value in the failed assertion. * @param expected values expected not to be contained in {@code actual}. * @param found the values in {@code expected} found in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContain(Object actual, Object expected, Object found) { return new ShouldNotContain(actual, expected, found, StandardComparisonStrategy.instance()); } private ShouldNotContain(Object actual, Object expected, Object found, ComparisonStrategy comparisonStrategy) { super("expecting\n<%s>\n not to contain\n<%s>\n but found\n<%s>\n%s", actual, expected, found, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContainAtIndex.java000066400000000000000000000051421243020563200311520ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.data.Index; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements does not contain a value at a given * index failed. A group of elements can be a collection, an array or a {@code String}.
* It also mention the {@link ComparisonStrategy} if the default one is not used. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotContainAtIndex extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContainAtIndex}. * @param actual the actual value in the failed assertion. * @param expected value expected to be in {@code actual}. * @param index the index of the expected value. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContainAtIndex(Object actual, Object expected, Index index, ComparisonStrategy comparisonStrategy) { return new ShouldNotContainAtIndex(actual, expected, index, comparisonStrategy); } /** * Creates a new {@link ShouldNotContainAtIndex}. * @param actual the actual value in the failed assertion. * @param expected value expected to be in {@code actual}. * @param index the index of the expected value. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContainAtIndex(Object actual, Object expected, Index index) { return new ShouldNotContainAtIndex(actual, expected, index, StandardComparisonStrategy.instance()); } private ShouldNotContainAtIndex(Object actual, Object expected, Index index, ComparisonStrategy comparisonStrategy) { super("expecting \n<%s>\n not to contain \n<%s>\n at index <%s>\n%s", actual, expected, index.value, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContainKey.java000066400000000000000000000025651243020563200303540ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a map does not contains a key failed. * * @author Nicolas François */ public class ShouldNotContainKey extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContainKey}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContainKey(Object actual, Object key) { return new ShouldNotContainKey(actual, key); } private ShouldNotContainKey(Object actual, Object key) { super("expecting:\n<%s>\n not to contain key:\n<%s>", actual, key); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContainNull.java000066400000000000000000000026531243020563200305340ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a group of elements does not contain null elements failed. * A group of elements can be a collection or an array. * * @author Joel Costigliola */ public class ShouldNotContainNull extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContainNull}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContainNull(Object actual) { return new ShouldNotContainNull(actual); } private ShouldNotContainNull(Object actual) { super("expecting:\n<%s>\n not to contain elements", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContainString.java000066400000000000000000000042641243020563200310700ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a {@code String} does not contain another * {@code String} failed. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotContainString extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContainString}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected not to be in {@code actual}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContain(String actual, String sequence) { return new ShouldNotContainString(actual, sequence, StandardComparisonStrategy.instance()); } /** * Creates a new {@link ShouldNotContainString}. * @param actual the actual value in the failed assertion. * @param sequence the sequence of values expected not to be in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContain(String actual, String sequence, ComparisonStrategy comparisonStrategy) { return new ShouldNotContainString(actual, sequence, comparisonStrategy); } private ShouldNotContainString(String actual, String sequence, ComparisonStrategy comparisonStrategy) { super("expecting:<%s> not to contain:<%s>%s", actual, sequence, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotContainValue.java000066400000000000000000000026041243020563200306720ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies a map does not contains a value. * * @author Nicolas François */ public class ShouldNotContainValue extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotContainValue}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotContainValue(Object actual, Object value) { return new ShouldNotContainValue(actual, value); } private ShouldNotContainValue(Object actual, Object value) { super("expecting:\n<%s>\n not to contain value:\n<%s>", actual, value); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotExist.java000066400000000000000000000025111243020563200273730ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * Creates an error message indicating that an assertion that verifies that a {@link File} does not exist failed. * * @author Yvonne Wang */ public class ShouldNotExist extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotExist}. * @param actual the actual value in the failed assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotExist(File actual) { return new ShouldNotExist(actual); } private ShouldNotExist(File actual) { super("expecting file:<%s> not to exist", actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotHave.java000066400000000000000000000032031243020563200271610ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.core.Condition; /** * Creates an error message indicating that an assertion that verifies that a value does not satisfy a * {@link Condition} failed. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class ShouldNotHave extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotHave}. * @param guarantees that the type of the actual value and the generic type of the {@code Condition} are the same. * @param actual the actual value in the failed assertion. * @param condition the {@code Condition}. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotHave(T actual, Condition condition) { return new ShouldNotHave(actual, condition); } private ShouldNotHave(Object actual, Condition condition) { super("expecting:<%s> not to have:<%s>", actual, condition); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotHaveDuplicates.java000066400000000000000000000044711243020563200312070ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies a group of elements is does not have duplicates failed. A * group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotHaveDuplicates extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotHaveDuplicates}. * @param actual the actual value in the failed assertion. * @param duplicates the duplicate values found in {@code actual}. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return an instance of {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotHaveDuplicates(Object actual, Object duplicates, ComparisonStrategy comparisonStrategy) { return new ShouldNotHaveDuplicates(actual, duplicates, comparisonStrategy); } /** * Creates a new {@link ShouldNotHaveDuplicates}. * @param actual the actual value in the failed assertion. * @param duplicates the duplicate values found in {@code actual}. * @return an instance of {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotHaveDuplicates(Object actual, Object duplicates) { return new ShouldNotHaveDuplicates(actual, duplicates, StandardComparisonStrategy.instance()); } private ShouldNotHaveDuplicates(Object actual, Object duplicates, ComparisonStrategy comparisonStrategy) { super("found duplicate(s)\n<%s>\n in\n<%s>\n%s", duplicates, actual, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotHaveSameClass.java000066400000000000000000000027311243020563200307620ustar00rootroot00000000000000/* * Created on Jun 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that an object has same class as another instance failed. * * @author Nicolas François */ public class ShouldNotHaveSameClass extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldNotHaveSameClass}. * @param actual the actual value in the failed assertion. * @param other the type {@code actual} is expected to be. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotHaveSameClass(Object actual, Object other) { return new ShouldNotHaveSameClass(actual, other); } private ShouldNotHaveSameClass(Object actual, Object other) { super("expected <%s> not to have not the same class as:<%s> (%s)", actual, other, actual.getClass()); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldNotMatchPattern.java000066400000000000000000000026061243020563200306760ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; /** * Creates an error message indicating that an assertion that verifies that a {@code String} does not match a pattern failed. * * @author Alex Ruiz */ public class ShouldNotMatchPattern extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldStartWith}. * @param actual the actual value in the failed assertion. * @param pattern a regular expression pattern. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldNotMatch(String actual, String pattern) { return new ShouldNotMatchPattern(actual, pattern); } private ShouldNotMatchPattern(String actual, String pattern) { super("%s matches the pattern %s", actual, pattern); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/error/ShouldStartWith.java000066400000000000000000000044031243020563200275510ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import org.fest.assertions.internal.*; /** * Creates an error message indicating that an assertion that verifies that a group of elements starts with a given value or * sequence of values failed. A group of elements can be a collection, an array or a {@code String}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldStartWith extends BasicErrorMessageFactory { /** * Creates a new {@link ShouldStartWith}. * @param actual the actual value in the failed assertion. * @param expected the value or sequence of values that {@code actual} is expected to start with. * @param comparisonStrategy the {@link ComparisonStrategy} used to evaluate assertion. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldStartWith(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { return new ShouldStartWith(actual, expected, comparisonStrategy); } /** * Creates a new {@link ShouldStartWith}. * @param actual the actual value in the failed assertion. * @param expected the value or sequence of values that {@code actual} is expected to start with. * @return the created {@code ErrorMessageFactory}. */ public static ErrorMessageFactory shouldStartWith(Object actual, Object expected) { return new ShouldStartWith(actual, expected, StandardComparisonStrategy.instance()); } private ShouldStartWith(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { super("expecting\n<%s>\n to start with\n<%s>\n%s", actual, expected, comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/groups/000077500000000000000000000000001243020563200237635ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/groups/Properties.java000066400000000000000000000116231243020563200267650ustar00rootroot00000000000000/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.groups; import static org.fest.assertions.util.ArrayWrapperList.wrap; import org.fest.assertions.internal.PropertySupport; import org.fest.util.IntrospectionError; import org.fest.util.VisibleForTesting; /** * Extracts the values of a specified property from the elements of a given {@link Iterable} or array. * * @author Yvonne Wang * @author Mikhail Mazursky * @author Joel Costigliola * @author Florent Biville * @author Olivier Michallat */ public class Properties { @VisibleForTesting final String propertyName; final Class propertyType; @VisibleForTesting PropertySupport propertySupport = PropertySupport.instance(); /** * Creates a new {@link Properties}. * @param propertyName the name of the property to be read from the elements of a {@code Iterable}. It may be a nested * property (e.g. "address.street.number"). * @param propertyType the type of property to extract * @throws NullPointerException if the given property name is {@code null}. * @throws IllegalArgumentException if the given property name is empty. * @return the created {@code Properties}. */ public static Properties extractProperty(String propertyName, Class propertyType) { checkIsNotNullOrEmpty(propertyName); return new Properties(propertyName, propertyType); } /** * Creates a new {@link Properties} with given propertyName and Object as property type.. * @param propertyName the name of the property to be read from the elements of a {@code Iterable}. It may be a nested * property (e.g. "address.street.number"). * @throws NullPointerException if the given property name is {@code null}. * @throws IllegalArgumentException if the given property name is empty. * @return the created {@code Properties}. */ public static Properties extractProperty(String propertyName) { return extractProperty(propertyName, Object.class); } private static void checkIsNotNullOrEmpty(String propertyName) { if (propertyName == null) throw new NullPointerException("The name of the property to read should not be null"); if (propertyName.length() == 0) throw new IllegalArgumentException("The name of the property to read should not be empty"); } @VisibleForTesting Properties(String propertyName, Class propertyType) { this.propertyName = propertyName; this.propertyType = propertyType; } /** * Specifies the target type of an instance that was previously created with {@link #extractProperty(String)}. *

* This is so that you can write: *

   * extractProperty("name").ofType(String.class).from(fellowshipOfTheRing)
   * 
* instead of: *
   * extractProperty("name", String.class).from(fellowshipOfTheRing)
   * 
*

* @param propertyType the type of property to extract. * @return a new {@code Properties} with the given type. */ public Properties ofType(Class propertyType) { return extractProperty(this.propertyName, propertyType); } /** * Extracts the values of the property (specified previously in {@link #extractProperty(String)}) from the elements * of the given {@link Iterable}. * @param c the given {@code Iterable}. * @return the values of the previously specified property extracted from the given {@code Iterable}. * @throws IntrospectionError if an element in the given {@code Iterable} does not have a property with a matching name. */ public Iterable from(Iterable c) { return propertySupport.propertyValues(propertyName, propertyType, c); } /** * Extracts the values of the property (specified previously in {@link #extractProperty(String)}) from the elements * of the given array. * @param array the given array. * @return the values of the previously specified property extracted from the given array. * @throws IntrospectionError if an element in the given array does not have a property with a matching name. */ public Iterable from(Object[] array) { return propertySupport.propertyValues(propertyName, propertyType, wrap(array)); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/000077500000000000000000000000001243020563200242605ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/AbstractComparisonStrategy.java000066400000000000000000000045511243020563200324510ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.reflect.Array.getLength; import static org.fest.util.Iterables.isNullOrEmpty; import java.lang.reflect.Array; import java.util.HashSet; import java.util.Set; /** * Base implementation of {@link ComparisonStrategy} contract. * * @author Joel Costigliola */ public abstract class AbstractComparisonStrategy implements ComparisonStrategy { @Override public Iterable duplicatesFrom(Iterable iterable) { Set duplicates = new HashSet(); if (isNullOrEmpty(iterable)) { return duplicates; } Set noDuplicates = new HashSet(); for (Object element : iterable) { if (iterableContains(noDuplicates, element)) { duplicates.add(element); continue; } noDuplicates.add(element); } return duplicates; } @Override public boolean arrayContains(Object array, Object value) { for (int i = 0; i < getLength(array); i++) { Object element = Array.get(array, i); if (areEqual(element, value)) { return true; } } return false; } @Override public boolean isLessThan(Object actual, Object other) { if (areEqual(actual, other)) { return false; } return !isGreaterThan(actual, other); } @Override public boolean isLessThanOrEqualTo(Object actual, Object other) { if (areEqual(actual, other)) { return true; } return isLessThan(actual, other); } @Override public boolean isGreaterThanOrEqualTo(Object actual, Object other) { if (areEqual(actual, other)) { return true; } return isGreaterThan(actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Arrays.java000066400000000000000000000751521243020563200263760ustar00rootroot00000000000000/* * Created on Nov 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.reflect.Array.getLength; import static org.fest.assertions.error.ConditionAndGroupGenericParameterTypeShouldBeTheSame.shouldBeSameGenericBetweenIterableAndCondition; import static org.fest.assertions.error.ElementsShouldBe.elementsShouldBe; import static org.fest.assertions.error.ElementsShouldBeAtLeast.elementsShouldBeAtLeast; import static org.fest.assertions.error.ElementsShouldBeAtMost.elementsShouldBeAtMost; import static org.fest.assertions.error.ElementsShouldBeExactly.elementsShouldBeExactly; import static org.fest.assertions.error.ElementsShouldHave.elementsShouldHave; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.assertions.error.ElementsShouldHaveAtMost.elementsShouldHaveAtMost; import static org.fest.assertions.error.ElementsShouldHaveExactly.elementsShouldHaveExactly; import static org.fest.assertions.error.ElementsShouldNotBe.elementsShouldNotBe; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.assertions.error.ElementsShouldNotHaveAtMost.elementsShouldNotHaveAtMost; import static org.fest.assertions.error.ElementsShouldNotHaveExactly.elementsShouldNotHaveExactly; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.assertions.error.ShouldContainNull.shouldContainNull; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.assertions.error.ShouldNotContainNull.shouldNotContainNull; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.assertions.internal.CommonErrors.*; import static org.fest.assertions.internal.CommonValidations.checkIndexValueIsValid; import static org.fest.assertions.util.ArrayWrapperList.wrap; import static org.fest.util.Arrays.isArray; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Lists.newArrayList; import java.lang.reflect.Array; import java.util.*; import org.fest.assertions.core.*; import org.fest.assertions.data.Index; import org.fest.assertions.error.ElementsShouldNotBeExactly; import org.fest.assertions.util.ArrayWrapperList; import org.fest.util.*; /** * Assertions for object and primitive arrays. It trades off performance for DRY. * * @author Alex Ruiz * @author Joel Costigliola * @author Nicolas François */ class Arrays { private static final Arrays INSTANCE = new Arrays(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ static Arrays instance() { return INSTANCE; } private final ComparisonStrategy comparisonStrategy; private Arrays() { this(StandardComparisonStrategy.instance()); } public Arrays(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy) .getComparator(); } return null; } void assertNullOrEmpty(AssertionInfo info, Failures failures, Object array) { if (array == null || isArrayEmpty(array)) { return; } throw failures.failure(info, shouldBeNullOrEmpty(array)); } void assertEmpty(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); if (isArrayEmpty(array)) { return; } throw failures.failure(info, shouldBeEmpty(array)); } void assertHasSize(AssertionInfo info, Failures failures, Object array, int expectedSize) { assertNotNull(info, array); int sizeOfActual = sizeOf(array); if (sizeOfActual == expectedSize) { return; } throw failures.failure(info, shouldHaveSize(array, sizeOfActual, expectedSize)); } void assertHasSameSizeAs(AssertionInfo info, Failures failures, Object array, Iterable other) { assertNotNull(info, array); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = sizeOf(array); int sizeOfOther = org.fest.util.Iterables.sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(array, sizeOfActual, sizeOfOther)); } void assertHasSameSizeAs(AssertionInfo info, Failures failures, Object array, Object other) { assertNotNull(info, array); if (other == null) { throw arrayOfValuesToLookForIsNull(); } int sizeOfActual = sizeOf(array); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(array, sizeOfActual, sizeOfOther)); } void assertContains(AssertionInfo info, Failures failures, Object array, Object values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, array); Set notFound = new LinkedHashSet(); int valueCount = sizeOf(values); for (int i = 0; i < valueCount; i++) { Object value = Array.get(values, i); if (!arrayContains(array, value)) { notFound.add(value); } } if (notFound.isEmpty()) { return; } throw failures.failure(info, shouldContain(array, values, notFound, comparisonStrategy)); } void assertcontainsAll(AssertionInfo info, Failures failures, Object array, Iterable iterable) { if (iterable == null) { throw iterableToLookForIsNull(); } assertNotNull(info, array); Object[] values = newArrayList(iterable).toArray(); Set notFound = new LinkedHashSet(); for (Object value : values) { if (!arrayContains(array, value)) { notFound.add(value); } } if (notFound.isEmpty()) { return; } throw failures.failure(info, shouldContain(array, values, notFound, comparisonStrategy)); } void assertContains(AssertionInfo info, Failures failures, Object array, Object value, Index index) { assertNotNull(info, array); assertNotEmpty(info, failures, array); checkIndexValueIsValid(index, sizeOf(array) - 1); Object actualElement = Array.get(array, index.value); if (areEqual(actualElement, value)) { return; } throw failures.failure(info, shouldContainAtIndex(array, value, index, Array.get(array, index.value), comparisonStrategy)); } void assertNotEmpty(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); if (!isArrayEmpty(array)) { return; } throw failures.failure(info, shouldNotBeEmpty()); } void assertDoesNotContain(AssertionInfo info, Failures failures, Object array, Object value, Index index) { assertNotNull(info, array); checkIndexValueIsValid(index, Integer.MAX_VALUE); int indexValue = index.value; if (indexValue >= sizeOf(array)) { return; } Object actualElement = Array.get(array, index.value); if (!areEqual(actualElement, value)) { return; } throw failures.failure(info, shouldNotContainAtIndex(array, value, index, comparisonStrategy)); } void assertContainsOnly(AssertionInfo info, Failures failures, Object array, Object values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, array); Set notExpected = asSetWithoutDuplicatesAccordingToComparisonStrategy(array); Set notFound = containsOnly(notExpected, values); if (notExpected.isEmpty() && notFound.isEmpty()) { return; } throw failures.failure(info, shouldContainOnly(array, values, notFound, notExpected, comparisonStrategy)); } private Set containsOnly(Set actual, Object values) { Set notFound = new LinkedHashSet(); for (Object o : asSetWithoutDuplicatesAccordingToComparisonStrategy(values)) { if (collectionContains(actual, o)) { collectionRemoves(actual, o); } else { notFound.add(o); } } return notFound; } /** * build a Set with that avoid duplicates according to given comparison strategy * @param elements to feed the Set we want to build * @return a Set without duplicates according to given comparison strategy */ private Set asSetWithoutDuplicatesAccordingToComparisonStrategy(Object array) { Set set = new LinkedHashSet(); int size = sizeOf(array); for (int i = 0; i < size; i++) { Object element = Array.get(array, i); if (!collectionContains(set, element)) { set.add(element); } } return set; } /** * Delegates to {@link ComparisonStrategy#iterableContains(Collection, Object)} */ private boolean collectionContains(Collection actual, Object value) { return comparisonStrategy.iterableContains(actual, value); } /** * Delegates to {@link ComparisonStrategy#iterableRemoves(Iterable, Object)} */ private void collectionRemoves(Collection actual, Object value) { comparisonStrategy.iterableRemoves(actual, value); } void assertContainsSequence(AssertionInfo info, Failures failures, Object array, Object sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, array); boolean firstAlreadyFound = false; int i = 0; int sequenceSize = sizeOf(sequence); int sizeOfActual = sizeOf(array); for (int j = 0; j < sizeOfActual; j++) { Object o = Array.get(array, j); if (i >= sequenceSize) { break; } if (!firstAlreadyFound) { if (!areEqual(o, Array.get(sequence, i))) { continue; } firstAlreadyFound = true; i++; continue; } if (areEqual(o, Array.get(sequence, i++))) { continue; } throw arrayDoesNotContainSequence(info, failures, array, sequence); } if (!firstAlreadyFound || i < sequenceSize) { throw arrayDoesNotContainSequence(info, failures, array, sequence); } } /** * Delegates to {@link ComparisonStrategy#areEqual(Object, Object)} */ private boolean areEqual(Object actual, Object other) { return comparisonStrategy.areEqual(actual, other); } private AssertionError arrayDoesNotContainSequence(AssertionInfo info, Failures failures, Object array, Object sequence) { return failures.failure(info, shouldContainSequence(array, sequence, comparisonStrategy)); } void assertDoesNotContain(AssertionInfo info, Failures failures, Object array, Object values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, array); Set found = new LinkedHashSet(); for (int i = 0; i < sizeOf(values); i++) { Object value = Array.get(values, i); if (arrayContains(array, value)) { found.add(value); } } if (found.isEmpty()) { return; } throw failures.failure(info, shouldNotContain(array, values, found, comparisonStrategy)); } /** * Delegates to {@link ComparisonStrategy#arrayContains(Object, Object)} */ private boolean arrayContains(Object array, Object value) { return comparisonStrategy.arrayContains(array, value); } void assertDoesNotHaveDuplicates(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); ArrayWrapperList wrapped = wrap(array); Iterable duplicates = comparisonStrategy.duplicatesFrom(wrapped); if (isNullOrEmpty(duplicates)) { return; } throw failures.failure(info, shouldNotHaveDuplicates(array, duplicates, comparisonStrategy)); } void assertStartsWith(AssertionInfo info, Failures failures, Object array, Object sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, array); int sequenceSize = sizeOf(sequence); int arraySize = sizeOf(array); if (arraySize < sequenceSize) { throw arrayDoesNotStartWithSequence(info, failures, array, sequence); } for (int i = 0; i < sequenceSize; i++) { if (areEqual(Array.get(sequence, i), Array.get(array, i))) { continue; } throw arrayDoesNotStartWithSequence(info, failures, array, sequence); } } private AssertionError arrayDoesNotStartWithSequence(AssertionInfo info, Failures failures, Object array, Object sequence) { return failures.failure(info, shouldStartWith(array, sequence, comparisonStrategy)); } void assertEndsWith(AssertionInfo info, Failures failures, Object array, Object sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, array); int sequenceSize = sizeOf(sequence); int arraySize = sizeOf(array); if (arraySize < sequenceSize) { throw arrayDoesNotEndWithSequence(info, failures, array, sequence); } for (int i = 0; i < sequenceSize; i++) { int sequenceIndex = sequenceSize - (i + 1); int arrayIndex = arraySize - (i + 1); if (areEqual(Array.get(sequence, sequenceIndex), Array.get(array, arrayIndex))) { continue; } throw arrayDoesNotEndWithSequence(info, failures, array, sequence); } } void assertContainsNull(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); if (!arrayContains(array, null)) { throw failures.failure(info, shouldContainNull(array)); } } void assertDoesNotContainNull(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); if (arrayContains(array, null)) { throw failures.failure(info, shouldNotContainNull(array)); } } public void assertAre(AssertionInfo info, Failures failures, Conditions conditions, Object array, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldBe(array, notSatisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreNot(AssertionInfo info, Failures failures, Conditions conditions, Object array, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldNotBe(array, satisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertHave(AssertionInfo info, Failures failures, Conditions conditions, Object array, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldHave(array, notSatisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertHaveNot(AssertionInfo info, Failures failures, Conditions conditions, Object array, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldNotHave(array, satisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreAtLeast(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldBeAtLeast(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreNotAtLeast(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldNotBeAtLeast(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreAtMost(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldBeAtMost(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreNotAtMost(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldNotBeAtMost(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreExactly(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() == times) { return; } throw failures.failure(info, elementsShouldBeExactly(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertAreNotExactly(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() == times) { return; } throw failures.failure(info, ElementsShouldNotBeExactly.elementsShouldNotBeExactly(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertHaveAtLeast(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldHaveAtLeast(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertDoNotHaveAtLeast(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldNotHaveAtLeast(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertHaveAtMost(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldHaveAtMost(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertDoNotHaveAtMost(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldNotHaveAtMost(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertHaveExactly(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(array, condition); if (satisfiesCondition.size() == times) { return; } throw failures.failure(info, elementsShouldHaveExactly(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } public void assertDoNotHaveExactly(AssertionInfo info, Failures failures, Conditions conditions, Object array, int times, Condition condition) { assertNotNull(info, array); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(array, condition); if (notSatisfiesCondition.size() == times) { return; } throw failures.failure(info, elementsShouldNotHaveExactly(array, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(array, condition)); } } @SuppressWarnings("unchecked") private List notSatisfiesCondition(Object array, Condition condition) { List notSatisfiesCondition = new LinkedList(); int arraySize = sizeOf(array); for (int i = 0; i < arraySize; i++) { Object o = Array.get(array, i); if (!condition.matches((E) o)) { notSatisfiesCondition.add((E) o); } } return notSatisfiesCondition; } @SuppressWarnings("unchecked") private List satisfiesCondition(Object array, Condition condition) { List notSatisfiesCondition = new LinkedList(); int arraySize = sizeOf(array); for (int i = 0; i < arraySize; i++) { Object o = Array.get(array, i); if (condition.matches((E) o)) { notSatisfiesCondition.add((E) o); } } return notSatisfiesCondition; } void assertIsSorted(AssertionInfo info, Failures failures, Object array) { assertNotNull(info, array); if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { // instead of comparing array elements with their natural comparator, use the one set by client. Comparator comparator = ((ComparatorBasedComparisonStrategy) comparisonStrategy).getComparator(); assertIsSortedAccordingToComparator(info, failures, array, comparator); return; } // empty arrays are considered sorted even if component type is not sortable. if (sizeOf(array) == 0) { return; } assertThatArrayComponentTypeIsSortable(info, failures, array); try { // sorted assertion is only relevant if array elements are Comparable // => we should be able to build a Comparable array Comparable[] comparableArray = arrayOfComparableItems(array); // array with 0 or 1 element are considered sorted. if (comparableArray.length <= 1) { return; } for (int i = 0; i < comparableArray.length - 1; i++) { // array is sorted in ascending order iif element i is less or equal than element i+1 if (comparableArray[i].compareTo(comparableArray[i + 1]) > 0) { throw failures.failure(info, shouldBeSorted(i, array)); } } } catch (ClassCastException e) { // elements are either not Comparable or not mutually Comparable (e.g. array with String and Integer) throw failures.failure(info, shouldHaveMutuallyComparableElements(array)); } } // is static to avoid "generify" Arrays static void assertIsSortedAccordingToComparator(AssertionInfo info, Failures failures, Object array, Comparator comparator) { assertNotNull(info, array); if (comparator == null) { throw new NullPointerException("The given comparator should not be null"); } try { List arrayAsList = asList(array); // empty arrays are considered sorted even if comparator can't be applied to . if (arrayAsList.size() == 0) { return; } if (arrayAsList.size() == 1) { // call compare to see if unique element is compatible with comparator. comparator.compare(arrayAsList.get(0), arrayAsList.get(0)); return; } for (int i = 0; i < arrayAsList.size() - 1; i++) { // array is sorted in comparator defined order iif element i is less or equal than element i+1 if (comparator.compare(arrayAsList.get(i), arrayAsList.get(i + 1)) > 0) { throw failures.failure(info, shouldBeSortedAccordingToGivenComparator(i, array, comparator)); } } } catch (ClassCastException e) { throw failures.failure(info, shouldHaveComparableElementsAccordingToGivenComparator(array, comparator)); } } @SuppressWarnings("unchecked") private static List asList(Object array) { if (array == null) { return null; } if (!isArray(array)) { throw new IllegalArgumentException("The object should be an array"); } int length = getLength(array); List list = new ArrayList(length); for (int i = 0; i < length; i++) { list.add((T) Array.get(array, i)); } return list; } @SuppressWarnings("unchecked") private static Comparable[] arrayOfComparableItems(Object array) { ArrayWrapperList arrayWrapperList = wrap(array); Comparable[] arrayOfComparableItems = new Comparable[arrayWrapperList.size()]; for (int i = 0; i < arrayWrapperList.size(); i++) { arrayOfComparableItems[i] = (Comparable) arrayWrapperList.get(i); } return arrayOfComparableItems; } private static void assertThatArrayComponentTypeIsSortable(AssertionInfo info, Failures failures, Object array) { ArrayWrapperList arrayAsList = wrap(array); Class arrayComponentType = arrayAsList.getComponentType(); if (arrayComponentType.isPrimitive()) { return; } if (!Comparable.class.isAssignableFrom(arrayComponentType)) { throw failures.failure(info, shouldHaveMutuallyComparableElements(array)); } } private void checkIsNotNullAndNotEmpty(Object values) { if (values == null) { throw arrayOfValuesToLookForIsNull(); } if (isArrayEmpty(values)) { throw arrayOfValuesToLookForIsEmpty(); } } private boolean isArrayEmpty(Object array) { return sizeOf(array) == 0; } private AssertionError arrayDoesNotEndWithSequence(AssertionInfo info, Failures failures, Object array, Object sequence) { return failures.failure(info, shouldEndWith(array, sequence, comparisonStrategy)); } private static void assertNotNull(AssertionInfo info, Object array) { Objects.instance().assertNotNull(info, array); } private int sizeOf(Object array) { return Array.getLength(array); } }fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/BigDecimals.java000066400000000000000000000027721243020563200272760ustar00rootroot00000000000000/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import java.math.BigDecimal; import org.fest.util.*; /** * Reusable assertions for {@link BigDecimal}s. * * @author Yvonne Wang * @author Joel Costigliola */ public class BigDecimals extends Numbers { private static final BigDecimals INSTANCE = new BigDecimals(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static BigDecimals instance() { return INSTANCE; } @VisibleForTesting BigDecimals() { super(); } public BigDecimals(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected BigDecimal zero() { return BigDecimal.ZERO; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/BinaryDiff.java000066400000000000000000000041241243020563200271410ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2011 the original author or authors. */ package org.fest.assertions.internal; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import org.fest.util.VisibleForTesting; /** * Compares the binary content of two streams. * * @author Olivier Michallat */ @VisibleForTesting public class BinaryDiff { @VisibleForTesting public BinaryDiffResult diff(File actual, byte[] expected) throws IOException { InputStream expectedStream = new ByteArrayInputStream(expected); InputStream actualStream = null; boolean threw = true; try { actualStream = new FileInputStream(actual); BinaryDiffResult result = diff(actualStream, expectedStream); threw = false; return result; } finally { try { if (actualStream != null) actualStream.close(); } catch (IOException e) { // Only rethrow if it doesn't shadow an exception thrown from the inner try block if (!threw) throw e; } } } @VisibleForTesting public BinaryDiffResult diff(InputStream actualStream, InputStream expectedStream) throws IOException { int index = 0; while (true) { int actual = actualStream.read(); int expected = expectedStream.read(); if (actual == -1 && expected == -1) return BinaryDiffResult.noDiff(); // reached end of both streams if (actual != expected) return new BinaryDiffResult(index, expected, actual); index += 1; } } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/BinaryDiffResult.java000066400000000000000000000031651243020563200303440ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2011 the original author or authors. */ package org.fest.assertions.internal; /** * Value class to hold the result of comparing two binary streams. * * @author Olivier Michallat */ public class BinaryDiffResult { private static final int EOF = -1; public final int offset; public final String expected; public final String actual; /** * Builds a new instance. * * @param offset the offset at which the difference occurred. * @param expected the expected byte as an int in the range 0 to 255, or -1 for EOF. * @param actual the actual byte in the same format. */ public BinaryDiffResult(int offset, int expected, int actual) { this.offset = offset; this.expected = describe(expected); this.actual = describe(actual); } public boolean hasNoDiff() { return offset == EOF; } public static BinaryDiffResult noDiff() { return new BinaryDiffResult(EOF, 0, 0); } private String describe(int b) { return (b == EOF) ? "EOF" : "0x" + Integer.toHexString(b).toUpperCase(); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/BooleanArrays.java000066400000000000000000000305451243020563200276730ustar00rootroot00000000000000/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code boolean}s. * * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class BooleanArrays { private static final BooleanArrays INSTANCE = new BooleanArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static BooleanArrays instance() { return INSTANCE; } private final Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting BooleanArrays() {} /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, boolean[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, boolean[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, boolean[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, boolean[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, boolean[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, boolean[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, boolean[] actual, boolean[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, boolean[] actual, boolean value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, boolean[] actual, boolean value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, boolean[] actual, boolean[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, boolean[] actual, boolean[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, boolean[] actual, boolean[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, boolean[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, boolean[], boolean[])}, but it also verifies that the first * element in the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, boolean[] actual, boolean[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, boolean[], boolean[])}, but it also verifies that the last element * in the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, boolean[] actual, boolean[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, boolean[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, boolean[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Booleans.java000066400000000000000000000055521243020563200266740ustar00rootroot00000000000000/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Boolean}s. * * @author Alex Ruiz */ public class Booleans { private static final Booleans INSTANCE = new Booleans(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Booleans instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Booleans() {} /** * Asserts that two booleans are equal. * @param info contains information about the assertion. * @param actual the actual value. * @param expected the expected value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the expected one. This method will throw a * {@code org.junit.ComparisonFailure} instead if JUnit is in the classpath and the expected and actual values are not * equal. */ public void assertEqual(AssertionInfo info, Boolean actual, boolean expected) { assertNotNull(info, actual); if (actual.booleanValue() == expected) return; throw failures.failure(info, shouldBeEqual(actual, expected)); } /** * Asserts that two longs are not equal. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the other one. */ public void assertNotEqual(AssertionInfo info, Boolean actual, boolean other) { assertNotNull(info, actual); if (actual.booleanValue() != other) return; throw failures.failure(info, shouldNotBeEqual(actual, other)); } private static void assertNotNull(AssertionInfo info, Boolean actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/ByteArrays.java000066400000000000000000000307551243020563200272220ustar00rootroot00000000000000/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code byte}s. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class ByteArrays { private static final ByteArrays INSTANCE = new ByteArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ByteArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting ByteArrays() { this(StandardComparisonStrategy.instance()); } public ByteArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, byte[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, byte[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, byte[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, byte[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, byte[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, byte[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, byte[] actual, byte[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, byte[] actual, byte value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, byte[] actual, byte value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, byte[] actual, byte[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, byte[] actual, byte[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, byte[] actual, byte[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, byte[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, byte[], byte[])}, but it also verifies that the first element in * the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, byte[] actual, byte[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, byte[], byte[])}, but it also verifies that the last element in * the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, byte[] actual, byte[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, byte[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, byte[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Bytes.java000066400000000000000000000025041243020563200262120ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.util.*; /** * Reusable assertions for {@link Byte}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes extends Numbers { private static final Bytes INSTANCE = new Bytes(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Bytes instance() { return INSTANCE; } @VisibleForTesting Bytes() { super(); } public Bytes(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected Byte zero() { return 0; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/CharArrays.java000066400000000000000000000310171243020563200271640ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code char}s. * * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class CharArrays { private static final CharArrays INSTANCE = new CharArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static CharArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting CharArrays() { this(StandardComparisonStrategy.instance()); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } public CharArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, char[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, char[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, char[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, char[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, char[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, char[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, char[] actual, char[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, char[] actual, char value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, char[] actual, char value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, char[] actual, char[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, char[] actual, char[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, char[] actual, char[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, char[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, char[], char[])}, but it also verifies that the first element in * the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, char[] actual, char[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, char[], char[])}, but it also verifies that the last element in * the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, char[] actual, char[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, char[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, char[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Characters.java000066400000000000000000000051211243020563200272010ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.Character.*; import static org.fest.assertions.error.ShouldBeLowerCase.shouldBeLowerCase; import static org.fest.assertions.error.ShouldBeUpperCase.shouldBeUpperCase; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Character}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters extends Comparables { private static final Characters INSTANCE = new Characters(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Characters instance() { return INSTANCE; } @VisibleForTesting Characters() { super(); } public Characters(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } /** * Asserts that the actual value is a lowercase character. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not a lowercase character. */ public void assertLowerCase(AssertionInfo info, Character actual) { assertNotNull(info, actual); if (isLowerCase(actual)) return; throw failures.failure(info, shouldBeLowerCase(actual)); } /** * Asserts that the actual value is a uppercase character. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not a uppercase character. */ public void assertUpperCase(AssertionInfo info, Character actual) { assertNotNull(info, actual); if (isUpperCase(actual)) return; throw failures.failure(info, shouldBeUpperCase(actual)); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/CommonErrors.java000066400000000000000000000023331243020563200275510ustar00rootroot00000000000000/* * Created on Nov 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; /** * @author Alex Ruiz */ final class CommonErrors { static NullPointerException arrayOfValuesToLookForIsNull() { return new NullPointerException("The array of values to look for should not be null"); } static NullPointerException iterableToLookForIsNull() { return new NullPointerException("The iterable to look for should not be null"); } static IllegalArgumentException arrayOfValuesToLookForIsEmpty() { return new IllegalArgumentException("The array of values to look for should not be empty"); } private CommonErrors() {} } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/CommonValidations.java000066400000000000000000000027761243020563200305650ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.assertions.data.Index; import org.fest.assertions.data.Offset; /** * @author Alex Ruiz */ final class CommonValidations { static void checkIndexValueIsValid(Index index, int maximum) { if (index == null) throw new NullPointerException("Index should not be null"); if (index.value <= maximum) return; String format = "Index should be between <%d> and <%d> (inclusive,) but was <%d>"; throw new IndexOutOfBoundsException(String.format(format, 0, maximum, index.value)); } static void checkOffsetIsNotNull(Offset offset) { if (offset == null) throw new NullPointerException("The given offset should not be null"); } static void checkNumberIsNotNull(Number number) { if (number == null) throw new NullPointerException("The given number should not be null"); } private CommonValidations() {} } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Comparables.java000066400000000000000000000231701243020563200273560ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import java.util.Comparator; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Comparable}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables { private static final Comparables INSTANCE = new Comparables(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Comparables instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); ComparisonStrategy comparisonStrategy; @VisibleForTesting Comparables() { this(StandardComparisonStrategy.instance()); } public Comparables(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy) .getComparator(); } return null; } @VisibleForTesting void setFailures(Failures failures) { this.failures = failures; } /** * Asserts that two T instances are equal. * @param info contains information about the assertion. * @param actual the actual value. * @param expected the expected value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the expected one. This method will throw a * {@code org.junit.ComparisonFailure} instead if JUnit is in the classpath and the expected and actual values are not * equal. */ public void assertEqual(AssertionInfo info, T actual, T expected) { assertNotNull(info, actual); if (areEqual(actual, expected)) return; throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy)); } protected boolean areEqual(T actual, T expected) { return comparisonStrategy.areEqual(actual, expected); } /** * Asserts that two T instances are not equal. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the other one. */ public void assertNotEqual(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); if (!areEqual(actual, other)) return; throw failures.failure(info, shouldNotBeEqual(actual, other, comparisonStrategy)); } /** * Asserts that two {@link Comparable}s are equal by invoking {@link Comparable#compareTo(Object)}.
* Note that it does not rely on the custom {@link #comparisonStrategy} if one has been set. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param expected the expected value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the expected one. This method will throw a * {@code org.junit.ComparisonFailure} instead if JUnit is in the classpath and the expected and actual values are not * equal. */ public > void assertEqualByComparison(AssertionInfo info, T actual, T expected) { assertNotNull(info, actual); // we don't delegate to comparisonStrategy, as this assertion makes it clear it relies on Comparable if (actual.compareTo(expected) == 0) return; throw failures.failure(info, shouldBeEqual(actual, expected)); } /** * Asserts that two {@link Comparable}s are not equal by invoking {@link Comparable#compareTo(Object)} * .
* Note that it does not rely on the custom {@link #comparisonStrategy} if one has been set. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to the other one. */ public > void assertNotEqualByComparison(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); // we don't delagate to comparisonStrategy, as this assertion makes it clear it relies on Comparable if (actual.compareTo(other) != 0) return; throw failures.failure(info, shouldNotBeEqual(actual, other)); } /** * Asserts that the actual value is less than the other one. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not less than the other one: this assertion will fail if the actual value is * equal to or greater than the other value. */ public > void assertLessThan(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); if (isLessThan(actual, other)) return; throw failures.failure(info, shouldBeLess(actual, other, comparisonStrategy)); } /** * Asserts that the actual value is less than or equal to the other one. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is greater than the other one. */ public > void assertLessThanOrEqualTo(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); if (!isGreaterThan(actual, other)) return; throw failures.failure(info, shouldBeLessOrEqual(actual, other, comparisonStrategy)); } /** * Asserts that the actual value is greater than the other one. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not greater than the other one: this assertion will fail if the actual value is * equal to or less than the other value. */ public > void assertGreaterThan(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); if (isGreaterThan(actual, other)) return; throw failures.failure(info, shouldBeGreater(actual, other, comparisonStrategy)); } /** * delegates to {@link #comparisonStrategy#isGreaterThan(Object, Object)} */ private boolean isGreaterThan(Object actual, Object other) { return comparisonStrategy.isGreaterThan(actual, other); } /** * Asserts that the actual value is greater than or equal to the other one. * @param used to guarantee that two objects of the same type are being compared against each other. * @param info contains information about the assertion. * @param actual the actual value. * @param other the value to compare the actual value to. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is less than the other one. */ public > void assertGreaterThanOrEqualTo(AssertionInfo info, T actual, T other) { assertNotNull(info, actual); if (!isLessThan(actual, other)) return; throw failures.failure(info, shouldBeGreaterOrEqual(actual, other, comparisonStrategy)); } private boolean isLessThan(Object actual, Object other) { return comparisonStrategy.isLessThan(actual, other); } protected static void assertNotNull(AssertionInfo info, T actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/ComparatorBasedComparisonStrategy.java000066400000000000000000000136341243020563200337560ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Strings.quote; import java.util.Comparator; import java.util.Iterator; /** * Implements {@link ComparisonStrategy} contract with a comparison strategy based on a {@link Comparator}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy extends AbstractComparisonStrategy { // A raw type is necessary because we can't make assumptions on object to be compared. @SuppressWarnings("rawtypes") private Comparator comparator; /** * Creates a new {@link ComparatorBasedComparisonStrategy} specifying the comparison strategy with given * comparator. * @param comparator the comparison strategy to use. */ public ComparatorBasedComparisonStrategy(@SuppressWarnings("rawtypes") Comparator comparator) { this.comparator = comparator; } /** * Returns true if given {@link Iterable} contains given value according to {@link #comparator}, false otherwise.
* If given {@link Iterable} is null or empty, return false. * * @param iterable the {@link Iterable} to search value in * @param value the object to look for in given {@link Iterable} * @return true if given {@link Iterable} contains given value according to {@link #comparator}, false otherwise. */ @SuppressWarnings("unchecked") public boolean iterableContains(Iterable iterable, Object value) { if (isNullOrEmpty(iterable)) return false; for (Object element : iterable) { // avoid comparison when objects are the same or both null if (element == value) return true; // both objects are not null => if one is then the other is not => compare next element with value if (value == null || element == null) continue; if (comparator.compare(element, value) == 0) return true; } return false; } /** * Look for given value in given {@link Iterable} according to the {@link Comparator}, if value is found it is removed from it.
* Does nothing if given {@link Iterable} is null (meaning no exception thrown). * @param iterable the {@link Iterable} we want remove value from * @param value object to remove from given {@link Iterable} */ @SuppressWarnings("unchecked") public void iterableRemoves(Iterable iterable, Object value) { if (iterable == null) return; Iterator iterator = iterable.iterator(); while (iterator.hasNext()) { if (comparator.compare(iterator.next(), value) == 0) { iterator.remove(); } } } /** * Returns true if actual and other are equal according to {@link #comparator}, false otherwise.
* Handles the cases where one of the parameter is null so that internal {@link #comparator} does not have too. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual and other are equal according to {@link #comparator}, false otherwise. */ @SuppressWarnings("unchecked") public boolean areEqual(Object actual, Object other) { if (actual == null) return other == null; // actual is not null if (other == null) return false; // neither actual nor other are null return comparator.compare(actual, other) == 0; } /** * Returns any duplicate elements from the given {@link Iterable} according to {@link #comparator}. * * @param iterable the given {@link Iterable} we want to extract duplicate elements. * @return an {@link Iterable} containing the duplicate elements of the given one. If no duplicates are found, an empty * {@link Iterable} is returned. */ // overridden to write javadoc. @Override public Iterable duplicatesFrom(Iterable iterable) { return super.duplicatesFrom(iterable); } @Override public String toString() { String comparatorSimpleClassName = comparator.getClass().getSimpleName(); return quote(comparatorSimpleClassName.length() > 0 ? comparatorSimpleClassName : "anonymous comparator class"); } public Comparator getComparator() { return comparator; } @SuppressWarnings("unchecked") public boolean stringStartsWith(String string, String prefix) { if (string.length() < prefix.length()) return false; String stringPrefix = string.substring(0, prefix.length()); return comparator.compare(stringPrefix, prefix) == 0; } @SuppressWarnings("unchecked") public boolean stringEndsWith(String string, String suffix) { if (string.length() < suffix.length()) return false; String stringSuffix = string.substring(string.length() - suffix.length()); return comparator.compare(stringSuffix, suffix) == 0; } public boolean stringContains(String string, String sequence) { int sequenceLength = sequence.length(); for (int i = 0; i < string.length(); i++) { String subString = string.substring(i); if (subString.length() < sequenceLength) return false; if (stringStartsWith(subString, sequence)) return true; } return false; } @SuppressWarnings("unchecked") public boolean isGreaterThan(Object actual, Object other) { return comparator.compare(actual, other) > 0; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/ComparisonStrategy.java000066400000000000000000000142301243020563200307600ustar00rootroot00000000000000/* * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; /** * Describes the contract to implement a consistent comparison strategy that covers :
* - comparing two objects for equality and order
* - knowing if an object belongs to a group of objects (collection/array)
* - determining duplicates in a group of objects (collection/array)
* - string specific comparison
* * @author Joel Costigliola */ public interface ComparisonStrategy { /** * Returns true if actual and other are equal according to the implemented comparison strategy. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual and other are equal according to the underlying comparison strategy. */ boolean areEqual(Object actual, Object other); /** * Returns true if actual is greater than other, false otherwise. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual is greater than other, false otherwise. * @throws UnsupportedOperationException if operation is not supported by a concrete implementation. */ boolean isGreaterThan(Object actual, Object other); /** * Returns true if actual is greater than or equal to other, false otherwise. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual is greater than or equal to other, false otherwise. * @throws UnsupportedOperationException if operation is not supported by a concrete implementation. */ boolean isGreaterThanOrEqualTo(Object actual, Object other); /** * Returns true if actual is less than other, false otherwise. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual is less than other, false otherwise. * @throws UnsupportedOperationException if operation is not supported by a concrete implementation. */ boolean isLessThan(Object actual, Object other); /** * Returns true if actual is less than or equal to other, false otherwise. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual is less than or equal to other, false otherwise. * @throws UnsupportedOperationException if operation is not supported by a concrete implementation. */ boolean isLessThanOrEqualTo(Object actual, Object other); /** * Returns true if given {@link Iterable} contains given value according to the implemented comparison strategy, false * otherwise.
* If given {@link Iterable} is null, return false. * * @param collection the {@link Iterable} to search value in * @param value the object to look for in given {@link Iterable} * @return true if given {@link Iterable} contains given value according to the implemented comparison strategy, false * otherwise. */ boolean iterableContains(Iterable collection, Object value); /** * Look for given value in given {@link Iterable} according to the implemented comparison strategy, if value is found it is * removed from it.
* If given {@link Iterable} is null, does nothing. * * @param iterable the {@link Iterable} we want remove value from * @param value object to remove from given {@link Iterable} */ void iterableRemoves(Iterable iterable, Object value); /** * Returns any duplicate elements from the given {@link Iterable} according to the implemented comparison strategy. * * @param iterable the given {@link Iterable} we want to extract duplicate elements. * @return an {@link Iterable} containing the duplicate elements of the given one. If no duplicates are found, an empty * {@link Iterable} is returned. */ Iterable duplicatesFrom(Iterable iterable); /** * Returns true if given array contains given value according to the implemented comparison strategy, false otherwise. * * @param array the array to search value in (must not be null) * @param value the object to look for in given array * @return true if given array contains given value according to the implemented comparison strategy, false otherwise. */ boolean arrayContains(Object array, Object value); /** * Returns true if given string contains given sequence according to the implemented comparison strategy, false otherwise. * * @param string the string to search sequence in (must not be null) * @param sequence the String to look for in given string * @return true if given string contains given sequence according to the implemented comparison strategy, false otherwise. */ boolean stringContains(String string, String sequence); /** * Returns true if string starts with prefix according to the implemented comparison strategy, false otherwise. * * @param string the String we want to look starting prefix * @param prefix the prefix String to look for at string's start * @return true if string starts with prefix according to the implemented comparison strategy, false otherwise. */ boolean stringStartsWith(String string, String prefix); /** * Returns true if sstring ends with suffix according to the implemented comparison strategy, false otherwise. * * @param string the String we want to look starting suffix * @param suffix the suffix String to look for at string's end * @return true if string ends with suffix according to the implemented comparison strategy, false otherwise. */ boolean stringEndsWith(String string, String suffix); } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Conditions.java000066400000000000000000000117021243020563200272350ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBe.shouldBe; import static org.fest.assertions.error.ShouldHave.shouldHave; import static org.fest.assertions.error.ShouldNotBe.shouldNotBe; import static org.fest.assertions.error.ShouldNotHave.shouldNotHave; import org.fest.assertions.core.*; import org.fest.util.VisibleForTesting; /** * Verifies that a value satisfies a {@link Condition}. * * @author Alex Ruiz */ public class Conditions { private static final Conditions INSTANCE = new Conditions(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Conditions instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Conditions() {} /** * Asserts that the actual value satisfies the given {@link Condition}. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the actual value. * @param condition the given {@code Condition}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the actual value does not satisfy the given {@code Condition}. */ public void assertIs(AssertionInfo info, T actual, Condition condition) { assertIsNotNull(condition); if (condition.matches(actual)) return; throw failures.failure(info, shouldBe(actual, condition)); } /** * Asserts that the actual value does not satisfy the given {@link Condition}. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the actual value. * @param condition the given {@code Condition}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the actual value satisfies the given {@code Condition}. */ public void assertIsNot(AssertionInfo info, T actual, Condition condition) { assertIsNotNull(condition); if (!condition.matches(actual)) return; throw failures.failure(info, shouldNotBe(actual, condition)); } /** * Asserts that the actual value satisfies the given {@link Condition}. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the actual value. * @param condition the given {@code Condition}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the actual value does not satisfy the given {@code Condition}. */ public void assertHas(AssertionInfo info, T actual, Condition condition) { assertIsNotNull(condition); if (condition.matches(actual)) return; throw failures.failure(info, shouldHave(actual, condition)); } /** * Asserts that the actual value does not satisfy the given {@link Condition}. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the actual value. * @param condition the given {@code Condition}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the actual value satisfies the given {@code Condition}. */ public void assertDoesNotHave(AssertionInfo info, T actual, Condition condition) { assertIsNotNull(condition); if (!condition.matches(actual)) return; throw failures.failure(info, shouldNotHave(actual, condition)); } /** * Asserts the the given {@link Condition} is not null. * @param condition the given {@code Condition}. * @throws NullPointerException if the given {@code Condition} is {@code null}. */ public void assertIsNotNull(Condition condition) { if (condition == null) throw new NullPointerException("The condition to evaluate should not be null"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Dates.java000066400000000000000000000777041243020563200262020ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeAfter.shouldBeAfter; import static org.fest.assertions.error.ShouldBeAfterOrEqualsTo.shouldBeAfterOrEqualsTo; import static org.fest.assertions.error.ShouldBeBefore.shouldBeBefore; import static org.fest.assertions.error.ShouldBeBeforeOrEqualsTo.shouldBeBeforeOrEqualsTo; import static org.fest.assertions.error.ShouldBeBetween.shouldBeBetween; import static org.fest.assertions.error.ShouldBeCloseTo.shouldBeCloseTo; import static org.fest.assertions.error.ShouldBeInSameDay.shouldBeInSameDay; import static org.fest.assertions.error.ShouldBeInSameHour.shouldBeInSameHour; import static org.fest.assertions.error.ShouldBeInSameMinute.shouldBeInSameMinute; import static org.fest.assertions.error.ShouldBeInSameMonth.shouldBeInSameMonth; import static org.fest.assertions.error.ShouldBeInSameSecond.shouldBeInSameSecond; import static org.fest.assertions.error.ShouldBeInSameYear.shouldBeInSameYear; import static org.fest.assertions.error.ShouldBeInTheFuture.shouldBeInTheFuture; import static org.fest.assertions.error.ShouldBeInThePast.shouldBeInThePast; import static org.fest.assertions.error.ShouldBeToday.shouldBeToday; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.assertions.error.ShouldHaveTime.shouldHaveTime; import static org.fest.assertions.error.ShouldNotBeBetween.shouldNotBeBetween; import static org.fest.util.Dates.dayOfMonthOf; import static org.fest.util.Dates.dayOfWeekOf; import static org.fest.util.Dates.hourOfDay; import static org.fest.util.Dates.millisecondOf; import static org.fest.util.Dates.minuteOf; import static org.fest.util.Dates.monthOf; import static org.fest.util.Dates.secondOf; import static org.fest.util.Dates.today; import static org.fest.util.Dates.truncateTime; import static org.fest.util.Dates.yearOf; import java.util.Calendar; import java.util.Comparator; import java.util.Date; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Date}s. * * @author Joel Costigliola */ public class Dates { private static final Dates INSTANCE = new Dates(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Dates instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Dates() { this(StandardComparisonStrategy.instance()); } private ComparisonStrategy comparisonStrategy; public Dates(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy) .getComparator(); } return null; } /** * Verifies that the actual {@code Date} is strictly before the given one. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the other date to compare actual with. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly before the given one. */ public void assertIsBefore(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (isBefore(actual, other)) return; throw failures.failure(info, shouldBeBefore(actual, other, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is before or equal to the given one. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the other date to compare actual with. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not before or equal to the given one. */ public void assertIsBeforeOrEqualsTo(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (isBeforeOrEqualTo(actual, other)) return; throw failures.failure(info, shouldBeBeforeOrEqualsTo(actual, other, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is strictly after the given one. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given Date. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not strictly after the given one. */ public void assertIsAfter(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (isAfter(actual, other)) return; throw failures.failure(info, shouldBeAfter(actual, other, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is after or equal to the given one. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given Date. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not after or equal to the given one. */ public void assertIsAfterOrEqualsTo(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (isAfterOrEqualTo(actual, other)) return; throw failures.failure(info, shouldBeAfterOrEqualsTo(actual, other, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is in start:end period.
* start date belongs to the period if inclusiveStart is true.
* end date belongs to the period if inclusiveEnd is true.
* @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param start the period start, expected not to be null. * @param end the period end, expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in start:end period. */ public void assertIsBetween(AssertionInfo info, Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { assertNotNull(info, actual); startDateParameterIsNotNull(start); endDateParameterIsNotNull(end); boolean checkLowerBoundaryPeriod = inclusiveStart ? isAfterOrEqualTo(actual, start) : isAfter(actual, start); boolean checkUpperBoundaryPeriod = inclusiveEnd ? isBeforeOrEqualTo(actual, end) : isBefore(actual, end); if (checkLowerBoundaryPeriod && checkUpperBoundaryPeriod) return; throw failures.failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is not in start:end period..
* start date belongs to the period if inclusiveStart is true.
* end date belongs to the period if inclusiveEnd is true.
* @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param start the period start, expected not to be null. * @param end the period end, expected not to be null. * @param inclusiveStart wether to include start date in period. * @param inclusiveEnd wether to include end date in period. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if start {@code Date} is {@code null}. * @throws NullPointerException if end {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} is in start:end period. */ public void assertIsNotBetween(AssertionInfo info, Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd) { assertNotNull(info, actual); startDateParameterIsNotNull(start); endDateParameterIsNotNull(end); // check is in given period and use the negation of this result boolean checkLowerBoundaryPeriod = inclusiveStart ? isAfterOrEqualTo(actual, start) : isAfter(actual, start); boolean checkUpperBoundaryPeriod = inclusiveEnd ? isBeforeOrEqualTo(actual, end) : isBefore(actual, end); boolean isBetweenGivenPeriod = checkLowerBoundaryPeriod && checkUpperBoundaryPeriod; if (!isBetweenGivenPeriod) return; throw failures.failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is strictly in the past. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in the past. */ public void assertIsInThePast(AssertionInfo info, Date actual) { assertNotNull(info, actual); if (isBefore(actual, today())) return; throw failures.failure(info, shouldBeInThePast(actual, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is today, by comparing only year, month and day of actual to today (ie. we don't check * hours). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} is not today. */ public void assertIsToday(AssertionInfo info, Date actual) { assertNotNull(info, actual); Date todayWithoutTime = truncateTime(today()); Date actualWithoutTime = truncateTime(actual); if (areEqual(actualWithoutTime, todayWithoutTime)) return; throw failures.failure(info, shouldBeToday(actual, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is strictly in the future. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} is not in the future. */ public void assertIsInTheFuture(AssertionInfo info, Date actual) { assertNotNull(info, actual); if (isAfter(actual, today())) return; throw failures.failure(info, shouldBeInTheFuture(actual, comparisonStrategy)); } /** * Verifies that the actual {@code Date} is strictly before the given year. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param year the year to compare actual year to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is after or equal to the given year. */ public void assertIsBeforeYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) < year) return; throw failures.failure(info, shouldBeBefore(actual, year)); } /** * Verifies that the actual {@code Date} is strictly after the given year. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param year the year to compare actual year to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is before or equal to the given year. */ public void assertIsAfterYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) > year) return; throw failures.failure(info, shouldBeAfter(actual, year)); } /** * Verifies that the actual {@code Date} year is equal to the given year. * @param year the year to compare actual year to * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is not equal to the given year. */ public void assertIsWithinYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) == year) return; throw failures.failure(info, shouldBeWithin(actual, "year", year)); } /** * Verifies that the actual {@code Date} month is equal to the given month, month value starting at 1 (January=1, * February=2, ...). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param month the month to compare actual month to, see {@link Calendar#MONTH} for valid values * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} month is not equal to the given month. */ public void assertIsWithinMonth(AssertionInfo info, Date actual, int month) { assertNotNull(info, actual); if (monthOf(actual) == month) return; throw failures.failure(info, shouldBeWithin(actual, "month", month)); } /** * Verifies that the actual {@code Date} day of month is equal to the given day of month. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param dayOfMonth the day of month to compare actual day of month to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} month is not equal to the given day of month. */ public void assertIsWithinDayOfMonth(AssertionInfo info, Date actual, int dayOfMonth) { assertNotNull(info, actual); if (dayOfMonthOf(actual) == dayOfMonth) return; throw failures.failure(info, shouldBeWithin(actual, "day of month", dayOfMonth)); } /** * Verifies that the actual {@code Date} day of week is equal to the given day of week. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param dayOfWeek the day of week to compare actual day of week to, see {@link Calendar#DAY_OF_WEEK} for valid values * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not equal to the given day of week. */ public void assertIsWithinDayOfWeek(AssertionInfo info, Date actual, int dayOfWeek) { assertNotNull(info, actual); if (dayOfWeekOf(actual) == dayOfWeek) return; throw failures.failure(info, shouldBeWithin(actual, "day of week", dayOfWeek)); } /** * Verifies that the actual {@code Date} hour od day is equal to the given hour of day (24-hour clock). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param hourOfDay the hour of day to compare actual hour of day to (24-hour clock) * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} hour is not equal to the given hour. */ public void assertIsWithinHourOfDay(AssertionInfo info, Date actual, int hourOfDay) { assertNotNull(info, actual); if (hourOfDay(actual) == hourOfDay) return; throw failures.failure(info, shouldBeWithin(actual, "hour", hourOfDay)); } /** * Verifies that the actual {@code Date} minute is equal to the given minute. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param minute the minute to compare actual minute to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} minute is not equal to the given minute. */ public void assertIsWithinMinute(AssertionInfo info, Date actual, int minute) { assertNotNull(info, actual); if (minuteOf(actual) == minute) return; throw failures.failure(info, shouldBeWithin(actual, "minute", minute)); } /** * Verifies that the actual {@code Date} second is equal to the given second. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param second the second to compare actual second to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} second is not equal to the given second. */ public void assertIsWithinSecond(AssertionInfo info, Date actual, int second) { assertNotNull(info, actual); if (secondOf(actual) == second) return; throw failures.failure(info, shouldBeWithin(actual, "second", second)); } /** * Verifies that the actual {@code Date} millisecond is equal to the given millisecond. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param millisecond the millisecond to compare actual millisecond to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} millisecond is not equal to the given millisecond. */ public void assertIsWithinMillisecond(AssertionInfo info, Date actual, int millisecond) { assertNotNull(info, actual); if (millisecondOf(actual) == millisecond) return; throw failures.failure(info, shouldBeWithin(actual, "millisecond", millisecond)); } /** * Verifies that actual and given {@code Date} are in the same year. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not in the same year. */ public void assertIsInSameYearAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameYear(actual, other)) return; throw failures.failure(info, shouldBeInSameYear(actual, other)); } /** * Returns true if both date are in the same year, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, false otherwise */ private static boolean areInSameYear(Date actual, Date other) { return yearOf(actual) == yearOf(other); } /** * Verifies that actual and given {@code Date} are chronologically in the same month (and thus in the same year). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not chronologically speaking in the same month. */ public void assertIsInSameMonthAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameMonth(actual, other)) return; throw failures.failure(info, shouldBeInSameMonth(actual, other)); } /** * Returns true if both date are in the same year and month, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year and month, false otherwise */ private static boolean areInSameMonth(Date actual, Date other) { return areInSameYear(actual, other) && monthOf(actual) == monthOf(other); } /** * Verifies that actual and given {@code Date} are chronologically in the same day of month (and thus in the same month and * year). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not chronologically speaking in the same day of month. */ public void assertIsInSameDayAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameDayOfMonth(actual, other)) return; throw failures.failure(info, shouldBeInSameDay(actual, other)); } /** * Returns true if both date are in the same year, month and day of month, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, month and day of month, false otherwise */ private static boolean areInSameDayOfMonth(Date actual, Date other) { return areInSameMonth(actual, other) && dayOfMonthOf(actual) == dayOfMonthOf(other); } /** * Verifies that actual and given {@code Date} are chronologically in the same hour (and thus in the same day of month, month * and year). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not chronologically speaking in the same hour. */ public void assertIsInSameHourAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameHour(actual, other)) return; throw failures.failure(info, shouldBeInSameHour(actual, other)); } /** * Returns true if both date are in the same year, month, day of month and hour, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, month, day of month and hour, false otherwise. */ private static boolean areInSameHour(Date actual, Date other) { return areInSameDayOfMonth(actual, other) && hourOfDay(actual) == hourOfDay(other); } /** * Verifies that actual and given {@code Date} are chronologically in the same minute (and thus in the same hour, day of month, * month and year). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not chronologically speaking in the same minute. */ public void assertIsInSameMinuteAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameMinute(actual, other)) return; throw failures.failure(info, shouldBeInSameMinute(actual, other)); } /** * Returns true if both date are in the same year, month, day of month, hour and minute, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, month, day of month, hour and minute, false otherwise. */ private static boolean areInSameMinute(Date actual, Date other) { return areInSameHour(actual, other) && minuteOf(actual) == minuteOf(other); } /** * Verifies that actual and given {@code Date} are chronologically in the same second (and thus in the same minute, hour, day of * month, month and year). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if actual and given {@code Date} are not chronologically speaking in the same second. */ public void assertIsInSameSecondAs(AssertionInfo info, Date actual, Date other) { assertNotNull(info, actual); dateParameterIsNotNull(other); if (areInSameSecond(actual, other)) return; throw failures.failure(info, shouldBeInSameSecond(actual, other)); } /** * Returns true if both date are in the same year, month and day of month, hour, minute and second, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, month and day of month, hour, minute and second, false otherwise. */ private static boolean areInSameSecond(Date actual, Date other) { return areInSameMinute(actual, other) && secondOf(actual) == secondOf(other); } /** * Verifies that the actual {@code Date} is close to the other date by less than delta, if difference is equals to delta it is * ok.
* Note that delta expressed in milliseconds.
* Use handy TimeUnit to convert a duration in milliseconds, for example you can express a delta of 5 seconds with * TimeUnit.SECONDS.toMillis(5). * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param other the given {@code Date} to compare actual {@code Date} to. * @param deltaInMilliseconds the delta used for date comparison, expressed in milliseconds * @throws AssertionError if {@code actual} is {@code null}. * @throws NullPointerException if other {@code Date} is {@code null}. * @throws AssertionError if the actual {@code Date} week is not close to the given date by less than delta. */ public void assertIsCloseTo(AssertionInfo info, Date actual, Date other, long deltaInMilliseconds) { assertNotNull(info, actual); dateParameterIsNotNull(other); long difference = Math.abs(actual.getTime() - other.getTime()); if (difference <= deltaInMilliseconds) return; throw failures.failure(info, shouldBeCloseTo(actual, other, deltaInMilliseconds, difference)); } /** * Verifies that the actual {@code Date} time is equal to the given timestamp. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param timestamp the timestamp to compare actual time to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} time is not equal to the given timestamp. */ public void assertHasTime(AssertionInfo info, Date actual, long timestamp) { assertNotNull(info, actual); if (actual.getTime() == timestamp) return; throw failures.failure(info, shouldHaveTime(actual, timestamp)); } /** * used to check that the date to compare actual date to is not null, in that case throws a {@link NullPointerException} with an * explicit message * @param date the date to check * @throws a {@link NullPointerException} with an explicit message if the given date is null */ private static void dateParameterIsNotNull(Date date) { if (date == null) throw new NullPointerException("The date to compare actual with should not be null"); } /** * used to check that the start of period date to compare actual date to is not null, in that case throws a * {@link NullPointerException} with an explicit message * @param start the start date to check * @throws a {@link NullPointerException} with an explicit message if the given start date is null */ private static void startDateParameterIsNotNull(Date start) { if (start == null) throw new NullPointerException("The start date of period to compare actual with should not be null"); } /** * used to check that the end of perdio date to compare actual date to is not null, in that case throws a * {@link NullPointerException} with an explicit message * @param end the end date to check * @throws a {@link NullPointerException} with an explicit message if the given end date is null */ private static void endDateParameterIsNotNull(Date end) { if (end == null) throw new NullPointerException("The end date of period to compare actual with should not be null"); } private void assertNotNull(AssertionInfo info, Date actual) { Objects.instance().assertNotNull(info, actual); } /** * Returns true if the actual {@code Date} is before or equal to the given one according to underlying * {@link #comparisonStrategy}, false otherwise. * @param actual the actual date - must not be null. * @param other the given Date. * @return true if the actual {@code Date} is before or equal to the given one according to underlying * {@link #comparisonStrategy}, false otherwise. * @throws NullPointerException if {@code actual} is {@code null}. */ private boolean isBeforeOrEqualTo(Date actual, Date other) { return comparisonStrategy.isLessThanOrEqualTo(actual, other); } /** * Returns true if the actual {@code Date} is equal to the given one according to underlying {@link #comparisonStrategy}, false * otherwise. * @param actual the actual date - must not be null. * @param other the given Date. * @return true if the actual {@code Date} is equal to the given one according to underlying * {@link #comparisonStrategy}, false otherwise. */ private boolean areEqual(Date actual, Date other) { return comparisonStrategy.areEqual(other, actual); } /** * Returns true if the actual {@code Date} is after or equal to the given one according to underlying * {@link #comparisonStrategy}, false otherwise. * @param actual the actual date - must not be null. * @param other the given Date. * @return true if the actual {@code Date} is after or equal to the given one according to underlying * {@link #comparisonStrategy}, false otherwise. * @throws NullPointerException if {@code actual} is {@code null}. */ private boolean isAfterOrEqualTo(Date actual, Date other) { return comparisonStrategy.isGreaterThanOrEqualTo(actual, other); } /** * Returns true if actual is before other according to underlying {@link #comparisonStrategy}, false otherwise. * @param actual the {@link Date} to compare to other * @param other the {@link Date} to compare to actual * @return true if actual is before other according to underlying {@link #comparisonStrategy}, false otherwise. */ private boolean isBefore(Date actual, Date other) { return comparisonStrategy.isLessThan(actual, other); } /** * Returns true if actual is after other according to underlying {@link #comparisonStrategy}, false otherwise. * @param actual the {@link Date} to compare to other * @param other the {@link Date} to compare to actual * @return true if actual is after other according to underlying {@link #comparisonStrategy}, false otherwise. */ private boolean isAfter(Date actual, Date other) { return comparisonStrategy.isGreaterThan(actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Diff.java000066400000000000000000000102001243020563200257640ustar00rootroot00000000000000/* * Created on Feb 9, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2008-2012 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.String.format; import static java.util.Collections.unmodifiableList; import static org.fest.util.Closeables.closeQuietly; import static org.fest.util.Objects.areEqual; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import org.fest.util.VisibleForTesting; /** * Compares the contents of two files or two streams. * * @author David DIDIER * @author Alex Ruiz * @author Yvonne Wang * @author Matthieu Baechler * @author Olivier Michallat * @author Joel Costigliola */ @VisibleForTesting public class Diff { private static final String EOF = "EOF"; @VisibleForTesting public List diff(InputStream actual, InputStream expected) throws IOException { BufferedReader reader1 = null; BufferedReader reader2 = null; try { reader1 = readerFor(actual); reader2 = readerFor(expected); return unmodifiableList(diff(reader1, reader2)); } finally { closeQuietly(reader1); closeQuietly(reader2); } } @VisibleForTesting public List diff(File actual, File expected) throws IOException { BufferedReader reader1 = null; BufferedReader reader2 = null; try { reader1 = readerFor(actual); reader2 = readerFor(expected); return unmodifiableList(diff(reader1, reader2)); } finally { closeQuietly(reader1); closeQuietly(reader2); } } @VisibleForTesting public List diff(File actual, String expected, Charset charset) throws IOException { BufferedReader reader1 = null; try { reader1 = readerFor(actual, charset); BufferedReader reader2 = readerFor(expected); return unmodifiableList(diff(reader1, reader2)); } finally { closeQuietly(reader1); } } private BufferedReader readerFor(InputStream stream) { return new BufferedReader(new InputStreamReader(stream)); } private BufferedReader readerFor(InputStream stream, Charset charset) { return new BufferedReader(new InputStreamReader(stream, charset)); } private BufferedReader readerFor(File file) throws IOException { return readerFor(new FileInputStream(file)); } private BufferedReader readerFor(File file, Charset charset) throws IOException { return readerFor(new FileInputStream(file), charset); } private BufferedReader readerFor(String string) { return new BufferedReader(new StringReader(string)); } private List diff(BufferedReader actual, BufferedReader expected) throws IOException { List diffs = new ArrayList(); int lineNumber = 0; while (true) { String actualLine = actual.readLine(); String expectedLine = expected.readLine(); if (actualLine == null || expectedLine == null) { if (expectedLine != null) { diffs.add(output(lineNumber, EOF, expectedLine)); } if (actualLine != null) { diffs.add(output(lineNumber, actualLine, EOF)); } return diffs; } else if (!areEqual(actualLine, expectedLine)) { diffs.add(output(lineNumber, actualLine, expectedLine)); } lineNumber += 1; } } private String output(int lineNumber, String actual, String expected) { return format("line:<%d>, expected:<%s> but was:<%s>", lineNumber, expected, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/DoubleArrays.java000066400000000000000000000310671243020563200275260ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code double}s. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class DoubleArrays { private static final DoubleArrays INSTANCE = new DoubleArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static DoubleArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting DoubleArrays() { this(StandardComparisonStrategy.instance()); } public DoubleArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, double[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, double[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, double[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, double[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, double[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, double[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, double[] actual, double[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, double[] actual, double value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, double[] actual, double value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, double[] actual, double[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, double[] actual, double[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, double[] actual, double[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, double[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, double[], double[])}, but it also verifies that the first element * in the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, double[] actual, double[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, double[], double[])}, but it also verifies that the last element * in the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, double[] actual, double[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, double[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, double[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Doubles.java000066400000000000000000000065371243020563200265330ustar00rootroot00000000000000/* * Created on Oct 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.Math.abs; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.assertions.internal.CommonValidations.*; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.util.Objects; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Double}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles extends RealNumbers { private static final Doubles INSTANCE = new Doubles(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Doubles instance() { return INSTANCE; } @VisibleForTesting Doubles() { super(); } public Doubles(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected Double zero() { return 0.0d; } @Override protected Double NaN() { return Double.NaN; } /** * Verifies that two floats are equal within a positive offset.
* It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison * strategy. * @param info contains information about the assertion. * @param actual the actual value. * @param expected the expected value. * @param offset the given positive offset. * @throws NullPointerException if the given offset is {@code null}. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to the expected one. */ // can't be defined in RealNumbers because Offset parameter must inherits from Number // while RealNumber parameter must inherits from Comparable (sadly Number is not Comparable) public void assertEqual(AssertionInfo info, Double actual, Double expected, Offset offset) { checkOffsetIsNotNull(offset); checkNumberIsNotNull(expected); assertNotNull(info, actual); // doesn't use areEqual method relying on comparisonStrategy attribute if (Objects.areEqual(actual, expected)) return; if (expected != null && isEqualTo(actual, expected, offset)) return; throw failures.failure(info, shouldBeEqual(actual, expected, offset, abs(expected.doubleValue() - actual.doubleValue()))); } @Override protected boolean isEqualTo(Double actual, Double expected, Offset offset) { return abs(expected.doubleValue() - actual.doubleValue()) <= offset.value.doubleValue(); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Failures.java000066400000000000000000000164451243020563200267070ustar00rootroot00000000000000/* * Created on Aug 5, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Strings.isNullOrEmpty; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.error.AssertionErrorFactory; import org.fest.assertions.error.ErrorMessageFactory; import org.fest.assertions.error.MessageFormatter; import org.fest.assertions.error.ShouldBeEqual; import org.fest.util.Throwables; import org.fest.util.VisibleForTesting; /** * Failure actions. * * @author Yvonne Wang * @author Alex Ruiz */ public class Failures { private static final Failures INSTANCE = new Failures(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Failures instance() { return INSTANCE; } /** * flag indicating wether or not we remove elements related to Fest from assertion error stack trace. */ private boolean removeFestRelatedElementsFromStackTrace = true; /** * Sets wether we remove elements related to Fest from assertion error stack trace. * @param removeFestRelatedElementsFromStackTrace flag */ public void setRemoveFestRelatedElementsFromStackTrace(boolean removeFestRelatedElementsFromStackTrace) { this.removeFestRelatedElementsFromStackTrace = removeFestRelatedElementsFromStackTrace; } @VisibleForTesting Failures() {} /** * Creates a {@link AssertionError} following this pattern: *
    *
  1. creates a {@link AssertionError} using {@link AssertionInfo#overridingErrorMessage()} as the * error message if such value is not {@code null}, or
  2. *
  3. uses the given {@link AssertionErrorFactory} to create an {@link AssertionError}, prepending * the value of {@link AssertionInfo#description()} to the error message
  4. *
* @param info contains information about the failed assertion. * @param factory knows how to create {@code AssertionError}s. * @return the created {@link AssertionError}. */ public AssertionError failure(AssertionInfo info, AssertionErrorFactory factory) { AssertionError error = failureIfErrorMessageIsOverriden(info); if (error != null) return error; return factory.newAssertionError(info.description()); } /** * Creates a {@link AssertionError} following this pattern: *
    *
  1. creates a {@link AssertionError} using {@link AssertionInfo#overridingErrorMessage()} as the * error message if such value is not {@code null}, or
  2. *
  3. uses the given {@link ErrorMessageFactory} to create the detail message of the * {@link AssertionError}, prepending the value of {@link AssertionInfo#description()} to the error * message
  4. *
* @param info contains information about the failed assertion. * @param message knows how to create detail messages for {@code AssertionError}s. * @return the created {@link AssertionError}. */ public AssertionError failure(AssertionInfo info, ErrorMessageFactory message) { AssertionError error = failureIfErrorMessageIsOverriden(info); if (error != null) return error; AssertionError assertionError = new AssertionError(message.create(info.description())); removeFestRelatedElementsFromStackTraceIfNeeded(assertionError); return assertionError; } private AssertionError failureIfErrorMessageIsOverriden(AssertionInfo info) { String overridingErrorMessage = info.overridingErrorMessage(); return isNullOrEmpty(overridingErrorMessage) ? null : failure(MessageFormatter.instance().format(info.description(), overridingErrorMessage)); } /** * Creates a {@link AssertionError} using the given {@code String} as message. *

* It filters the AssertionError stack trace be default, to have full stack trace use * {@link #setRemoveFestRelatedElementsFromStackTrace(boolean)}. * @param message the message of the {@code AssertionError} to create. * @return the created {@link AssertionError}. */ public AssertionError failure(String message) { AssertionError assertionError = new AssertionError(message); removeFestRelatedElementsFromStackTraceIfNeeded(assertionError); return assertionError; } /** * If is {@link #removeFestRelatedElementsFromStackTrace} is true, it filters the stack trace of the given {@link AssertionError} * by removing stack trace elements related to Fest in order to get a more readable stack trace. *

* See example below : *

--------------- stack trace not filtered -----------------
org.junit.ComparisonFailure: expected:<'[Ronaldo]'> but was:<'[Messi]'>
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
  at org.fest.assertions.error.ConstructorInvoker.newInstance(ConstructorInvoker.java:34)
  at org.fest.assertions.error.ShouldBeEqual.newComparisonFailure(ShouldBeEqual.java:111)
  at org.fest.assertions.error.ShouldBeEqual.comparisonFailure(ShouldBeEqual.java:103)
  at org.fest.assertions.error.ShouldBeEqual.newAssertionError(ShouldBeEqual.java:81)
  at org.fest.assertions.internal.Failures.failure(Failures.java:76)
  at org.fest.assertions.internal.Objects.assertEqual(Objects.java:116)
  at org.fest.assertions.api.AbstractAssert.isEqualTo(AbstractAssert.java:74)
  at examples.StackTraceFilterExample.main(StackTraceFilterExample.java:13)
  
--------------- stack trace filtered -----------------
org.junit.ComparisonFailure: expected:<'[Ronaldo]'> but was:<'[Messi]'>
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at examples.StackTraceFilterExample.main(StackTraceFilterExample.java:20)
   * 
* * Method is public because we need to call it from {@link ShouldBeEqual#newAssertionError(org.fest.assertions.description.Description)} that is building a junit ComparisonFailure by reflection. * * @param assertionError the {@code AssertionError} to filter stack trace if option is set. */ public void removeFestRelatedElementsFromStackTraceIfNeeded(AssertionError assertionError) { if (removeFestRelatedElementsFromStackTrace) { Throwables.removeFestRelatedElementsFromStackTrace(assertionError); } } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Files.java000066400000000000000000000251111243020563200261650ustar00rootroot00000000000000/* * Created on Jan 26, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeAbsolutePath.shouldBeAbsolutePath; import static org.fest.assertions.error.ShouldBeDirectory.shouldBeDirectory; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import static org.fest.assertions.error.ShouldBeReadable.shouldBeReadable; import static org.fest.assertions.error.ShouldBeRelativePath.shouldBeRelativePath; import static org.fest.assertions.error.ShouldBeWritable.shouldBeWritable; import static org.fest.assertions.error.ShouldExist.shouldExist; import static org.fest.assertions.error.ShouldHaveBinaryContent.shouldHaveBinaryContent; import static org.fest.assertions.error.ShouldHaveContent.shouldHaveContent; import static org.fest.assertions.error.ShouldHaveEqualContent.shouldHaveEqualContent; import static org.fest.assertions.error.ShouldNotExist.shouldNotExist; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.util.FilesException; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link File}s. * * @author David DIDIER * @author Yvonne Wang * @author Alex Ruiz * @author Olivier Demeijer */ public class Files { private static final Files INSTANCE = new Files(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Files instance() { return INSTANCE; } @VisibleForTesting Diff diff = new Diff(); @VisibleForTesting BinaryDiff binaryDiff = new BinaryDiff(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Files() {} /** * Asserts that the given files have equal content. Adapted from FileAssert (from JUnit-addons.) * @param info contains information about the assertion. * @param actual the "actual" file. * @param expected the "expected" file. * @throws NullPointerException if {@code expected} is {@code null}. * @throws IllegalArgumentException if {@code expected} is not an existing file. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if {@code actual} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the given files do not have equal content. */ public void assertEqualContent(AssertionInfo info, File actual, File expected) { verifyIsFile(expected); assertIsFile(info, actual); try { List diffs = diff.diff(actual, expected); if (diffs.isEmpty()) return; throw failures.failure(info, shouldHaveEqualContent(actual, expected, diffs)); } catch (IOException e) { String msg = String.format("Unable to compare contents of files:<%s> and:<%s>", actual, expected); throw new FilesException(msg, e); } } /** * Asserts that the given file has the given binary content. * @param info contains information about the assertion. * @param actual the "actual" file. * @param expected the "expected" binary content. * @throws NullPointerException if {@code expected} is {@code null}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if {@code actual} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the file does not have the binary content. */ public void assertHasBinaryContent(AssertionInfo info, File actual, byte[] expected) { if (expected == null) throw new NullPointerException("The binary content to compare to should not be null"); assertIsFile(info, actual); try { BinaryDiffResult result = binaryDiff.diff(actual, expected); if (result.hasNoDiff()) return; throw failures.failure(info, shouldHaveBinaryContent(actual, result)); } catch (IOException e) { String msg = String.format("Unable to verify binary contents of file:<%s>", actual); throw new FilesException(msg, e); } } /** * Asserts that the given file has the given text content. * @param info contains information about the assertion. * @param actual the "actual" file. * @param expected the "expected" text content. * @param charset the charset to use to read the file. * @throws NullPointerException if {@code expected} is {@code null}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if {@code actual} is not an existing file. * @throws FilesException if an I/O error occurs. * @throws AssertionError if the file does not have the text content. */ public void assertHasContent(AssertionInfo info, File actual, String expected, Charset charset) { if (expected == null) throw new NullPointerException("The text to compare to should not be null"); assertIsFile(info, actual); try { List diffs = diff.diff(actual, expected, charset); if (diffs.isEmpty()) return; throw failures.failure(info, shouldHaveContent(actual, charset, diffs)); } catch (IOException e) { String msg = String.format("Unable to verify text contents of file:<%s>", actual); throw new FilesException(msg, e); } } private void verifyIsFile(File expected) { if (expected == null) throw new NullPointerException("The file to compare to should not be null"); if (expected.isFile()) return; throw new IllegalArgumentException(String.format("Expected file:<'%s'> should be an existing file", expected)); } /** * Asserts that the given file is an existing file. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file is not an existing file. */ public void assertIsFile(AssertionInfo info, File actual) { assertNotNull(info, actual); if (actual.isFile()) return; throw failures.failure(info, shouldBeFile(actual)); } /** * Asserts that the given file is an existing directory. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file is not an existing directory. */ public void assertIsDirectory(AssertionInfo info, File actual) { assertNotNull(info, actual); if (actual.isDirectory()) return; throw failures.failure(info, shouldBeDirectory(actual)); } /** * Asserts that the given file is an absolute path. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file is not an absolute path. */ public void assertIsAbsolute(AssertionInfo info, File actual) { if (isAbsolutePath(info, actual)) return; throw failures.failure(info, shouldBeAbsolutePath(actual)); } /** * Asserts that the given file is a relative path. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file is not a relative path. */ public void assertIsRelative(AssertionInfo info, File actual) { if (!isAbsolutePath(info, actual)) return; throw failures.failure(info, shouldBeRelativePath(actual)); } private boolean isAbsolutePath(AssertionInfo info, File actual) { assertNotNull(info, actual); return actual.isAbsolute(); } /** * Asserts that the given file exists, regardless it's a file or directory. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file does not exist. */ public void assertExists(AssertionInfo info, File actual) { assertNotNull(info, actual); if (actual.exists()) return; throw failures.failure(info, shouldExist(actual)); } /** * Asserts that the given file does not exist. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file exists. */ public void assertDoesNotExist(AssertionInfo info, File actual) { assertNotNull(info, actual); if (!actual.exists()) return; throw failures.failure(info, shouldNotExist(actual)); } /** * Asserts that the given file can be modified by the application. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file can not be modified. */ public void assertCanWrite(AssertionInfo info, File actual) { assertNotNull(info, actual); if (actual.canWrite()) return; throw failures.failure(info, shouldBeWritable(actual)); } /** * Asserts that the given file can be read by the application. * @param info contains information about the assertion. * @param actual the given file. * @throws AssertionError if the given file is {@code null}. * @throws AssertionError if the given file can not be modified. */ public void assertCanRead(AssertionInfo info, File actual) { assertNotNull(info, actual); if (actual.canRead()) return; throw failures.failure(info, shouldBeReadable(actual)); } private static void assertNotNull(AssertionInfo info, File actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/FloatArrays.java000066400000000000000000000310241243020563200273520ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code float}s. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class FloatArrays { private static final FloatArrays INSTANCE = new FloatArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static FloatArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting FloatArrays() { this(StandardComparisonStrategy.instance()); } public FloatArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, float[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, float[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, float[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, float[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, float[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, float[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, float[] actual, float[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, float[] actual, float value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, float[] actual, float value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, float[] actual, float[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, float[] actual, float[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, float[] actual, float[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, float[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, float[], float[])}, but it also verifies that the first element in * the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, float[] actual, float[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, float[], float[])}, but it also verifies that the last element in * the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, float[] actual, float[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, float[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, float[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Floats.java000066400000000000000000000063561243020563200263650ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.Math.abs; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.assertions.internal.CommonValidations.*; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.util.Objects; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Float}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats extends RealNumbers { private static final Floats INSTANCE = new Floats(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Floats instance() { return INSTANCE; } @VisibleForTesting Floats() { super(); } public Floats(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected Float zero() { return 0.0f; } @Override protected Float NaN() { return Float.NaN; } @Override protected boolean isEqualTo(Float actual, Float expected, Offset offset) { return abs(expected - actual.floatValue()) <= offset.value.floatValue(); } /** * Verifies that two floats are equal within a positive offset.
* It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison * strategy. * @param info contains information about the assertion. * @param actual the actual value. * @param expected the expected value. * @param offset the given positive offset. * @throws NullPointerException if the given offset is {@code null}. * @throws AssertionError if the actual value is not equal to the expected one. */ // can't be defined in RealNumbers because Offset parameter must inherits from Number // while RealNumber parameter must inherits from Comparable (sadly Number is not Comparable) public void assertEqual(AssertionInfo info, Float actual, Float expected, Offset offset) { assertNotNull(info, actual); checkOffsetIsNotNull(offset); checkNumberIsNotNull(expected); // doesn't use areEqual method relying on comparisonStrategy attribute if (Objects.areEqual(actual, expected)) return; if (expected != null && isEqualTo(actual, expected, offset)) return; throw failures.failure(info, shouldBeEqual(actual, expected, offset, abs(expected - actual.floatValue()))); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/InputStreams.java000066400000000000000000000054421243020563200275660ustar00rootroot00000000000000/* * Created on Jan 26, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.String.format; import static org.fest.assertions.error.ShouldHaveEqualContent.shouldHaveEqualContent; import java.io.IOException; import java.io.InputStream; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link InputStream}s. * * @author Matthieu Baechler */ public class InputStreams { private static final InputStreams INSTANCE = new InputStreams(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static InputStreams instance() { return INSTANCE; } @VisibleForTesting Diff diff = new Diff(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting InputStreams() {} /** * Asserts that the given InputStreams have equal content. * * @param info contains information about the assertion. * @param actual the "actual" InputStream. * @param expected the "expected" InputStream. * @throws NullPointerException if {@code expected} is {@code null}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the given InputStreams do not have equal content. * @throws InputStreamsException if an I/O error occurs. */ public void assertEqualContent(AssertionInfo info, InputStream actual, InputStream expected) { if (expected == null) throw new NullPointerException("The InputStream to compare to should not be null"); assertNotNull(info, actual); try { List diffs = diff.diff(actual, expected); if (diffs.isEmpty()) return; throw failures.failure(info, shouldHaveEqualContent(actual, expected, diffs)); } catch (IOException e) { String msg = format("Unable to compare contents of InputStreams :<%s> and:<%s>", actual, expected); throw new InputStreamsException(msg, e); } } private static void assertNotNull(AssertionInfo info, InputStream stream) { Objects.instance().assertNotNull(info, stream); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/InputStreamsException.java000066400000000000000000000024731243020563200314460ustar00rootroot00000000000000/* * Created on May 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.internal; /** * Exception thrown by {@link InputStreams}. * * @author Matthieu Baechler */ public class InputStreamsException extends RuntimeException { private static final long serialVersionUID = 1L; /** * Creates a new {@link InputStreamsException}. * @param message the detail message. */ public InputStreamsException(String message) { super(message); } /** * Creates a new {@link InputStreamsException}. * @param message the detail message. * @param cause the cause of the error. */ public InputStreamsException(String message, Throwable cause) { super(message, cause); } }fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/IntArrays.java000066400000000000000000000307531243020563200270470ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code int}s. * * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class IntArrays { private static final IntArrays INSTANCE = new IntArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static IntArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting IntArrays() { this(StandardComparisonStrategy.instance()); } public IntArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, int[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, int[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, int[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, int[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, int[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, int[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, int[] actual, int[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, int[] actual, int value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, int[] actual, int value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, int[] actual, int[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, int[] actual, int[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, int[] actual, int[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, int[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, int[], int[])}, but it also verifies that the first element in the * sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, int[] actual, int[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, int[], int[])}, but it also verifies that the last element in the * sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, int[] actual, int[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, int[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, int[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Integers.java000066400000000000000000000027051243020563200267070ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Integer}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers extends Numbers { private static final Integers INSTANCE = new Integers(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Integers instance() { return INSTANCE; } @VisibleForTesting Integers() { super(); } public Integers(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected Integer zero() { return 0; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Iterables.java000066400000000000000000001310461243020563200270420ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ConditionAndGroupGenericParameterTypeShouldBeTheSame.shouldBeSameGenericBetweenIterableAndCondition; import static org.fest.assertions.error.ElementsShouldBe.elementsShouldBe; import static org.fest.assertions.error.ElementsShouldBeAtLeast.elementsShouldBeAtLeast; import static org.fest.assertions.error.ElementsShouldBeExactly.elementsShouldBeExactly; import static org.fest.assertions.error.ElementsShouldHave.elementsShouldHave; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.assertions.error.ElementsShouldHaveAtMost.elementsShouldHaveAtMost; import static org.fest.assertions.error.ElementsShouldHaveExactly.elementsShouldHaveExactly; import static org.fest.assertions.error.ElementsShouldNotBe.elementsShouldNotBe; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.assertions.error.ElementsShouldNotBeExactly.elementsShouldNotBeExactly; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.assertions.error.ElementsShouldNotHaveAtMost.elementsShouldNotHaveAtMost; import static org.fest.assertions.error.ElementsShouldNotHaveExactly.elementsShouldNotHaveExactly; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.error.ShouldBeSubsetOf.shouldBeSubsetOf; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.error.ShouldContainExactly.shouldContainExactly; import static org.fest.assertions.error.ShouldContainNull.shouldContainNull; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.assertions.error.ShouldNotContainNull.shouldNotContainNull; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.assertions.internal.CommonErrors.arrayOfValuesToLookForIsEmpty; import static org.fest.assertions.internal.CommonErrors.arrayOfValuesToLookForIsNull; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Iterables.sizeOf; import static org.fest.util.Lists.newArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Iterable}s. * * @author Alex Ruiz * @author Yvonne Wang * @author Maciej Jaskowski * @author Nicolas François * @author Joel Costigliola */ public class Iterables { private static final Iterables INSTANCE = new Iterables(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Iterables instance() { return INSTANCE; } private final ComparisonStrategy comparisonStrategy; @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Conditions conditions = Conditions.instance(); @VisibleForTesting Iterables() { this(StandardComparisonStrategy.instance()); } public Iterables(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy).getComparator(); } return null; } /** * Asserts that the given {@link Iterable} is {@code null} or empty. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws AssertionError if the given {@code Iterable} is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, Iterable actual) { if (actual == null || isNullOrEmpty(actual)) { return; } throw failures.failure(info, shouldBeNullOrEmpty(actual)); } /** * Asserts that the given {@code Iterable} is empty. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} is not empty. */ public void assertEmpty(AssertionInfo info, Iterable actual) { assertNotNull(info, actual); if (isNullOrEmpty(actual)) { return; } throw failures.failure(info, shouldBeEmpty(actual)); } /** * Asserts that the given {@code Iterable} is not empty. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} is empty. */ public void assertNotEmpty(AssertionInfo info, Iterable actual) { assertNotNull(info, actual); if (!isNullOrEmpty(actual)) { return; } throw failures.failure(info, shouldNotBeEmpty()); } /** * Asserts that the number of elements in the given {@code Iterable} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of elements in the given {@code Iterable} is different than the expected one. */ public void assertHasSize(AssertionInfo info, Iterable actual, int expectedSize) { assertNotNull(info, actual); int sizeOfActual = sizeOf(actual); if (sizeOfActual == expectedSize) { return; } throw failures.failure(info, shouldHaveSize(actual, sizeOfActual, expectedSize)); } /** * Assert that the actual {@code Iterable} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param other the given array to compare. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if actual {@code Iterable} and other array don't have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Iterable actual, Object[] other) { assertNotNull(info, actual); if (other == null) { throw arrayOfValuesToLookForIsNull(); } int sizeOfActual = sizeOf(actual); int sizeOfOther = other.length; if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); } /** * Assert that the actual {@code Iterable} has the same size as the other {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param other the given {@code Iterable}. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if actual and other {@code Iterable} don't have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Iterable actual, Iterable other) { assertNotNull(info, actual); checkNotNull(info, other); int sizeOfActual = sizeOf(actual); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); } /** * Asserts that the given {@code Iterable} contains the given values, in any order. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param values the values that are expected to be in the given {@code Iterable}. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain the given values. */ public void assertContains(AssertionInfo info, Iterable actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); Set notFound = new LinkedHashSet(); for (Object value : values) { if (!iterableContains(actual, value)) { notFound.add(value); } } if (notFound.isEmpty()) { return; } throw failures.failure(info, shouldContain(actual, values, notFound, comparisonStrategy)); } /** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable actual, Object value) { return comparisonStrategy.iterableContains(actual, value); } /** * Delegates to {@link ComparisonStrategy#iterableRemoves(Iterable, Object)} */ private void iterableRemoves(Iterable actual, Object value) { comparisonStrategy.iterableRemoves(actual, value); } /** * Asserts that the given {@code Iterable} contains only the given values and nothing else, in any order. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param values the values that are expected to be in the given {@code Iterable}. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain the given values or if the given * {@code Iterable} contains values that are not in the given array. */ public void assertContainsOnly(AssertionInfo info, Iterable actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); Set notExpected = setFromIterable(actual); Set notFound = containsOnly(notExpected, values); if (notExpected.isEmpty() && notFound.isEmpty()) { return; } throw failures.failure(info, shouldContainOnly(actual, values, notFound, notExpected, comparisonStrategy)); } private Set containsOnly(Set actual, Object[] values) { Set notFound = new LinkedHashSet(); for (Object o : set(values)) { if (iterableContains(actual, o)) { iterableRemoves(actual, o); } else { notFound.add(o); } } return notFound; } /** * build a Set with that avoid duplicates according to given comparison strategy * * @param elements to feed the Set we want to build * @return a Set without duplicates according to given comparison strategy */ private Set set(Object... elements) { if (elements == null) { return null; } Set set = new HashSet(); for (Object e : elements) { // only add is not already there if (!iterableContains(set, e)) { set.add(e); } } return set; } /** * build a Set with that avoid duplicates according to given comparison strategy * * @param iterable to feed the Set we want to build * @return a Set without duplicates according to given comparison strategy */ private Set setFromIterable(Iterable iterable) { if (iterable == null) { return null; } Set set = new HashSet(); for (Object e : iterable) { // only add is not already there if (!iterableContains(set, e)) { set.add(e); } } return set; } /** * Verifies that the given {@link Iterable} contains the given sequence of objects, without any other * objects between them. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given {@code Iterable} does not contain the given sequence of objects. */ public void assertContainsSequence(AssertionInfo info, Iterable actual, Object[] sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, actual); List actualAsList = newArrayList(actual); for (int i = 0; i < actualAsList.size(); i++) { // look for given sequence in actual starting from current index (i) if (containsSequenceAtGivenIndex(actualAsList, sequence, i)) { return; } } throw actualDoesNotContainSequence(info, actual, sequence); } /** * Verifies that the actual Iterable is a subset of values Iterable.
* Both actual and given iterable are treated as sets, therefore duplicates on either of them are ignored. * * @param info contains information about the assertion. * @param actual the actual {@code Iterable}. * @param values the {@code Iterable} that should contain all actual elements. * @throws AssertionError if the actual {@code Iterable} is {@code null}. * @throws NullPointerException if the given Iterable is {@code null}. * @throws AssertionError if the actual {@code Iterable} is not subset of set {@link Iterable} */ public void assertIsSubsetOf(AssertionInfo info, Iterable actual, Iterable values) { assertNotNull(info, actual); checkNotNull(info, values); List extra = newArrayList(); for (Object actualElement : actual) { if (!iterableContains(values, actualElement)) { extra.add(actualElement); } } if (extra.size() > 0) { throw actualIsNotSubsetOfSet(info, actual, values, extra); } } private static void checkNotNull(AssertionInfo info, Iterable set) { if (set == null) { throw iterableToLookForIsNull(); } } private AssertionError actualIsNotSubsetOfSet(AssertionInfo info, Object actual, Iterable set, Iterable extra) { return failures.failure(info, shouldBeSubsetOf(actual, set, extra, comparisonStrategy)); } /** * Return true if actualAsList contains exactly the given sequence at given starting index, false otherwise. * * @param actualAsList the list to look sequance in * @param sequence the sequence to look for * @param startingIndex the index of actual list at which we start looking for sequence. * @return */ private boolean containsSequenceAtGivenIndex(List actualAsList, Object[] sequence, int startingIndex) { // check that, starting from given index, actualAsList has enough remaining elements to contain sequence if (actualAsList.size() - startingIndex < sequence.length) { return false; } for (int i = 0; i < sequence.length; i++) { if (!areEqual(actualAsList.get(startingIndex + i), sequence[i])) { return false; } } return true; } /** * Delegates to {@link ComparisonStrategy#areEqual(Object, Object)} */ private boolean areEqual(Object actual, Object other) { return comparisonStrategy.areEqual(actual, other); } private AssertionError actualDoesNotContainSequence(AssertionInfo info, Iterable actual, Object[] sequence) { return failures.failure(info, shouldContainSequence(actual, sequence, comparisonStrategy)); } /** * Asserts that the given {@code Iterable} does not contain the given values. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param values the values that are expected not to be in the given {@code Iterable}. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, Iterable actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); Set found = new LinkedHashSet(); for (Object o : values) { if (iterableContains(actual, o)) { found.add(o); } } if (found.isEmpty()) { return; } throw failures.failure(info, shouldNotContain(actual, values, found, comparisonStrategy)); } /** * Asserts that the given {@code Iterable} does not have duplicate values. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, Iterable actual) { assertNotNull(info, actual); Iterable duplicates = comparisonStrategy.duplicatesFrom(actual); if (isNullOrEmpty(duplicates)) { return; } throw failures.failure(info, shouldNotHaveDuplicates(actual, duplicates, comparisonStrategy)); } /** * Verifies that the given {@code Iterable} starts with the given sequence of objects, without any other objects * between them. Similar to {@link #assertContainsSequence(AssertionInfo, Iterable, Object[])}, but it * also verifies that the first element in the sequence is also the first element of the given {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not start with the given sequence of objects. */ public void assertStartsWith(AssertionInfo info, Iterable actual, Object[] sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, actual); int sequenceSize = sequence.length; if (sizeOf(actual) < sequenceSize) { throw actualDoesNotStartWithSequence(info, actual, sequence); } int i = 0; for (Object o : actual) { if (i >= sequenceSize) { break; } if (areEqual(o, sequence[i++])) { continue; } throw actualDoesNotStartWithSequence(info, actual, sequence); } } private AssertionError actualDoesNotStartWithSequence(AssertionInfo info, Iterable actual, Object[] sequence) { return failures.failure(info, shouldStartWith(actual, sequence, comparisonStrategy)); } /** * Verifies that the given {@code Iterable} ends with the given sequence of objects, without any other objects between * them. Similar to {@link #assertContainsSequence(AssertionInfo, Iterable, Object[])}, but it also * verifies that the last element in the sequence is also the last element of the given {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param sequence the sequence of objects to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not end with the given sequence of objects. */ public void assertEndsWith(AssertionInfo info, Iterable actual, Object[] sequence) { checkIsNotNullAndNotEmpty(sequence); assertNotNull(info, actual); int sequenceSize = sequence.length; int sizeOfActual = sizeOf(actual); if (sizeOfActual < sequenceSize) { throw actualDoesNotEndWithSequence(info, actual, sequence); } int start = sizeOfActual - sequenceSize; int sequenceIndex = 0, indexOfActual = 0; for (Object o : actual) { if (indexOfActual++ < start) { continue; } if (areEqual(o, sequence[sequenceIndex++])) { continue; } throw actualDoesNotEndWithSequence(info, actual, sequence); } } /** * Asserts that the given {@code Iterable} contains at least a null element. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain at least a null element. */ public void assertContainsNull(AssertionInfo info, Iterable actual) { assertNotNull(info, actual); if (!iterableContains(actual, null)) { throw failures.failure(info, shouldContainNull(actual)); } } /** * Asserts that the given {@code Iterable} does not contain null elements. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} contains a null element. */ public void assertDoesNotContainNull(AssertionInfo info, Iterable actual) { assertNotNull(info, actual); if (iterableContains(actual, null)) { throw failures.failure(info, shouldNotContainNull(actual)); } } /** * Assert that each element of given {@code Iterable} satisfies the given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element not satisfy the given condition. */ public void assertAre(AssertionInfo info, Iterable actual, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldBe(actual, notSatisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that each element of given {@code Iterable} not satisfies the given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element satisfy the given condition. */ public void assertAreNot(AssertionInfo info, Iterable actual, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldNotBe(actual, satisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that each element of given {@code Iterable} satisfies the given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element not satisfy the given condition. */ public void assertHave(AssertionInfo info, Iterable actual, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldHave(actual, notSatisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that each element of given {@code Iterable} not satisfies the given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if one or more element satisfy the given condition. */ public void assertDoNotHave(AssertionInfo info, Iterable actual, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.isEmpty()) { return; } throw failures.failure(info, elementsShouldNotHave(actual, satisfiesCondition, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that there is at least n elements in the actual {@code Iterable} satisfying the given * condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the minimum number of times the condition should be verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is < n. */ public void assertAreAtLeast(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() >= n) { return; } throw failures.failure(info, elementsShouldBeAtLeast(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that there is at least n elements in the actual {@code Iterable} not satisfying the * given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the number of times the condition should not be verified at least. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is < n. */ public void assertAreNotAtLeast(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() >= n) { return; } throw failures.failure(info, elementsShouldNotBeAtLeast(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Assert that there is at most n elements in the actual {@code Iterable} satisfying the given * condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the number of times the condition should be at most verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is > n. */ public void assertAreAtMost(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() <= n) { return; } throw failures.failure(info, elementsShouldNotBeAtMost(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Verifies that there is at most n elements in the actual {@code Iterable} not satisfying the * given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the number of times the condition should not be verified at most. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is > n. */ public void assertAreNotAtMost(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() <= n) { return; } throw failures.failure(info, elementsShouldNotBeAtMost(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Verifies that there is exactly n elements in the actual {@code Iterable} satisfying the given * condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the exact number of times the condition should be verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements satisfying the given condition is ≠ n. */ public void assertAreExactly(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() == n) { return; } throw failures.failure(info, elementsShouldBeExactly(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Verifies that there is exactly n elements in the actual {@code Iterable} not satisfying the * given condition. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param n the exact number of times the condition should not be verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if a element cannot be cast to E. * @throws AssertionError if the number of elements not satisfying the given condition is ≠ n. */ public void assertAreNotExactly(AssertionInfo info, Iterable actual, int n, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() == n) { return; } throw failures.failure(info, elementsShouldNotBeExactly(actual, n, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreAtLeast(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent * api (same logic, only error message differs). */ public void assertHaveAtLeast(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldHaveAtLeast(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreNotAtLeast(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent * api (same logic, only error message differs). */ public void assertDoNotHaveAtLeast(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() >= times) { return; } throw failures.failure(info, elementsShouldNotHaveAtLeast(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreAtMost(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent api * (same logic, only error message differs). */ public void assertHaveAtMost(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldHaveAtMost(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreNotAtMost(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent * api (same logic, only error message differs). */ public void assertDoNotHaveAtMost(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() <= times) { return; } throw failures.failure(info, elementsShouldNotHaveAtMost(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreExactly(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent * api (same logic, only error message differs). */ public void assertHaveExactly(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List satisfiesCondition = satisfiesCondition(actual, condition); if (satisfiesCondition.size() == times) { return; } throw failures.failure(info, elementsShouldHaveExactly(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * An alias method of {@link #assertAreNotExactly(AssertionInfo, Iterable, int, Condition)} to provide a richer fluent * api (same logic, only error message differs). */ public void assertDoNotHaveExactly(AssertionInfo info, Iterable actual, int times, Condition condition) { assertNotNull(info, actual); conditions.assertIsNotNull(condition); try { List notSatisfiesCondition = notSatisfiesCondition(actual, condition); if (notSatisfiesCondition.size() == times) { return; } throw failures.failure(info, elementsShouldNotHaveExactly(actual, times, condition)); } catch (ClassCastException e) { throw failures.failure(info, shouldBeSameGenericBetweenIterableAndCondition(actual, condition)); } } /** * Asserts that the given {@code Iterable} contains all the elements of the other {@code Iterable}, in any order. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param other the other {@code Iterable}. * @throws NullPointerException if {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain all the elements of the other * {@code Iterable}, in any order. */ public void assertContainsAll(AssertionInfo info, Iterable actual, Iterable other) { if (other == null) { throw iterableToLookForIsNull(); } assertNotNull(info, actual); Object[] values = newArrayList(other).toArray(); Set notFound = new LinkedHashSet(); for (Object value : values) { if (!iterableContains(actual, value)) { notFound.add(value); } } if (notFound.isEmpty()) { return; } throw failures.failure(info, shouldContain(actual, values, notFound, comparisonStrategy)); } /** * Asserts that the given {@code Iterable} contains exactly the given values and nothing else, in order. * * @param info contains information about the assertion. * @param actual the given {@code Iterable}. * @param values the values that are expected to be in the given {@code Iterable} in order. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain the given values or if the given * {@code Iterable} contains values that are not in the given array, in order. */ public void assertContainsExactly(AssertionInfo info, Iterable actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertHasSameSizeAs(info, actual, values); // include chack that actual is not null Set notExpected = setFromIterable(actual); Set notFound = containsOnly(notExpected, values); if (notExpected.isEmpty() && notFound.isEmpty()) { // actual and values have the same elements but are they in the same order. int i = 0; for (Object elementFromActual : actual) { if (!areEqual(elementFromActual, values[i])) { throw failures.failure(info, shouldContainExactly(elementFromActual, values[i], i, comparisonStrategy)); } i++; } return; } throw failures.failure(info, shouldContainExactly(actual, values, notFound, notExpected, comparisonStrategy)); } private void checkIsNotNullAndNotEmpty(Object[] values) { if (values == null) { throw arrayOfValuesToLookForIsNull(); } if (values.length == 0) { throw arrayOfValuesToLookForIsEmpty(); } } private void assertNotNull(AssertionInfo info, Iterable actual) { Objects.instance().assertNotNull(info, actual); } private AssertionError actualDoesNotEndWithSequence(AssertionInfo info, Iterable actual, Object[] sequence) { return failures.failure(info, shouldEndWith(actual, sequence, comparisonStrategy)); } private List notSatisfiesCondition(Iterable actual, Condition condition) { List notSatisfiesCondition = new LinkedList(); for (E o : actual) { if (!condition.matches(o)) { notSatisfiesCondition.add(o); } } return notSatisfiesCondition; } private List satisfiesCondition(Iterable actual, Condition condition) { List satisfiesCondition = new LinkedList(); for (E o : actual) { if (condition.matches(o)) { satisfiesCondition.add(o); } } return satisfiesCondition; } static public NullPointerException iterableToLookForIsNull() { return new NullPointerException("The iterable to look for should not be null"); } static public IllegalArgumentException iterableToLookForIsEmpty() { return new IllegalArgumentException("The iterable to look for should not be empty"); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/JavaBeanDescriptor.java000066400000000000000000000020271243020563200306320ustar00rootroot00000000000000/* * Created on Jan 12, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; /** * Wrapper for {@link PropertyDescriptor}. * * @author Alex Ruiz */ class JavaBeanDescriptor { Object invokeReadMethod(PropertyDescriptor d, Object o) throws IllegalAccessException, InvocationTargetException { return d.getReadMethod().invoke(o); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Lists.java000066400000000000000000000331011243020563200262170ustar00rootroot00000000000000/* * Created on Nov 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeAtIndex.shouldBeAtIndex; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSorted; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.assertions.error.ShouldBeSorted.shouldHaveComparableElementsAccordingToGivenComparator; import static org.fest.assertions.error.ShouldBeSorted.shouldHaveMutuallyComparableElements; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.assertions.error.ShouldHaveAtIndex.shouldHaveAtIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.assertions.internal.CommonValidations.checkIndexValueIsValid; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link List}s. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ // TODO inherits from Collections to avoid repeating comparisonStrategy ? public class Lists { private static final Lists INSTANCE = new Lists(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Lists instance() { return INSTANCE; } private ComparisonStrategy comparisonStrategy; @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Lists() { this(StandardComparisonStrategy.instance()); } public Lists(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy) .getComparator(); } return null; } /** * Verifies that the given {@code List} contains the given object at the given index. * @param info contains information about the assertion. * @param actual the given {@code List}. * @param value the object to look for. * @param index the index where the object should be stored in the given {@code List}. * @throws AssertionError if the given {@code List} is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * {@code List}. * @throws AssertionError if the given {@code List} does not contain the given object at the given index. */ public void assertContains(AssertionInfo info, List actual, Object value, Index index) { assertNotNull(info, actual); Iterables.instance().assertNotEmpty(info, actual); checkIndexValueIsValid(index, actual.size() - 1); Object actualElement = actual.get(index.value); if (areEqual(actualElement, value)) return; throw failures.failure(info, shouldContainAtIndex(actual, value, index, actual.get(index.value), comparisonStrategy)); } /** * Verifies that the given {@code List} does not contain the given object at the given index. * @param info contains information about the assertion. * @param actual the given {@code List}. * @param value the object to look for. * @param index the index where the object should be stored in the given {@code List}. * @throws AssertionError if the given {@code List} is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given {@code List} contains the given object at the given index. */ public void assertDoesNotContain(AssertionInfo info, List actual, Object value, Index index) { assertNotNull(info, actual); checkIndexValueIsValid(index, Integer.MAX_VALUE); int indexValue = index.value; if (indexValue >= actual.size()) return; Object actualElement = actual.get(index.value); if (!areEqual(actualElement, value)) return; throw failures.failure(info, shouldNotContainAtIndex(actual, value, index, comparisonStrategy)); } /** * Verifies that the actual list is sorted into ascending order according to the natural ordering of its elements. *

* All list elements must implement the {@link Comparable} interface and must be mutually comparable (that is, e1.compareTo(e2) * must not throw a ClassCastException for any elements e1 and e2 in the list), examples : *

    *
  • a list composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
  • *
  • a list composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
  • *
  • a list composed of {True, "abc", False} is NOT ok because elements are not mutually comparable
  • *
* Empty lists are considered sorted.
Unique element lists are considered sorted unless the element type is not Comparable. * * @param info contains information about the assertion. * @param actual the given {@code List}. * * @throws AssertionError if the actual list is not sorted into ascending order according to the natural ordering of its * elements. * @throws AssertionError if the actual list is null. * @throws AssertionError if the actual list element type does not implement {@link Comparable}. * @throws AssertionError if the actual list elements are not mutually {@link Comparable}. */ public void assertIsSorted(AssertionInfo info, List actual) { assertNotNull(info, actual); if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { // instead of comparing elements with their natural comparator, use the one set by client. Comparator comparator = ((ComparatorBasedComparisonStrategy) comparisonStrategy).getComparator(); assertIsSortedAccordingToComparator(info, actual, comparator); return; } try { // sorted assertion is only relevant if elements are Comparable, we assume they are List> comparableList = listOfComparableElements(actual); // array with 0 or 1 element are considered sorted. if (comparableList.size() <= 1) return; for (int i = 0; i < comparableList.size() - 1; i++) { // array is sorted in ascending order iif element i is less or equal than element i+1 if (comparableList.get(i).compareTo(comparableList.get(i + 1)) > 0) throw failures.failure(info, shouldBeSorted(i, actual)); } } catch (ClassCastException e) { // elements are either not Comparable or not mutually Comparable (e.g. List containing String and Integer) throw failures.failure(info, shouldHaveMutuallyComparableElements(actual)); } } /** * Verifies that the actual list is sorted according to the given comparator.
Empty lists are considered sorted whatever * the comparator is.
One element lists are considered sorted if element is compatible with comparator. * * @param info contains information about the assertion. * @param actual the given {@code List}. * @param comparator the {@link Comparator} used to compare list elements * * @throws AssertionError if the actual list is not sorted according to the given comparator. * @throws AssertionError if the actual list is null. * @throws NullPointerException if the given comparator is null. * @throws AssertionError if the actual list elements are not mutually comparabe according to given Comparator. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void assertIsSortedAccordingToComparator(AssertionInfo info, List actual, Comparator comparator) { assertNotNull(info, actual); if (comparator == null) throw new NullPointerException("The given comparator should not be null"); try { // Empty collections are considered sorted even if comparator can't be applied to their element type // We can't verify that point because of erasure type at runtime. if (actual.size() == 0) return; Comparator rawComparator = comparator; if (actual.size() == 1) { // Compare unique element with itself to verify that it is compatible with comparator (a ClassCastException is // thrown if not). We have to use a raw comparator to compare the unique element of actual ... :( rawComparator.compare(actual.get(0), actual.get(0)); return; } for (int i = 0; i < actual.size() - 1; i++) { // List is sorted in comparator defined order if current element is less or equal than next element if (rawComparator.compare(actual.get(i), actual.get(i + 1)) > 0) throw failures.failure(info, shouldBeSortedAccordingToGivenComparator(i, actual, comparator)); } } catch (ClassCastException e) { throw failures.failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, comparator)); } } /** * Verifies that the given {@code List} satisfies the given {@link Condition} at the given index. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the given {@code List}. * @param condition the given {@code Condition}. * @param index the index where the object should be stored in the given {@code List}. * @throws AssertionError if the given {@code List} is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * {@code List}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the value in the given {@code List} at the given index does not satisfy the given {@code Condition} * . */ public void assertHas(AssertionInfo info, List actual, Condition condition, Index index) { assertNotNull(info, actual); assertNotNull(condition); Iterables.instance().assertNotEmpty(info, actual); checkIndexValueIsValid(index, actual.size() - 1); int indexValue = index.value; if (indexValue >= actual.size()) return; T actualElement = actual.get(index.value); if (condition.matches(actualElement)) return; throw failures.failure(info, shouldHaveAtIndex(actual, condition, index, actualElement)); } /** * Verifies that the given {@code List} satisfies the given {@link Condition} at the given index. * @param the type of the actual value and the type of values that given {@code Condition} takes. * @param info contains information about the assertion. * @param actual the given {@code List}. * @param condition the given {@code Condition}. * @param index the index where the object should be stored in the given {@code List}. * @throws AssertionError if the given {@code List} is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * {@code List}. * @throws NullPointerException if the given {@code Condition} is {@code null}. * @throws AssertionError if the value in the given {@code List} at the given index does not satisfy the given {@code Condition} * . */ public void assertIs(AssertionInfo info, List actual, Condition condition, Index index) { assertNotNull(info, actual); assertNotNull(condition); Iterables.instance().assertNotEmpty(info, actual); checkIndexValueIsValid(index, actual.size() - 1); int indexValue = index.value; if (indexValue >= actual.size()) return; T actualElement = actual.get(index.value); if (condition.matches(actualElement)) return; throw failures.failure(info, shouldBeAtIndex(actual, condition, index, actualElement)); } @SuppressWarnings("unchecked") private static List> listOfComparableElements(List collection) { List> listOfComparableElements = new ArrayList>(); for (Object object : collection) { listOfComparableElements.add((Comparable) object); } return listOfComparableElements; } private void assertNotNull(AssertionInfo info, List actual) { Objects.instance().assertNotNull(info, actual); } private void assertNotNull(Condition condition) { Conditions.instance().assertIsNotNull(condition); } /** * Delegates to {@link ComparisonStrategy#areEqual(Object, Object)} */ private boolean areEqual(Object actual, Object other) { return comparisonStrategy.areEqual(actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/LongArrays.java000066400000000000000000000310121243020563200272010ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code long}s. * * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class LongArrays { private static final LongArrays INSTANCE = new LongArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static LongArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting LongArrays() { this(StandardComparisonStrategy.instance()); } public LongArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, long[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, long[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, long[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, long[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, long[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, long[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, long[] actual, long[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, long[] actual, long value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, long[] actual, long value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, long[] actual, long[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, long[] actual, long[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, long[] actual, long[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, long[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, long[], long[])}, but it also verifies that the first element in * the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, long[] actual, long[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, long[], long[])}, but it also verifies that the last element in * the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, long[] actual, long[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, long[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, long[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Longs.java000066400000000000000000000025051243020563200262070ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.util.*; /** * Reusable assertions for {@link Long}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs extends Numbers { private static final Longs INSTANCE = new Longs(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Longs instance() { return INSTANCE; } @Override protected Long zero() { return 0L; } @VisibleForTesting Longs() { super(); } public Longs(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Maps.java000066400000000000000000000273051243020563200260320ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.error.ShouldContainKey.shouldContainKey; import static org.fest.assertions.error.ShouldContainValue.shouldContainValue; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.assertions.error.ShouldNotContainKey.shouldNotContainKey; import static org.fest.assertions.error.ShouldNotContainValue.shouldNotContainValue; import static org.fest.assertions.internal.CommonErrors.arrayOfValuesToLookForIsNull; import static org.fest.util.Iterables.sizeOf; import static org.fest.util.Objects.areEqual; import java.lang.reflect.Array; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.MapEntry; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Map}s. * * @author Alex Ruiz * @author Nicolas François */ public class Maps { private static Maps INSTANCE = new Maps(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Maps instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Maps() {} /** * Asserts that the given {@code Map} is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given map. * @throws AssertionError if the given {@code Map} is not {@code null} *and* contains one or more entries. */ public void assertNullOrEmpty(AssertionInfo info, Map actual) { if (actual == null || actual.isEmpty()) { return; } throw failures.failure(info, shouldBeNullOrEmpty(actual)); } /** * Asserts that the given {@code Map} is empty. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Map} is not empty. */ public void assertEmpty(AssertionInfo info, Map actual) { assertNotNull(info, actual); if (actual.isEmpty()) { return; } throw failures.failure(info, shouldBeEmpty(actual)); } /** * Asserts that the given {@code Map} is not empty. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Map} is empty. */ public void assertNotEmpty(AssertionInfo info, Map actual) { assertNotNull(info, actual); if (!actual.isEmpty()) { return; } throw failures.failure(info, shouldNotBeEmpty()); } /** * Asserts that the number of entries in the given {@code Map} is equal to the expected one. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the number of entries in the given {@code Map} is different than the expected one. */ public void assertHasSize(AssertionInfo info, Map actual, int expectedSize) { assertNotNull(info, actual); int sizeOfActual = actual.size(); if (sizeOfActual == expectedSize) { return; } throw failures.failure(info, shouldHaveSize(actual, sizeOfActual, expectedSize)); } /** * Asserts that the number of entries in the given {@code Map} has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param map the given {@code Map}. * @param other the group to compare * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of entries in the given {@code Map} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Map map, Iterable other) { assertNotNull(info, map); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = map.size(); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(map, sizeOfActual, sizeOfOther)); } /** * Asserts that the number of entries in the given {@code Map} has the same size as the other array. * @param info contains information about the assertion. * @param map the given {@code Map}. * @param other the group to compare * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of entries in the given {@code Map} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Map map, Object[] other) { assertNotNull(info, map); if (other == null) { throw arrayOfValuesToLookForIsNull(); } int sizeOfActual = map.size(); int sizeOfOther = Array.getLength(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(map, sizeOfActual, sizeOfOther)); } /** * Asserts that the given {@code Map} contains the given entries, in any order. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param entries the entries that are expected to be in the given {@code Map}. * @throws NullPointerException if the array of entries is {@code null}. * @throws IllegalArgumentException if the array of entries is empty. * @throws NullPointerException if any of the entries in the given array is {@code null}. * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Map} does not contain the given entries. */ public void assertContains(AssertionInfo info, Map actual, MapEntry[] entries) { isNotEmptyOrNull(entries); assertNotNull(info, actual); Set notFound = new LinkedHashSet(); for (MapEntry entry : entries) { if (!containsEntry(actual, entry)) { notFound.add(entry); } } if (notFound.isEmpty()) { return; } throw failures.failure(info, shouldContain(actual, entries, notFound)); } /** * Asserts that the given {@code Map} does not contain the given entries. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param entries the entries that are expected to be in the given {@code Map}. * @throws NullPointerException if the array of entries is {@code null}. * @throws IllegalArgumentException if the array of entries is empty. * @throws NullPointerException if any of the entries in the given array is {@code null}. * @throws AssertionError if the given {@code Map} is {@code null}. * @throws AssertionError if the given {@code Map} contains any of the given entries. */ public void assertDoesNotContain(AssertionInfo info, Map actual, MapEntry[] entries) { isNotEmptyOrNull(entries); assertNotNull(info, actual); Set found = new LinkedHashSet(); for (MapEntry entry : entries) { if (containsEntry(actual, entry)) { found.add(entry); } } if (found.isEmpty()) { return; } throw failures.failure(info, shouldNotContain(actual, entries, found)); } /** * Verifies that the actual map contain the given key. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param key the given key * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map not contains the given key. */ public void assertContainsKey(AssertionInfo info, Map actual, K key) { assertNotNull(info, actual); if (actual.containsKey(key)) { return; } throw failures.failure(info, shouldContainKey(actual, key)); } /** * Verifies that the actual map not contains the given key. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param key the given key * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map contains the given key. */ public void assertDoesNotContainKey(AssertionInfo info, Map actual, K key) { assertNotNull(info, actual); if (!actual.containsKey(key)) { return; } throw failures.failure(info, shouldNotContainKey(actual, key)); } /** * Verifies that the actual map contain the given value. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param value the given value * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map not contains the given value. */ public void assertContainsValue(AssertionInfo info, Map actual, V value) { assertNotNull(info, actual); if (actual.containsValue(value)) { return; } throw failures.failure(info, shouldContainValue(actual, value)); } /** * Verifies that the actual map not contains the given value. * @param info contains information about the assertion. * @param actual the given {@code Map}. * @param value the given value * @throws AssertionError if the actual map is {@code null}. * @throws AssertionError if the actual map contains the given value. */ public void assertDoesNotContainValue(AssertionInfo info, Map actual, V value) { assertNotNull(info, actual); if (!actual.containsValue(value)) { return; } throw failures.failure(info, shouldNotContainValue(actual, value)); } private void isNotEmptyOrNull(MapEntry[] entries) { if (entries == null) { throw new NullPointerException("The array of entries to look for should not be null"); } if (entries.length == 0) { throw new IllegalArgumentException("The array of entries to look for should not be empty"); } } private boolean containsEntry(Map actual, MapEntry entry) { if (entry == null) { throw new NullPointerException("Entries to look for should not be null"); } if (!actual.containsKey(entry.key)) { return false; } return areEqual(actual.get(entry.key), entry.value); } private void assertNotNull(AssertionInfo info, Map actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Numbers.java000066400000000000000000000073501243020563200265430ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.assertions.core.AssertionInfo; /** * Base class of reusable assertions for numbers. * * @author Joel Costigliola * @author Nicolas François */ public abstract class Numbers> extends Comparables { public Numbers() { super(); } public Numbers(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } protected abstract NUMBER zero(); /** * Asserts that the actual value is equal to zero.
* It does not rely on the custom comparisonStrategy (if one is set). * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not equal to zero. */ public void assertIsZero(AssertionInfo info, NUMBER actual) { assertEqualByComparison(info, actual, zero()); } /** * Asserts that the actual value is not equal to zero.
* It does not rely on the custom comparisonStrategy (if one is set). * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is equal to zero. */ public void assertIsNotZero(AssertionInfo info, NUMBER actual) { assertNotEqualByComparison(info, actual, zero()); } /** * Asserts that the actual value is negative. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not negative: it is either equal to or greater than zero. */ public void assertIsNegative(AssertionInfo info, NUMBER actual) { assertLessThan(info, actual, zero()); } /** * Asserts that the actual value is positive. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not positive: it is either equal to or less than zero. */ public void assertIsPositive(AssertionInfo info, NUMBER actual) { assertGreaterThan(info, actual, zero()); } /** * Asserts that the actual value is not negative. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is negative. */ public void assertIsNotNegative(AssertionInfo info, NUMBER actual) { assertGreaterThanOrEqualTo(info, actual, zero()); } /** * Asserts that the actual value is not positive. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is positive. */ public void assertIsNotPositive(AssertionInfo info, NUMBER actual) { assertLessThanOrEqualTo(info, actual, zero()); } }fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/ObjectArrays.java000066400000000000000000000562041243020563200275220ustar00rootroot00000000000000/* * Created on Nov 3, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of objects. * * @author Alex Ruiz * @author Joel Costigliola * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrays { private static final ObjectArrays INSTANCE = new ObjectArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ObjectArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting ObjectArrays() { this(StandardComparisonStrategy.instance()); } public ObjectArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Conditions conditions = Conditions.instance(); /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, Object[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, Object[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, Object[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, Object[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given iterable. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Object[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, Object[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, Object[] actual, Object[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given object at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the object to look for. * @param index the index where the object should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given object at the given index. */ public void assertContains(AssertionInfo info, Object[] actual, Object value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given object at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the object to look for. * @param index the index where the object should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given object at the given index. */ public void assertDoesNotContain(AssertionInfo info, Object[] actual, Object value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, Object[] actual, Object[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of objects, without any other objects between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of objects to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of objects. */ public void assertContainsSequence(AssertionInfo info, Object[] actual, Object[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, Object[] actual, Object[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, Object[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of objects, without any other objects between them. Similar to * {@link #assertContainsSequence(AssertionInfo, Object[], Object[])}, but it also verifies that the first element * in the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of objects to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of objects. */ public void assertStartsWith(AssertionInfo info, Object[] actual, Object[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of objects, without any other objects between them. Similar to * {@link #assertContainsSequence(AssertionInfo, Object[], Object[])}, but it also verifies that the last element * in the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of objects to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of objects. */ public void assertEndsWith(AssertionInfo info, Object[] actual, Object[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Asserts that the given array contains at least a null element. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain a null element. */ public void assertContainsNull(AssertionInfo info, Object[] actual) { arrays.assertContainsNull(info, failures, actual); } /** * Asserts that the given array does not contain null elements. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains a null element. */ public void assertDoesNotContainNull(AssertionInfo info, Object[] actual) { arrays.assertDoesNotContainNull(info, failures, actual); } /** * Assert that each element of given array satisfies the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if one or more element not satisfy the given condition. */ public void assertAre(AssertionInfo info, E[] actual, Condition condition) { arrays.assertAre(info, failures, conditions, actual, condition); } /** * Assert that each element of given array not satisfies the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if one or more element satisfy the given condition. */ public void assertAreNot(AssertionInfo info, E[] actual, Condition condition) { arrays.assertAreNot(info, failures, conditions, actual, condition); } /** * Assert that each element of given array satisfies the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if one or more element not satisfy the given condition. */ public void assertHave(AssertionInfo info, E[] actual, Condition condition) { arrays.assertHave(info, failures, conditions, actual, condition); } /** * Assert that each element of given array not satisfies the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if one or more element satisfy the given condition. */ public void assertDoNotHave(AssertionInfo info, E[] actual, Condition condition) { arrays.assertHaveNot(info, failures, conditions, actual, condition); } /** * Assert that there is at least n array elements satisfying the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param n the minimum number of times the condition should be verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements satisfying the given condition is < n. */ public void assertAreAtLeast(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreAtLeast(info, failures, conditions, actual, n, condition); } /** * Assert that there is at least n array elements not satisfying the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param n the number of times the condition should not be verified at least. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements not satisfying the given condition is < n. */ public void assertAreNotAtLeast(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreNotAtLeast(info, failures, conditions, actual, n, condition); } /** * Assert that there is at most n array elements satisfying the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param n the number of times the condition should be at most verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements satisfying the given condition is > n. */ public void assertAreAtMost(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreAtMost(info, failures, conditions, actual, n, condition); } /** * Verifies that there is at most n array elements not satisfying the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param n the number of times the condition should not be verified at most. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements not satisfying the given condition is > n. */ public void assertAreNotAtMost(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreNotAtMost(info, failures, conditions, actual, n, condition); } /** * Verifies that there is exactly n array elements satisfying the given condition. * @param info contains information about the assertion. * @param actual the given array. * @param n the exact number of times the condition should be verified. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements satisfying the given condition is ≠ n. */ public void assertAreExactly(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreExactly(info, failures, conditions, actual, n, condition); } /** * Verifies that there is exactly n elements in the actual {@code Iterable} not satisfying the given * condition. * @param info contains information about the assertion. * @param actual the given array. * @param n most times the condition should not be verify. * @param condition the given {@code Condition}. * @throws NullPointerException if the given condition is {@code null}. * @throws AssertionError if the number of elements not satisfying the given condition is ≠ n. */ public void assertAreNotExactly(AssertionInfo info, E[] actual, int n, Condition condition) { arrays.assertAreNotExactly(info, failures, conditions, actual, n, condition); } /** * An alias method of {@link #assertAreAtLeast(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertHaveAtLeast(info, failures, conditions, actual, times, condition); } /** * An alias method of {@link #assertAreNotAtLeast(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertDoNotHaveAtLeast(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertDoNotHaveAtLeast(info, failures, conditions, actual, times, condition); } /** * An alias method of {@link #assertAreAtMost(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertHaveAtMost(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertHaveAtMost(info, failures, conditions, actual, times, condition); } /** * An alias method of {@link #assertAreNotAtMost(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertDoNotHaveAtMost(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertDoNotHaveAtMost(info, failures, conditions, actual, times, condition); } /** * An alias method of {@link #assertAreExactly(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertHaveExactly(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertHaveExactly(info, failures, conditions, actual, times, condition); } /** * An alias method of {@link #assertAreNotExactly(AssertionInfo, Object[], int, Condition)} to provide a richer fluent api (same * logic, only error message differs). */ public void assertDoNotHaveExactly(AssertionInfo info, E[] actual, int times, Condition condition) { arrays.assertDoNotHaveExactly(info, failures, conditions, actual, times, condition); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, Object[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, E[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } /** * Asserts that the given array contains all the elements of the given {@code Iterable}, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param other the other {@code Iterable}. * @throws NullPointerException if {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the given {@code Iterable} does not contain all the elements of the other {@code Iterable}, in any * order. */ public void assertContainsAll(AssertionInfo info, E[] actual, Iterable other) { arrays.assertcontainsAll(info, failures, actual, other); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Objects.java000066400000000000000000000710231243020563200265170ustar00rootroot00000000000000/* * Created on Aug 4, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.assertions.error.ShouldBeExactlyInstanceOf.shouldBeExactlyInstance; import static org.fest.assertions.error.ShouldBeIn.shouldBeIn; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstanceButWasNull; import static org.fest.assertions.error.ShouldBeInstanceOfAny.shouldBeInstanceOfAny; import static org.fest.assertions.error.ShouldBeLenientEqualByAccepting.shouldBeLenientEqualByAccepting; import static org.fest.assertions.error.ShouldBeLenientEqualByIgnoring.shouldBeLenientEqualByIgnoring; import static org.fest.assertions.error.ShouldBeOfClassIn.shouldBeOfClassIn; import static org.fest.assertions.error.ShouldBeSame.shouldBeSame; import static org.fest.assertions.error.ShouldHaveSameClass.shouldHaveSameClass; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.assertions.error.ShouldNotBeExactlyInstanceOf.shouldNotBeExactlyInstance; import static org.fest.assertions.error.ShouldNotBeIn.shouldNotBeIn; import static org.fest.assertions.error.ShouldNotBeInstance.shouldNotBeInstance; import static org.fest.assertions.error.ShouldNotBeInstanceOfAny.shouldNotBeInstanceOfAny; import static org.fest.assertions.error.ShouldNotBeNull.shouldNotBeNull; import static org.fest.assertions.error.ShouldNotBeOfClassIn.shouldNotBeOfClassIn; import static org.fest.assertions.error.ShouldNotBeSame.shouldNotBeSame; import static org.fest.assertions.error.ShouldNotHaveSameClass.shouldNotHaveSameClass; import static org.fest.util.Lists.newArrayList; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.ToString.toStringOf; import java.lang.reflect.Field; import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.fest.assertions.core.AssertionInfo; import org.fest.util.IntrospectionError; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@code Object}s. * * @author Yvonne Wang * @author Alex Ruiz * @author Nicolas François * @author Mikhail Mazursky */ public class Objects { private static final Objects INSTANCE = new Objects(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Objects instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting PropertySupport propertySupport = PropertySupport.instance(); private final ComparisonStrategy comparisonStrategy; @VisibleForTesting Objects() { this(StandardComparisonStrategy.instance()); } public Objects(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy).getComparator(); } return null; } /** * Verifies that the given object is an instance of the given type. * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the given object against. * @throws NullPointerException if the given type is {@code null}. * @throws AssertionError if the given object is {@code null}. * @throws AssertionError if the given object is not an instance of the given type. */ public void assertIsInstanceOf(AssertionInfo info, Object actual, Class type) { if (type == null) { throw new NullPointerException("The given type should not be null"); } assertNotNull(info, actual); if (type.isInstance(actual)) { return; } throw failures.failure(info, shouldBeInstance(actual, type)); } /** * Verifies that the given object is an instance of any of the given types. * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the given object against. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws NullPointerException if the given array has {@code null} elements. * @throws AssertionError if the given object is {@code null}. * @throws AssertionError if the given object is not an instance of any of the given types. */ public void assertIsInstanceOfAny(AssertionInfo info, Object actual, Class[] types) { checkIsNotNullAndIsNotEmpty(types); assertNotNull(info, actual); boolean found = false; for (Class type : types) { if (type == null) { String format = "The given array of types:<%s> should not have null elements"; throw new NullPointerException(String.format(format, toStringOf(types))); } if (type.isInstance(actual)) { found = true; break; } } if (found) { return; } throw failures.failure(info, shouldBeInstanceOfAny(actual, types)); } /** * Verifies that the given object is not an instance of the given type. * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the given object against. * @throws NullPointerException if the given type is {@code null}. * @throws AssertionError if the given object is {@code null}. * @throws AssertionError if the given object is an instance of the given type. */ public void assertIsNotInstanceOf(AssertionInfo info, Object actual, Class type) { if (type == null) { throw new NullPointerException("The given type should not be null"); } assertNotNull(info, actual); if (!type.isInstance(actual)) { return; } throw failures.failure(info, shouldNotBeInstance(actual, type)); } /** * Verifies that the given object is not an instance of any of the given types. * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the given object against. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws NullPointerException if the given array has {@code null} elements. * @throws AssertionError if the given object is {@code null}. * @throws AssertionError if the given object is an instance of any of the given types. */ public void assertIsNotInstanceOfAny(AssertionInfo info, Object actual, Class[] types) { checkIsNotNullAndIsNotEmpty(types); assertNotNull(info, actual); boolean found = false; for (Class type : types) { if (type == null) { String format = "The given array of types:<%s> should not have null elements"; throw new NullPointerException(String.format(format, toStringOf(types))); } if (type.isInstance(actual)) { found = true; break; } } if (!found) { return; } throw failures.failure(info, shouldNotBeInstanceOfAny(actual, types)); } /** * Verifies that the actual value has the same class as the given object. * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the actual has not the same type has the given object. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ public void assertHasSameClassAs(AssertionInfo info, Object actual, Object other) { assertNotNull(info, actual); if (other == null) { throw new NullPointerException("The given object should not be null"); } Class actualClass = actual.getClass(); Class otherClass = other.getClass(); if (actualClass.equals(otherClass)) { return; } throw failures.failure(info, shouldHaveSameClass(actual, other)); } /** * Verifies that the actual value does not have the same class as the given object. * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to check type against. * @throws AssertionError if the actual has the same type has the given object. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ public void assertDoesNotHaveSameClassAs(AssertionInfo info, Object actual, Object other) { assertNotNull(info, actual); if (other == null) { throw new NullPointerException("The given object should not be null"); } Class actualClass = actual.getClass(); Class otherClass = other.getClass(); if (!actualClass.equals(otherClass)) { return; } throw failures.failure(info, shouldNotHaveSameClass(actual, other)); } /** * Verifies that the actual value is exactly a instance of given type. * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the actual value against. * @throws AssertionError if the actual is not exactly a instance of given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ public void assertIsExactlyInstanceOf(AssertionInfo info, Object actual, Class type) { assertNotNull(info, actual); if (type == null) { throw new NullPointerException("The given type should not be null"); } Class current = actual.getClass(); if (type.equals(current)) { return; } throw failures.failure(info, shouldBeExactlyInstance(actual, type)); } /** * Verifies that the actual value is not exactly a instance of given type. * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the actual value against. * @throws AssertionError if the actual is exactly a instance of given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given object is null. */ public void assertIsNotExactlyInstanceOf(AssertionInfo info, Object actual, Class type) { assertNotNull(info, actual); if (type == null) { throw new NullPointerException("The given type should not be null"); } Class current = actual.getClass(); if (!type.equals(current)) { return; } throw failures.failure(info, shouldNotBeExactlyInstance(actual, type)); } /** * Verifies that the actual value type is in given types. * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the actual value against. * @throws AssertionError if the actual value type is in given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given types is null. */ public void assertIsOfAnyClassIn(AssertionInfo info, Object actual, Class[] types) { assertNotNull(info, actual); if (types == null) { throw new NullPointerException("The given types should not be null"); } if (isItemInArray(actual.getClass(), types)) { return; } throw failures.failure(info, shouldBeOfClassIn(actual, types)); } /** * Verifies that the actual value type is not in given types. * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the actual value against. * @throws AssertionError if the actual value type is in given type. * @throws NullPointerException if the actual value is null. * @throws NullPointerException if the given types is null. */ public void assertIsNotOfAnyClassIn(AssertionInfo info, Object actual, Class[] types) { assertNotNull(info, actual); if (types == null) { throw new NullPointerException("The given types should not be null"); } if (!isItemInArray(actual.getClass(), types)) { return; } throw failures.failure(info, shouldNotBeOfClassIn(actual, types)); } private void checkIsNotNullAndIsNotEmpty(Class[] types) { if (types == null) { throw new NullPointerException("The given array of types should not be null"); } if (types.length == 0) { throw new IllegalArgumentException("The given array of types should not be empty"); } } /** * Asserts that two objects are equal. * * @param info contains information about the assertion. * @param actual the "actual" object. * @param expected the "expected" object. * @throws AssertionError if {@code actual} is not equal to {@code expected}. This method will throw a * {@code org.junit.ComparisonFailure} instead if JUnit is in the classpath and the given objects are not * equal. */ public void assertEqual(AssertionInfo info, Object actual, Object expected) { if (areEqual(actual, expected)) { return; } throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy)); } /** * Asserts that two objects are not equal. * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. * @throws AssertionError if {@code actual} is equal to {@code other}. */ public void assertNotEqual(AssertionInfo info, Object actual, Object other) { if (!areEqual(actual, other)) { return; } throw failures.failure(info, shouldNotBeEqual(actual, other, comparisonStrategy)); } /** * Compares actual and other with standard strategy (null safe equals check). * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual and other are equal (null safe equals check), false otherwise. */ private boolean areEqual(Object actual, Object other) { return comparisonStrategy.areEqual(other, actual); } /** * Asserts that the given object is {@code null}. * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the given object is not {@code null}. */ public void assertNull(AssertionInfo info, Object actual) { if (actual == null) { return; } throw failures.failure(info, shouldBeEqual(actual, null, comparisonStrategy)); } /** * Asserts that the given object is not {@code null}. * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the given object is {@code null}. */ public void assertNotNull(AssertionInfo info, Object actual) { if (actual != null) { return; } throw failures.failure(info, shouldNotBeNull()); } /** * Asserts that two objects refer to the same object. * * @param info contains information about the assertion. * @param actual the given object. * @param expected the expected object. * @throws AssertionError if the given objects do not refer to the same object. */ public void assertSame(AssertionInfo info, Object actual, Object expected) { if (actual == expected) { return; } throw failures.failure(info, shouldBeSame(actual, expected)); } /** * Asserts that two objects do not refer to the same object. * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. * @throws AssertionError if the given objects refer to the same object. */ public void assertNotSame(AssertionInfo info, Object actual, Object other) { if (actual != other) { return; } throw failures.failure(info, shouldNotBeSame(actual)); } /** * Asserts that the given object is present in the given array. * * @param info contains information about the assertion. * @param actual the given object. * @param values the given array. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws AssertionError if the given object is not present in the given array. */ public void assertIsIn(AssertionInfo info, Object actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); if (isItemInArray(actual, values)) { return; } throw failures.failure(info, shouldBeIn(actual, values, comparisonStrategy)); } /** * Asserts that the given object is not present in the given array. * * @param info contains information about the assertion. * @param actual the given object. * @param values the given array. * @throws NullPointerException if the given array is {@code null}. * @throws IllegalArgumentException if the given array is empty. * @throws AssertionError if the given object is present in the given array. */ public void assertIsNotIn(AssertionInfo info, Object actual, Object[] values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); if (!isItemInArray(actual, values)) { return; } throw failures.failure(info, shouldNotBeIn(actual, values, comparisonStrategy)); } private void checkIsNotNullAndNotEmpty(Object[] values) { if (values == null) { throw new NullPointerException("The given array should not be null"); } if (values.length == 0) { throw new IllegalArgumentException("The given array should not be empty"); } } /** * Returns true if given item is in given array, false otherwise. * * @param item the object to look for in arrayOfValues * @param arrayOfValues the array of values * @return true if given item is in given array, false otherwise. */ private boolean isItemInArray(Object item, Object[] arrayOfValues) { for (Object value : arrayOfValues) { if (areEqual(value, item)) { return true; } } return false; } /** * Asserts that the given object is present in the given collection. * * @param info contains information about the assertion. * @param actual the given object. * @param values the given iterable. * @throws NullPointerException if the given collection is {@code null}. * @throws IllegalArgumentException if the given collection is empty. * @throws AssertionError if the given object is not present in the given collection. */ public void assertIsIn(AssertionInfo info, A actual, Iterable values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); if (isActualIn(actual, values)) { return; } throw failures.failure(info, shouldBeIn(actual, values, comparisonStrategy)); } /** * Asserts that the given object is not present in the given collection. * * @param info contains information about the assertion. * @param actual the given object. * @param values the given collection. * @throws NullPointerException if the given iterable is {@code null}. * @throws IllegalArgumentException if the given collection is empty. * @throws AssertionError if the given object is present in the given collection. */ public void assertIsNotIn(AssertionInfo info, A actual, Iterable values) { checkIsNotNullAndNotEmpty(values); assertNotNull(info, actual); if (!isActualIn(actual, values)) { return; } throw failures.failure(info, shouldNotBeIn(actual, values, comparisonStrategy)); } private void checkIsNotNullAndNotEmpty(Iterable values) { if (values == null) { throw new NullPointerException("The given iterable should not be null"); } if (!values.iterator().hasNext()) { throw new IllegalArgumentException("The given iterable should not be empty"); } } private boolean isActualIn(A actual, Iterable values) { for (A value : values) { if (areEqual(value, actual)) { return true; } } return false; } /** * Assert that the given object is lenient equals by ignoring null fields value on other object (including inherited * fields). * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. * @throws NullPointerException if the actual type is {@code null}. * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. */ public void assertIsLenientEqualsToByIgnoringNullFields(AssertionInfo info, A actual, A other) { assertNotNull(info, actual); assertOtherTypeIsCompatibleWithActualClass(info, other, actual.getClass()); List fieldsNames = new LinkedList(); List values = new LinkedList(); List nullFields = new LinkedList(); for (Field field : getDeclaredFieldsIncludingInherited(actual.getClass())) { try { Object otherFieldValue = propertySupport.propertyValue(field.getName(), field.getType(), other); if (otherFieldValue != null) { Object actualFieldValue = propertySupport.propertyValue(field.getName(), field.getType(), actual); if (!otherFieldValue.equals(actualFieldValue)) { fieldsNames.add(field.getName()); values.add(otherFieldValue); } } else { nullFields.add(field.getName()); } } catch (IntrospectionError e) { // Not readeable field, skip. } } if (fieldsNames.isEmpty()) { return; } throw failures.failure(info, shouldBeLenientEqualByIgnoring(actual, fieldsNames, values, nullFields)); } /** * Assert that the given object is lenient equals to other object by comparing given fields value only. * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. * @param fields accepted fields * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if actual is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. * @throws IntrospectionError if a field does not exist in actual. */ public void assertIsLenientEqualsToByAcceptingFields(AssertionInfo info, A actual, A other, String... fields) { assertNotNull(info, actual); assertOtherTypeIsCompatibleWithActualClass(info, other, actual.getClass()); List rejectedFieldsNames = new LinkedList(); List expectedValues = new LinkedList(); for (String fieldName : fields) { Object actualFieldValue = propertySupport.propertyValue(fieldName, Object.class, actual); Object otherFieldValue = propertySupport.propertyValue(fieldName, Object.class, other); if (!(actualFieldValue == otherFieldValue || (actualFieldValue != null && actualFieldValue .equals(otherFieldValue)))) { rejectedFieldsNames.add(fieldName); expectedValues.add(otherFieldValue); } } if (rejectedFieldsNames.isEmpty()) { return; } throw failures.failure(info, shouldBeLenientEqualByAccepting(actual, rejectedFieldsNames, expectedValues, newArrayList(fields))); } /** * Assert that the given object is lenient equals to the other by comparing all fields (including inherited fields) * unless given ignored ones. * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. * @param fields the fields to ignore in comparison * @throws NullPointerException if the other type is {@code null}. * @throws AssertionError if actual is {@code null}. * @throws AssertionError if the actual and the given object are not lenient equals. * @throws AssertionError if the other object is not an instance of the actual type. */ public void assertIsLenientEqualsToByIgnoringFields(AssertionInfo info, A actual, A other, String... fields) { assertNotNull(info, actual); assertOtherTypeIsCompatibleWithActualClass(info, other, actual.getClass()); List fieldsNames = new LinkedList(); List expectedValues = new LinkedList(); Set ignoredFields = newLinkedHashSet(fields); for (Field field : getDeclaredFieldsIncludingInherited(actual.getClass())) { try { if (!ignoredFields.contains(field.getName())) { String fieldName = field.getName(); Object actualFieldValue = propertySupport.propertyValue(fieldName, Object.class, actual); Object otherFieldValue = propertySupport.propertyValue(fieldName, Object.class, other); if (!org.fest.util.Objects.areEqual(actualFieldValue, otherFieldValue)) { fieldsNames.add(fieldName); expectedValues.add(otherFieldValue); } } } catch (IntrospectionError e) { // Not readeable field, skip. } } if (fieldsNames.isEmpty()) { return; } throw failures.failure(info, shouldBeLenientEqualByIgnoring(actual, fieldsNames, expectedValues, newArrayList(fields))); } /** * Returns the declared fields of given class and its superclasses stopping at superclass in java.lang * package whose fields are not included. * * @param clazz the class we want the declared fields. * @return the declared fields of given class and its superclasses. */ private static Set getDeclaredFieldsIncludingInherited(Class clazz) { if (clazz == null) { throw new NullPointerException("expecting parameter not to be null"); } Set declaredFields = newLinkedHashSet(clazz.getDeclaredFields()); // get fields declared in superclass Class superclazz = clazz.getSuperclass(); while (superclazz != null && !superclazz.getName().startsWith("java.lang")) { declaredFields.addAll(newLinkedHashSet(superclazz.getDeclaredFields())); superclazz = superclazz.getSuperclass(); } return declaredFields; } /** * Verifies that other object is an instance of the given type. * * @param info contains information about the assertion. * @param other the object to check type against given class. * @param type the type to check the given object against. * @throws NullPointerException if the given type is {@code null}. * @throws AssertionError if other is {@code null}. * @throws AssertionError if other is not an instance of the given type. */ private void assertOtherTypeIsCompatibleWithActualClass(AssertionInfo info, Object other, Class clazz) { if (other == null) { throw failures.failure(info, shouldBeInstanceButWasNull("other", clazz)); } if (clazz.isInstance(other)) { return; } throw failures.failure(info, shouldBeInstance(other, clazz)); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/PropertySupport.java000066400000000000000000000171511243020563200303510ustar00rootroot00000000000000/* * Created on Jun 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static java.lang.String.format; import static java.util.Collections.*; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Introspection.getProperty; import static org.fest.util.Iterables.nonNullElementsIn; import java.beans.PropertyDescriptor; import java.util.ArrayList; import java.util.List; import org.fest.util.IntrospectionError; import org.fest.util.VisibleForTesting; /** * Utility methods for properties access. * * @author Joel Costigliola * @author Alex Ruiz * @author Nicolas François * @author Florent Biville */ public class PropertySupport { private static final String SEPARATOR = "."; private static final PropertySupport INSTANCE = new PropertySupport(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static PropertySupport instance() { return INSTANCE; } @VisibleForTesting JavaBeanDescriptor javaBeanDescriptor = new JavaBeanDescriptor(); @VisibleForTesting PropertySupport() {} /** * Returns a {@link List} containing the values of the given property name, from the elements of the given * {@link Iterable}. If the given {@code Iterable} is empty or {@code null}, this method will return an empty * {@code List}. This method supports nested properties (e.g. "address.street.number"). * @param propertyName the name of the property. It may be a nested property. It is left to the clients to validate for * {@code null} or empty. * @param target the given {@code Iterable}. * @return an {@code Iterable} containing the values of the given property name, from the elements of the given {@code Iterable}. * @throws IntrospectionError if an element in the given {@code Iterable} does not have a property with a matching name. */ public Iterable propertyValues(String propertyName, Class clazz, Iterable target) { // ignore null elements as we can't extract a property from a null object Iterable cleanedUp = nonNullElementsIn(target); if (isNullOrEmpty(cleanedUp)) { return emptyList(); } if (isNestedProperty(propertyName)) { String firstPropertyName = popPropertyNameFrom(propertyName); Iterable propertyValues = propertyValues(firstPropertyName, Object.class, cleanedUp); // extract next sub-property values until reaching the last sub-property return propertyValues(nextPropertyNameFrom(propertyName), clazz, propertyValues); } return simplePropertyValues(propertyName, clazz, cleanedUp); } /** * Static variant of {@link #propertyValue(String, Class, Object)} for syntactic sugar. *

* @param propertyName the name of the property. It may be a nested property. It is left to the clients to validate for * {@code null} or empty. * @param target the given object * @param clazz type of property * @return a the values of the given property name * @throws IntrospectionError if the given target does not have a property with a matching name. */ public static T propertyValueOf(String propertyName, Object target, Class clazz) { return instance().propertyValue(propertyName, clazz, target); } private List simplePropertyValues(String propertyName, Class clazz, Iterable target) { List propertyValues = new ArrayList(); for (Object e : target) { propertyValues.add(propertyValue(propertyName, clazz, e)); } return unmodifiableList(propertyValues); } private String popPropertyNameFrom(String propertyNameChain) { if (!isNestedProperty(propertyNameChain)) { return propertyNameChain; } return propertyNameChain.substring(0, propertyNameChain.indexOf(SEPARATOR)); } private String nextPropertyNameFrom(String propertyNameChain) { if (!isNestedProperty(propertyNameChain)) { return ""; } return propertyNameChain.substring(propertyNameChain.indexOf(SEPARATOR) + 1); } /** *

   * isNestedProperty("address.street"); // true
   * isNestedProperty("address.street.name"); // true
   * isNestedProperty("person"); // false
   * isNestedProperty(".name"); // false
   * isNestedProperty("person."); // false
   * isNestedProperty("person.name."); // false
   * isNestedProperty(".person.name"); // false
   * isNestedProperty("."); // false
   * isNestedProperty(""); // false
   * 
*/ private boolean isNestedProperty(String propertyName) { return propertyName.contains(SEPARATOR) && !propertyName.startsWith(SEPARATOR) && !propertyName.endsWith(SEPARATOR); } /** * Return the value of property from a target object. * @param propertyName the name of the property. It may be a nested property. It is left to the clients to validate for * {@code null} or empty. * @param target the given object * @param clazz type of property * @return a the values of the given property name * @throws IntrospectionError if the given target does not have a property with a matching name. */ public T propertyValue(String propertyName, Class clazz, Object target) { PropertyDescriptor descriptor = getProperty(propertyName, target); try { return clazz.cast(javaBeanDescriptor.invokeReadMethod(descriptor, target)); } catch (ClassCastException e) { String msg = format("Unable to obtain the value of the property <'%s'> from <%s> - wrong property type specified <%s>", propertyName, target, clazz); throw new IntrospectionError(msg, e); } catch (Throwable unexpected) { String msg = format("Unable to obtain the value of the property <'%s'> from <%s>", propertyName, target); throw new IntrospectionError(msg, unexpected); } } /** * Returns the value of the given property name given target. If the given object is {@code null}, this method will return null.
* This method supports nested properties (e.g. "address.street.number"). * @param propertyName the name of the property. It may be a nested property. It is left to the clients to validate for * {@code null} or empty. * @param clazz the class of property. * @param target the given Object to extract property from. * @return the value of the given property name given target. * @throws IntrospectionError if target object does not have a property with a matching name. */ public T propertyValueOf(String propertyName, Class clazz, Object target) { // returns null if target is null as we can't extract a property from a null object if (target == null) { return null; } if (isNestedProperty(propertyName)) { String firstPropertyName = popPropertyNameFrom(propertyName); Object propertyValue = propertyValue(firstPropertyName, Object.class, target); // extract next sub-property values until reaching the last sub-property return propertyValueOf(nextPropertyNameFrom(propertyName), clazz, propertyValue); } return propertyValue(propertyName, clazz, target); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/RealNumbers.java000066400000000000000000000035571243020563200273540ustar00rootroot00000000000000package org.fest.assertions.internal; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; /** * Base class of reusable assertions for real numbers (float and double). * * @author Joel Costigliola */ public abstract class RealNumbers> extends Numbers { public RealNumbers() { super(); } public RealNumbers(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } /** * Verifies that the actual value is equal to {@code NaN}.
* It does not rely on the custom comparisonStrategy (if one is set). * * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is not equal to {@code NaN}. */ public void assertIsNaN(AssertionInfo info, NUMBER actual) { assertEqualByComparison(info, actual, NaN()); } protected abstract NUMBER NaN(); /** * Verifies that the actual value is not equal to {@code NaN}. * @param info contains information about the assertion. * @param actual the actual value. * @throws AssertionError if the actual value is equal to {@code NaN}. */ public void assertIsNotNaN(AssertionInfo info, NUMBER actual) { assertNotEqualByComparison(info, actual, NaN()); } /** * Returns true if the two floats parameter are equal within a positive offset, false otherwise.
* It does not rely on the custom comparisonStrategy (if one is set) because using an offset is already a specific comparison * strategy. * @param actual the actual value. * @param expected the expected value. * @param offset the given positive offset. * @return true if the two floats parameter are equal within a positive offset, false otherwise. */ protected abstract boolean isEqualTo(NUMBER actual, NUMBER expected, Offset offset); }fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/ShortArrays.java000066400000000000000000000310221243020563200274020ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import java.util.Comparator; import org.fest.assertions.core.ArraySortedAssert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.util.VisibleForTesting; /** * Reusable assertions for arrays of {@code short}s. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class ShortArrays { private static final ShortArrays INSTANCE = new ShortArrays(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static ShortArrays instance() { return INSTANCE; } private Arrays arrays = Arrays.instance(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting ShortArrays() { this(StandardComparisonStrategy.instance()); } public ShortArrays(ComparisonStrategy comparisonStrategy) { this.arrays = new Arrays(comparisonStrategy); } @VisibleForTesting public Comparator getComparator() { return arrays.getComparator(); } /** * Asserts that the given array is {@code null} or empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is not {@code null} *and* contains one or more elements. */ public void assertNullOrEmpty(AssertionInfo info, short[] actual) { arrays.assertNullOrEmpty(info, failures, actual); } /** * Asserts that the given array is empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is not empty. */ public void assertEmpty(AssertionInfo info, short[] actual) { arrays.assertEmpty(info, failures, actual); } /** * Asserts that the given array is not empty. * @param info contains information about the assertion. * @param actual the given array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array is empty. */ public void assertNotEmpty(AssertionInfo info, short[] actual) { arrays.assertNotEmpty(info, failures, actual); } /** * Asserts that the number of elements in the given array is equal to the expected one. * @param info contains information about the assertion. * @param actual the given array. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of elements in the given array is different than the expected one. */ public void assertHasSize(AssertionInfo info, short[] actual, int expectedSize) { arrays.assertHasSize(info, failures, actual, expectedSize); } /** * Assert that the actual array has the same size as the other {@code Iterable}. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, short[] actual, Iterable other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Assert that the actual array has the same size as the other array. * @param info contains information about the assertion. * @param actual the given array. * @param other the group to compare * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the other group is {@code null}. * @throws AssertionError if the actual group does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, short[] actual, Object[] other) { arrays.assertHasSameSizeAs(info, failures, actual, other); } /** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, short[] actual, short[] values) { arrays.assertContains(info, failures, actual, values); } /** * Verifies that the given array contains the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of the given * array. * @throws AssertionError if the given array does not contain the given value at the given index. */ public void assertContains(AssertionInfo info, short[] actual, short value, Index index) { arrays.assertContains(info, failures, actual, value, index); } /** * Verifies that the given array does not contain the given value at the given index. * @param info contains information about the assertion. * @param actual the given array. * @param value the value to look for. * @param index the index where the value should be stored in the given array. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the given array contains the given value at the given index. */ public void assertDoesNotContain(AssertionInfo info, short[] actual, short value, Index index) { arrays.assertDoesNotContain(info, failures, actual, value, index); } /** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, short[] actual, short[] values) { arrays.assertContainsOnly(info, failures, actual, values); } /** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, short[] actual, short[] sequence) { arrays.assertContainsSequence(info, failures, actual, sequence); } /** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, short[] actual, short[] values) { arrays.assertDoesNotContain(info, failures, actual, values); } /** * Asserts that the given array does not have duplicate values. * @param info contains information about the assertion. * @param actual the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains duplicate values. */ public void assertDoesNotHaveDuplicates(AssertionInfo info, short[] actual) { arrays.assertDoesNotHaveDuplicates(info, failures, actual); } /** * Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, short[], short[])}, but it also verifies that the first element in * the sequence is also the first element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not start with the given sequence of values. */ public void assertStartsWith(AssertionInfo info, short[] actual, short[] sequence) { arrays.assertStartsWith(info, failures, actual, sequence); } /** * Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to * {@link #assertContainsSequence(AssertionInfo, short[], short[])}, but it also verifies that the last element in * the sequence is also the last element of the given array. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not end with the given sequence of values. */ public void assertEndsWith(AssertionInfo info, short[] actual, short[] sequence) { arrays.assertEndsWith(info, failures, actual, sequence); } /** * Concrete implementation of {@link ArraySortedAssert#isSorted()}. * * @param info contains information about the assertion. * @param actual the given array. */ public void assertIsSorted(AssertionInfo info, short[] actual) { arrays.assertIsSorted(info, failures, actual); } /** * Concrete implementation of {@link ArraySortedAssert#isSortedAccordingTo(Comparator)}. * * @param info contains information about the assertion. * @param actual the given array. * @param comparator the {@link Comparator} used to compare array elements */ public void assertIsSortedAccordingToComparator(AssertionInfo info, short[] actual, Comparator comparator) { Arrays.assertIsSortedAccordingToComparator(info, failures, actual, comparator); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Shorts.java000066400000000000000000000025151243020563200264100ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.util.*; /** * Reusable assertions for {@link Short}s. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts extends Numbers { private static final Shorts INSTANCE = new Shorts(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Shorts instance() { return INSTANCE; } @VisibleForTesting Shorts() { super(); } public Shorts(ComparisonStrategy comparisonStrategy) { super(comparisonStrategy); } @Override protected Short zero() { return 0; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/StandardComparisonStrategy.java000066400000000000000000000106111243020563200324400ustar00rootroot00000000000000package org.fest.assertions.internal; /* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ import static java.lang.String.format; import java.util.Iterator; import org.fest.util.Objects; /** * Implements {@link ComparisonStrategy} contract with a comparison strategy based on {@link Object#equals(Object)} method, it is * also based on {@link Comparable#compareTo(Object)} when Object are {@link Comparable} method. * * @author Joel Costigliola */ public class StandardComparisonStrategy extends AbstractComparisonStrategy { private static final StandardComparisonStrategy INSTANCE = new StandardComparisonStrategy(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static StandardComparisonStrategy instance() { return INSTANCE; } /** * Creates a new {@link StandardComparisonStrategy}, comparison strategy being based on * {@link Object#equals(Object)}. */ private StandardComparisonStrategy() {} /** * Returns true if actual and other are equal based on {@link Object#equals(Object)}, false otherwise. * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual and other are equal based on {@link Object#equals(Object)}, false otherwise. */ @Override public boolean areEqual(Object actual, Object other) { return Objects.areEqual(actual, other); } /** * Returns true if given {@link Iterable} contains given value based on {@link Object#equals(Object)}, false otherwise.
* If given {@link Iterable} is null, return false. * * @param iterable the {@link Iterable} to search value in * @param value the object to look for in given {@link Iterable} * @return true if given {@link Iterable} contains given value based on {@link Object#equals(Object)}, false otherwise. */ @Override public boolean iterableContains(Iterable iterable, Object value) { if (iterable == null) { return false; } for (Object next : iterable) { if (Objects.areEqual(next, value)) { return true; } } return false; } /** * {@inheritDoc} */ @Override public void iterableRemoves(Iterable iterable, Object value) { if (iterable == null) { return; } Iterator iterator = iterable.iterator(); while (iterator.hasNext()) { if (Objects.areEqual(iterator.next(), value)) { iterator.remove(); } } } /** * Returns any duplicate elements from the given collection according to {@link Object#equals(Object)} comparison strategy. * * @param iterable the given {@link Iterable} we want to extract duplicate elements. * @return an {@link Iterable} containing the duplicate elements of the given one. If no duplicates are found, an empty * {@link Iterable} is returned. */ // overridden to write javadoc. @Override public Iterable duplicatesFrom(Iterable iterable) { return super.duplicatesFrom(iterable); } @Override public boolean stringStartsWith(String string, String prefix) { return string.startsWith(prefix); } @Override public boolean stringEndsWith(String string, String suffix) { return string.endsWith(suffix); } @Override public boolean stringContains(String string, String sequence) { return string.contains(sequence); } @Override @SuppressWarnings("unchecked") public boolean isGreaterThan(Object actual, Object other) { if (!(actual instanceof Comparable)) { throw new IllegalArgumentException(format("argument '%s' should be Comparable but is not", actual)); } return Comparable.class.cast(actual).compareTo(other) > 0; } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Strings.java000066400000000000000000000436401243020563200265630ustar00rootroot00000000000000/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.assertions.error.ShouldBeEqualIgnoringCase.shouldBeEqual; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.error.ShouldContainString.shouldContain; import static org.fest.assertions.error.ShouldContainString.shouldContainIgnoringCase; import static org.fest.assertions.error.ShouldContainStringOnlyOnce.shouldContainOnlyOnce; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.assertions.error.ShouldMatchPattern.shouldMatch; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.assertions.error.ShouldNotContainString.shouldNotContain; import static org.fest.assertions.error.ShouldNotMatchPattern.shouldNotMatch; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.assertions.internal.CommonErrors.arrayOfValuesToLookForIsNull; import static org.fest.util.Iterables.sizeOf; import java.lang.reflect.Array; import java.util.Comparator; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link String}s. * * @author Alex Ruiz * @author Joel Costigliola * @author Nicolas François */ public class Strings { private static final Strings INSTANCE = new Strings(); /** * Returns the singleton instance of this class based on {@link StandardComparisonStrategy}. * * @return the singleton instance of this class based on {@link StandardComparisonStrategy}. */ public static Strings instance() { return INSTANCE; } @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Strings() { this(StandardComparisonStrategy.instance()); } private final ComparisonStrategy comparisonStrategy; public Strings(ComparisonStrategy comparisonStrategy) { this.comparisonStrategy = comparisonStrategy; } @VisibleForTesting public Comparator getComparator() { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) { return ((ComparatorBasedComparisonStrategy) comparisonStrategy).getComparator(); } return null; } /** * Asserts that the given {@code String} is {@code null} or empty. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @throws AssertionError if the given {@code String} is not {@code null} *and* it is not empty. */ public void assertNullOrEmpty(AssertionInfo info, String actual) { if (actual == null || !hasContents(actual)) { return; } throw failures.failure(info, shouldBeNullOrEmpty(actual)); } /** * Asserts that the given {@code String} is empty. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the given {@code String} is not empty. */ public void assertEmpty(AssertionInfo info, String actual) { assertNotNull(info, actual); if (!hasContents(actual)) { return; } throw failures.failure(info, shouldBeEmpty(actual)); } /** * Asserts that the given {@code String} is not empty. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the given {@code String} is empty. */ public void assertNotEmpty(AssertionInfo info, String actual) { assertNotNull(info, actual); if (hasContents(actual)) { return; } throw failures.failure(info, shouldNotBeEmpty()); } private static boolean hasContents(String s) { return s.length() > 0; } /** * Asserts that the size of the given {@code String} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param expectedSize the expected size of {@code actual}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the size of the given {@code String} is different than the expected one. */ public void assertHasSize(AssertionInfo info, String actual, int expectedSize) { assertNotNull(info, actual); int sizeOfActual = actual.length(); if (sizeOfActual == expectedSize) { return; } throw failures.failure(info, shouldHaveSize(actual, sizeOfActual, expectedSize)); } /** * Asserts that the number of entries in the given {@code String} has the same size as the other {@code Iterable}. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param other the group to compare * @throws AssertionError if the given {@code String}. is {@code null}. * @throws AssertionError if the given {@code Iterable} is {@code null}. * @throws AssertionError if the number of entries in the given {@code String} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, String actual, Iterable other) { assertNotNull(info, actual); if (other == null) { throw new NullPointerException("The iterable to look for should not be null"); } int sizeOfActual = actual.length(); int sizeOfOther = sizeOf(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); } /** * Asserts that the number of entries in the given {@code String} has the same size as the other array. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param other the group to compare * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the number of entries in the given {@code String} does not have the same size. */ public void assertHasSameSizeAs(AssertionInfo info, String actual, Object[] other) { assertNotNull(info, actual); if (other == null) { throw arrayOfValuesToLookForIsNull(); } int sizeOfActual = actual.length(); int sizeOfOther = Array.getLength(other); if (sizeOfActual == sizeOfOther) { return; } throw failures.failure(info, shouldHaveSameSizeAs(actual, sizeOfActual, sizeOfOther)); } /** * Verifies that the given {@code String} contains the given sequence. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param sequence the sequence to search for. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not contain the given sequence. */ public void assertContains(AssertionInfo info, String actual, String sequence) { checkSequenceIsNotNull(sequence); assertNotNull(info, actual); if (stringContains(actual, sequence)) { return; } throw failures.failure(info, shouldContain(actual, sequence, comparisonStrategy)); } /** * Delegates to {@link ComparisonStrategy#stringContains(String, String)} */ private boolean stringContains(String actual, String sequence) { return comparisonStrategy.stringContains(actual, sequence); } /** * Verifies that the given {@code String} contains the given sequence, ignoring case considerations. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param sequence the sequence to search for. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not contain the given sequence. */ public void assertContainsIgnoringCase(AssertionInfo info, String actual, String sequence) { checkSequenceIsNotNull(sequence); assertNotNull(info, actual); if (actual.toLowerCase().contains(sequence.toLowerCase())) { return; } throw failures.failure(info, shouldContainIgnoringCase(actual, sequence)); } /** * Verifies that the given {@code String} does not contain the given sequence. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param sequence the sequence to search for. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} contains the given sequence. */ public void assertDoesNotContain(AssertionInfo info, String actual, String sequence) { checkSequenceIsNotNull(sequence); assertNotNull(info, actual); if (!stringContains(actual, sequence)) { return; } throw failures.failure(info, shouldNotContain(actual, sequence, comparisonStrategy)); } private void checkSequenceIsNotNull(String sequence) { if (sequence == null) { throw new NullPointerException("The sequence to look for should not be null"); } } /** * Verifies that two {@code String}s are equal, ignoring case considerations. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param expected the expected {@code String}. * @throws AssertionError if the given {@code String}s are not equal. */ public void assertEqualsIgnoringCase(AssertionInfo info, String actual, String expected) { if (areEqualIgnoringCase(actual, expected)) { return; } throw failures.failure(info, shouldBeEqual(actual, expected)); } private boolean areEqualIgnoringCase(String actual, String expected) { if (actual == null) { return expected == null; } return actual.equalsIgnoreCase(expected); } /** * Verifies that actual {@code String}s contains only once the given sequence. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param sequence the given {@code String}. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not contains only once the given {@code String}. */ public void assertContainsOnlyOnce(AssertionInfo info, String actual, String sequence) { checkSequenceIsNotNull(sequence); assertNotNull(info, actual); int sequenceOccurencesInActual = countOccurences(sequence, actual); if (sequenceOccurencesInActual == 1) return; throw failures.failure(info, shouldContainOnlyOnce(actual, sequence, sequenceOccurencesInActual, comparisonStrategy)); } /** * Count occurences of sequenceToSearch in actual {@link String}. * * @param sequenceToSearch the sequence to search in in actual {@link String}. * @param actual the {@link String} to search occurences in. * @return the number of occurences of sequenceToSearch in actual {@link String}. */ private int countOccurences(String sequenceToSearch, String actual) { int occurences = 0; for (int i = 0; i <= (actual.length() - sequenceToSearch.length()); i++) { if (comparisonStrategy.areEqual(actual.substring(i, i + sequenceToSearch.length()), sequenceToSearch)) { occurences++; } } return occurences; } /** * Verifies that the given {@code String} starts with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not start with the given prefix. */ public void assertStartsWith(AssertionInfo info, String actual, String prefix) { if (prefix == null) { throw new NullPointerException("The given prefix should not be null"); } assertNotNull(info, actual); if (comparisonStrategy.stringStartsWith(actual, prefix)) { return; } throw failures.failure(info, shouldStartWith(actual, prefix, comparisonStrategy)); } /** * Verifies that the given {@code String} ends with the given suffix. * * @param info contains information about the assertion. * @param actual the actual {@code String}. * @param suffix the given suffix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not end with the given suffix. */ public void assertEndsWith(AssertionInfo info, String actual, String suffix) { if (suffix == null) { throw new NullPointerException("The given suffix should not be null"); } assertNotNull(info, actual); if (comparisonStrategy.stringEndsWith(actual, suffix)) { return; } throw failures.failure(info, shouldEndWith(actual, suffix, comparisonStrategy)); } /** * Verifies that the given {@code String} matches the given regular expression. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param regex the regular expression to which the actual {@code String} is to be matched. * @throws NullPointerException if the given pattern is {@code null}. * @throws PatternSyntaxException if the regular expression's syntax is invalid. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the actual {@code String} does not match the given regular expression. */ public void assertMatches(AssertionInfo info, String actual, String regex) { checkRegexIsNotNull(regex); assertNotNull(info, actual); if (Pattern.matches(regex, actual)) { return; } throw failures.failure(info, shouldMatch(actual, regex)); } /** * Verifies that the given {@code String} does not match the given regular expression. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param regex the regular expression to which the actual {@code String} is to be matched. * @throws NullPointerException if the given pattern is {@code null}. * @throws PatternSyntaxException if the regular expression's syntax is invalid. * @throws AssertionError if the actual {@code String} matches the given regular expression. */ public void assertDoesNotMatch(AssertionInfo info, String actual, String regex) { checkRegexIsNotNull(regex); if (actual == null || !Pattern.matches(regex, actual)) { return; } throw failures.failure(info, shouldNotMatch(actual, regex)); } private void checkRegexIsNotNull(String regex) { if (regex == null) { throw patternToMatchIsNull(); } } /** * Verifies that the given {@code String} matches the given regular expression. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param pattern the regular expression to which the actual {@code String} is to be matched. * @throws NullPointerException if the given pattern is {@code null}. * @throws AssertionError if the given {@code String} is {@code null}. * @throws AssertionError if the given {@code String} does not match the given regular expression. */ public void assertMatches(AssertionInfo info, String actual, Pattern pattern) { checkIsNotNull(pattern); assertNotNull(info, actual); if (pattern.matcher(actual).matches()) { return; } throw failures.failure(info, shouldMatch(actual, pattern.pattern())); } /** * Verifies that the given {@code String} does not match the given regular expression. * * @param info contains information about the assertion. * @param actual the given {@code String}. * @param pattern the regular expression to which the actual {@code String} is to be matched. * @throws NullPointerException if the given pattern is {@code null}. * @throws AssertionError if the given {@code String} matches the given regular expression. */ public void assertDoesNotMatch(AssertionInfo info, String actual, Pattern pattern) { checkIsNotNull(pattern); if (actual == null || !pattern.matcher(actual).matches()) { return; } throw failures.failure(info, shouldNotMatch(actual, pattern.pattern())); } private void checkIsNotNull(Pattern pattern) { if (pattern == null) { throw patternToMatchIsNull(); } } private NullPointerException patternToMatchIsNull() { return new NullPointerException("The regular expression pattern to match should not be null"); } private void assertNotNull(AssertionInfo info, String actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/internal/Throwables.java000066400000000000000000000132031243020563200272340ustar00rootroot00000000000000/* * Created on Jan 26, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.error.ShouldContainString.shouldContain; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.assertions.error.ShouldHaveMessage.shouldHaveMessage; import static org.fest.assertions.error.ShouldHaveNoCause.shouldHaveNoCause; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.Objects.areEqual; import org.fest.assertions.core.AssertionInfo; import org.fest.util.VisibleForTesting; /** * Reusable assertions for {@link Throwable}s. * * @author Joel Costigliola */ public class Throwables { private static final Throwables INSTANCE = new Throwables(); /** * Returns the singleton instance of this class. * @return the singleton instance of this class. */ public static Throwables instance() { return INSTANCE; } @VisibleForTesting Diff diff = new Diff(); @VisibleForTesting Failures failures = Failures.instance(); @VisibleForTesting Throwables() {} /** * Asserts that the given actual {@code Throwable} message is equal to the given one. * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param message the expected message. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} is not equal to the given one. */ public void assertHasMessage(AssertionInfo info, Throwable actual, String message) { assertNotNull(info, actual); if (areEqual(actual.getMessage(), message)) return; throw failures.failure(info, shouldHaveMessage(actual, message)); } /** * Asserts that the actual {@code Throwable} does not have a cause. * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the actual {@code Throwable} has a cause. */ public void assertHasNoCause(AssertionInfo info, Throwable actual) { assertNotNull(info, actual); Throwable actualCause = actual.getCause(); if (actualCause == null) return; throw failures.failure(info, shouldHaveNoCause(actual)); } /** * Asserts that the message of the actual {@code Throwable} starts with the given description. * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param description the description expected to start the actual {@code Throwable}'s message. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not start with the given description. */ public void assertHasMessageStartingWith(AssertionInfo info, Throwable actual, String description) { assertNotNull(info, actual); // TODO unit test with null exception message if (actual.getMessage() != null && actual.getMessage().startsWith(description)) return; throw failures.failure(info, shouldStartWith(actual.getMessage(), description)); } /** * Asserts that the message of the actual {@code Throwable} contains with the given description. * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param description the description expected to be contained in the actual {@code Throwable}'s message. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not contain the given description. */ public void assertHasMessageContaining(AssertionInfo info, Throwable actual, String description) { assertNotNull(info, actual); if (actual.getMessage() != null && actual.getMessage().contains(description)) return; throw failures.failure(info, shouldContain(actual.getMessage(), description)); } /** * Asserts that the message of the actual {@code Throwable} ends with the given description. * @param info contains information about the assertion. * @param actual the given {@code Throwable}. * @param description the description expected to end the actual {@code Throwable}'s message. * @throws AssertionError if the actual {@code Throwable} is {@code null}. * @throws AssertionError if the message of the actual {@code Throwable} does not end with the given description. */ public void assertHasMessageEndingWith(AssertionInfo info, Throwable actual, String description) { assertNotNull(info, actual); if (actual.getMessage() != null && actual.getMessage().endsWith(description)) return; throw failures.failure(info, shouldEndWith(actual.getMessage(), description)); } private static void assertNotNull(AssertionInfo info, Throwable actual) { Objects.instance().assertNotNull(info, actual); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/util/000077500000000000000000000000001243020563200234215ustar00rootroot00000000000000fest-assert-2.0M10/src/main/java/org/fest/assertions/util/ArrayWrapperList.java000066400000000000000000000047041243020563200275440ustar00rootroot00000000000000/* * Created on Nov 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.util; import java.lang.reflect.Array; import java.util.AbstractList; import org.fest.util.VisibleForTesting; /** * A list-like wrapper for arrays. This class does not provide type-safety in order to handle both arrays of objects * and arrays of primitives. * * @author Alex Ruiz * @author Yvonne Wang */ public class ArrayWrapperList extends AbstractList { /** * Wraps a given array with a {@link ArrayWrapperList} * * @param array the array to wrap. * @return the wrapped array or {@code null} if the given array was already {@code null}. * @throws IllegalArgumentException if the {@code array} is not an array. */ public static ArrayWrapperList wrap(Object array) { if (array == null) { return null; } if (!array.getClass().isArray()) { throw new IllegalArgumentException("The object to wrap should be an array"); } return new ArrayWrapperList(array); } @VisibleForTesting final Object array; @VisibleForTesting ArrayWrapperList(Object array) { this.array = array; } /** * {@inheritDoc} */ @Override public Object get(int index) { checkIsInRange(index); return Array.get(array, index); } private void checkIsInRange(int index) { int size = size(); if (index >= 0 && index < size()) { return; } String message = String.format("Index should be between 0 and %d (inclusive,) but was %d", size - 1, index); throw new IndexOutOfBoundsException(message); } /** * {@inheritDoc} */ @Override public int size() { return Array.getLength(array); } /** * Returns the component type of the wrapped array. * * @return the component type of the wrapped array. */ public Class getComponentType() { return array.getClass().getComponentType(); } } fest-assert-2.0M10/src/main/java/org/fest/assertions/util/BigDecimalComparator.java000066400000000000000000000013601243020563200302740ustar00rootroot00000000000000package org.fest.assertions.util; import java.math.BigDecimal; import java.util.Comparator; /** * * A {@link BigDecimal} {@link Comparator} based on {@link BigDecimal#compareTo(BigDecimal)}.
* Is useful if ones wants to use BigDecimal assertions based on {@link BigDecimal#compareTo(BigDecimal)} instead of * {@link BigDecimal#equals(Object)} method. * * @author Joel Costigliola */ public class BigDecimalComparator implements Comparator { /** * an instance of {@link BigDecimalComparator}. */ public static final BigDecimalComparator BIG_DECIMAL_COMPARATOR = new BigDecimalComparator(); public int compare(BigDecimal bigDecimal1, BigDecimal bigDecimal2) { return bigDecimal1.compareTo(bigDecimal2); } } fest-assert-2.0M10/src/site/000077500000000000000000000000001243020563200156215ustar00rootroot00000000000000fest-assert-2.0M10/src/site/resources/000077500000000000000000000000001243020563200176335ustar00rootroot00000000000000fest-assert-2.0M10/src/site/resources/images/000077500000000000000000000000001243020563200211005ustar00rootroot00000000000000fest-assert-2.0M10/src/site/resources/images/built-on-Dev@Cloud-Cloudbees.png000066400000000000000000000165051243020563200270540ustar00rootroot00000000000000PNG  IHDRHT pHYs  IDATx=x3!Ԅ"B"1E="gK"@?}>D ͈Ҕi jH@ )$swf6߷{{ʽ3sΝ3,qYP m8Z#ۮۂx] 6ꃂ:I!!4k̡X!x}?y`$2Xvs:u&pj XXC<zPL 2`3… ͞eGv ͛yj-ZO1c 1`@D>Sppa?@n%"pݻv^]S\|yEE.,nXdI!YB۲H {s^829M#;a[J|݀yxJ^y$B3PǁFRZ"5h[ą6 %6x a!)KE hSiϣ <̙3gʕ+kyt+\ MpH7MNvOPٳgJ%TQڦRxrr(yL\q 3 XsfBNTTxR$̡.!fYN" @ KxzyyN1fe&= O<6-y c2x R:*DPRN)o.\B^ :%S\NT[ZZ\.LKƧ FF8V "Ͳd(!eB6mz1I5mN8}2Sd~&aHPB˜5q±aUUUu9Kwl=ǒ)ǑQvُu(sG+#3!2&XrFeAkY'׮P7իeVe"CpU6>DouΝK?}&XF$8QMG:unXDvjUi?dCGR:a D4*D>s7~& % sJ#Y͢ ɲCje0ୃ0<1sEEpZâ? }z]-Zhʨ׭nh-X?,z1!Xg١r5 oIA: cӕh֢=RWg;=:xq`Όx*5-7}Źd#LD'i/|%5*2r7).ZK)Ht޸.0d(T'_~zG3 y,$S˖>towPrZPōd+xUܾєA9t? zG"&}h Ғ;w>G[&=̌䓏MMuS<>( OջgeeFX$0P)#G(818m*^o7ʞ5kV: 0>adi{+.O# DE8;iV!G~mIU#AO)"[đ$n>~\ѝp, ebZ#b`3#v}֭ER96ĕt^ZxL/[+A3/fFC%Z=-wC$L[^n.\.7r iA^^ܺdaDdEL[,8I2$ aQrqadany¨$X@mN=kʁwVmS8X`WHURʯ漲e4aCً`q<y E0Z_Vː@: {=@D B,,8\E9S:rcrtޜC&lypQ1xck͆u74pR<)1!gz9>U{T: fϾ$p2<"sɾ KY |$>9[Fn$Od-yFf\I_}TK 9+28y $гywaEEfQEEEh=ǟ7Wܱ`"2|*"HȟԑeyHj_~YaǷ)IoV'֬=[4wh')YgZOLU9-==9F-ZWghS[[SCg62Rc8ӀqTh@5=Zs2zs•SHƜ W*N5R9_5Tj s2<ږ~h463L; ht-Prz)[S"G~n]nO{ɲ=?cM5&kƧ=Db``{&JNV  ;;;ZE7ck(zcgďP4?;wxp& ˴ SMi !Zz%>YU˻A;)"'-eyl-l]`3 ?ױcǮN <}=Ly}v}sxܶm[+Wr+>쳋@f\Yi]\ݭ#Y` zlxO, Dw5h>Ƕ\v eA:|Lqq\F{`un$k |H j+]}_#׭ʺV:Z-:נܼᛕEhhrccoho} Z pWmʙ8yp#G盒DZNx?h1#A#Jp\ ?Y"ׂ ՛G^d<}i0\ :qLxR- $aTD "Ax~o`#"b,D`|c1{Ì'#=oBˊvlKx~'wz>݅Jsވ#: 4nthhsTF^0%ſd  XO>?? 4{Y;AhfC,:I@4K >z e)$ien&g&9W5Ocbbm1b駟fy>N*{쥳 ҩQM+A!psƩ[!H9g19@C1>msì_=1 `>G,ᶎ메 R r["L@ܯ% Ňs220%MBhTH((.<~2YF5荩^3$fs=d7lb64Gsr xkBwpSq< Y<@8LY)lGc[CyQ& d > )a4Ti(7|v;`X0*_#?tVrt3(\"GpDeFzF|?pj ƃẎPkC)JxlOrx J$ef\:Z%H>!N׳bY4kUG(q0jI=R?sƌg\-=^w:To;0999HOxJ Gt>l80m(?|̓UWWDSZM岹C!]qP@M#x )6OX _`aneeE9r7m&> [1HC kg3o_JL97㙩RD5w,_ooo{z{)}PVf6m"r4 6?xr\0^ym":a#GS"|Fo/: $''s= qSXoy0sد~P_dyyߧGDH=z|-n9u=00m^E}#*q6o%?$$s#:hp'ˉXjJ/9[5k{Us+8HLe)y!a֠/`O4b_/V|X~oN1hؕ_x}N ÷EUO@@׵kS82#& =Gm s7Nx:Ɗ dA+I6ǘ"d뿲Ir[kFF{Ҁ,/ּuX څS!g૯m[׮]o0gl2`P@M&# mE1Oc,oV3BI˥K. н[=r;"I  bZCͱ&ͱ5c*Sacy]soE7*GԬzra:F sҡ= su! IZ<#d 1?aO5Q<<-'^^޻ϰ́o7ﱼ|&B|j!$!4(NEJ3ZNn lkj1_DovHOB16=u^*1 8r@lZۭQ>+(@ HaXuw $?qcEN2;BN o9BhrȒ*H0.QKǷHM iʮ gweWդj1h[sm|p t\+iFzi'Oݻ1z2O9gyAZe Koq#!x4!=֭['RP ۢ.Tg˳VD"B`Y13wbb`q҄ӽU'OqKs)s!Z)6$d咴SQ%DcJD$CXnf?Vu01:8ۈˠ%?AHdSKUK`a ĉ,q;E><.|cHltjA놃>@c#8ٺuߡxΜ9ڼ:!.A]׶];bk$Ċw+$D6SlA0RGaI#httr8 ԘiLlm l9i uF,bfW,vP1!48{DfCa W0?Q]qĄ Fɲ8R d#ZXqa~n,Ao`{%s'>}QwT@~=1:y% N7sG\xA, G!gCYgض,' "89NJNScQ7;%u`W WD _΂(jQVCC|\Z$2okdt vt,oJڵkHj!.\5D;,$),1GzCTVV֯[[u˺ͿϜC. ˹,Kk/!|!""owr-T/SWUUɥ9W*mJ!>1`Ofdhqϋnj)OZw8l\-xЪAq{:鑯.>CZ,hh')Y4xog~+sQQq;K2/e ,jkā*j5>:yā5U9pXk!q`~8*?R*krt.21/@kNmސOt2v.#890SAU1{'o.ArB7αsG޳a?]O#8ps`;80tBݮs͵կtY崿o޹OOn{`āۘxklv:ZОo}kyCC 7Β:ĹCr yێ=粏m=Bpn? V>߄gTۇ^nB1RtӟI/kx9DCF@mɡFsouisߕBu|3&BۅRq*&rЏY!Y_8ڟo~׿YC~ի^ũzJhB2l_O?Ͽg|n4Bɇfk.j-.`{H![ǟ;m#̙u+mzm.g7BH,DW׽pо!^;u S9կ~kk7/8j}p\>|“/^wuow}enC >tHw?l|?/]v/g١' ;qc娳>{?~e˖7#<ԾNXm6h|. 0zj,OvLOO?~ӟK.lPYÍ>h3m:V$V Ok+97: k@=B zj]AD{[@\ve/ qǯF~{LD-qڇ|3B/ qBGz>WE=BsgLD#ݨ`ڱox3s_+{mJKN;;m8/6u :=8 / RR 8CON qҏ7rKIUss]BlqZ> HΓY$B umB)<7n}N)OygsEyV茶O;/u}hOW^1 [o^:Hds٨tHpn4A]odTENt[.#^⌯}9d˧BX1$2@~闤 paC qҏ!|47tdvu49 b_ 3-PD k9wg~#<(_"Fe0a͍}EUv_MHySiB:P7ψG~\H61[vZӊ+ pcKO~g?Y ?tl0'C"u}Mqn9:ސ Um bJLooHZY> m)1ea&{"Ax;)`yKoC@Bh2y8*3 mxrɠ?^!XUvEYWaVyפ-Hn gk·Ì 5yE2($p9~PsR&|~/m=ZL&%):҉s\SAPh%'Z1ImȲ~ ^s9\;8ޯ}k_Zx`<\Fe0a ρ>h˙즈0$xTJf !NyĐ\;!J芐R蜠$Z~Lz,mmS줤L8dY-\}rSO5L_ D ݵS:Lb ]g"+-~-ëB\Ck2ה>|fmv}<Pš*3 ɊCo BQƑs3/q]9ߗ,ݠնCMH3yK/idMu?9ioJ;Y7+Ϯsy,ko4fm[6Ԙ[>olr).5 ?9$\ՅV2ie0IX=m_W{ ٍ7YheҥKK?_v>%.м hmc+B&h_D*(Y4lZ)} djA"$N&վoB&9|-տ C29"4XX]ѹ_k}[pȫ@]#smz`y)F<1Nя~σcU1戀U&ƂC9l0Ї>r[޻loҺr0unI)w,W Y(ۭmw0<0K8JNLX8=8^u fI%G}Vɠok6ޮ~K[ܧqU06 $8!%`gU~F .O;W RjΖQگ3 ([sDE&8\J@sK1cB u#>ud3,2l]cr?Oߧ?JeZ orKm귷ޗ2}GgdB/8 x0Nq&gq衇 D`%tsuL_̃qւ(aw)MH3c\W^?n;B'<9ܠ(11e*3qq3sg@523v" '}3UnH@ ԴN)<'ӆyC"0v9Leu= Ǒc.ioZ/6E/Jo`}w1I:Rcqx7$3FVq 5uiHWER5>`y\&+8< >Wf:蠃,"Pf2.[2m]0CpE~ .Dl?.#%JzruU0y9:(SMOeNhP tgмP=_KÔ=+zr:p4믿rʻ<`;JR_e:]z2|sʮ!YLeQ+9c8kLr_#o[H},fQn 8d$2q9?tM/l_)MV|f.eFgiqrmam lś2I,b5#u$Q1| '9X_N=9Jyxg}|RZ% Q<'UHĶ(4mi<ַu9y2O-Px- ;Ϲ}_~/ x"~9gN2 WwisxÏ8_W:20'm!5'2%{&կ~@md&[: ]'ۺY$` =aPq}/S$s{S~->}3i1J/BtC< ='dwRE~}WtHfn!eT4KK{a¼m}_FHF7A!ܼĿ!5y/jso|U;lqF%̥9>e}DE(//mM_g2V7r"fZ 6@1< qhMqȗo;)'h(qvp 1]Lَ (Og$aG d2!,&;Jgwg"_=OV7:~zrh#90a- RB$N`HJ#)ZΫ}5[bG=1Wα&n"t`B8_ Ӟ4u Y9c!L 5O~j2pX;vI<5|@BV$O##fܦa 1V<\ZU9E,?(9щ$w꫿zoG"/e+r~ߪD1 D3D_ǵ^ky,jfSs-`mXn%}JS{]뢋.1ǞXH9ʨdU @7a6dw2$ „v1WJ!շ⨻.{~-D:x +KOBuYQ}9/3QI 1awMo6__g/]1st9'F4'ʡ-3zL^D[і !}![IBԁ|ԕUv y'f EiLX:1d7A93}d٧A=kQ,h. y%y$Ik){Yѳi]fEU }6eV lV.Be2@Q9{-Od)*U&O2<{Am?J٧YdQ" PH&=T-Wj'tCLn` Rrzڤ EP!Ed2>9m ghEEV8.S ñC]UMT`^E37jjۅ(.di߆hOɹ. +/9$8FFhXc?289Zʹ4g,3%{Q:/\>RΎ=;T   \Q!qc`Rn&2=oE'gX!;(8e[ήk됅Ok_lOwm^IHfoM`w~] ]*dR! ӟ% @j9yȊ-$X$#.f j:%SJ,Sv[ҭܭ{C?+:~QGuӻ|ɟ/͍KnOhEQ?c,Wsĵ9j5ZJs~~!fTVSHlRnDzJDcq^}jڧ>_ U7Wkb}K"x,_6$ȠcmW3"ʙVfn?>"ŏ8JQ+]F!2w+dZ0DދB"Fiw}2 @J׾VpQ+VH8n`p2eYl ̷oaPXؖp0mmiݺo.6rz{-LdU s>B([dz P~j^u+-b $wdrKBdHG_d=(Z^6o"J$':gJH?" F9Q0ƽ$$P2)yRQW~} #V}aQ*lҬo雋W}IE0"sB= (I((YQks+˔QY- hwԜ89"L`2šclЍxYs}s%Qpm8X GN- 2>Y˪|{VR.qn۾>hn6}Id0Wˊ9_]ك1+p6c0e0_wsj S\ByH G, X T!*>=2q {;$`P{Q8e$)]A]X) B_C"iJ;I `wQœ2 @M@BP>$$tEOs3t'Yu #b)fѓ@P^*-=7ȍ[OsJ)3 `qih2 ~l&dPn:: 8c@PN, fd阿aN<˼/M菨D|oZ*j.Gy]'XK.oYpǯ/s.rv }P%b#< ɬT8o/ @{TKS~Os-#`^maZ^ A)V]B/(D=)O]s  JɈ.:@R^5Y(ax1'V"/얙8n 8q3e})s=I ,8\\9yg VF}ö;EG2S æ B )ɠ̅<+3sԕI(љ.)uoMޡW@ĎObAkC& \bd e4'rڊfw  i8gfJ<+]/ݦps]Rxc=ӔDCBme_\9@'< XwtcR&%+&}Q+<1seq>ۛ#ND-XVdm+՚²lR^Hi'fJJ]pf}d- .2Te|m!9 )/IV*mED/o|N޳dWoMb?$*t"9r 8x%嘇D"CI9S:Iݹ>#?xS35L 1^K)K44ԶD_y)s9ʖJMߊE+b>VZ*$TYR\ٯ_oᆇݗ{08k7e/ScWLEoS.9fQșJ3LJ@yf^I$9XXqVSJ<"J 7d,k<H959G"}4$pdJ<&ؗA ae|`qLΩS;6lN<"%22> NVF1ȑ !& UʨT"L ITDYJ8E8~\4$8<Ere` qP5d/hiP5ANه @&\D5 3*XO8檁9&Z=j็{=߮`uRxi+3\' 8c @RzCГ<ϙԯuwr3C]]/= PXZZ:ڼJn e=l2͜e#V"N}oMܳ3W|G@OQґH<0+{7AV/@d>G*:$ٕNdbNxQHF;Hq_i G{2|)ِϤ>!іH|6 OMY!7G(]i /"L+]d3d&C_dåbs./:Q*ЯzI>ِ*w.ިκW^&Jl(ro4@Ecr$D(Ћr $8=1{NMחw3Uz)֠cc"ϜDhIhiHv؏yӛtbwh=$)Hܡ )tB #>}ׄd02hǶߐ (U:' zֳ5A~cϱ6rBl 8w[D,1_SV{␡>p3% .9!F#sNڿ-7NSOW4<9F&VjȄLdm]Ұ[[f@^$ #,"%'J1~)d?YNZɧʙA$`K4"(dtJfԇd gOTmceMu gMӵW_rIc!޸MOcYP1ɒDu/@lʌ>eʱȧƧ11A#h9 8sCCYG붎DU^CZn69'YY.RHL1y]K:a? DJn+sT*T5g:O>cL_R{s Joc!]/ P5%0Bwp}eN8ϐn[ƧNGaox`* ^oLӁ~iHCWgt60 z'W rFÿ@R}?y<]! ?Y4LoU+/c땹K˗+5[SL=o]&O=KŏrEIIC[GDw7/Μr(cMLD, A2cr e% D] y+rmf'l^Eo+7Iɲ 68@0jm]>٩zڳ R!e'poQSK^㔙 gl,AuL]剪a|!8Ħñꯈ9/jfw&e2%@š %HSHf /K\Lae=p hd[A}<Wdy 02^e3<|dgː+=.}7ݖD 1zo[e%WGV "-KLm^2BfwgՌpYH)! gE+/Y2G=JV ҋCJxdQu܀z}dc}y]e&`A`)(ྉĵ~-s}%hc;.PpMe?4d$_{f!EL.7E?Bntn6x/P^wYR |*9 -qV߁i-SS}m Ӕ<˾}@) Iٽz ¿>7qJ4f"/5]΂~&d&R̊&E+/Y1sBSp^Hn[CB]]|xA[ϟ}&^]{&L'^G(8S%ι{{FmDl3o?q:-w]e&%ƙx]__@ő` rŹ'd~ ظݳ} $+91/@Ӳ"㐹dߵ %裏V~WHbEL -6 frs'՟q[gh`bH'J3'@Ҭۺ3DdRxqv蜖OVaLb=h>Od-GR)&O5糠`E:OQ}brS@yW,Mjv|"ڼu'Ǵ,woVNU8{q}-Y}t)Q2obKʹsfB#/Ύo\u^T'05/ȑ3;wzc̿xt'n yRo r?;WefZ}= K`t^V$4olye>|Qު뚿YXdJef[ Bfs,r8{6x=47P-3ŋ>G,&'@>zbHh,t;9woއ{Q;L8pxg8e!5j2Yuf]V/eGC"2UQvXE@;ImPKcdi:7Wsy]yiE;h"#BJ.Ub ڇ';{qos-Yib2e!&t-}0{Y}[x0!c1yaqQCg#fzʦ<OdV9OL~6d,̺>>eoշnfOd(>E&BI1gȐR[J !ᥡgD69ӏ3?*3&} 0fA Vțl""I7 siؔ5n~^GG& 7O]dl3vSXi}JJԜ(܇BSAF%<)ߖ7 w5*J/fM1$kHwD"ew׆Lh~#d!i@ CƤ䠻60d?>p(z7d>>%K(O ]hY 0L`Ā. q@B&)&.s9 $*rq/i";.o[taQH7Ȥü*=C頃2##&b8}J@Tw9+x_Jy gcIH$ThdW>&z}V}/OҾqí>%GhW7% U_CO?z&0.X<(޿P~$zL?IO]{޿U-F6dDV37to}pFy3/ikHYg%}$ܺ>gֱM)$q!/CEBmo}7t}HyQHt(.j瘟* LC%ׅ}]ڳB*;Oe .ls8DJOy(hEaU@LԸe,!YOon ms[8kCx-C}jBdD3l&QҞ9M ({bw<罫(^>684$-Lqz(n.Ymiش>h?Oٟ9gbƊ?~]w7EA{[kwqF3q\3) Ҝ簀i(_t"zMd^S")P @pxt<"wc}LHD*z r G8N5wBA6~!mE $SDo׶@XԶ-XxK@ߑ-FFd5Reж`>+ɀ4z 5)Dž!/ q1.I3^0ȝ.g|Z QS_;@rwB:A<4𝱮1Rb΂1;nPa̛DUQvp N C;t%!2@Cdu8G껨_88 %F_SıBcg.?go/=;jL_  B/E ?|V'r*mdD66!A]HBB5@I 5HQ:=D!BmQI)  ʯ*Qnd\8׸k㬥@PjΡ0zF}X:>zo=0OqD|"# 9Nӕ2,2s ;nkN,rxőmv!0#G!!$&ZU @pM'D*)B %F+U:/sΜqETՇdž/ _DelCI9'@ڜ?",o/ )V_MDEA7B#]w j0Sxv_ȏ?^T9|Yc%F4OUF̐!(pPK%P]Ӭ ]!Ti?C4>wmwXHI&ॹ/ 9`< c VdQ:maK>8n۷w=9.֎ L̤4D]"gC,`'ѮUP0(k6zҳ>m )Kq@ !Mqyx{?'9 d%Z@'X]%f 8=CKB'%'z?ó;6}n4I=HTc!J.EI7!S*і cg2Dո8[va쌱>|VSQwFapȐCdvD*QdJ8FQwܚ01U)Bdĉ0 =(a. Nv]ǂ?Hڧ) 8=8dY5'*c[]Y/oDA'I蓈U+﷾e5>6c|n<^;C~DAoץ]{cLluu>~62/[D*Iɉ`>(%!*ap zsp$-Ef<B%p8 mQ0t"VyWu}6nJY}$E!2 Kұ:c+'t9"cmɗȍCh9|α/eqɜ^n͔)/[$Ɋ>9nT9F_ٹ56dCV8 OxB9`CD]rB?hol4xrjotȏ1+~X9~nϤS:js0b7rţamj{u4~oN1U;qeD|8OȕATj_(ÍZ-@Yo8\^'Sq&Ⱥ}^sV/k2{h&S֘b|OzkUI8i4ypoʳ>Y}P .Y011iN^C)ȣ#'?[ɾ/?kGzᑹU% ,wAy\n'?<4Gu~&iI^@ԶClj({Wk{co+ǚǖu?ה旲.mvn],XPW9#,뵭ۮ5ֺ|D˲5K(8M.! }Vqe"~>0&(d%G5f°O9#Lk5nrk@~MM77{ >y 0vM=ļ_"ߵi|]7.Ck]HH7meQ:\p_kNg jZw.o7lr'xh<<cK/J;wϻ7N4xȠzv_҃A]]?v387^MM>?zܞ{[}Ml {ousN~)6,7=C9/3jGKV՟%m3,]iqҟϕD9:q`xyҎwHa A-ӺQF8vRjѠ˅ok 62!+9f 倚 ɎqUDewbq%gLھ95aq !c"'e_і {QJA/oۯɤKm֝_|Rf94 |Zh"Q[Kwv^>YN#y:nUo/w!d!] 8 )\N(tvI3FTZTy^"8|$inϜwulq"}^n:VD7j7ɯHYvؾ+<;M :`o_ÃF~3%6  hoe{|o];l`4 ÚEɯe~lyL\Wnw˖-뵯}~y_3v mJ A*pk1^s)⟒$R(]9CS$m 5EMJ'(JjͥT{e{s4K3_퀴}P^D#7 "U7i} sW>'w%@ 0N8A4V<5g,!ؾ\ uʓt) =o{4)䐀dqe[>яO?h_V?mI=΂NA}v C&;PMhD =E];Mּsm?7w$:k=@m -eOκ}w.LX uwIVySǿVjqCͽ~SlaE C얌@ /lP|P0> ȜtۖOSO}$ĎGέ 󛍍Jv `)ߧD2OՆ_ @y/iV^ͻ qK^]{%e+a5b 28t׎vmy3圳>[;>g]$E;|-m7Fv)gС!.GP7DFv 7(ُa|d' Dۢ)/N[i%1j˜cwSy P]DUT)lׯxX•d6Ը|}Y( k-Ǽuj ק~m|>?-@]c1'vpHH8FlVT q@hQw]ϫ}|*ڱ:VDE~1:C5A cX~nzؽ %#E'Hч.@pn<>|ӗ֡~oXzt>/~'}SH;~Z-#&p|tvn#槐Rn^޶M_ʃ>PdȨ;n+*Ʉj* O 3_}1< t pvÖoJlɊ/~u%4@44FLP|6=Iʺ TX2ihN>Kۃ( گef\o;&І;'0hkҮ 8Kdo 5ʌkӖj0j6V3'>k :[1A(d~`EhiN(+Rzx0dQ!K CDB3Z.5GjM(N 8V.`}Jp_ZO(=şa1, "H$}r͒5K=\R'nJa mNi<Ʌ^xh2X`i7jh{t/yQ1DCF@825G-6SSΖ)pRh;&3.Ԏ%w}c D$@svȵ0Y8lYm6F?9:-ظ&A*Y@&:|0JIl> ٌOXmiyG&"n+wҫ,1D#\ƚ$60fvLJ%:*ۣ:%&6T1/MYAx}lr6W]vمW`qsO|qJ@Yj&D.@viByCtt`9ύ*& rVq%nx ojV?M u^0FN9S:e.j6JQ' Ck8V?iH䷨Zt(r~ʵ2‰]qG!le-@PmM}n4QOP)9܆rׇx8&*wQ<MSfZܔ@FtoƂiK,yI[O{Z[Rm"Lھ2M+e{. > (w=mY(Yu/.e&}["k ;]77"JĹkB7JiΟ4%*cg>sc9 NXГd|~k~ono˗Xn,4Д-]j:,Dna_9RL˩N8RB}ڌ'[-Ph:~X!n{sIPvP.{L}<`$R_9NBK}ĬNR3Jw% x㍟Pf(xM6(;g8T0s[?!^;a2]׾|_0߀C腩7ߢ_ w~5)a692"$\D~*LwHpޢxHB"4s7AњMiigFk^#3^YQn٠o"Cqb-8@2c)#gޖȚ~~}[DN%kHZdJ2Pq\ԵS'{ۺ9-j919o-4.K&x @QEWi(Y3A\]6s_zZFo4/+}49H 2N<̻͗nbe7 Pv,4eKfZ Dݲ6$'/=s2,).+x>YI"\tBm%6`CڬVLX!|aǁ?*LÆ!*g9wg1]sǘ1g$&?+ץwxYx 4I)'#f /ܨd<脅?W1}iq. < { & QnL(>*[[FKSԇ'p -ONnH;M!)wuV [0 $qm'gHۋe(>F6p#\;JF@VYHaE^M(h̔+6 vU2fqcIۥ[)gZF k8)q{S,B48.~+90 R)1^Xe{(dy}#׿%/Yp_F$dg4[lߞҋDwSw['Β3VNw .ߛ--ppc(V]Y^FoDk;G'%7Y_]Զq e(+@׀DwݝNW7&kЇ>#>>~Ůw~8ղ|!z; =L?{pXoVxPv-r`vP|rȗ]hK3/lIr7.D;}#')e=t]r`2 Of hmR iυDf")Ƨ`".? b u:efq&:=t} (0cXQ?2Rn[e'Sc^k$ ݭmr1kIk:cJ$_8D5ݷhd!|<+r>>D|8r혮qsdwC1{ K߮8$3ol"+W7/=S( 5>LMyV휑ctIęM>)!Qhp=E /9.ͧFOx]:MzPi PDxt^YRGD"E9#:XI&H>ߘ nh>톍J*ˇl 0;}%3vFfO>' %6MOo]9Y%i~QVP 8^җ&;Y%&r^cA7H_wɈ*b$;VS(O(Hq4/g(t*c*Uw%i+ic"D8 ;(_֘]59 X9md~\F;qnFߝǯlfڪ? SkY)O<4ȁ!8.Wty0^e}0 ~APCƍj8tW#Λ/!gWhX=EtCbt?%a{d$D@G_T)_cя~tWVmss1K=m=.' D =ZAB^DxAᝃQUT3F<2QP@+(*Gxil(av>-|@~2"9")v]*S9fqֹ@C  Ν"s^C2.+16ڧiveCV}Quܪ?=pi M樀(2&w0$B#ȅcrNwt+#27|w|gx9ԷH]G_];x9]PZTxgAFe3]kB_ > ޓ> '}3>|vZ^lJngi+=El5Vv}PHȀl,޲]5~+}~l>7,ڠڕNܛqW0RFv@أxz&^ɂn"+ðA%}?oHɋ0cż2Fe48D[ |zt{!"J` Q*NKh+,Cm[ܿA|ʈKI exqe)q9?c.(+Ɋfڪ?G^F/eUksDu(6G4*ٸNxhC>5qjmC; *yt\8 u}cW|8>P|XiOe3X~sxC{O3z:Qq>ve a7r~L[a/b|ժخ`_{OxCN\xq痜K?ˆ\/>;EM"tE;{ qGczYhP7 š? -Fp͠q"#cf2.p㲏!S܊;y騢"F, y>)E )sE ҵl_1r}/'ﮏ ewg|Z2*P@Xmf]ِtUі1W&e|DL \]hVpcصYNrKi~?c"{Ԗ$Mis:4 @3}2v_d0[ǥ胴(P +* EKGx\QS9z a:Jp GR)*H9vzϩH1i@RxFFˢkpSfVԘ-c@/]X}ۧQV"98`XcN?}vÿύ Hv'@`<"EHdGJxU.0fdHoDhdAw+*,K&x};} @Gע}E}:/]*1Bۍ;L[a/b|m;u7KO+ c6UvI2b{]YGl?xن~xh,H@ &}-g`cXIO)R,F]TP` hа\n/)`)'Ym~-K1,arEї8;h:S}yc1!־ -<76 ~<:6NxR2`A;Q<v$Cfp#~϶'>>W"oc#we#-.~sy}(L:ߵҕ>t[dVYʚ xf Rȯo\{خ񗮒-ٓ_!V@cE/z]ݛN/HR7 Lv  YJpP0[u_Gۈc@#zLjр{tu2 Y*]oB߭T8 ]QQQ"A~JT@H~?ud}L-*g80x4]QE~,F'߷M抺YX~0s:o|jj57$b*2P#r;Uyj~L)i.)Fq`*Fq`^SIENDB`fest-assert-2.0M10/src/test/000077500000000000000000000000001243020563200156345ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/000077500000000000000000000000001243020563200165555ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/000077500000000000000000000000001243020563200173445ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/000077500000000000000000000000001243020563200203055ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/000077500000000000000000000000001243020563200224775ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/000077500000000000000000000000001243020563200232505ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/AbstractAssertBaseTest.java000066400000000000000000000017701243020563200305000ustar00rootroot00000000000000/* * Created on Jul 29, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * Base class to test the concrete methods of {@link AbstractAssert} (using a dummy implementation). * * @author Olivier Michallat */ public abstract class AbstractAssertBaseTest extends BaseTestTemplate { @Override protected ConcreteAssert create_assertions() { return new ConcreteAssert(6L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/AbstractComparableAssertBaseTest.java000066400000000000000000000025431243020563200324650ustar00rootroot00000000000000/* * Created on Jul 29, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Comparables; /** * Base class to test the concrete methods of {@link AbstractComparableAssert} (using a dummy implementation). * * @author Olivier Michallat */ public abstract class AbstractComparableAssertBaseTest extends BaseTestTemplate { protected Comparables comparables; @Override protected ConcreteComparableAssert create_assertions() { return new ConcreteComparableAssert(8); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); comparables = mock(Comparables.class); assertions.comparables = comparables; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/AbstractUnevenComparableAssertBaseTest.java000066400000000000000000000026011243020563200336410ustar00rootroot00000000000000/* * Created on Jul 29, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Comparables; /** * Base class to test the concrete methods of {@link AbstractUnevenComparableAssert} (using a dummy implementation). * * @author Olivier Michallat */ public abstract class AbstractUnevenComparableAssertBaseTest extends BaseTestTemplate { protected Comparables comparables; @Override protected ConcreteUnevenComparableAssert create_assertions() { return new ConcreteUnevenComparableAssert(8); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); comparables = mock(Comparables.class); assertions.comparables = comparables; } } Assertions_assertThat_with_BigDecimal_Test.java000066400000000000000000000023511243020563200344630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import static java.math.BigDecimal.*; import static org.junit.Assert.*; import java.math.BigDecimal; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(BigDecimal)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_BigDecimal_Test { @Test public void should_create_Assert() { BigDecimalAssert assertions = Assertions.assertThat(ZERO); assertNotNull(assertions); } @Test public void should_pass_actual() { BigDecimalAssert assertions = Assertions.assertThat(ONE); assertSame(ONE, assertions.actual); } } Assertions_assertThat_with_BooleanArray_Test.java000066400000000000000000000024441243020563200350640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(boolean[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_BooleanArray_Test { @Test public void should_create_Assert() { BooleanArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { boolean[] actual = emptyArray(); BooleanArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_Boolean_Test.java000066400000000000000000000023071243020563200340630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.lang.Boolean.TRUE; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Boolean)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Boolean_Test { @Test public void should_create_Assert() { BooleanAssert assertions = Assertions.assertThat(TRUE); assertNotNull(assertions); } @Test public void should_pass_actual() { BooleanAssert assertions = Assertions.assertThat(TRUE); assertSame(TRUE, assertions.actual); } } Assertions_assertThat_with_ByteArray_Test.java000066400000000000000000000024221243020563200344040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(byte[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_ByteArray_Test { @Test public void should_create_Assert() { ByteArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { byte[] actual = emptyArray(); ByteArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Byte_Test.java000066400000000000000000000022761243020563200334730ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Byte)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Byte_Test { @Test public void should_create_Assert() { Byte zero = 0; ByteAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Byte eight = 8; ByteAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } Assertions_assertThat_with_CharArray_Test.java000066400000000000000000000024221243020563200343560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(char[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_CharArray_Test { @Test public void should_create_Assert() { CharArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { char[] actual = emptyArray(); CharArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_Character_Test.java000066400000000000000000000023161243020563200344000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Character)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Character_Test { @Test public void should_create_Assert() { Character a = 'a'; CharacterAssert assertions = Assertions.assertThat(a); assertNotNull(assertions); } @Test public void should_pass_actual() { Character b = 'b'; CharacterAssert assertions = Assertions.assertThat(b); assertSame(b, assertions.actual); } } Assertions_assertThat_with_DoubleArray_Test.java000066400000000000000000000024361243020563200347200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(double[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_DoubleArray_Test { @Test public void should_create_Assert() { DoubleArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { double[] actual = emptyArray(); DoubleArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Double_Test.java000066400000000000000000000023141243020563200337730ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Double)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Double_Test { @Test public void should_create_Assert() { Double zero = 0d; DoubleAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Double eight = 8d; DoubleAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_File_Test.java000066400000000000000000000024371243020563200334460ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import java.io.File; import org.junit.*; /** * Tests for {@link Assertions#assertThat(File)}. * * @author Yvonne Wang */ public class Assertions_assertThat_with_File_Test { private static File actual; @BeforeClass public static void setUpOnce() { actual = new File("xyz"); } @Test public void should_create_Assert() { FileAssert assertions = Assertions.assertThat(actual); assertNotNull(assertions); } @Test public void should_pass_actual() { FileAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_FloatArray_Test.java000066400000000000000000000024301243020563200345450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(float[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_FloatArray_Test { @Test public void should_create_Assert() { FloatArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { float[] actual = emptyArray(); FloatArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Float_Test.java000066400000000000000000000023061243020563200336270ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Float)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Float_Test { @Test public void should_create_Assert() { Float zero = 0f; FloatAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Float eight = 8f; FloatAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } Assertions_assertThat_with_InputStream_Test.java000066400000000000000000000026531243020563200347630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.junit.BeforeClass; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(InputStream)}. * * @author Matthieu Baechler */ public class Assertions_assertThat_with_InputStream_Test { private static InputStream actual; @BeforeClass public static void setUpOnce() { actual = new ByteArrayInputStream(new byte[0]); } @Test public void should_create_Assert() { InputStreamAssert assertions = Assertions.assertThat(actual); assertNotNull(assertions); } @Test public void should_pass_actual() { InputStreamAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_IntArray_Test.java000066400000000000000000000024141243020563200342340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(int[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_IntArray_Test { @Test public void should_create_Assert() { IntArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { int[] actual = emptyArray(); IntArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_Integer_Test.java000066400000000000000000000023201243020563200340740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Integer)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Integer_Test { @Test public void should_create_Assert() { Integer zero = 0; IntegerAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Integer eight = 8; IntegerAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } Assertions_assertThat_with_Iterable_Test.java000066400000000000000000000025141243020563200342330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.util.Sets.newLinkedHashSet; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Iterable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Assertions_assertThat_with_Iterable_Test { @Test public void should_create_Assert() { IterableAssert assertions = Assertions.assertThat(newLinkedHashSet()); assertNotNull(assertions); } @Test public void should_pass_actual() { Iterable names = newLinkedHashSet("Luke"); IterableAssert assertions = Assertions.assertThat(names); assertSame(names, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_List_Test.java000066400000000000000000000025171243020563200335010ustar00rootroot00000000000000/* * Created on Oct 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api; import static java.util.Collections.*; import static org.junit.Assert.*; import java.util.List; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(List)}. * * @author Yvonne Wang * @author Alex Ruiz * @author Mikhail Mazursky */ public class Assertions_assertThat_with_List_Test { @Test public void should_create_Assert() { ListAssert assertions = Assertions.assertThat(emptyList()); assertNotNull(assertions); } @Test public void should_pass_actual() { List names = singletonList("Luke"); ListAssert assertions = Assertions.assertThat(names); assertSame(names, assertions.actual); } } Assertions_assertThat_with_LongArray_Test.java000066400000000000000000000024221243020563200344000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(long[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_LongArray_Test { @Test public void should_create_Assert() { LongArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { long[] actual = emptyArray(); LongArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Long_Test.java000066400000000000000000000023001243020563200334530ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Long)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Long_Test { @Test public void should_create_Assert() { Long zero = 0L; LongAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Long eight = 8L; LongAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Map_Test.java000066400000000000000000000026561243020563200333070ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.util.Collections.emptyMap; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import java.util.HashMap; import java.util.Map; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Map)}. * * @author Alex Ruiz * @author Nicolas François */ public class Assertions_assertThat_with_Map_Test { @Test public void should_create_Assert() { MapAssert assertions = Assertions.assertThat(emptyMap()); assertNotNull(assertions); } @Test public void should_pass_actual() { Map actual = new HashMap(); MapAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_ObjectArray_Test.java000066400000000000000000000025121243020563200347070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Object[])}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class Assertions_assertThat_with_ObjectArray_Test { @Test public void should_create_Assert() { ObjectArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { Object[] actual = emptyArray(); ObjectArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Object_Test.java000066400000000000000000000024231243020563200337700ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Object)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class Assertions_assertThat_with_Object_Test { @Test public void should_create_Assert() { Object actual = new Object(); ObjectAssert assertions = Assertions.assertThat(actual); assertNotNull(assertions); } @Test public void should_pass_actual() { Object actual = new Object(); ObjectAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_ShortArray_Test.java000066400000000000000000000024301243020563200345770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(short[])}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_ShortArray_Test { @Test public void should_create_Assert() { ShortArrayAssert assertions = Assertions.assertThat(emptyArray()); assertNotNull(assertions); } @Test public void should_pass_actual() { short[] actual = emptyArray(); ShortArrayAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_Short_Test.java000066400000000000000000000023241243020563200336610ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(Short)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_Short_Test { @Test public void should_create_Assert() { Short zero = (short) 0; ShortAssert assertions = Assertions.assertThat(zero); assertNotNull(assertions); } @Test public void should_pass_actual() { Short eight = (short) 8; ShortAssert assertions = Assertions.assertThat(eight); assertSame(eight, assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/Assertions_assertThat_with_String_Test.java000066400000000000000000000022771243020563200340370ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(String)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_String_Test { @Test public void should_create_Assert() { StringAssert assertions = Assertions.assertThat("Yoda"); assertNotNull(assertions); } @Test public void should_pass_actual() { String actual = "Yoda"; StringAssert assertions = Assertions.assertThat(actual); assertSame(actual, assertions.actual); } } Assertions_assertThat_with_primitive_boolean_Test.java000066400000000000000000000022551243020563200362150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(boolean)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_boolean_Test { @Test public void should_create_Assert() { BooleanAssert assertions = Assertions.assertThat(true); assertNotNull(assertions); } @Test public void should_pass_actual() { BooleanAssert assertions = Assertions.assertThat(true); assertEquals(true, assertions.actual); } } Assertions_assertThat_with_primitive_byte_Test.java000066400000000000000000000022671243020563200355440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(byte)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_byte_Test { @Test public void should_create_Assert() { ByteAssert assertions = Assertions.assertThat((byte) 0); assertNotNull(assertions); } @Test public void should_pass_actual() { ByteAssert assertions = Assertions.assertThat((byte) 8); assertEquals(new Byte((byte) 8), assertions.actual); } } Assertions_assertThat_with_primitive_char_Test.java000066400000000000000000000022671243020563200355160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(char)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_char_Test { @Test public void should_create_Assert() { CharacterAssert assertions = Assertions.assertThat('a'); assertNotNull(assertions); } @Test public void should_pass_actual() { CharacterAssert assertions = Assertions.assertThat('b'); assertEquals(new Character('b'), assertions.actual); } } Assertions_assertThat_with_primitive_double_Test.java000066400000000000000000000022571243020563200360520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(double)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_double_Test { @Test public void should_create_Assert() { DoubleAssert assertions = Assertions.assertThat(0d); assertNotNull(assertions); } @Test public void should_pass_actual() { DoubleAssert assertions = Assertions.assertThat(8d); assertEquals(new Double(8d), assertions.actual); } } Assertions_assertThat_with_primitive_float_Test.java000066400000000000000000000022511243020563200356770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(float)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_float_Test { @Test public void should_create_Assert() { FloatAssert assertions = Assertions.assertThat(0f); assertNotNull(assertions); } @Test public void should_pass_actual() { FloatAssert assertions = Assertions.assertThat(8f); assertEquals(new Float(8), assertions.actual); } } Assertions_assertThat_with_primitive_int_Test.java000066400000000000000000000022511243020563200353640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(int)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_int_Test { @Test public void should_create_Assert() { IntegerAssert assertions = Assertions.assertThat(0); assertNotNull(assertions); } @Test public void should_pass_actual() { IntegerAssert assertions = Assertions.assertThat(8); assertEquals(new Integer(8), assertions.actual); } } Assertions_assertThat_with_primitive_long_Test.java000066400000000000000000000022441243020563200355330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(long)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_long_Test { @Test public void should_create_Assert() { LongAssert assertions = Assertions.assertThat(0L); assertNotNull(assertions); } @Test public void should_pass_actual() { LongAssert assertions = Assertions.assertThat(8L); assertEquals(new Long(8), assertions.actual); } } Assertions_assertThat_with_primitive_short_Test.java000066400000000000000000000022771243020563200357410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.junit.Assert.*; import org.junit.Test; /** * Tests for {@link Assertions#assertThat(short)}. * * @author Alex Ruiz */ public class Assertions_assertThat_with_primitive_short_Test { @Test public void should_create_Assert() { ShortAssert assertions = Assertions.assertThat((short) 8); assertNotNull(assertions); } @Test public void should_pass_actual() { ShortAssert assertions = Assertions.assertThat((short) 8); assertEquals(new Short((short) 8), assertions.actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/BaseTestTemplate.java000066400000000000000000000102041243020563200273160ustar00rootroot00000000000000/* * Created on Jul 29, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static junit.framework.Assert.assertSame; import static org.mockito.Mockito.mock; import org.fest.assertions.api.abstract_.AbstractAssert_isNull_Test; import org.fest.assertions.core.Assert; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.junit.Test; /** * Template to write tests for {@link AbstractAssert} implementations. * *

* These classes are simple wrapper types, that delegate the real work to internal objects. For each method, we only need to test * that: *

    *
  • invoking the method properly delegates to the relevant internal objects;
  • *
  • the method returns {@code this} (for assertion chaining).
  • *
* This template factors most of the code to make the actual tests quick to write. *

*

* For each assertion class (e.g {@link BigDecimalAssert}), the template is specialized by a "base" class in the same package ( * {@link BigDecimalAssertBaseTest}). To avoid cluttering the main package with hundreds of classes, the concrete tests reside in * a subpackage ({@link org.fest.assertions.api.bigdecimal}). The base class also serves as a proxy to the package-private fields * of the assertion that need to be verified in the tests. *

* * @param the "self" type of the assertion under test. * @param the type of the "actual" value. * * @author Olivier Michallat */ public abstract class BaseTestTemplate, A> { protected S assertions; protected Objects objects; protected Conditions conditions; @Before public final void setUp() { assertions = create_assertions(); inject_internal_objects(); } /** * Builds an instance of the {@link Assert} implementation under test. * * This object will be accessible through the {@link #assertions} field. */ protected abstract S create_assertions(); /** * Injects any additional internal objects (typically mocks) into {@link #assertions}. * * Subclasses that override this method must call the superclass implementation. */ protected void inject_internal_objects() { objects = mock(Objects.class); assertions.objects = objects; conditions = mock(Conditions.class); assertions.conditions = conditions; } @Test public void should_have_internal_effects() { invoke_api_method(); verify_internal_effects(); } /** * For the few API methods that don't return {@code this}, override this method to do nothing (see * {@link AbstractAssert_isNull_Test#should_return_this()} for an example). */ @Test public void should_return_this() { S returned = invoke_api_method(); assertSame(assertions, returned); } protected AssertionInfo getInfo(S someAssertions) { return someAssertions.info; } protected A getActual(S someAssertions) { return someAssertions.actual; } protected Objects getObjects(S someAssertions) { return someAssertions.objects; } /** * Invokes the API method under test. * * @return the assertion object that is returned by the method. If the method is {@code void}, return {@code null} and override * {@link #should_return_this()}. */ protected abstract S invoke_api_method(); /** * Verifies that invoking the API method had the expected effects (usually, setting some internal state or invoking an internal * object). */ protected abstract void verify_internal_effects(); } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/BigDecimalAssertBaseTest.java000066400000000000000000000032501243020563200307100ustar00rootroot00000000000000/* * Created on Aug 01, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.math.BigDecimal.ONE; import static org.mockito.Mockito.mock; import java.math.BigDecimal; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.Comparables; /** * Base class for {@link BigDecimalAssert} tests. * * @author Olivier Michallat */ public abstract class BigDecimalAssertBaseTest extends BaseTestTemplate { protected static final String ONE_AS_STRING = "1"; protected BigDecimals bigDecimals; protected Comparables comparables; @Override protected BigDecimalAssert create_assertions() { return new BigDecimalAssert(ONE); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); bigDecimals = mock(BigDecimals.class); assertions.bigDecimals = bigDecimals; comparables = mock(Comparables.class); assertions.comparables = comparables; } protected BigDecimals getBigDecimals(BigDecimalAssert someAssertions) { return someAssertions.bigDecimals; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/BooleanArrayAssertBaseTest.java000066400000000000000000000027021243020563200313070ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.BooleanArrays; /** * Base class for {@link BooleanArrayAssert} tests. * * @author Olivier Michallat */ public abstract class BooleanArrayAssertBaseTest extends BaseTestTemplate { protected BooleanArrays arrays; @Override protected BooleanArrayAssert create_assertions() { return new BooleanArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(BooleanArrays.class); assertions.arrays = arrays; } protected BooleanArrays getArrays(BooleanArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/BooleanAssertBaseTest.java000066400000000000000000000025171243020563200303140ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Booleans; /** * Base class for {@link BooleanAssert} tests. * * @author Olivier Michallat */ public abstract class BooleanAssertBaseTest extends BaseTestTemplate { protected Booleans booleans; @Override protected BooleanAssert create_assertions() { return new BooleanAssert(true); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); booleans = mock(Booleans.class); assertions.booleans = booleans; } protected Booleans getBooleans(BooleanAssert someAssertions) { return someAssertions.booleans; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ByteArrayAssertBaseTest.java000066400000000000000000000026361243020563200306410ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.ByteArrays; /** * Base class for {@link ByteArrayAssert} tests. * * @author Olivier Michallat */ public abstract class ByteArrayAssertBaseTest extends BaseTestTemplate { protected ByteArrays arrays; @Override protected ByteArrayAssert create_assertions() { return new ByteArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(ByteArrays.class); assertions.arrays = arrays; } protected ByteArrays getArrays(ByteArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ByteAssertBaseTest.java000066400000000000000000000024401243020563200276330ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Bytes; /** * Base class for {@link ByteAssert} tests. * * @author Olivier Michallat */ public abstract class ByteAssertBaseTest extends BaseTestTemplate { protected Bytes bytes; @Override protected ByteAssert create_assertions() { return new ByteAssert((byte) 0); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); bytes = mock(Bytes.class); assertions.bytes = bytes; } protected Bytes getBytes(ByteAssert someAssertions) { return someAssertions.bytes; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/CharArrayAssertBaseTest.java000066400000000000000000000026361243020563200306130ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.CharArrays; /** * Base class for {@link CharArrayAssert} tests. * * @author Olivier Michallat */ public abstract class CharArrayAssertBaseTest extends BaseTestTemplate { protected CharArrays arrays; @Override protected CharArrayAssert create_assertions() { return new CharArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(CharArrays.class); assertions.arrays = arrays; } protected CharArrays getArrays(CharArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/CharacterAssertBaseTest.java000066400000000000000000000025601243020563200306270ustar00rootroot00000000000000/* * Created on Aug 03, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Characters; /** * Base class for {@link CharacterAssert} tests. * * @author Olivier Michallat */ public abstract class CharacterAssertBaseTest extends BaseTestTemplate { protected Characters characters; @Override protected CharacterAssert create_assertions() { return new CharacterAssert('a'); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); characters = mock(Characters.class); assertions.characters = characters; } protected Characters getCharacters(CharacterAssert someAssertions) { return someAssertions.characters; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/CollectionAssert_usingComparator_Test.java000066400000000000000000000036231243020563200336300ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Tests for {@link ByteAssert#usingComparator(java.util.Comparator)} and * {@link ByteAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class CollectionAssert_usingComparator_Test { private ByteAssert assertions = new ByteAssert((byte) 5); @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Test public void using_default_comparator_test() { assertions.usingDefaultComparator(); assertSame(assertions.objects, Objects.instance()); assertSame(assertions.bytes, Bytes.instance()); } @Test public void using_custom_comparator_test() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator assertions.usingComparator(comparator); assertSame(assertions.objects.getComparator(), comparator); assertSame(assertions.bytes.getComparator(), comparator); } } ComparableAssertion_should_be_flexible_Test.java000066400000000000000000000017571243020563200347000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/apipackage org.fest.assertions.api; import org.junit.Test; public class ComparableAssertion_should_be_flexible_Test { @Test public void comparable_api_should_be_flexible() { TestClass testClass1 = new TestClass(); TestClass testClass2 = new TestClass(); TestClassAssert.assertThat(testClass1).isEqualByComparingTo(testClass2); } // The important thing here is that TestClass implements Comparable and not Comparable // even private static final class TestClass implements Comparable { public int compareTo(Object other) { return 0; // always equals for the test } } // we'd like to get rid of the compile error here private static final class TestClassAssert extends AbstractUnevenComparableAssert { TestClassAssert(TestClass actual) { super(actual, TestClassAssert.class); } static TestClassAssert assertThat(TestClass actual) { return new TestClassAssert(actual); } } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteAssert.java000066400000000000000000000030221243020563200270340ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import org.fest.assertions.core.WritableAssertionInfo; import org.fest.assertions.internal.Objects; /** * @author Alex Ruiz * @author Joel Costigliola */ public class ConcreteAssert extends AbstractAssert { public ConcreteAssert(Object actual) { super(actual, ConcreteAssert.class); } /** * Not a really relevant assertion, the goal is to show how to write a new assertion with a specific error message * that honors the description set by the assertion user. */ public ConcreteAssert checkNull() { // set a specific error message WritableAssertionInfo info = getWritableAssertionInfo(); info.overridingErrorMessage("specific error message"); Objects.instance().assertNull(info, actual); // return the current assertion for method chaining return this; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteComparableAssert.java000066400000000000000000000016661243020563200310360ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Alex Ruiz */ public class ConcreteComparableAssert extends AbstractComparableAssert { public ConcreteComparableAssert(Integer actual) { super(actual, ConcreteComparableAssert.class); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteGenericAssert.java000066400000000000000000000016421243020563200303370ustar00rootroot00000000000000/* * Created on Apr 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Mikhail Mazursky */ public class ConcreteGenericAssert> extends AbstractAssert, A> { public ConcreteGenericAssert(A actual) { super(actual, ConcreteGenericAssert.class); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteGenericComparableAssert.java000066400000000000000000000017461243020563200323320ustar00rootroot00000000000000/* * Created on Apr 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Mikhail Mazursky */ public class ConcreteGenericComparableAssert> extends AbstractComparableAssert, A> { public ConcreteGenericComparableAssert(A actual) { super(actual, ConcreteGenericComparableAssert.class); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteIterableAssert.java000066400000000000000000000017741243020563200305200ustar00rootroot00000000000000/* * Created on Nov 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import java.util.Collection; /** * @author Alex Ruiz * @author Mikhail Mazursky */ public class ConcreteIterableAssert extends AbstractIterableAssert, Collection, T> { public ConcreteIterableAssert(Collection actual) { super(actual, ConcreteIterableAssert.class); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ConcreteUnevenComparableAssert.java000066400000000000000000000017201243020563200322060ustar00rootroot00000000000000/* * Created on Jan 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Yvonne Wang */ public class ConcreteUnevenComparableAssert extends AbstractUnevenComparableAssert { public ConcreteUnevenComparableAssert(Integer actual) { super(actual, ConcreteUnevenComparableAssert.class); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/DateAssertBaseTest.java000066400000000000000000000022601243020563200276050ustar00rootroot00000000000000package org.fest.assertions.api; import static org.mockito.Mockito.mock; import java.text.DateFormat; import java.util.Date; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.Objects; import org.junit.Before; /** * * Abstract base of all DateAssert tests. * * @author Joel Costigliola * */ public abstract class DateAssertBaseTest { protected DateAssert assertions; protected Dates dates; protected Objects objects; @Before public void setUp() { dates = mock(Dates.class); objects = mock(Objects.class); assertions = new DateAssert(new Date()); assertions.dates = dates; assertions.objects = objects; } protected DateFormat dateFormat() { return DateAssert.dateFormat; } protected AssertionInfo getInfo(DateAssert someAssertions) { return someAssertions.info; } protected Date getActual(DateAssert someAssertions) { return someAssertions.actual; } protected Objects getObjects(DateAssert someAssertions) { return someAssertions.objects; } protected Dates getDates(DateAssert someAssertions) { return someAssertions.dates; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/DoubleArrayAssertBaseTest.java000066400000000000000000000026661243020563200311530ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.DoubleArrays; /** * Base class for {@link DoubleArrayAssert} tests. * * @author Olivier Michallat */ public abstract class DoubleArrayAssertBaseTest extends BaseTestTemplate { protected DoubleArrays arrays; @Override protected DoubleArrayAssert create_assertions() { return new DoubleArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(DoubleArrays.class); assertions.arrays = arrays; } protected DoubleArrays getArrays(DoubleArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/DoubleAssertBaseTest.java000066400000000000000000000024761243020563200301530ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Doubles; /** * Base class for {@link DoubleAssert} tests. * * @author Olivier Michallat */ public abstract class DoubleAssertBaseTest extends BaseTestTemplate { protected Doubles doubles; @Override protected DoubleAssert create_assertions() { return new DoubleAssert(3.14); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); doubles = mock(Doubles.class); assertions.doubles = doubles; } protected Doubles getDoubles(DoubleAssert someAssertions) { return someAssertions.doubles; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/FileAssertBaseTest.java000066400000000000000000000033041243020563200276070ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import java.io.File; import java.nio.charset.Charset; import org.fest.assertions.internal.Files; /** * Base class for {@link FileAssert} tests. * * @author Olivier Michallat */ public abstract class FileAssertBaseTest extends BaseTestTemplate { protected Files files; protected Charset defaultCharset; protected Charset otherCharset; @Override protected FileAssert create_assertions() { return new FileAssert(new File("abc")); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); files = mock(Files.class); assertions.files = files; defaultCharset = Charset.defaultCharset(); for (Charset charset : Charset.availableCharsets().values()) { if (!charset.equals(defaultCharset)) otherCharset = charset; } } protected Files getFiles(FileAssert someAssertions) { return someAssertions.files; } protected Charset getCharset(FileAssert someAssertions) { return someAssertions.charset; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/FloatArrayAssertBaseTest.java000066400000000000000000000026521243020563200310010ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.FloatArrays; /** * Base class for {@link FloatArrayAssert} tests. * * @author Olivier Michallat */ public abstract class FloatArrayAssertBaseTest extends BaseTestTemplate { protected FloatArrays arrays; @Override protected FloatArrayAssert create_assertions() { return new FloatArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(FloatArrays.class); assertions.arrays = arrays; } protected FloatArrays getArrays(FloatArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/FloatAssertBaseTest.java000066400000000000000000000024551243020563200300030ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Floats; /** * Base class for {@link FloatAssert} tests. * * @author Olivier Michallat */ public abstract class FloatAssertBaseTest extends BaseTestTemplate { protected Floats floats; @Override protected FloatAssert create_assertions() { return new FloatAssert(6.0f); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); floats = mock(Floats.class); assertions.floats = floats; } protected Floats getFloats(FloatAssert someAssertions) { return someAssertions.floats; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/GenericComparableInterfaceface.java000066400000000000000000000014261243020563200321200ustar00rootroot00000000000000/* * Created on Apr 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Mikhail Mazursky */ public interface GenericComparableInterfaceface extends Comparable { } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/GenericInterface.java000066400000000000000000000013621243020563200273120ustar00rootroot00000000000000/* * Created on Apr 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; /** * @author Mikhail Mazursky */ public interface GenericInterface { } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/InputStreamAssertBaseTest.java000066400000000000000000000027751243020563200312160ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.fest.assertions.internal.InputStreams; /** * Base class for {@link InputStreamAssert} tests. * * @author Joel Costigliola */ public abstract class InputStreamAssertBaseTest extends BaseTestTemplate { protected InputStreams inputStreams; @Override protected InputStreamAssert create_assertions() { return new InputStreamAssert(new ByteArrayInputStream(new byte[] { 'a' })); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); inputStreams = mock(InputStreams.class); assertions.inputStreams = inputStreams; } protected InputStreams getInputStreams(InputStreamAssert someAssertions) { return someAssertions.inputStreams; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/IntArrayAssertBaseTest.java000066400000000000000000000026221243020563200304630ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.IntArrays; /** * Base class for {@link IntArrayAssert} tests. * * @author Olivier Michallat */ public abstract class IntArrayAssertBaseTest extends BaseTestTemplate { protected IntArrays arrays; @Override protected IntArrayAssert create_assertions() { return new IntArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(IntArrays.class); assertions.arrays = arrays; } protected IntArrays getArrays(IntArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/IntegerAssertBaseTest.java000066400000000000000000000025141243020563200303270ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Integers; /** * Base class for {@link IntegerAssert} tests. * * @author Olivier Michallat */ public abstract class IntegerAssertBaseTest extends BaseTestTemplate { protected Integers integers; @Override protected IntegerAssert create_assertions() { return new IntegerAssert(0); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); integers = mock(Integers.class); assertions.integers = integers; } protected Integers getIntegers(IntegerAssert someAssertions) { return someAssertions.integers; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/IterableAssertBaseTest.java000066400000000000000000000026351243020563200304650ustar00rootroot00000000000000/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.util.Collections.emptyList; import static org.mockito.Mockito.mock; import java.util.Collection; import org.fest.assertions.internal.Iterables; /** * Tests for {@link AbstractIterableAssert#contains(Object...)}. * * @author Joel Costigliola */ public abstract class IterableAssertBaseTest extends BaseTestTemplate, Collection>{ protected Iterables iterables; @Override protected ConcreteIterableAssert create_assertions() { return new ConcreteIterableAssert(emptyList()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); iterables = mock(Iterables.class); assertions.iterables = iterables; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ListAssertBaseTest.java000066400000000000000000000024611243020563200276460ustar00rootroot00000000000000/* * Created on Aug 02, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import java.util.Collections; import java.util.List; import org.fest.assertions.internal.Lists; /** * Base class for {@link ListAssert} tests. * * @author Olivier Michallat */ public abstract class ListAssertBaseTest extends BaseTestTemplate, List> { protected Lists lists; @Override protected ListAssert create_assertions() { return new ListAssert(Collections. emptyList()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); lists = mock(Lists.class); assertions.lists = lists; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/LongArrayAssertBaseTest.java000066400000000000000000000026361243020563200306350ustar00rootroot00000000000000/* * Created on Aug 01, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.LongArrays; /** * Base class for {@link LongArrayAssert} tests. * * @author Olivier Michallat */ public abstract class LongArrayAssertBaseTest extends BaseTestTemplate { protected LongArrays arrays; @Override protected LongArrayAssert create_assertions() { return new LongArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(LongArrays.class); assertions.arrays = arrays; } protected LongArrays getArrays(LongArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/LongAssertBaseTest.java000066400000000000000000000024321243020563200276300ustar00rootroot00000000000000/* * Created on Aug 01, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Longs; /** * Base class for {@link LongAssert} tests. * * @author Olivier Michallat */ public abstract class LongAssertBaseTest extends BaseTestTemplate { protected Longs longs; @Override protected LongAssert create_assertions() { return new LongAssert(0L); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); longs = mock(Longs.class); assertions.longs = longs; } protected Longs getLongs(LongAssert someAssertions) { return someAssertions.longs; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/MapAssertBaseTest.java000066400000000000000000000024761243020563200274560ustar00rootroot00000000000000/* * Created on Aug 01, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static java.util.Collections.emptyMap; import static org.mockito.Mockito.mock; import java.util.Map; import org.fest.assertions.internal.Maps; /** * Base class for {@link MapAssert} tests. * * @author Olivier Michallat */ public abstract class MapAssertBaseTest extends BaseTestTemplate, Map> { protected Maps maps; @Override protected MapAssert create_assertions() { return new MapAssert(emptyMap()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); maps = mock(Maps.class); assertions.maps = maps; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ObjectArrayAssertBaseTest.java000066400000000000000000000027271243020563200311450ustar00rootroot00000000000000/* * Created on Jul 31, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.ObjectArrays; /** * Base class for {@link ObjectArrayAssert} tests. * * @author Olivier Michallat */ public abstract class ObjectArrayAssertBaseTest extends BaseTestTemplate, Object[]> { protected ObjectArrays arrays; @Override protected ObjectArrayAssert create_assertions() { return new ObjectArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(ObjectArrays.class); assertions.arrays = arrays; } protected ObjectArrays getArrays(ObjectArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ObjectAssertBaseTest.java000066400000000000000000000017751243020563200301500ustar00rootroot00000000000000/* * Created on Jul 31, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import org.fest.test.Jedi; /** * Base class for {@link ObjectAssert} tests. * * @author Olivier Michallat */ public abstract class ObjectAssertBaseTest extends BaseTestTemplate, Jedi> { @Override protected ObjectAssert create_assertions() { return new ObjectAssert(new Jedi("Yoda", "Green")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ShortArrayAssertBaseTest.java000066400000000000000000000026521243020563200310330ustar00rootroot00000000000000/* * Created on Jul 31, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.ShortArrays; /** * Base class for {@link ShortArrayAssert} tests. * * @author Olivier Michallat */ public abstract class ShortArrayAssertBaseTest extends BaseTestTemplate { protected ShortArrays arrays; @Override protected ShortArrayAssert create_assertions() { return new ShortArrayAssert(emptyArray()); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); arrays = mock(ShortArrays.class); assertions.arrays = arrays; } protected ShortArrays getArrays(ShortArrayAssert someAssertions) { return someAssertions.arrays; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ShortAssertBaseTest.java000066400000000000000000000024621243020563200300330ustar00rootroot00000000000000/* * Created on Jul 31, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Shorts; /** * Base class for {@link ShortAssert} tests. * * @author Olivier Michallat */ public abstract class ShortAssertBaseTest extends BaseTestTemplate { protected Shorts shorts; @Override protected ShortAssert create_assertions() { return new ShortAssert((short) 6); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); shorts = mock(Shorts.class); assertions.shorts = shorts; } protected Shorts getShorts(ShortAssert someAssertions) { return someAssertions.shorts; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/StringAssertBaseTest.java000066400000000000000000000025001243020563200301730ustar00rootroot00000000000000/* * Created on Jul 30, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Strings; /** * Base class for {@link StringAssert} tests. * * @author Olivier Michallat */ public abstract class StringAssertBaseTest extends BaseTestTemplate { protected Strings strings; @Override protected StringAssert create_assertions() { return new StringAssert("Yoda"); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); strings = mock(Strings.class); assertions.strings = strings; } protected Strings getStrings(StringAssert someAssertions) { return someAssertions.strings; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/ThrowableAssertBaseTest.java000066400000000000000000000024471243020563200306660ustar00rootroot00000000000000/* * Created on Jul 30, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api; import static org.mockito.Mockito.mock; import org.fest.assertions.internal.Throwables; /** * Base class for {@link ThrowableAssertAssert} tests. * * @author Olivier Michallat */ public abstract class ThrowableAssertBaseTest extends BaseTestTemplate { protected Throwables throwables; @Override protected ThrowableAssert create_assertions() { return new ThrowableAssert(new Throwable("throwable message")); } @Override protected void inject_internal_objects() { super.inject_internal_objects(); throwables = mock(Throwables.class); assertions.throwables = throwables; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/000077500000000000000000000000001243020563200252125ustar00rootroot00000000000000AbstractAssert_as_with_description_Test.java000066400000000000000000000040471243020563200360500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someDescription; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.description.Description; import org.fest.assertions.test.ExpectedException; /** * Tests for {@link AbstractAssert#as(Description)} * * @author Alex Ruiz */ public class AbstractAssert_as_with_description_Test { @Rule public ExpectedException thrown = none(); private ConcreteAssert assertions; private Description d; @Before public void setUp() { assertions = new ConcreteAssert(6L); d = someDescription(); } @Test public void should_set_description() { assertions.as(d); assertEquals(d.value(), assertions.descriptionText()); } @Test public void should_return_this() { ConcreteAssert descriptable = assertions.as(d); assertSame(assertions, descriptable); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); assertions.as((Description) null); } } AbstractAssert_as_with_text_description_Test.java000066400000000000000000000036531243020563200371160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.*; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AbstractAssert#as(String)}. * * @author Alex Ruiz */ public class AbstractAssert_as_with_text_description_Test { @Rule public ExpectedException thrown = none(); private ConcreteAssert assertions; private String description; @Before public void setUp() { assertions = new ConcreteAssert(6L); description = someTextDescription(); } @Test public void should_set_description() { assertions.as(description); assertEquals(description, assertions.descriptionText()); } @Test public void should_return_this() { ConcreteAssert descriptable = assertions.as(description); assertSame(assertions, descriptable); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); assertions.as((String) null); } } AbstractAssert_describedAs_with_description_Test.java000066400000000000000000000037431243020563200376570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.*; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someDescription; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.description.Description; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AbstractAssert#describedAs(Description)} * * @author Alex Ruiz */ public class AbstractAssert_describedAs_with_description_Test { @Rule public ExpectedException thrown = none(); private ConcreteAssert assertions; private Description d; @Before public void setUp() { assertions = new ConcreteAssert(6L); d = someDescription(); } @Test public void should_set_description() { assertions.describedAs(d); assertEquals(d.value(), assertions.descriptionText()); } @Test public void should_return_this() { ConcreteAssert descriptable = assertions.describedAs(d); assertSame(assertions, descriptable); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); assertions.describedAs((Description) null); } } AbstractAssert_describedAs_with_text_description_Test.java000066400000000000000000000037371243020563200407260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AbstractAssert#describedAs(String)}. * * @author Alex Ruiz */ public class AbstractAssert_describedAs_with_text_description_Test { @Rule public ExpectedException thrown = none(); private ConcreteAssert assertions; private String description; @Before public void setUp() { assertions = new ConcreteAssert(6L); description = someTextDescription(); } @Test public void should_set_description() { assertions.describedAs(description); assertSame(description, assertions.descriptionText()); } @Test public void should_return_this() { ConcreteAssert descriptable = assertions.describedAs(description); assertSame(assertions, descriptable); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); assertions.describedAs((String) null); } } AbstractAssert_doesNotHaveTheSameClassAs_Test.java000066400000000000000000000025371243020563200367510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#doesNotHaveSameClassAs(Object)}. * * @author Nicolas François */ public class AbstractAssert_doesNotHaveTheSameClassAs_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.doesNotHaveSameClassAs("Luke"); } @Override protected void verify_internal_effects() { verify(objects).assertDoesNotHaveSameClassAs(getInfo(assertions), getActual(assertions), "Luke"); } } AbstractAssert_doesNotHave_Test.java000066400000000000000000000031001243020563200342130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#doesNotHave(Condition)}. * * @author Yvonne Wang */ public class AbstractAssert_doesNotHave_Test extends AbstractAssertBaseTest { private static Condition condition; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Override protected ConcreteAssert invoke_api_method() { return assertions.doesNotHave(condition); } @Override protected void verify_internal_effects() { verify(conditions).assertDoesNotHave(getInfo(assertions), getActual(assertions), condition); } } AbstractAssert_equal_hashCode_Test.java000066400000000000000000000031451243020563200347120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Mar 18, 2018 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.*; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.test.ExpectedException; import org.junit.Rule; import org.junit.Test; /** * Tests for {@link AbstractAssert#equals(Object)} and {@link AbstractAssert#hashCode()}. * * @author Nicolas François */ public class AbstractAssert_equal_hashCode_Test { @Rule public ExpectedException thrown = none(); private ConcreteAssert assertions = new ConcreteAssert("myString"); @Test public void should_fail_because_not_supported_operation() { thrown.expectUnsupportedOperationException("'equals' is not supported...maybe you intended to call 'isEqualTo"); assertions.equals("anotherString"); } @Test public void shouldReturnOneAsHashCode() { assertEquals(1, assertions.hashCode()); } }AbstractAssert_get_writable_info_Test.java000066400000000000000000000026641243020563200354750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.assertEquals; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import org.junit.Test; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#getWClass()}. * * @author Joel Costigliola */ public class AbstractAssert_get_writable_info_Test { @Test public void should_keep_specific_error_message_and_description_set_by_user() { try { new ConcreteAssert(6L).as("user description").checkNull(); } catch (AssertionError e) { assertEquals("[user description] specific error message", e.getMessage()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } AbstractAssert_hasTheSameClassAs_Test.java000066400000000000000000000024771243020563200353100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#hasSameClassAs(Object)}. * * @author Nicolas François */ public class AbstractAssert_hasTheSameClassAs_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.hasSameClassAs("Luke"); } @Override protected void verify_internal_effects() { verify(objects).assertHasSameClassAs(getInfo(assertions), getActual(assertions), "Luke"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/AbstractAssert_has_Test.java000066400000000000000000000030401243020563200326310ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#has(Condition)}. * * @author Yvonne Wang */ public class AbstractAssert_has_Test extends AbstractAssertBaseTest { private static Condition condition; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Override protected ConcreteAssert invoke_api_method() { return assertions.has(condition); } @Override protected void verify_internal_effects() { verify(conditions).assertHas(getInfo(assertions), getActual(assertions), condition); } } AbstractAssert_isEqualTo_Test.java000066400000000000000000000024421243020563200337120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isEqualTo(Object)}. * * @author Alex Ruiz */ public class AbstractAssert_isEqualTo_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isEqualTo(new Long(8L)); } @Override protected void verify_internal_effects() { verify(objects).assertEqual(getInfo(assertions), getActual(assertions), 8L); } } AbstractAssert_isExactlyInstanceOf_Test.java000066400000000000000000000024571243020563200357310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link ObjectAssert#isExactlyInstanceOf(Class))}. * * @author Nicolas François */ public class AbstractAssert_isExactlyInstanceOf_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isExactlyInstanceOf(String.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsExactlyInstanceOf(getInfo(assertions), getActual(assertions), String.class); } } AbstractAssert_isIn_with_Iterable_Test.java000066400000000000000000000027751243020563200355610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 3, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#isIn(Iterable))}. * * @author Yvonne Wang * @author Joel Costigliola * @author Nicolas François */ public class AbstractAssert_isIn_with_Iterable_Test extends AbstractAssertBaseTest { private static Iterable values; @BeforeClass public static void setUpOnce() { values = newArrayList("Yoda", "Luke"); } @Override protected ConcreteAssert invoke_api_method() { return assertions.isIn(values); } @Override protected void verify_internal_effects() { verify(objects).assertIsIn(getInfo(assertions), getActual(assertions), values); } } AbstractAssert_isIn_with_array_Test.java000066400000000000000000000027401243020563200351400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 2, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#isIn(Object...)}. * * @author Yvonne Wang */ public class AbstractAssert_isIn_with_array_Test extends AbstractAssertBaseTest { private static Object[] values; @BeforeClass public static void setUpOnce() { values = array("Yoda", "Luke"); } @Override protected ConcreteAssert invoke_api_method() { return assertions.isIn(values); } @Override protected void verify_internal_effects() { verify(objects).assertIsIn(getInfo(assertions), getActual(assertions), values); } } AbstractAssert_isIn_with_vararg_Test.java000066400000000000000000000025061243020563200353040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 3, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isIn(Iterable))}. * * @author Yvonne Wang * @author Joel Costigliola * @author Nicolas François */ public class AbstractAssert_isIn_with_vararg_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isIn("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(objects).assertIsIn(getInfo(assertions), getActual(assertions), new Object[] { "Yoda", "Luke" }); } } AbstractAssert_isInstanceOfAny_Test.java000066400000000000000000000027341243020563200350450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * AbstractAssert_isInstanceOf_Test.java * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isInstanceOfAny(Class...)}. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class AbstractAssert_isInstanceOfAny_Test extends AbstractAssertBaseTest { private final Class[] types = { String.class, Object.class }; @Override protected ConcreteAssert invoke_api_method() { return assertions.isInstanceOfAny(types); } @Override protected void verify_internal_effects() { verify(objects).assertIsInstanceOfAny(getInfo(assertions), getActual(assertions), types); } } AbstractAssert_isInstanceOf_Test.java000066400000000000000000000025601243020563200343720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isInstanceOf(Class)}. * * @author Alex Ruiz * @author Mikhail Mazursky * @author Nicolas François */ public class AbstractAssert_isInstanceOf_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isInstanceOf(String.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsInstanceOf(getInfo(assertions), getActual(assertions), String.class); } } AbstractAssert_isNotEqualTo_Test.java000066400000000000000000000024561243020563200344000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isNotEqualTo(Object)}. * * @author Alex Ruiz */ public class AbstractAssert_isNotEqualTo_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotEqualTo(new Long(8L)); } @Override protected void verify_internal_effects() { verify(objects).assertNotEqual(getInfo(assertions), getActual(assertions), 8L); } } AbstractAssert_isNotExactlyInstanceOf_Test.java000066400000000000000000000024731243020563200364100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link ObjectAssert#isNotExactlyInstanceOf(Class))}. * * @author Nicolas François */ public class AbstractAssert_isNotExactlyInstanceOf_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotExactlyInstanceOf(String.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotExactlyInstanceOf(getInfo(assertions), getActual(assertions), String.class); } } AbstractAssert_isNotIn_with_Iterable_Test.java000066400000000000000000000030671243020563200362350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 5, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#isNotIn(Iterable)}. * * @author Yvonne Wang * @author Joel Costigliola * @author Nicolas François */ public class AbstractAssert_isNotIn_with_Iterable_Test extends AbstractAssertBaseTest { private static Iterable values; @BeforeClass public static void setUpOnce() { values = newArrayList("Yoda", "Luke"); } @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotIn(values); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotIn(getInfo(assertions), getActual(assertions), values); } } AbstractAssert_isNotIn_with_array_Test.java000066400000000000000000000027541243020563200356260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 4, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#isNotIn(Object...)}. * * @author Yvonne Wang */ public class AbstractAssert_isNotIn_with_array_Test extends AbstractAssertBaseTest { private static Object[] values; @BeforeClass public static void setUpOnce() { values = array("Yoda", "Luke"); } @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotIn(values); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotIn(getInfo(assertions), getActual(assertions), values); } } AbstractAssert_isNotIn_with_vararg_Test.java000066400000000000000000000026001243020563200357600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Feb 5, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isNotIn(Iterable)}. * * @author Yvonne Wang * @author Joel Costigliola * @author Nicolas François */ public class AbstractAssert_isNotIn_with_vararg_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotIn("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotIn(getInfo(assertions), getActual(assertions), new Object[] { "Yoda", "Luke" }); } } AbstractAssert_isNotInstanceOfAny_Test.java000066400000000000000000000026161243020563200355250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isNotInstanceOfAny(Class...)}. * * @author Nicolas François */ public class AbstractAssert_isNotInstanceOfAny_Test extends AbstractAssertBaseTest { private final Class[] types = { String.class, Object.class }; @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotInstanceOfAny(types); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotInstanceOfAny(getInfo(assertions), getActual(assertions), types); } } AbstractAssert_isNotInstanceOf_Test.java000066400000000000000000000025121243020563200350500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isNotInstanceOf(Class)}. * * @author Nicolas François */ public class AbstractAssert_isNotInstanceOf_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotInstanceOf(String.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotInstanceOf(getInfo(assertions), getActual(assertions), String.class); } } AbstractAssert_isNotNull_Test.java000066400000000000000000000024151243020563200337330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isNotNull()}. * * @author Alex Ruiz */ public class AbstractAssert_isNotNull_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotNull(); } @Override protected void verify_internal_effects() { verify(objects).assertNotNull(getInfo(assertions), getActual(assertions)); } }AbstractAssert_isNotOfAnyClassIn_Test.java000066400000000000000000000026201243020563200353100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import java.io.File; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isNotOfAnyClassIn(Class...)}. * * @author Nicolas François */ public class AbstractAssert_isNotOfAnyClassIn_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotOfAnyClassIn(Long.class, File.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsNotOfAnyClassIn(getInfo(assertions), getActual(assertions), new Class[] { Long.class, File.class }); } } AbstractAssert_isNotSameAs_Test.java000066400000000000000000000024661243020563200342000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isNotSameAs(Object)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class AbstractAssert_isNotSameAs_Test extends AbstractAssertBaseTest{ @Override protected ConcreteAssert invoke_api_method() { return assertions.isNotSameAs(8L); } @Override protected void verify_internal_effects() { verify(objects).assertNotSame(getInfo(assertions), getActual(assertions), 8L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/AbstractAssert_isNot_Test.java000066400000000000000000000030531243020563200331560ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#isNot(Condition)}. * * @author Alex Ruiz */ public class AbstractAssert_isNot_Test extends AbstractAssertBaseTest { private static Condition condition; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Override protected ConcreteAssert invoke_api_method() { return assertions.isNot(condition); } @Override protected void verify_internal_effects() { verify(conditions).assertIsNot(getInfo(assertions), getActual(assertions), condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/AbstractAssert_isNull_Test.java000066400000000000000000000027361243020563200333370ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.junit.Test; /** * Tests for {@link AbstractAssert#isNull()}. * * @author Alex Ruiz */ public class AbstractAssert_isNull_Test extends AbstractAssertBaseTest{ @Test public void should_verify_that_actual_value_is_null() { } @Override protected ConcreteAssert invoke_api_method() { assertions.isNull(); return null; } @Override protected void verify_internal_effects() { verify(objects).assertNull(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isNull method is void. } } AbstractAssert_isOfAnyClassIn_Test.java000066400000000000000000000026101243020563200346260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import java.io.File; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.api.ObjectAssert; /** * Tests for {@link ObjectAssert#isOfAnyClassIn(Class...)}. * * @author Nicolas François */ public class AbstractAssert_isOfAnyClassIn_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isOfAnyClassIn(String.class, File.class); } @Override protected void verify_internal_effects() { verify(objects).assertIsOfAnyClassIn(getInfo(assertions), getActual(assertions), new Class[] { String.class, File.class }); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/AbstractAssert_isSameAs_Test.java000066400000000000000000000024231243020563200335670ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#isSameAs(Object)}. * * @author Alex Ruiz */ public class AbstractAssert_isSameAs_Test extends AbstractAssertBaseTest { @Override protected ConcreteAssert invoke_api_method() { return assertions.isSameAs(8L); } @Override protected void verify_internal_effects() { verify(objects).assertSame(getInfo(assertions), getActual(assertions), 8L); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/AbstractAssert_is_Test.java000066400000000000000000000030371243020563200324770ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.AbstractAssertBaseTest; import org.fest.assertions.api.ConcreteAssert; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractAssert#is(Condition)}. * * @author Alex Ruiz */ public class AbstractAssert_is_Test extends AbstractAssertBaseTest { private static Condition condition; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Override protected ConcreteAssert invoke_api_method() { return assertions.is(condition); } @Override protected void verify_internal_effects() { verify(conditions).assertIs(getInfo(assertions), getActual(assertions), condition); } } AbstractAssert_overridingErrorMessage_Test.java000066400000000000000000000054371243020563200365020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/abstract_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.abstract_; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertSame; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import org.junit.Before; import org.junit.Test; import org.fest.assertions.api.AbstractAssert; import org.fest.assertions.api.ConcreteAssert; /** * Tests for {@link AbstractAssert#overridingErrorMessage(String, Object...)}. * * @author Joel Costigliola */ public class AbstractAssert_overridingErrorMessage_Test { private ConcreteAssert assertions; @Before public void setUp() { assertions = new ConcreteAssert(6L); } @Test public void should_pass_with_error_message_overriden() { assertions.overridingErrorMessage("new error message").isEqualTo(6L); } @Test public void should_fail_with_overriden_error_message() { try { assertions.overridingErrorMessage("new error message").isEqualTo(8L); } catch (AssertionError err) { assertEquals("new error message", err.getMessage()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_with_overriden_error_message_using_string_format_feature() { try { long expected = 8L; assertions.overridingErrorMessage("new error message, expected value was : '%s'", expected).isEqualTo(expected); } catch (AssertionError err) { assertEquals("new error message, expected value was : '8'", err.getMessage()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_with_description_and_overriden_error_message_using_string_format_feature() { try { long expected = 8L; assertions.as("test").overridingErrorMessage("new error message, expected value was : '%s'", expected).isEqualTo(expected); } catch (AssertionError err) { assertEquals("[test] new error message, expected value was : '8'", err.getMessage()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_return_this() { assertSame(assertions, assertions.overridingErrorMessage("")); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/000077500000000000000000000000001243020563200253305ustar00rootroot00000000000000BigDecimalAssert_isEqualByComparingToWithStringParameter_Test.java000066400000000000000000000025771243020563200422750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isEqualByComparingTo(String)}. * * @author Joel Costigliola */ public class BigDecimalAssert_isEqualByComparingToWithStringParameter_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isEqualByComparingTo(ONE_AS_STRING); } @Override protected void verify_internal_effects() { verify(comparables).assertEqualByComparison(getInfo(assertions), getActual(assertions), new BigDecimal(ONE_AS_STRING)); } } BigDecimalAssert_isEqualToWithStringParameter_Test.java000066400000000000000000000025161243020563200401330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isEqualTo(String)}. * * @author Joel Costigliola */ public class BigDecimalAssert_isEqualToWithStringParameter_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isEqualTo(ONE_AS_STRING); } @Override protected void verify_internal_effects() { verify(objects).assertEqual(getInfo(assertions), getActual(assertions), new BigDecimal(ONE_AS_STRING)); } } BigDecimalAssert_isNegative_Test.java000066400000000000000000000023601243020563200344340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isNegative()}. * * @author Alex Ruiz */ public class BigDecimalAssert_isNegative_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsNegative(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_isNotNegative_Test.java000066400000000000000000000024121243020563200351130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011-2012 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isNotNegative()}. * * @author Nicolas François */ public class BigDecimalAssert_isNotNegative_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_isNotPositive_Test.java000066400000000000000000000024121243020563200351530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011-2012 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isNotPositive()}. * * @author Nicolas François */ public class BigDecimalAssert_isNotPositive_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_isNotZero_Test.java000066400000000000000000000023561243020563200342770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isNotZero()}. * * @author Yvonne Wang */ public class BigDecimalAssert_isNotZero_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_isPositive_Test.java000066400000000000000000000023621243020563200344760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isPositive()}. * * @author Yvonne Wang */ public class BigDecimalAssert_isPositive_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsPositive(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_isZero_Test.java000066400000000000000000000023421243020563200336110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Jan 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; /** * Tests for {@link BigDecimalAssert#isZero()}. * * @author Yvonne Wang */ public class BigDecimalAssert_isZero_Test extends BigDecimalAssertBaseTest { @Override protected BigDecimalAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(bigDecimals).assertIsZero(getInfo(assertions), getActual(assertions)); } } BigDecimalAssert_usingComparator_Test.java000066400000000000000000000034111243020563200355110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.math.BigDecimal; import java.util.Comparator; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link BigDecimalAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BigDecimalAssert_usingComparator_Test extends BigDecimalAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected BigDecimalAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getBigDecimals(assertions).getComparator(), comparator); } } BigDecimalAssert_usingDefaultComparator_Test.java000066400000000000000000000034201243020563200370160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bigdecimal/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bigdecimal; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.math.BigDecimal; import java.util.Comparator; import org.fest.assertions.api.BigDecimalAssert; import org.fest.assertions.api.BigDecimalAssertBaseTest; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link BigDecimalAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BigDecimalAssert_usingDefaultComparator_Test extends BigDecimalAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected BigDecimalAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getBigDecimals(assertions), BigDecimals.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/000077500000000000000000000000001243020563200250265ustar00rootroot00000000000000BooleanAssert_isEqualTo_boolean_Test.java000066400000000000000000000023621243020563200350420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; /** * Tests for {@link BooleanAssert#isEqualTo(boolean)}. * * @author Alex Ruiz */ public class BooleanAssert_isEqualTo_boolean_Test extends BooleanAssertBaseTest { @Override protected BooleanAssert invoke_api_method() { return assertions.isEqualTo(false); } @Override protected void verify_internal_effects() { verify(booleans).assertEqual(getInfo(assertions), getActual(assertions), false); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/BooleanAssert_isFalse_Test.java000066400000000000000000000023301243020563200330750ustar00rootroot00000000000000/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; /** * Tests for {@link BooleanAssert#isFalse()}. * * @author Alex Ruiz */ public class BooleanAssert_isFalse_Test extends BooleanAssertBaseTest { @Override protected BooleanAssert invoke_api_method() { return assertions.isFalse(); } @Override protected void verify_internal_effects() { verify(booleans).assertEqual(getInfo(assertions), getActual(assertions), false); } } BooleanAssert_isNotEqualTo_boolean_Test.java000066400000000000000000000023761243020563200355300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; /** * Tests for {@link BooleanAssert#isNotEqualTo(boolean)}. * * @author Alex Ruiz */ public class BooleanAssert_isNotEqualTo_boolean_Test extends BooleanAssertBaseTest { @Override protected BooleanAssert invoke_api_method() { return assertions.isNotEqualTo(false); } @Override protected void verify_internal_effects() { verify(booleans).assertNotEqual(getInfo(assertions), getActual(assertions), false); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/BooleanAssert_isTrue_Test.java000066400000000000000000000023241243020563200327650ustar00rootroot00000000000000/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; /** * Tests for {@link BooleanAssert#isTrue()}. * * @author Alex Ruiz */ public class BooleanAssert_isTrue_Test extends BooleanAssertBaseTest { @Override protected BooleanAssert invoke_api_method() { return assertions.isTrue(); } @Override protected void verify_internal_effects() { verify(booleans).assertEqual(getInfo(assertions), getActual(assertions), true); } } BooleanAssert_usingComparator_Test.java000066400000000000000000000040011243020563200346020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; import org.fest.assertions.test.ExpectedException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; /** * Tests for {@link BooleanAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class BooleanAssert_usingComparator_Test extends BooleanAssertBaseTest { @Rule public ExpectedException thrown = none(); @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override @Test public void should_have_internal_effects() { thrown.expect(UnsupportedOperationException.class); // in that, we don't care of the comparator, the point to check is that we can't use a comparator assertions.usingComparator(comparator); } @Override @Test public void should_return_this() { // Disabled since this method throws an exception } @Override protected BooleanAssert invoke_api_method() { // Not used in this test return null; } @Override protected void verify_internal_effects() { // Not used in this test } } BooleanAssert_usingDefaultComparator_Test.java000066400000000000000000000025671243020563200361260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/boolean_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.boolean_; import static junit.framework.Assert.assertSame; import org.fest.assertions.api.BooleanAssert; import org.fest.assertions.api.BooleanAssertBaseTest; import org.fest.assertions.internal.Objects; /** * Tests for {@link BooleanAssert#usingComparator(java.util.Comparator)} and * {@link BooleanAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class BooleanAssert_usingDefaultComparator_Test extends BooleanAssertBaseTest { @Override protected BooleanAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/000077500000000000000000000000001243020563200257265ustar00rootroot00000000000000BooleanArrayAssert_containsOnly_Test.java000066400000000000000000000025601243020563200360140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#containsOnly(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_containsOnly_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.containsOnly(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_containsSequence_Test.java000066400000000000000000000026001243020563200366360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#containsSequence(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_containsSequence_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.containsSequence(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_contains_Test.java000066400000000000000000000025401243020563200351500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#contains(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_contains_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.contains(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_contains_at_Index_Test.java000066400000000000000000000026641243020563200367720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link BooleanArrayAssert#contains(boolean, Index)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_contains_at_Index_Test extends BooleanArrayAssertBaseTest { private final Index index = someIndex(); @Override protected BooleanArrayAssert invoke_api_method() { return assertions.contains(true, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), true, index); } } BooleanArrayAssert_doesNotContain_Test.java000066400000000000000000000025701243020563200362640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#doesNotContain(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_doesNotContain_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.doesNotContain(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000027141243020563200400770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link BooleanArrayAssert#doesNotContain(boolean, Index)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_doesNotContain_at_Index_Test extends BooleanArrayAssertBaseTest { private final Index index = someIndex(); @Override protected BooleanArrayAssert invoke_api_method() { return assertions.doesNotContain(true, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), true, index); } } BooleanArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024531243020563200375720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class BooleanArrayAssert_doesNotHaveDuplicates_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } BooleanArrayAssert_endsWith_Test.java000066400000000000000000000025401243020563200351170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#endsWith(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_endsWith_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.endsWith(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026751243020563200402340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class BooleanArrayAssert_hasSameSizeAs_with_Array_Test extends BooleanArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected BooleanArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } BooleanArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027531243020563200407020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class BooleanArrayAssert_hasSameSizeAs_with_Iterable_Test extends BooleanArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected BooleanArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } BooleanArrayAssert_hasSize_Test.java000066400000000000000000000024401243020563200347370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_hasSize_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } BooleanArrayAssert_isEmpty_Test.java000066400000000000000000000026551243020563200347730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link BooleanArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class BooleanArrayAssert_isEmpty_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isEmpty is void } } BooleanArrayAssert_isNotEmpty_Test.java000066400000000000000000000024431243020563200354470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class BooleanArrayAssert_isNotEmpty_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } BooleanArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026351243020563200361250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link BooleanArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class BooleanArrayAssert_isNullOrEmpty_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isNullOrEmpty is void } } BooleanArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031261243020563200412740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link BooleanArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class BooleanArrayAssert_isSortedAccordingToComparator_Test extends BooleanArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected BooleanArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } BooleanArrayAssert_isSorted_Test.java000066400000000000000000000023761243020563200351350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class BooleanArrayAssert_isSorted_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } BooleanArrayAssert_startsWith_Test.java000066400000000000000000000025501243020563200355070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Dec 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; /** * Tests for {@link BooleanArrayAssert#startsWith(boolean...)}. * * @author Alex Ruiz */ public class BooleanArrayAssert_startsWith_Test extends BooleanArrayAssertBaseTest { @Override protected BooleanArrayAssert invoke_api_method() { return assertions.startsWith(true, false); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(true, false)); } } BooleanArrayAssert_usingComparator_Test.java000066400000000000000000000035541243020563200365150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.internal.BooleanArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link BooleanArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BooleanArrayAssert_usingComparator_Test extends BooleanArrayAssertBaseTest { @Mock private Comparator comparator; private BooleanArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected BooleanArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } BooleanArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000035041243020563200400150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link BooleanArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BooleanArrayAssert_usingDefaultComparator_Test extends BooleanArrayAssertBaseTest { @Mock private Comparator comparator; private BooleanArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected BooleanArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } BooleanArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000034201243020563200413240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.ExpectedException.none; import java.util.Comparator; import org.junit.Rule; import org.junit.Test; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.test.ExpectedException; /** * Tests for {@link BooleanArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BooleanArrayAssert_usingDefaultElementComparator_Test extends BooleanArrayAssertBaseTest { @Rule public ExpectedException thrown = none(); @Override @Test public void should_have_internal_effects() { thrown.expect(UnsupportedOperationException.class); assertions.usingDefaultElementComparator(); } @Override @Test public void should_return_this() { // Disabled since this method throws an exception } @Override protected BooleanArrayAssert invoke_api_method() { // Not used in this test return null; } @Override protected void verify_internal_effects() { // Not used in this test } } BooleanArrayAssert_usingElementComparator_Test.java000066400000000000000000000036751243020563200400330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/booleanarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.booleanarray; import static org.fest.assertions.test.ExpectedException.none; import java.util.Comparator; import org.fest.assertions.api.BooleanArrayAssert; import org.fest.assertions.api.BooleanArrayAssertBaseTest; import org.fest.assertions.test.ExpectedException; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; /** * Tests for {@link BooleanArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class BooleanArrayAssert_usingElementComparator_Test extends BooleanArrayAssertBaseTest { @Rule public ExpectedException thrown = none(); @Mock private Comparator comparator; @Override @Test public void should_have_internal_effects() { thrown.expect(UnsupportedOperationException.class); // in that, we don't care of the comparator, the point to check is that we can't use a comparator assertions.usingElementComparator(comparator); } @Override @Test public void should_return_this() { // Disabled since this method throws an exception } @Override protected BooleanArrayAssert invoke_api_method() { // Not used in this test return null; } @Override protected void verify_internal_effects() { // Not used in this test } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/000077500000000000000000000000001243020563200243525ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isEqualTo_byte_Test.java000066400000000000000000000023321243020563200333120ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isEqualTo(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isEqualTo_byte_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isEqualTo((byte) 8); } @Override protected void verify_internal_effects() { verify(bytes).assertEqual(getInfo(assertions), getActual(assertions), (byte) 8); } } ByteAssert_isGreaterThanOrEqualTo_byte_Test.java000066400000000000000000000024201243020563200356570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isGreaterThanOrEqualTo(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isGreaterThanOrEqualTo_byte_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo((byte) 6); } @Override protected void verify_internal_effects() { verify(bytes).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), (byte) 6); } } ByteAssert_isGreaterThan_byte_Test.java000066400000000000000000000023541243020563200340710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isGreaterThan(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isGreaterThan_byte_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isGreaterThan((byte) 6); } @Override protected void verify_internal_effects() { verify(bytes).assertGreaterThan(getInfo(assertions), getActual(assertions), (byte) 6); } } ByteAssert_isLessThanOrEqualTo_long_Test.java000066400000000000000000000024041243020563200351720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isLessThanOrEqualTo(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isLessThanOrEqualTo_long_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isLessThanOrEqualTo((byte) 8); } @Override protected void verify_internal_effects() { verify(bytes).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), (byte) 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isLessThan_byte_Test.java000066400000000000000000000023401243020563200334600ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isLessThan(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isLessThan_byte_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isLessThan((byte) 8); } @Override protected void verify_internal_effects() { verify(bytes).assertLessThan(getInfo(assertions), getActual(assertions), (byte) 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isNegative_Test.java000066400000000000000000000023071243020563200324610ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isNegative()}. * * @author Alex Ruiz */ public class ByteAssert_isNegative_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsNegative(getInfo(assertions), getActual(assertions)); } } ByteAssert_isNotEqualTo_byte_Test.java000066400000000000000000000023461243020563200337210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isNotEqualTo(byte)}. * * @author Alex Ruiz */ public class ByteAssert_isNotEqualTo_byte_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isNotEqualTo((byte) 8); } @Override protected void verify_internal_effects() { verify(bytes).assertNotEqual(getInfo(assertions), getActual(assertions), (byte) 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isNotNegative_Test.java000066400000000000000000000023331243020563200331410ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isNotNegative()}. * * @author Nicolas François */ public class ByteAssert_isNotNegative_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isNotPositive_Test.java000066400000000000000000000023331243020563200332010ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isNotPositive()}. * * @author Nicolas François */ public class ByteAssert_isNotPositive_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isNotZero_Test.java000066400000000000000000000023031243020563200323130ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isNotZero()}. * * @author Alex Ruiz */ public class ByteAssert_isNotZero_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isPositive_Test.java000066400000000000000000000023071243020563200325210ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isPositive()}. * * @author Alex Ruiz */ public class ByteAssert_isPositive_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_isZero_Test.java000066400000000000000000000022671243020563200316430ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; /** * Tests for {@link ByteAssert#isZero()}. * * @author Alex Ruiz */ public class ByteAssert_isZero_Test extends ByteAssertBaseTest { @Override protected ByteAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(bytes).assertIsZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/ByteAssert_usingComparator_Test.java000066400000000000000000000032331243020563200335370ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class ByteAssert_usingComparator_Test extends ByteAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ByteAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getBytes(assertions).getComparator(), comparator); } } ByteAssert_usingDefaultComparator_Test.java000066400000000000000000000032261243020563200347670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/byte_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.byte_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteAssert; import org.fest.assertions.api.ByteAssertBaseTest; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class ByteAssert_usingDefaultComparator_Test extends ByteAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected ByteAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getBytes(assertions), Bytes.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/000077500000000000000000000000001243020563200252525ustar00rootroot00000000000000ByteArrayAssert_containsOnly_Test.java000066400000000000000000000025251243020563200346650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#containsOnly(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_containsOnly_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.containsOnly((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_containsSequence_Test.java000066400000000000000000000025451243020563200355160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#containsSequence(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_containsSequence_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.containsSequence((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_contains_Test.java000066400000000000000000000025051243020563200340210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#contains(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_contains_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.contains((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_contains_at_Index_Test.java000066400000000000000000000026361243020563200356410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ByteArrayAssert#contains(byte, Index)}. * * @author Alex Ruiz */ public class ByteArrayAssert_contains_at_Index_Test extends ByteArrayAssertBaseTest { private Index index = someIndex(); @Override protected ByteArrayAssert invoke_api_method() { return assertions.contains((byte) 8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), (byte) 8, index); } } ByteArrayAssert_doesNotContain_Test.java000066400000000000000000000025351243020563200351350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#doesNotContain(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_doesNotContain_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.doesNotContain((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026741243020563200367540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ByteArrayAssert#doesNotContain(byte, Index)}. * * @author Alex Ruiz */ public class ByteArrayAssert_doesNotContain_at_Index_Test extends ByteArrayAssertBaseTest { private final Index index = someIndex(); @Override protected ByteArrayAssert invoke_api_method() { return assertions.doesNotContain((byte) 8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), (byte) 8, index); } } ByteArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024261243020563200364420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class ByteArrayAssert_doesNotHaveDuplicates_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } ByteArrayAssert_endsWith_Test.java000066400000000000000000000025051243020563200337700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#endsWith(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_endsWith_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.endsWith((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026501243020563200370750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class ByteArrayAssert_hasSameSizeAs_with_Array_Test extends ByteArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected ByteArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } ByteArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027261243020563200375520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class ByteArrayAssert_hasSameSizeAs_with_Iterable_Test extends ByteArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected ByteArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/ByteArrayAssert_hasSize_Test.java000066400000000000000000000024131243020563200336660ustar00rootroot00000000000000/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class ByteArrayAssert_hasSize_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/ByteArrayAssert_isEmpty_Test.java000066400000000000000000000026301243020563200337130ustar00rootroot00000000000000/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ByteArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class ByteArrayAssert_isEmpty_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isEmpty is void } } ByteArrayAssert_isNotEmpty_Test.java000066400000000000000000000024161243020563200343170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class ByteArrayAssert_isNotEmpty_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } ByteArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026101243020563200347660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ByteArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class ByteArrayAssert_isNullOrEmpty_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isNullOrEmpty is void } } ByteArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000030761243020563200401500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class ByteArrayAssert_isSortedAccordingToComparator_Test extends ByteArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ByteArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } ByteArrayAssert_isSorted_Test.java000066400000000000000000000023511243020563200337760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class ByteArrayAssert_isSorted_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } ByteArrayAssert_startsWith_Test.java000066400000000000000000000025151243020563200343600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Dec 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; /** * Tests for {@link ByteArrayAssert#startsWith(byte...)}. * * @author Alex Ruiz */ public class ByteArrayAssert_startsWith_Test extends ByteArrayAssertBaseTest { @Override protected ByteArrayAssert invoke_api_method() { return assertions.startsWith((byte) 6, (byte) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ByteArrayAssert_usingComparator_Test.java000066400000000000000000000035161243020563200353630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.internal.ByteArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ByteArrayAssert_usingComparator_Test extends ByteArrayAssertBaseTest { @Mock private Comparator comparator; private ByteArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected ByteArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } ByteArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034461243020563200366720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ByteArrayAssert_usingDefaultComparator_Test extends ByteArrayAssertBaseTest { @Mock private Comparator comparator; private ByteArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected ByteArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } ByteArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035041243020563200401770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ByteArrayAssert_usingDefaultElementComparator_Test extends ByteArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected ByteArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), ByteArrays.instance()); } } ByteArrayAssert_usingElementComparator_Test.java000066400000000000000000000035251243020563200366750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/bytearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.bytearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ByteArrayAssert; import org.fest.assertions.api.ByteArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ByteArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ByteArrayAssert_usingElementComparator_Test extends ByteArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected ByteArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/000077500000000000000000000000001243020563200252045ustar00rootroot00000000000000CharacterAssert_isEqualTo_char_Test.java000066400000000000000000000023671243020563200350400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isEqualTo(char)}. * * @author Alex Ruiz */ public class CharacterAssert_isEqualTo_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isEqualTo('b'); } @Override protected void verify_internal_effects() { verify(characters).assertEqual(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isGreaterThanOrEqualTo_char_Test.java000066400000000000000000000024521243020563200374610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 16, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isGreaterThanOrEqualTo(char)}. * * @author Yvonne Wang */ public class CharacterAssert_isGreaterThanOrEqualTo_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo('b'); } @Override protected void verify_internal_effects() { verify(characters).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isGreaterThan_char_Test.java000066400000000000000000000024061243020563200356640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 16, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isGreaterThan(char)}. * * @author Yvonne Wang */ public class CharacterAssert_isGreaterThan_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isGreaterThan('b'); } @Override protected void verify_internal_effects() { verify(characters).assertGreaterThan(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isLessThanOrEqualTo_char_Test.java000066400000000000000000000024361243020563200370000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 16, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isLessThanOrEqualTo(char)}. * * @author Yvonne Wang */ public class CharacterAssert_isLessThanOrEqualTo_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isLessThanOrEqualTo('b'); } @Override protected void verify_internal_effects() { verify(characters).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isLessThan_char_Test.java000066400000000000000000000023721243020563200352030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 16, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isLessThan(char)}. * * @author Yvonne Wang */ public class CharacterAssert_isLessThan_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isLessThan('b'); } @Override protected void verify_internal_effects() { verify(characters).assertLessThan(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isLowerCase_Test.java000066400000000000000000000023551243020563200343520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isLowerCase()}. * * @author Yvonne Wang */ public class CharacterAssert_isLowerCase_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isLowerCase(); } @Override protected void verify_internal_effects() { verify(characters).assertLowerCase(getInfo(assertions), getActual(assertions)); } } CharacterAssert_isNotEqualTo_char_Test.java000066400000000000000000000024031243020563200355100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isNotEqualTo(char)}. * * @author Alex Ruiz */ public class CharacterAssert_isNotEqualTo_char_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isNotEqualTo('b'); } @Override protected void verify_internal_effects() { verify(characters).assertNotEqual(getInfo(assertions), getActual(assertions), 'b'); } } CharacterAssert_isUpperCase_Test.java000066400000000000000000000023551243020563200343550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.character; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; /** * Tests for {@link CharacterAssert#isUpperCase()}. * * @author Yvonne Wang */ public class CharacterAssert_isUpperCase_Test extends CharacterAssertBaseTest { @Override protected CharacterAssert invoke_api_method() { return assertions.isUpperCase(); } @Override protected void verify_internal_effects() { verify(characters).assertUpperCase(getInfo(assertions), getActual(assertions)); } } CharacterAssert_usingComparator_Test.java000066400000000000000000000033071243020563200353050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.character; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharacterAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class CharacterAssert_usingComparator_Test extends CharacterAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected CharacterAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getCharacters(assertions).getComparator(), comparator); } } CharacterAssert_usingDefaultComparator_Test.java000066400000000000000000000033141243020563200366100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/character/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.character; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharacterAssert; import org.fest.assertions.api.CharacterAssertBaseTest; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharacterAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class CharacterAssert_usingDefaultComparator_Test extends CharacterAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected CharacterAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getCharacters(assertions), Characters.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/000077500000000000000000000000001243020563200252245ustar00rootroot00000000000000CharArrayAssert_containsOnly_Test.java000066400000000000000000000025171243020563200346120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#containsOnly(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_containsOnly_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.containsOnly('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_containsSequence_Test.java000066400000000000000000000025371243020563200354430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#containsSequence(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_containsSequence_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.containsSequence('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_contains_Test.java000066400000000000000000000024771243020563200337550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#contains(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_contains_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.contains('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_contains_at_Index_Test.java000066400000000000000000000026311243020563200355600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link CharArrayAssert#contains(char, Index)}. * * @author Alex Ruiz */ public class CharArrayAssert_contains_at_Index_Test extends CharArrayAssertBaseTest { private final Index index = someIndex(); @Override protected CharArrayAssert invoke_api_method() { return assertions.contains('a', index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), 'a', index); } } CharArrayAssert_doesNotContain_Test.java000066400000000000000000000025271243020563200350620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#doesNotContain(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_doesNotContain_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.doesNotContain('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026621243020563200366750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link CharArrayAssert#doesNotContain(char, Index)}. * * @author Alex Ruiz */ public class CharArrayAssert_doesNotContain_at_Index_Test extends CharArrayAssertBaseTest { private final Index index = someIndex(); @Override protected CharArrayAssert invoke_api_method() { return assertions.doesNotContain('a', index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), 'a', index); } } CharArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024261243020563200363660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class CharArrayAssert_doesNotHaveDuplicates_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } CharArrayAssert_endsWith_Test.java000066400000000000000000000024771243020563200337240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#endsWith(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_endsWith_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.endsWith('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026501243020563200370210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class CharArrayAssert_hasSameSizeAs_with_Array_Test extends CharArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected CharArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } CharArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027261243020563200374760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class CharArrayAssert_hasSameSizeAs_with_Iterable_Test extends CharArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected CharArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/CharArrayAssert_hasSize_Test.java000066400000000000000000000024131243020563200336120ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class CharArrayAssert_hasSize_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/CharArrayAssert_isEmpty_Test.java000066400000000000000000000026301243020563200336370ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link CharArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class CharArrayAssert_isEmpty_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isEmpty is void } } CharArrayAssert_isNotEmpty_Test.java000066400000000000000000000024161243020563200342430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class CharArrayAssert_isNotEmpty_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } CharArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026101243020563200347120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link CharArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class CharArrayAssert_isNullOrEmpty_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isNullOrEmpty is void } } CharArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031031243020563200400630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class CharArrayAssert_isSortedAccordingToComparator_Test extends CharArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected CharArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } CharArrayAssert_isSorted_Test.java000066400000000000000000000023511243020563200337220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class CharArrayAssert_isSorted_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } CharArrayAssert_startsWith_Test.java000066400000000000000000000025071243020563200343050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; /** * Tests for {@link CharArrayAssert#startsWith(char...)}. * * @author Alex Ruiz */ public class CharArrayAssert_startsWith_Test extends CharArrayAssertBaseTest { @Override protected CharArrayAssert invoke_api_method() { return assertions.startsWith('a', 'b'); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf('a', 'b')); } } CharArrayAssert_usingComparator_Test.java000066400000000000000000000035161243020563200353070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.internal.CharArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class CharArrayAssert_usingComparator_Test extends CharArrayAssertBaseTest { @Mock private Comparator comparator; private CharArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected CharArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } CharArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034461243020563200366160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class CharArrayAssert_usingDefaultComparator_Test extends CharArrayAssertBaseTest { @Mock private Comparator comparator; private CharArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected CharArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } CharArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035111243020563200401210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class CharArrayAssert_usingDefaultElementComparator_Test extends CharArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected CharArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), CharArrays.instance()); } } CharArrayAssert_usingElementComparator_Test.java000066400000000000000000000035321243020563200366170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/chararray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.chararray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.CharArrayAssert; import org.fest.assertions.api.CharArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link CharArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class CharArrayAssert_usingElementComparator_Test extends CharArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected CharArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/comparable/000077500000000000000000000000001243020563200253555ustar00rootroot00000000000000AbstractComparableAssert_isGreaterThanOrEqualTo_Test.java000066400000000000000000000026331243020563200404730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/comparable/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.comparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractComparableAssert; import org.fest.assertions.api.AbstractComparableAssertBaseTest; import org.fest.assertions.api.ConcreteComparableAssert; /** * Tests for {@link AbstractComparableAssert#isGreaterThanOrEqualTo(Comparable)}. * * @author Alex Ruiz */ public class AbstractComparableAssert_isGreaterThanOrEqualTo_Test extends AbstractComparableAssertBaseTest { @Override protected ConcreteComparableAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo(6); } @Override protected void verify_internal_effects() { verify(comparables).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 6); } } AbstractComparableAssert_isGreaterThan_Test.java000066400000000000000000000025661243020563200367040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/comparable/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.comparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractComparableAssert; import org.fest.assertions.api.AbstractComparableAssertBaseTest; import org.fest.assertions.api.ConcreteComparableAssert; /** * Tests for {@link AbstractComparableAssert#isGreaterThan(Comparable)}. * * @author Alex Ruiz */ public class AbstractComparableAssert_isGreaterThan_Test extends AbstractComparableAssertBaseTest { @Override protected ConcreteComparableAssert invoke_api_method() { return assertions.isGreaterThan(6); } @Override protected void verify_internal_effects() { verify(comparables).assertGreaterThan(getInfo(assertions), getActual(assertions), 6); } } AbstractComparableAssert_isLessThanOrEqualTo_Test.java000066400000000000000000000026171243020563200400120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/comparable/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.comparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractComparableAssert; import org.fest.assertions.api.AbstractComparableAssertBaseTest; import org.fest.assertions.api.ConcreteComparableAssert; /** * Tests for {@link AbstractComparableAssert#isLessThanOrEqualTo(Comparable)}. * * @author Alex Ruiz */ public class AbstractComparableAssert_isLessThanOrEqualTo_Test extends AbstractComparableAssertBaseTest { @Override protected ConcreteComparableAssert invoke_api_method() { return assertions.isLessThanOrEqualTo(8); } @Override protected void verify_internal_effects() { verify(comparables).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 8); } } AbstractComparableAssert_isLessThan_Test.java000066400000000000000000000025531243020563200362150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/comparable/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.comparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractComparableAssert; import org.fest.assertions.api.AbstractComparableAssertBaseTest; import org.fest.assertions.api.ConcreteComparableAssert; /** * Tests for {@link AbstractComparableAssert#isLessThan(Comparable)}. * * @author Alex Ruiz */ public class AbstractComparableAssert_isLessThan_Test extends AbstractComparableAssertBaseTest { @Override protected ConcreteComparableAssert invoke_api_method() { return assertions.isLessThan(8); } @Override protected void verify_internal_effects() { verify(comparables).assertLessThan(getInfo(assertions), getActual(assertions), 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/000077500000000000000000000000001243020563200241655ustar00rootroot00000000000000AbstractDateAssertWithDateArg_Test.java000066400000000000000000000104511243020563200335600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/datepackage org.fest.assertions.api.date; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.assertSame; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.fest.assertions.internal.Dates; import org.fest.assertions.test.ExpectedException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; /** * * Abstract class that factorize DateAssert tests with a date arg (either Date or String based). *

* For the most part, date assertion tests are (whatever the concrete date assertion method invoked is) : *

    *
  • successfull assertion test with a date
  • *
  • successfull assertion test with a date as string following default date format
  • *
  • successfull assertion test with a date as string following custom date format
  • *
  • failed assertion test when date as string does not follow the expected date format
  • *
  • checking that DateAssert instance used for assertions is returned to allow fluent assertions chaining
  • *
* * Subclasses are expected to define the invoked assertion method. * * @author Joel Costigliola * */ public abstract class AbstractDateAssertWithDateArg_Test extends DateAssertBaseTest { protected Date otherDate; protected String dateAsStringWithDefaultFormat; protected String dateAsStringWithCustomFormat; protected String dateAsStringWithBadFormat; protected SimpleDateFormat customDateFormat; @Rule public ExpectedException thrown = none(); @Override @Before public void setUp() { super.setUp(); customDateFormat = new SimpleDateFormat("dd/MM/yyyy"); otherDate = new Date(); dateAsStringWithCustomFormat = "31/12/2000"; dateAsStringWithDefaultFormat = "2011-01-01"; dateAsStringWithBadFormat = "31/12/2000"; // expected format is "yyyy-MM-dd" } @Test public void should_verify_assertion_with_date_arg() { assertionInvocationWithDateArg(); verifyAssertionInvocation(otherDate); } @Test public void should_verify_assertion_with_date_arg_string_with_default_format() throws ParseException { assertionInvocationWithStringArg(dateAsStringWithDefaultFormat); verifyAssertionInvocation(dateFormat().parse(dateAsStringWithDefaultFormat)); } @Test public void should_verify_assertion_with_date_arg_string_following_custom_format() throws ParseException { assertions.withDateFormat(customDateFormat); assertionInvocationWithStringArg(dateAsStringWithCustomFormat); verifyAssertionInvocation(dateFormat().parse(dateAsStringWithCustomFormat)); assertions.withIsoDateFormat(); } @Test public void should_fail_because_date_string_representation_does_not_follow_expected_format() { thrown.expectAssertionError("Failed to parse " + dateAsStringWithBadFormat + " with date format " + dateFormat()); assertionInvocationWithStringArg(dateAsStringWithBadFormat); } @Test public void should_return_this() { DateAssert returned = assertionInvocationWithDateArg(); assertSame(assertions, returned); } /** * Overrides to invoke the {@link DateAssert} assertion method under test with the {@link #otherDate} attribute. *

* example with isBefore date assertion:
* assertions.isBefore(otherDate); * * @return the DateAssert instance called */ protected abstract DateAssert assertionInvocationWithDateArg(); /** * Overrides to invoke the {@link DateAssert} assertion method under test with the given date as String. *

* example with isBefore date assertion:
* assertions.isBefore(date); * * @param dateAsString a date in String based format * @return the DateAssert instance called */ protected abstract DateAssert assertionInvocationWithStringArg(String dateAsString); /** * Overrides to verify that the {@link Dates} assertion method was invoked with the given date. *

* example with isBefore date assertion:
* verify(dates).assertIsBefore(getInfo(assertions), getActual(assertions), date); * * @param date the given date (not the actual date !) */ protected abstract void verifyAssertionInvocation(Date date); } AbstractDateAssertWithOneIntArg_Test.java000066400000000000000000000037061243020563200341040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/datepackage org.fest.assertions.api.date; import static org.junit.Assert.assertSame; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.fest.assertions.internal.Dates; import org.junit.Before; import org.junit.Test; /** * * Abstract class that factorize DateAssert tests with an int arg. *

* For the most part, date assertion tests are (whatever the concrete date assertion method invoked is) : *

    *
  • successfull assertion test with an int
  • *
  • checking that DateAssert instance used for assertions is returned to allow fluent assertions chaining
  • *
* * Subclasses are expected to define what is the invoked assertion method. * * @author Joel Costigliola * */ public abstract class AbstractDateAssertWithOneIntArg_Test extends DateAssertBaseTest { protected int intArg; @Override @Before public void setUp() { super.setUp(); intArg = 5; } @Test public void should_verify_assertion_with_int_arg() { assertionInvocationWithOneIntArg(); verifyAssertionInvocation(); } @Test public void should_return_this() { DateAssert returned = assertionInvocationWithOneIntArg(); assertSame(assertions, returned); } /** * Must be overriden to invoke the {@link DateAssert} assertion method under test with the {@link #intArg} attribute. *

* example with isWithinMonth date assertion:
* assertions.isWithinMonth(5); * * @return the DateAssert instance called */ protected abstract DateAssert assertionInvocationWithOneIntArg(); /** * Must be overriden to verify that the {@link Dates} assertion method was invoked with the {@link #intArg} attribute. *

* example with isWithinMonth date assertion:
* verify(dates).isWithinMonth(getInfo(assertions), getActual(assertions), intArg); * */ protected abstract void verifyAssertionInvocation(); } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_hasTime_Test.java000066400000000000000000000026701243020563200315450ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.date; import static junit.framework.Assert.assertSame; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.junit.Test; /** * Tests for {@link DateAssert#hasTime(long)}. * * @author Guillaume Girou * @author Nicolas François */ public class DateAssert_hasTime_Test extends DateAssertBaseTest { @Test public void should_verify_that_actual_has_time_equals_to_expected() { assertions.hasTime(42L); verify(dates).assertHasTime(getInfo(assertions), getActual(assertions), 42L); } @Test public void should_return_this() { DateAssert returned = assertions.hasTime(42L); assertSame(assertions, returned); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isAfterOrEqualsTo_Test.java000066400000000000000000000026761243020563200335350ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isAfterOrEqualsTo(Date)}. * * @author Joel Costigliola */ public class DateAssert_isAfterOrEqualsTo_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isAfterOrEqualsTo(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isAfterOrEqualsTo(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsAfterOrEqualsTo(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isAfterYear_Test.java000066400000000000000000000023711243020563200323670ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isAfterYear(int)}. * * @author Joel Costigliola */ public class DateAssert_isAfterYear_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isAfterYear(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsAfterYear(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isAfter_Test.java000066400000000000000000000026141243020563200315460ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isAfter(Date)}. * * @author Joel Costigliola */ public class DateAssert_isAfter_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isAfter(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isAfter(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsAfter(getInfo(assertions), getActual(assertions), date); } } DateAssert_isBeforeOrEqualsTo_Test.java000066400000000000000000000027031243020563200336060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isBeforeOrEqualsTo(Date)}. * * @author Joel Costigliola */ public class DateAssert_isBeforeOrEqualsTo_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isBeforeOrEqualsTo(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isBeforeOrEqualsTo(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsBeforeOrEqualsTo(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isBeforeYear_Test.java000066400000000000000000000023751243020563200325340ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isBeforeYear(int)}. * * @author Joel Costigliola */ public class DateAssert_isBeforeYear_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isBeforeYear(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsBeforeYear(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isBefore_Test.java000066400000000000000000000026331243020563200317100ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isBefore(java.util.Date)}. * * @author Joel Costigliola */ public class DateAssert_isBefore_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isBefore(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isBefore(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsBefore(getInfo(assertions), getActual(assertions), date); } } DateAssert_isBetweenSpecifyingBoundariesInclusion_Test.java000066400000000000000000000035621243020563200377430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; import org.junit.Before; /** * Tests for {@link DateAssert#isBetween(Date, Date, boolean, boolean)} and * {@link DateAssert#isBetween(String, String, boolean, boolean)}. * * @author Joel Costigliola */ public class DateAssert_isBetweenSpecifyingBoundariesInclusion_Test extends AbstractDateAssertWithDateArg_Test { private boolean inclusiveStart; private boolean inclusiveEnd; @Override @Before public void setUp() { super.setUp(); inclusiveStart = false; inclusiveEnd = true; }; @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isBetween(otherDate, otherDate, inclusiveStart, inclusiveEnd); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isBetween(dateAsString, dateAsString, inclusiveStart, inclusiveEnd); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsBetween(getInfo(assertions), getActual(assertions), date, date, inclusiveStart, inclusiveEnd); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isBetween_Test.java000066400000000000000000000027741243020563200321050ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isBetween(Date, Date)} and {@link DateAssert#isBetween(String, String)}. * * @author Joel Costigliola */ public class DateAssert_isBetween_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isBetween(otherDate, otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isBetween(dateAsString, dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsBetween(getInfo(assertions), getActual(assertions), date, date, true, false); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isCloseTo_Test.java000066400000000000000000000031641243020563200320560ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; import org.junit.Before; /** * Tests for {@link DateAssert#isCloseTo(Date, long)} and {@link DateAssert#isCloseTo(String, long)}. * * @author Joel Costigliola */ public class DateAssert_isCloseTo_Test extends AbstractDateAssertWithDateArg_Test { private long delta; @Override @Before public void setUp() { super.setUp(); delta = 100; } @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isCloseTo(otherDate, delta); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isCloseTo(dateAsString, delta); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsCloseTo(getInfo(assertions), getActual(assertions), date, delta); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isEqualTo_Test.java000066400000000000000000000027001243020563200320530ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isEqualTo(Date)} and {@link DateAssert#isEqualTo(String)}. * * @author Joel Costigliola */ public class DateAssert_isEqualTo_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isEqualTo(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isEqualTo(dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertEqual(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInSameDayAs_Test.java000066400000000000000000000026521243020563200326050ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameDayAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameDayAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameDayAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameDayAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameDayAs(getInfo(assertions), getActual(assertions), date); } } DateAssert_isInSameHourOfDayAs_Test.java000066400000000000000000000026641243020563200336540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameHourAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameHourOfDayAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameHourAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameHourAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameHourAs(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInSameMinuteAs_Test.java000066400000000000000000000026711243020563200333320ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameMinuteAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameMinuteAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameMinuteAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameMinuteAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameMinuteAs(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInSameMonthAs_Test.java000066400000000000000000000026641243020563200331600ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameMonthAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameMonthAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameMonthAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameMonthAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameMonthAs(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInSameSecondAs_Test.java000066400000000000000000000026711243020563200333040ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameSecondAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameSecondAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameSecondAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameSecondAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameSecondAs(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInSameYearAs_Test.java000066400000000000000000000026571243020563200327750ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isInSameYearAs(Date)}. * * @author Joel Costigliola */ public class DateAssert_isInSameYearAs_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isInSameYearAs(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String date) { return assertions.isInSameYearAs(date); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsInSameYearAs(getInfo(assertions), getActual(assertions), date); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInTheFuture_Test.java000066400000000000000000000026321243020563200327070ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.junit.Assert.assertSame; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.junit.Test; /** * Tests for {@link DateAssert#isInTheFuture()}. * * @author Joel Costigliola */ public class DateAssert_isInTheFuture_Test extends DateAssertBaseTest { @Test public void should_verify_that_actual_is_in_the_past() { assertions.isInTheFuture(); verify(dates).assertIsInTheFuture(getInfo(assertions), getActual(assertions)); } @Test public void should_return_this() { DateAssert returned = assertions.isInTheFuture(); assertSame(assertions, returned); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isInThePast_Test.java000066400000000000000000000026201243020563200323410ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.junit.Assert.assertSame; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.junit.Test; /** * Tests for {@link DateAssert#isInThePast()}. * * @author Joel Costigliola */ public class DateAssert_isInThePast_Test extends DateAssertBaseTest { @Test public void should_verify_that_actual_is_in_the_past() { assertions.isInThePast(); verify(dates).assertIsInThePast(getInfo(assertions), getActual(assertions)); } @Test public void should_return_this() { DateAssert returned = assertions.isInThePast(); assertSame(assertions, returned); } } DateAssert_isIn_Test_with_collection_param.java000066400000000000000000000030761243020563200354250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isIn(java.util.Collection))} with Collection of Date or String. * * @author Joel Costigliola */ public class DateAssert_isIn_Test_with_collection_param extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isIn(newArrayList(otherDate)); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isInWithStringDateCollection(newArrayList(dateAsString)); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertIsIn(getInfo(assertions), getActual(assertions), newArrayList(date)); } } DateAssert_isIn_Test_with_vararg_param.java000066400000000000000000000027101243020563200345460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isIn(Object...)} with vararg of Date or String. * * @author Joel Costigliola */ public class DateAssert_isIn_Test_with_vararg_param extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isIn(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isIn(dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertIsIn(getInfo(assertions), getActual(assertions), new Object[] { date }); } } DateAssert_isNotBetweenSpecifyingBoundariesInclusion_Test.java000066400000000000000000000036041243020563200404210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; import org.junit.Before; /** * Tests for {@link DateAssert#isNotBetween(Date, Date, boolean, boolean)} and * {@link DateAssert#isNotBetween(String, String, boolean, boolean)}. * * @author Joel Costigliola */ public class DateAssert_isNotBetweenSpecifyingBoundariesInclusion_Test extends AbstractDateAssertWithDateArg_Test { private boolean inclusiveStart; private boolean inclusiveEnd; @Override @Before public void setUp() { super.setUp(); inclusiveStart = false; inclusiveEnd = true; }; @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isNotBetween(otherDate, otherDate, inclusiveStart, inclusiveEnd); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isNotBetween(dateAsString, dateAsString, inclusiveStart, inclusiveEnd); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsNotBetween(getInfo(assertions), getActual(assertions), date, date, inclusiveStart, inclusiveEnd); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isNotBetween_Test.java000066400000000000000000000030161243020563200325540ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isNotBetween(Date, Date)} and {@link DateAssert#isNotBetween(String, String)}. * * @author Joel Costigliola */ public class DateAssert_isNotBetween_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isNotBetween(otherDate, otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isNotBetween(dateAsString, dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(dates).assertIsNotBetween(getInfo(assertions), getActual(assertions), date, date, true, false); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isNotEqualTo_Test.java000066400000000000000000000027221243020563200325400ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isNotEqualTo(Date)} and {@link DateAssert#isNotEqualTo(String)}. * * @author Joel Costigliola */ public class DateAssert_isNotEqualTo_Test extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isNotEqualTo(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isNotEqualTo(dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertNotEqual(getInfo(assertions), getActual(assertions), date); } } DateAssert_isNotIn_Test_with_collection_param.java000066400000000000000000000031121243020563200360750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isIn(java.util.Collection))} with Collection of Date or String. * * @author Joel Costigliola */ public class DateAssert_isNotIn_Test_with_collection_param extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isNotIn(newArrayList(otherDate)); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isNotInWithStringDateCollection(newArrayList(dateAsString)); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertIsNotIn(getInfo(assertions), getActual(assertions), newArrayList(date)); } } DateAssert_isNotIn_Test_with_vararg_param.java000066400000000000000000000027241243020563200352340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import java.util.Date; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isIn(Object...)} with vararg of Date or String. * * @author Joel Costigliola */ public class DateAssert_isNotIn_Test_with_vararg_param extends AbstractDateAssertWithDateArg_Test { @Override protected DateAssert assertionInvocationWithDateArg() { return assertions.isNotIn(otherDate); } @Override protected DateAssert assertionInvocationWithStringArg(String dateAsString) { return assertions.isNotIn(dateAsString); } @Override protected void verifyAssertionInvocation(Date date) { verify(objects).assertIsNotIn(getInfo(assertions), getActual(assertions), new Object[] { date }); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isToday_Test.java000066400000000000000000000025661243020563200315730ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.junit.Assert.assertSame; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.junit.Test; /** * Tests for {@link DateAssert#isToday()}. * * @author Joel Costigliola */ public class DateAssert_isToday_Test extends DateAssertBaseTest { @Test public void should_verify_that_actual_is_today() { assertions.isToday(); verify(dates).assertIsToday(getInfo(assertions), getActual(assertions)); } @Test public void should_return_this() { DateAssert returned = assertions.isToday(); assertSame(assertions, returned); } } DateAssert_isWithinDayOfMonth_Test.java000066400000000000000000000024251243020563200336210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinDayOfMonth(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinDayOfMonth_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinDayOfMonth(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinDayOfMonth(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinDayOfWeek_Test.java000066400000000000000000000024211243020563200335020ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinDayOfWeek(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinDayOfWeek_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinDayOfWeek(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinDayOfWeek(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinHourOfDay_Test.java000066400000000000000000000024211243020563200335240ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinHourOfDay(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinHourOfDay_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinHourOfDay(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinHourOfDay(getInfo(assertions), getActual(assertions), intArg); } } DateAssert_isWithinMillisecond_Test.java000066400000000000000000000024311243020563200340500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinMillisecond(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinMillisecond_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinMillisecond(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinMillisecond(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinMinute_Test.java000066400000000000000000000024051243020563200331270ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinMinute(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinMinute_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinMinute(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinMinute(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinMonth_Test.java000066400000000000000000000024011243020563200327470ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinMonth(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinMonth_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinMonth(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinMonth(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinSecond_Test.java000066400000000000000000000024051243020563200331010ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinSecond(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinSecond_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinSecond(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinSecond(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_isWithinYear_Test.java000066400000000000000000000023751243020563200325740ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DateAssert; /** * Tests for {@link DateAssert#isWithinYear(int)}. * * @author Joel Costigliola */ public class DateAssert_isWithinYear_Test extends AbstractDateAssertWithOneIntArg_Test { @Override protected DateAssert assertionInvocationWithOneIntArg() { return assertions.isWithinYear(intArg); } @Override protected void verifyAssertionInvocation() { verify(dates).assertIsWithinYear(getInfo(assertions), getActual(assertions), intArg); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/date/DateAssert_usingComparator_Test.java000066400000000000000000000037631243020563200333340ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.date; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import java.util.Date; import org.fest.assertions.api.DateAssertBaseTest; import org.fest.assertions.api.DateAssert; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; /** * Tests for {@link DateAssert#usingComparator(java.util.Comparator)} and * {@link DateAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class DateAssert_usingComparator_Test extends DateAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Test public void using_default_comparator_test() { assertions.usingDefaultComparator(); assertSame(getObjects(assertions), Objects.instance()); assertSame(getDates(assertions), Dates.instance()); } @Test public void using_custom_comparator_test() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator assertions.usingComparator(comparator); assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getDates(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/000077500000000000000000000000001243020563200246615ustar00rootroot00000000000000DoubleAssert_isEqualTo_double_Test.java000066400000000000000000000023421243020563200343610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isEqualTo(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isEqualTo_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isEqualTo(8d); } @Override protected void verify_internal_effects() { verify(doubles).assertEqual(getInfo(assertions), getActual(assertions), 8d); } } DoubleAssert_isEqualTo_double_with_offset_Test.java000066400000000000000000000026301243020563200367620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.fest.assertions.data.Offset.offset; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; import org.fest.assertions.data.Offset; /** * Tests for {@link DoubleAssert#isEqualTo(double, Offset)}. * * @author Alex Ruiz */ public class DoubleAssert_isEqualTo_double_with_offset_Test extends DoubleAssertBaseTest { private final Offset offset = offset(5d); @Override protected DoubleAssert invoke_api_method() { return assertions.isEqualTo(8d, offset); } @Override protected void verify_internal_effects() { verify(doubles).assertEqual(getInfo(assertions), getActual(assertions), 8d, offset); } } DoubleAssert_isEqualTo_with_offset_Test.java000066400000000000000000000027201243020563200354300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.fest.assertions.data.Offset.offset; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; import org.fest.assertions.data.Offset; /** * Tests for {@link DoubleAssert#isEqualTo(Double, Offset)}. * * @author Alex Ruiz */ public class DoubleAssert_isEqualTo_with_offset_Test extends DoubleAssertBaseTest { private final Offset offset = offset(5d); private final Double expected = new Double(8d); @Override protected DoubleAssert invoke_api_method() { return assertions.isEqualTo(expected, offset); } @Override protected void verify_internal_effects() { verify(doubles).assertEqual(getInfo(assertions), getActual(assertions), expected, offset); } } DoubleAssert_isGreaterThanOrEqualTo_double_Test.java000066400000000000000000000024271243020563200370130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isGreaterThanOrEqualTo(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isGreaterThanOrEqualTo_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo(6); } @Override protected void verify_internal_effects() { verify(doubles).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 6d); } } DoubleAssert_isGreaterThan_double_Test.java000066400000000000000000000023631243020563200352160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isGreaterThan(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isGreaterThan_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isGreaterThan(6); } @Override protected void verify_internal_effects() { verify(doubles).assertGreaterThan(getInfo(assertions), getActual(assertions), 6d); } } DoubleAssert_isLessThanOrEqualTo_double_Test.java000066400000000000000000000024141243020563200363240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isLessThanOrEqualTo(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isLessThanOrEqualTo_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isLessThanOrEqualTo(8d); } @Override protected void verify_internal_effects() { verify(doubles).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 8d); } } DoubleAssert_isLessThan_double_Test.java000066400000000000000000000023501243020563200345270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isLessThan(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isLessThan_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isLessThan(8d); } @Override protected void verify_internal_effects() { verify(doubles).assertLessThan(getInfo(assertions), getActual(assertions), 8d); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isNaN_Test.java000066400000000000000000000023001243020563200322020ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNaN()}. * * @author Yvonne Wang */ public class DoubleAssert_isNaN_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNaN(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNaN(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isNegative_Test.java000066400000000000000000000023271243020563200333010ustar00rootroot00000000000000/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNegative()}. * * @author Alex Ruiz */ public class DoubleAssert_isNegative_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNegative(getInfo(assertions), getActual(assertions)); } } DoubleAssert_isNotEqualTo_double_Test.java000066400000000000000000000023561243020563200350470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNotEqualTo(double)}. * * @author Alex Ruiz */ public class DoubleAssert_isNotEqualTo_double_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNotEqualTo(8d); } @Override protected void verify_internal_effects() { verify(doubles).assertNotEqual(getInfo(assertions), getActual(assertions), 8d); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isNotNaN_Test.java000066400000000000000000000023141243020563200326700ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNotNaN()}. * * @author Yvonne Wang */ public class DoubleAssert_isNotNaN_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNotNaN(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNotNaN(getInfo(assertions), getActual(assertions)); } } DoubleAssert_isNotNegative_Test.java000066400000000000000000000023531243020563200337020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNotNegative()}. * * @author Nicolas François */ public class DoubleAssert_isNotNegative_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } DoubleAssert_isNotPositive_Test.java000066400000000000000000000023531243020563200337420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNotPositive()}. * * @author Nicolas François */ public class DoubleAssert_isNotPositive_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isNotZero_Test.java000066400000000000000000000023231243020563200331330ustar00rootroot00000000000000/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isNotZero()}. * * @author Alex Ruiz */ public class DoubleAssert_isNotZero_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isPositive_Test.java000066400000000000000000000023271243020563200333410ustar00rootroot00000000000000/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isPositive()}. * * @author Alex Ruiz */ public class DoubleAssert_isPositive_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/DoubleAssert_isZero_Test.java000066400000000000000000000023071243020563200324540ustar00rootroot00000000000000/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; /** * Tests for {@link DoubleAssert#isZero()}. * * @author Alex Ruiz */ public class DoubleAssert_isZero_Test extends DoubleAssertBaseTest { @Override protected DoubleAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(doubles).assertIsZero(getInfo(assertions), getActual(assertions)); } } DoubleAssert_usingComparator_Test.java000066400000000000000000000032551243020563200343020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class DoubleAssert_usingComparator_Test extends DoubleAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected DoubleAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getDoubles(assertions).getComparator(), comparator); } } DoubleAssert_usingDefaultComparator_Test.java000066400000000000000000000032541243020563200356060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/double_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.double_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleAssert; import org.fest.assertions.api.DoubleAssertBaseTest; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class DoubleAssert_usingDefaultComparator_Test extends DoubleAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected DoubleAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getDoubles(assertions), Doubles.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/000077500000000000000000000000001243020563200255615ustar00rootroot00000000000000DoubleArrayAssert_containsOnly_Test.java000066400000000000000000000025351243020563200355040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#containsOnly(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_containsOnly_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.containsOnly(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_containsSequence_Test.java000066400000000000000000000025551243020563200363350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#containsSequence(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_containsSequence_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.containsSequence(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_contains_Test.java000066400000000000000000000025151243020563200346400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#contains(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_contains_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.contains(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_contains_at_Index_Test.java000066400000000000000000000026501243020563200364530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link DoubleArrayAssert#contains(double, Index)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_contains_at_Index_Test extends DoubleArrayAssertBaseTest { private final Index index = someIndex(); @Override protected DoubleArrayAssert invoke_api_method() { return assertions.contains(8d, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), 8d, index); } } DoubleArrayAssert_doesNotContain_Test.java000066400000000000000000000025451243020563200357540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#doesNotContain(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_doesNotContain_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.doesNotContain(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000027001243020563200375600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link DoubleArrayAssert#doesNotContain(double, Index)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_doesNotContain_at_Index_Test extends DoubleArrayAssertBaseTest { private final Index index = someIndex(); @Override protected DoubleArrayAssert invoke_api_method() { return assertions.doesNotContain(8d, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), 8d, index); } } DoubleArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024441243020563200372600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class DoubleArrayAssert_doesNotHaveDuplicates_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } DoubleArrayAssert_endsWith_Test.java000066400000000000000000000025151243020563200346070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#endsWith(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_endsWith_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.endsWith(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026661243020563200377220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class DoubleArrayAssert_hasSameSizeAs_with_Array_Test extends DoubleArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected DoubleArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } DoubleArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027441243020563200403700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class DoubleArrayAssert_hasSameSizeAs_with_Iterable_Test extends DoubleArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected DoubleArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } DoubleArrayAssert_hasSize_Test.java000066400000000000000000000024311243020563200344250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_hasSize_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } DoubleArrayAssert_isEmpty_Test.java000066400000000000000000000026471243020563200344620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link DoubleArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class DoubleArrayAssert_isEmpty_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this tests since isEmpty is void } } DoubleArrayAssert_isNotEmpty_Test.java000066400000000000000000000024341243020563200351350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class DoubleArrayAssert_isNotEmpty_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } DoubleArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026261243020563200356130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link DoubleArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class DoubleArrayAssert_isNullOrEmpty_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isNullOrEmpty is void } } DoubleArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031151243020563200407600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class DoubleArrayAssert_isSortedAccordingToComparator_Test extends DoubleArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected DoubleArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } DoubleArrayAssert_isSorted_Test.java000066400000000000000000000023661243020563200346220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class DoubleArrayAssert_isSorted_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } DoubleArrayAssert_startsWith_Test.java000066400000000000000000000025251243020563200351770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; /** * Tests for {@link DoubleArrayAssert#startsWith(double...)}. * * @author Alex Ruiz */ public class DoubleArrayAssert_startsWith_Test extends DoubleArrayAssertBaseTest { @Override protected DoubleArrayAssert invoke_api_method() { return assertions.startsWith(6d, 8d); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6d, 8d)); } } DoubleArrayAssert_usingComparator_Test.java000066400000000000000000000035421243020563200362000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.internal.DoubleArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class DoubleArrayAssert_usingComparator_Test extends DoubleArrayAssertBaseTest { @Mock private Comparator comparator; private DoubleArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected DoubleArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } DoubleArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034721243020563200375070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class DoubleArrayAssert_usingDefaultComparator_Test extends DoubleArrayAssertBaseTest { @Mock private Comparator comparator; private DoubleArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected DoubleArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } DoubleArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035301243020563200410140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class DoubleArrayAssert_usingDefaultElementComparator_Test extends DoubleArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected DoubleArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), DoubleArrays.instance()); } } DoubleArrayAssert_usingElementComparator_Test.java000066400000000000000000000035451243020563200375150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/doublearray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.doublearray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.DoubleArrayAssert; import org.fest.assertions.api.DoubleArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link DoubleArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class DoubleArrayAssert_usingElementComparator_Test extends DoubleArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected DoubleArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/fail/000077500000000000000000000000001243020563200241635ustar00rootroot00000000000000Fail_fail_because_exception_was_not_thrown_Test.java000066400000000000000000000030571243020563200365210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/fail/* * Created on Sep 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.api.fail; import static org.fest.assertions.test.ExpectedException.none; import org.junit.Rule; import org.junit.Test; import org.fest.assertions.api.Fail; import org.fest.assertions.test.ExpectedException; /** * Tests for {@link Fail#failBecauseExceptionWasNotThrown(Class)}. * * @author Joel Costigliola */ public class Fail_fail_because_exception_was_not_thrown_Test { @Rule public ExpectedException thrown = none(); @Test public void should_include_message_built_with_given_exception_name() { thrown.expectAssertionError("Expected NullPointerException to be thrown"); Fail.failBecauseExceptionWasNotThrown(NullPointerException.class); } @Test public void should_include_message_built_with_given_throwable_name() { thrown.expectAssertionError("Expected OutOfMemoryError to be thrown"); Fail.failBecauseExceptionWasNotThrown(OutOfMemoryError.class); } } Fail_fail_withMessageAndCause_Test.java000066400000000000000000000024501243020563200335610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/fail/* * Created on Sep 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.api.fail; import static org.junit.Assert.*; import org.junit.Test; import org.fest.assertions.api.Fail; /** * Tests for {@link Fail#fail(String, Throwable)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class Fail_fail_withMessageAndCause_Test { @Test public void shouldThrowErrorWithGivenMessageAndCause() { String message = "Some Throwable"; Throwable cause = new Throwable(); try { Fail.fail(message, cause); fail("AssertionError should have been thrown"); } catch (AssertionError e) { assertEquals(e.getMessage(), message); assertSame(e.getCause(), cause); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/fail/Fail_fail_withMessage_Test.java000066400000000000000000000023101243020563200322270ustar00rootroot00000000000000/* * Created on Sep 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.api.fail; import static org.fest.assertions.test.ExpectedException.none; import org.junit.*; import org.fest.assertions.api.Fail; import org.fest.assertions.test.ExpectedException; /** * Tests for {@link Fail#fail(String)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class Fail_fail_withMessage_Test { @Rule public ExpectedException thrown = none(); @Test public void shouldIncludeMessageWhenFailing() { String message = "Failed :("; thrown.expectAssertionError(message); Fail.fail(message); } } Fail_fest_elements_stack_trace_filtering_Test.java000066400000000000000000000033241243020563200361460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/fail/* * Created on Sep 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.api.fail; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.util.StackTraceUtils.hasStackTraceElementRelatedToFest; import org.junit.Test; import org.fest.assertions.api.Fail; /** * Tests for {@link Fail#setRemoveFestRelatedElementsFromStackTrace(boolean)}. * * @author Joel Costigliola */ public class Fail_fest_elements_stack_trace_filtering_Test { @Test public void fest_elements_should_be_removed_from_assertion_error_stack_trace() { Fail.setRemoveFestRelatedElementsFromStackTrace(true); try { assertThat(5).isLessThan(0); } catch (AssertionError assertionError) { assertThat(hasStackTraceElementRelatedToFest(assertionError)).isFalse(); } } @Test public void fest_elements_should_be_kept_in_assertion_error_stack_trace() { Fail.setRemoveFestRelatedElementsFromStackTrace(false); try { assertThat(5).isLessThan(0); } catch (AssertionError assertionError) { assertThat(hasStackTraceElementRelatedToFest(assertionError)).isTrue(); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/000077500000000000000000000000001243020563200241675ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_canRead_Test.java000066400000000000000000000023051243020563200315070ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#canRead()}. * * @author Olivier Demeijer * */ public class FileAssert_canRead_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.canRead(); } @Override protected void verify_internal_effects() { verify(files).assertCanRead(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_canWrite_Test.java000066400000000000000000000023121243020563200317240ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#canWrite()}. * * @author Olivier Demeijer * */ public class FileAssert_canWrite_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.canWrite(); } @Override protected void verify_internal_effects() { verify(files).assertCanWrite(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_doesNotExist_Test.java000066400000000000000000000023131243020563200326010ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#doesNotExist()}. * * @author Yvonne Wang */ public class FileAssert_doesNotExist_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.doesNotExist(); } @Override protected void verify_internal_effects() { verify(files).assertDoesNotExist(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_exists_Test.java000066400000000000000000000022631243020563200314740ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#exists()}. * * @author Yvonne Wang */ public class FileAssert_exists_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.exists(); } @Override protected void verify_internal_effects() { verify(files).assertExists(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_hasBinaryContent_Test.java000066400000000000000000000024401243020563200334250ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#hasBinaryContent(byte[])}. * * @author Olivier Michallat */ public class FileAssert_hasBinaryContent_Test extends FileAssertBaseTest { private byte[] content = new byte[0]; @Override protected FileAssert invoke_api_method() { return assertions.hasBinaryContent(content); } @Override protected void verify_internal_effects() { verify(files).assertHasBinaryContent(getInfo(assertions), getActual(assertions), content); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_hasContentEqualTo_Test.java000066400000000000000000000026351243020563200335610ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import java.io.File; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link FileAssert#hasContentEqualTo(File)}. * * @author Yvonne Wang */ public class FileAssert_hasContentEqualTo_Test extends FileAssertBaseTest { private static File expected; @BeforeClass public static void beforeOnce() { expected = new File("xyz"); } @Override protected FileAssert invoke_api_method() { return assertions.hasContentEqualTo(expected); } @Override protected void verify_internal_effects() { verify(files).assertEqualContent(getInfo(assertions), getActual(assertions), expected); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_hasContent_Test.java000066400000000000000000000026101243020563200322570ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link FileAssert#hasContent(String)}. * * @author Olivier Michallat */ public class FileAssert_hasContent_Test extends FileAssertBaseTest { private static String expected; @BeforeClass public static void beforeOnce() { expected = "xyz"; } @Override protected FileAssert invoke_api_method() { return assertions.hasContent(expected); } @Override protected void verify_internal_effects() { verify(files).assertHasContent(getInfo(assertions), getActual(assertions), expected, getCharset(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_isAbsolute_Test.java000066400000000000000000000023031243020563200322620ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#isAbsolute()}. * * @author Yvonne Wang */ public class FileAssert_isAbsolute_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.isAbsolute(); } @Override protected void verify_internal_effects() { verify(files).assertIsAbsolute(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_isDirectory_Test.java000066400000000000000000000023071243020563200324540ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#isDirectory()}. * * @author Yvonne Wang */ public class FileAssert_isDirectory_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.isDirectory(); } @Override protected void verify_internal_effects() { verify(files).assertIsDirectory(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_isFile_Test.java000066400000000000000000000022621243020563200313670ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#isFile()}. * * @author Yvonne Wang */ public class FileAssert_isFile_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.isFile(); } @Override protected void verify_internal_effects() { verify(files).assertIsFile(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_isRelative_Test.java000066400000000000000000000023021243020563200322560ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests for {@link FileAssert#isRelative()}. * * @author Yvonne Wang */ public class FileAssert_isRelative_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.isRelative(); } @Override protected void verify_internal_effects() { verify(files).assertIsRelative(getInfo(assertions), getActual(assertions)); } } FileAssert_usingCharset_String_Test.java000066400000000000000000000023311243020563200340570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.junit.Assert.assertEquals; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Test for {@link FileAssert#usingCharset(String)}. * * @author Olivier Michallat */ public class FileAssert_usingCharset_String_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.usingCharset(otherCharset.name()); } @Override protected void verify_internal_effects() { assertEquals(otherCharset, getCharset(assertions)); } } FileAssert_usingCharset_String_invalid_Test.java000066400000000000000000000032721243020563200355720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; import org.fest.assertions.test.ExpectedException; import org.junit.Rule; import org.junit.Test; /** * Tests for {@link FileAssert#usingCharset(String)} when the provided string is invalid. * * @author Olivier Michallat */ public class FileAssert_usingCharset_String_invalid_Test extends FileAssertBaseTest { @Rule public ExpectedException thrown = none(); @Override @Test public void should_have_internal_effects() { thrown.expectIllegalArgumentException("Charset:<'Klingon'> is not supported on this system"); assertions.usingCharset("Klingon"); } @Override @Test public void should_return_this() { // Disable this test since the call fails } @Override protected FileAssert invoke_api_method() { // not used here return null; } @Override protected void verify_internal_effects() { // not used here } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_usingCharset_Test.java000066400000000000000000000023561243020563200326170ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.junit.Assert.assertEquals; import java.nio.charset.Charset; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Test for {@link FileAssert#usingCharset(Charset)}. * * @author Olivier Michallat */ public class FileAssert_usingCharset_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { return assertions.usingCharset(otherCharset); } @Override protected void verify_internal_effects() { assertEquals(otherCharset, getCharset(assertions)); } } FileAssert_usingCharset_default_Test.java000066400000000000000000000023701243020563200342400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.junit.Assert.assertEquals; import java.nio.charset.Charset; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; /** * Tests the default charset for {@link FileAssert}. * * @author Olivier Michallat */ public class FileAssert_usingCharset_default_Test extends FileAssertBaseTest { @Override protected FileAssert invoke_api_method() { // do nothing return assertions; } @Override protected void verify_internal_effects() { assertEquals(getCharset(assertions), Charset.defaultCharset()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/file/FileAssert_usingCharset_null_Test.java000066400000000000000000000032741243020563200336510ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.file; import static org.fest.assertions.test.ExpectedException.none; import java.nio.charset.Charset; import org.fest.assertions.api.FileAssert; import org.fest.assertions.api.FileAssertBaseTest; import org.fest.assertions.test.ExpectedException; import org.junit.Rule; import org.junit.Test; /** * Test for {@link FileAssert#usingCharset(Charset)} when the provided charset is null. * * @author Olivier Michallat */ public class FileAssert_usingCharset_null_Test extends FileAssertBaseTest { @Rule public ExpectedException thrown = none(); @Override @Test public void should_have_internal_effects() { thrown.expectNullPointerException("The charset should not be null"); assertions.usingCharset((Charset) null); } @Override @Test public void should_return_this() { // Disable this test since the call fails } @Override protected FileAssert invoke_api_method() { // not used here return null; } @Override protected void verify_internal_effects() { // not used here } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/000077500000000000000000000000001243020563200245355ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/AbstractTest_equals_filter.java000066400000000000000000000032011243020563200327160ustar00rootroot00000000000000package org.fest.assertions.api.filter; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; import org.fest.util.IntrospectionError; public abstract class AbstractTest_equals_filter extends AbstractTest_filter { @Test public void should_filter_iterable_elements_with_property_equals_to_given_value() { Iterable bullsPlayers = filterIterable(players, "team", "Chicago Bulls"); assertThat(bullsPlayers).containsOnly(rose, noah); // players is not modified assertThat(players).hasSize(4); Iterable filteredPlayers = filter(players).with("name.last", "James").get(); assertThat(filteredPlayers).containsOnly(james); // players is not modified assertThat(players).hasSize(4); } protected abstract Iterable filterIterable(Iterable players, String propertyName, Object propertyValue); @Test public void should_fail_if_property_to_filter_on_is_null() { try { filterIterable(players, null, 6000L); fail("NullPointerException expected"); } catch (NullPointerException e) { assertThat(e).hasMessage("The property name to filter on should not be null"); } } @Test public void should_fail_if_elements_to_filter_do_not_have_property_used_by_filter() { try { filterIterable(players, "nickname", "dude"); fail("IntrospectionError expected"); } catch (IntrospectionError e) { assertThat(e).hasMessage("No getter for property 'nickname' in org.fest.test.Player"); } } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/AbstractTest_filter.java000066400000000000000000000022261243020563200313520ustar00rootroot00000000000000package org.fest.assertions.api.filter; import static org.fest.util.Lists.newArrayList; import java.util.List; import org.junit.BeforeClass; import org.fest.test.Name; import org.fest.test.Player; public class AbstractTest_filter { protected static Player rose; protected static Player james; protected static Player durant; protected static Player noah; protected static List players; @BeforeClass public static void setUpOnce() { rose = new Player(new Name("Derrick", "Rose"), "Chicago Bulls"); rose.setAssistsPerGame(8); rose.setPointsPerGame(25); rose.setReboundsPerGame(5); james = new Player(new Name("Lebron", "James"), "Miami Heat"); james.setAssistsPerGame(6); james.setPointsPerGame(27); james.setReboundsPerGame(8); durant = new Player(new Name("Kevin", "Durant"), "OKC"); durant.setAssistsPerGame(4); durant.setPointsPerGame(30); durant.setReboundsPerGame(5); noah = new Player(new Name("Joachim", "Noah"), "Chicago Bulls"); noah.setAssistsPerGame(4); noah.setPointsPerGame(10); noah.setReboundsPerGame(11); players = newArrayList(rose, james, durant, noah); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/Filter_being_condition_Test.java000066400000000000000000000017331243020563200330420ustar00rootroot00000000000000package org.fest.assertions.api.filter; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; public class Filter_being_condition_Test extends AbstractTest_filter { private PotentialMvpCondition potentialMvp = new PotentialMvpCondition(); @Test public void should_filter_iterable_elements_satisfying_condition() { Iterable potentialMvpPlayers = filter(players).being(potentialMvp).get(); assertThat(potentialMvpPlayers).containsOnly(rose, james); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_filter_condition_is_null() { try { filter(players).being(null); fail("NullPointerException expected"); } catch (NullPointerException e) { assertThat(e).hasMessage("The filter condition should not be null"); } } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/Filter_create_Test.java000066400000000000000000000025051243020563200311510ustar00rootroot00000000000000package org.fest.assertions.api.filter; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import java.util.List; import org.junit.Test; import org.fest.test.Player; public class Filter_create_Test extends AbstractTest_filter { @Test public void should_create_filter_from_iterable() { Filters filter = filter(players); assertEquals(players, filter.get()); } @Test public void should_create_filter_from_array() { Player[] playersArray = players.toArray(new Player[0]); Filters filter = filter(playersArray); assertEquals(players, filter.get()); } @Test public void should_fail_if_constructor_iterable_parameter_is_null() { try { filter((List) null); fail("NullPointerException expected"); } catch (NullPointerException e) { assertThat(e).hasMessage("The iterable to filter should not be null"); } } @Test public void should_fail_if_constructor_array_parameter_is_null() { try { filter((Player[]) null); fail("NullPointerException expected"); } catch (NullPointerException e) { assertThat(e).hasMessage("The array to filter should not be null"); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/Filter_having_condition_Test.java000066400000000000000000000017301243020563200332270ustar00rootroot00000000000000package org.fest.assertions.api.filter; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; public class Filter_having_condition_Test extends AbstractTest_filter { private PotentialMvpCondition mvpStats = new PotentialMvpCondition(); @Test public void should_filter_iterable_elements_satisfying_condition() { Iterable playersHavinMvpStats = filter(players).having(mvpStats).get(); assertThat(playersHavinMvpStats).containsOnly(rose, james); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_filter_condition_is_null() { try { filter(players).having(null); fail("NullPointerException expected"); } catch (NullPointerException e) { assertThat(e).hasMessage("The filter condition should not be null"); } } }Filter_on_differents_properties_Test.java000066400000000000000000000027371243020563200347370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.util.IntrospectionError; public class Filter_on_differents_properties_Test extends AbstractTest_filter { @Test public void should_filter_iterable_elements_on_different_properties() { // rose and durant have 5 rebounds per game but only rose does not play in OKC assertThat(filter(players).with("reboundsPerGame").equalsTo(5).and("team").notEqualsTo("OKC").get()).containsOnly(rose); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_property_to_filter_on_is_null() { try { filter(players).with("reboundsPerGame").equalsTo(5).and(null).equalsTo("OKC"); fail("NullPointerException expected"); } catch (NullPointerException e) { assertEquals("The property name to filter on should not be null", e.getMessage()); } } @Test public void should_fail_if_elements_to_filter_do_not_have_property_used_by_filter() { try { filter(players).with("reboundsPerGame").equalsTo(5).and("nickname").notEqualsTo("dude"); fail("IntrospectionError expected"); } catch (IntrospectionError e) { assertEquals("No getter for property 'nickname' in org.fest.test.Player", e.getMessage()); } } }Filter_with_property_equals_to_given_value_Test.java000066400000000000000000000006771243020563200372160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static org.fest.assertions.api.filter.Filters.filter; import org.fest.test.Player; public class Filter_with_property_equals_to_given_value_Test extends AbstractTest_equals_filter { @Override protected Iterable filterIterable(Iterable employees, String propertyName, Object propertyValue) { return filter(employees).with(propertyName).equalsTo(propertyValue).get(); } } Filter_with_property_equals_to_given_value_short_version_Test.java000066400000000000000000000007041243020563200421710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static org.fest.assertions.api.filter.Filters.filter; import org.fest.test.Player; public class Filter_with_property_equals_to_given_value_short_version_Test extends AbstractTest_equals_filter { @Override protected Iterable filterIterable(Iterable employees, String propertyName, Object propertyValue) { return filter(employees).with(propertyName, propertyValue).get(); } } Filter_with_property_equals_to_null_value_Test.java000066400000000000000000000012371243020563200370510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import org.junit.Test; import org.fest.test.Player; public class Filter_with_property_equals_to_null_value_Test extends AbstractTest_filter { @Test public void should_filter_iterable_elements_with_property_in_given_values() { rose.setTeam(null); durant.setTeam(null); Iterable filteredPlayers = filter(players).with("team").equalsTo(null).get(); assertThat(filteredPlayers).containsOnly(rose, durant); // players is not modified assertThat(players).hasSize(4); } } Filter_with_property_in_given_values_Test.java000066400000000000000000000031471243020563200360060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; import org.fest.util.IntrospectionError; public class Filter_with_property_in_given_values_Test extends AbstractTest_filter { @Test public void should_filter_iterable_elements_with_property_in_given_values() { Iterable filteredPlayers = filter(players).with("team").in("OKC", "Chicago Bulls").get(); assertThat(filteredPlayers).containsOnly(rose, noah, durant); // players is not modified assertThat(players).hasSize(4); filteredPlayers = filter(players).with("name.last").in("Rose", "Noah").get(); assertThat(filteredPlayers).containsOnly(rose, noah); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_property_to_filter_on_is_null() { try { filter(players).with(null).in("foo", "bar"); fail("NullPointerException expected"); } catch (NullPointerException e) { assertEquals("The property name to filter on should not be null", e.getMessage()); } } @Test public void should_fail_if_elements_to_filter_do_not_have_property_used_by_filter() { try { filter(players).with("nickname").in("dude", "al"); fail("IntrospectionError expected"); } catch (IntrospectionError e) { assertEquals("No getter for property 'nickname' in org.fest.test.Player", e.getMessage()); } } }Filter_with_property_not_equals_to_given_value_Test.java000066400000000000000000000032161243020563200400660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; import org.fest.util.IntrospectionError; public class Filter_with_property_not_equals_to_given_value_Test extends AbstractTest_filter { @Test public void should_filter_iterable_elements_with_property_not_equals_to_given_value() { Iterable nonOKCPlayers = filter(players).with("team").notEqualsTo("OKC").get(); assertThat(nonOKCPlayers).containsOnly(rose, noah, james); // players is not modified assertThat(players).hasSize(4); Iterable filteredPlayers = filter(players).with("name.last").notEqualsTo("Rose").get(); assertThat(filteredPlayers).containsOnly(durant, noah, james); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_property_to_filter_on_is_null() { try { filter(players).with(null).notEqualsTo("foo"); fail("NullPointerException expected"); } catch (NullPointerException e) { assertEquals("The property name to filter on should not be null", e.getMessage()); } } @Test public void should_fail_if_elements_to_filter_do_not_have_property_used_by_filter() { try { filter(players).with("nickname").notEqualsTo("dude"); fail("IntrospectionError expected"); } catch (IntrospectionError e) { assertEquals("No getter for property 'nickname' in org.fest.test.Player", e.getMessage()); } } }Filter_with_property_not_in_given_values_Test.java000066400000000000000000000031631243020563200366640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filterpackage org.fest.assertions.api.filter; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.api.filter.Filters.filter; import static org.junit.Assert.fail; import org.junit.Test; import org.fest.test.Player; import org.fest.util.IntrospectionError; public class Filter_with_property_not_in_given_values_Test extends AbstractTest_filter { @Test public void should_filter_iterable_elements_with_property_not_in_given_values() { Iterable filteredPlayers = filter(players).with("team").notIn("OKC", "Miami Heat").get(); assertThat(filteredPlayers).containsOnly(rose, noah); // players is not modified assertThat(players).hasSize(4); filteredPlayers = filter(players).with("name.last").notIn("Rose", "Noah").get(); assertThat(filteredPlayers).containsOnly(durant, james); // players is not modified assertThat(players).hasSize(4); } @Test public void should_fail_if_property_to_filter_on_is_null() { try { filter(players).with(null).notIn("foo", "bar"); fail("NullPointerException expected"); } catch (NullPointerException e) { assertEquals("The property name to filter on should not be null", e.getMessage()); } } @Test public void should_fail_if_elements_to_filter_do_not_have_property_used_by_filter() { try { filter(players).with("nickname").notIn("dude", "al"); fail("IntrospectionError expected"); } catch (IntrospectionError e) { assertEquals("No getter for property 'nickname' in org.fest.test.Player", e.getMessage()); } } }fest-assert-2.0M10/src/test/java/org/fest/assertions/api/filter/PotentialMvpCondition.java000066400000000000000000000022351243020563200316730ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.filter; import org.fest.assertions.core.Condition; import org.fest.test.Player; /** * * A {@code Condition} checking if a {@link Player} is a potential MVP. * * @author Joel Costigliola */ public class PotentialMvpCondition extends Condition { public PotentialMvpCondition() { super("is a potential MVP"); } @Override public boolean matches(Player player) { return player.getPointsPerGame() > 20 && (player.getAssistsPerGame() >= 8 || player.getReboundsPerGame() >= 8); }; } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/000077500000000000000000000000001243020563200245145ustar00rootroot00000000000000FloatAssert_isEqualTo_float_Test.java000066400000000000000000000023301243020563200336770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isEqualTo(float)}. * * @author Alex Ruiz */ public class FloatAssert_isEqualTo_float_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isEqualTo(8f); } @Override protected void verify_internal_effects() { verify(floats).assertEqual(getInfo(assertions), getActual(assertions), 8f); } } FloatAssert_isEqualTo_float_with_offset_Test.java000066400000000000000000000026161243020563200363070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.fest.assertions.data.Offset.offset; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; import org.fest.assertions.data.Offset; /** * Tests for {@link FloatAssert#isEqualTo(float, Offset)}. * * @author Alex Ruiz */ public class FloatAssert_isEqualTo_float_with_offset_Test extends FloatAssertBaseTest { private final Offset offset = offset(5f); @Override protected FloatAssert invoke_api_method() { return assertions.isEqualTo(8f, offset); } @Override protected void verify_internal_effects() { verify(floats).assertEqual(getInfo(assertions), getActual(assertions), 8f, offset); } } FloatAssert_isEqualTo_with_offset_Test.java000066400000000000000000000027041243020563200351200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.fest.assertions.data.Offset.offset; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; import org.fest.assertions.data.Offset; /** * Tests for {@link FloatAssert#isEqualTo(Float, Offset)}. * * @author Alex Ruiz */ public class FloatAssert_isEqualTo_with_offset_Test extends FloatAssertBaseTest { private final Offset offset = offset(5f); private final Float expected = new Float(8f); @Override protected FloatAssert invoke_api_method() { return assertions.isEqualTo(expected, offset); } @Override protected void verify_internal_effects() { verify(floats).assertEqual(getInfo(assertions), getActual(assertions), expected, offset); } } FloatAssert_isGreaterThanOrEqualTo_float_Test.java000066400000000000000000000024151243020563200363310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isGreaterThanOrEqualTo(float)}. * * @author Alex Ruiz */ public class FloatAssert_isGreaterThanOrEqualTo_float_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo(6); } @Override protected void verify_internal_effects() { verify(floats).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 6f); } } FloatAssert_isGreaterThan_float_Test.java000066400000000000000000000023511243020563200345340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isGreaterThan(float)}. * * @author Alex Ruiz */ public class FloatAssert_isGreaterThan_float_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isGreaterThan(6); } @Override protected void verify_internal_effects() { verify(floats).assertGreaterThan(getInfo(assertions), getActual(assertions), 6f); } } FloatAssert_isLessThanOrEqualTo_float_Test.java000066400000000000000000000024021243020563200356420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isLessThanOrEqualTo(float)}. * * @author Alex Ruiz */ public class FloatAssert_isLessThanOrEqualTo_float_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isLessThanOrEqualTo(8f); } @Override protected void verify_internal_effects() { verify(floats).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 8f); } } FloatAssert_isLessThan_float_Test.java000066400000000000000000000023361243020563200340540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isLessThan(float)}. * * @author Alex Ruiz */ public class FloatAssert_isLessThan_float_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isLessThan(8f); } @Override protected void verify_internal_effects() { verify(floats).assertLessThan(getInfo(assertions), getActual(assertions), 8f); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNaN_Test.java000066400000000000000000000022701243020563200316760ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNaN()}. * * @author Yvonne Wang */ public class FloatAssert_isNaN_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNaN(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNaN(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNegative_Test.java000066400000000000000000000023171243020563200327660ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNegative()}. * * @author Alex Ruiz */ public class FloatAssert_isNegative_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNegative(getInfo(assertions), getActual(assertions)); } } FloatAssert_isNotEqualTo_float_Test.java000066400000000000000000000023301243020563200343600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNotEqualTo(float)}. * * @author Alex Ruiz */ public class FloatAssert_isNotEqualTo_float_Test extends FloatAssertBaseTest { protected FloatAssert invoke_api_method() { return assertions.isNotEqualTo(8f); } @Override protected void verify_internal_effects() { verify(floats).assertNotEqual(getInfo(assertions), getActual(assertions), 8f); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNotNaN_Test.java000066400000000000000000000023041243020563200323550ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNotNaN()}. * * @author Yvonne Wang */ public class FloatAssert_isNotNaN_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNotNaN(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNotNaN(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNotNegative_Test.java000066400000000000000000000023431243020563200334460ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNotNegative()}. * * @author Nicolas François */ public class FloatAssert_isNotNegative_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNotPositive_Test.java000066400000000000000000000023431243020563200335060ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNotPositive()}. * * @author Nicolas François */ public class FloatAssert_isNotPositive_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isNotZero_Test.java000066400000000000000000000023131243020563200326200ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isNotZero()}. * * @author Alex Ruiz */ public class FloatAssert_isNotZero_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(floats).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isPositive_Test.java000066400000000000000000000023171243020563200330260ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isPositive()}. * * @author Alex Ruiz */ public class FloatAssert_isPositive_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(floats).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/FloatAssert_isZero_Test.java000066400000000000000000000022771243020563200321500ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; /** * Tests for {@link FloatAssert#isZero()}. * * @author Alex Ruiz */ public class FloatAssert_isZero_Test extends FloatAssertBaseTest { @Override protected FloatAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(floats).assertIsZero(getInfo(assertions), getActual(assertions)); } } FloatAssert_usingComparator_Test.java000066400000000000000000000032441243020563200337660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class FloatAssert_usingComparator_Test extends FloatAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected FloatAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getFloats(assertions).getComparator(), comparator); } } FloatAssert_usingDefaultComparator_Test.java000066400000000000000000000032411243020563200352700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/float_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.float_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatAssert; import org.fest.assertions.api.FloatAssertBaseTest; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class FloatAssert_usingDefaultComparator_Test extends FloatAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected FloatAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getFloats(assertions), Floats.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/000077500000000000000000000000001243020563200254145ustar00rootroot00000000000000FloatArrayAssert_containsOnly_Test.java000066400000000000000000000025241243020563200351700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#containsOnly(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_containsOnly_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.containsOnly(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_containsSequence_Test.java000066400000000000000000000025441243020563200360210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#containsSequence(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_containsSequence_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.containsSequence(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_contains_Test.java000066400000000000000000000025041243020563200343240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#contains(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_contains_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.contains(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_contains_at_Index_Test.java000066400000000000000000000026401243020563200361400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link FloatArrayAssert#contains(float, Index)}. * * @author Alex Ruiz */ public class FloatArrayAssert_contains_at_Index_Test extends FloatArrayAssertBaseTest { private final Index index = someIndex(); @Override protected FloatArrayAssert invoke_api_method() { return assertions.contains(8f, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), 8f, index); } } FloatArrayAssert_doesNotContain_Test.java000066400000000000000000000025341243020563200354400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#doesNotContain(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_doesNotContain_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.doesNotContain(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026701243020563200372540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link FloatArrayAssert#doesNotContain(float, Index)}. * * @author Alex Ruiz */ public class FloatArrayAssert_doesNotContain_at_Index_Test extends FloatArrayAssertBaseTest { private final Index index = someIndex(); @Override protected FloatArrayAssert invoke_api_method() { return assertions.doesNotContain(8f, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), 8f, index); } } FloatArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024351243020563200367460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class FloatArrayAssert_doesNotHaveDuplicates_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } FloatArrayAssert_endsWith_Test.java000066400000000000000000000025041243020563200342730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#endsWith(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_endsWith_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.endsWith(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026571243020563200374100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class FloatArrayAssert_hasSameSizeAs_with_Array_Test extends FloatArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected FloatArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } FloatArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027351243020563200400560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class FloatArrayAssert_hasSameSizeAs_with_Iterable_Test extends FloatArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected FloatArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } FloatArrayAssert_hasSize_Test.java000066400000000000000000000024221243020563200341130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class FloatArrayAssert_hasSize_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } FloatArrayAssert_isEmpty_Test.java000066400000000000000000000026351243020563200341450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link FloatArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class FloatArrayAssert_isEmpty_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isEmpty is void } } FloatArrayAssert_isNotEmpty_Test.java000066400000000000000000000024251243020563200346230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class FloatArrayAssert_isNotEmpty_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } FloatArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026171243020563200353010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link FloatArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class FloatArrayAssert_isNullOrEmpty_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test since isNullOrEmpty is void } } FloatArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031051243020563200404450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class FloatArrayAssert_isSortedAccordingToComparator_Test extends FloatArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected FloatArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } FloatArrayAssert_isSorted_Test.java000066400000000000000000000023571243020563200343100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class FloatArrayAssert_isSorted_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } FloatArrayAssert_startsWith_Test.java000066400000000000000000000025141243020563200346630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; /** * Tests for {@link FloatArrayAssert#startsWith(float...)}. * * @author Alex Ruiz */ public class FloatArrayAssert_startsWith_Test extends FloatArrayAssertBaseTest { @Override protected FloatArrayAssert invoke_api_method() { return assertions.startsWith(6f, 8f); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6f, 8f)); } } FloatArrayAssert_usingComparator_Test.java000066400000000000000000000035301243020563200356630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.internal.FloatArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class FloatArrayAssert_usingComparator_Test extends FloatArrayAssertBaseTest { @Mock private Comparator comparator; private FloatArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected FloatArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } FloatArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034601243020563200371720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class FloatArrayAssert_usingDefaultComparator_Test extends FloatArrayAssertBaseTest { @Mock private Comparator comparator; private FloatArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected FloatArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } FloatArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035161243020563200405060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class FloatArrayAssert_usingDefaultElementComparator_Test extends FloatArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected FloatArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), FloatArrays.instance()); } } FloatArrayAssert_usingElementComparator_Test.java000066400000000000000000000035351243020563200372020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/floatarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.floatarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.FloatArrayAssert; import org.fest.assertions.api.FloatArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link FloatArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class FloatArrayAssert_usingElementComparator_Test extends FloatArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected FloatArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/inputstream/000077500000000000000000000000001243020563200256235ustar00rootroot00000000000000InputStreamAssert_hasContentEqualTo_Test.java000066400000000000000000000031171243020563200365260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/inputstream/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.inputstream; import static org.mockito.Mockito.verify; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.junit.BeforeClass; import org.fest.assertions.api.InputStreamAssert; import org.fest.assertions.api.InputStreamAssertBaseTest; /** * Tests for {@link InputStreamAssert#hasContentEqualTo(InputStream)}. * * @author Matthieu Baechler * @author Joel Costigliola */ public class InputStreamAssert_hasContentEqualTo_Test extends InputStreamAssertBaseTest { private static InputStream expected; @BeforeClass public static void setUpOnce() { expected = new ByteArrayInputStream(new byte[] { 'b' }); } @Override protected InputStreamAssert invoke_api_method() { return assertions.hasContentEqualTo(expected); } @Override protected void verify_internal_effects() { verify(inputStreams).assertEqualContent(getInfo(assertions), getActual(assertions), expected); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/000077500000000000000000000000001243020563200251015ustar00rootroot00000000000000IntArrayAssert_containsOnly_Test.java000066400000000000000000000024761243020563200343500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#containsOnly(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_containsOnly_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.containsOnly(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } IntArrayAssert_containsSequence_Test.java000066400000000000000000000025161243020563200351720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#containsSequence(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_containsSequence_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.containsSequence(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/IntArrayAssert_contains_Test.java000066400000000000000000000024561243020563200335630ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#contains(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_contains_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.contains(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } IntArrayAssert_contains_at_Index_Test.java000066400000000000000000000026151243020563200353140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link IntArrayAssert#contains(int, Index)}. * * @author Alex Ruiz */ public class IntArrayAssert_contains_at_Index_Test extends IntArrayAssertBaseTest { private final Index index = someIndex(); @Override protected IntArrayAssert invoke_api_method() { return assertions.contains(8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), 8, index); } } IntArrayAssert_doesNotContain_Test.java000066400000000000000000000025061243020563200346110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#doesNotContain(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_doesNotContain_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.doesNotContain(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } IntArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026461243020563200364310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link IntArrayAssert#doesNotContain(int, Index)}. * * @author Alex Ruiz */ public class IntArrayAssert_doesNotContain_at_Index_Test extends IntArrayAssertBaseTest { private final Index index = someIndex(); @Override protected IntArrayAssert invoke_api_method() { return assertions.doesNotContain(8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), 8, index); } } IntArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024171243020563200361200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class IntArrayAssert_doesNotHaveDuplicates_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/IntArrayAssert_endsWith_Test.java000066400000000000000000000024561243020563200335320ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#endsWith(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_endsWith_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.endsWith(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } IntArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026411243020563200365530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class IntArrayAssert_hasSameSizeAs_with_Array_Test extends IntArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected IntArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } IntArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027171243020563200372300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class IntArrayAssert_hasSameSizeAs_with_Iterable_Test extends IntArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected IntArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/IntArrayAssert_hasSize_Test.java000066400000000000000000000024041243020563200333440ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class IntArrayAssert_hasSize_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/IntArrayAssert_isEmpty_Test.java000066400000000000000000000026231243020563200333730ustar00rootroot00000000000000/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link IntArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class IntArrayAssert_isEmpty_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isEmpty is void } } IntArrayAssert_isNotEmpty_Test.java000066400000000000000000000024071243020563200337750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class IntArrayAssert_isNotEmpty_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } IntArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026031243020563200344460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link IntArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class IntArrayAssert_isNullOrEmpty_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isNullOrEmpty is void } } IntArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000030711243020563200376210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class IntArrayAssert_isSortedAccordingToComparator_Test extends IntArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected IntArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/IntArrayAssert_isSorted_Test.java000066400000000000000000000023411243020563200335320ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class IntArrayAssert_isSorted_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } IntArrayAssert_startsWith_Test.java000066400000000000000000000024661243020563200340430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; /** * Tests for {@link IntArrayAssert#startsWith(int...)}. * * @author Alex Ruiz */ public class IntArrayAssert_startsWith_Test extends IntArrayAssertBaseTest { @Override protected IntArrayAssert invoke_api_method() { return assertions.startsWith(6, 8); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } IntArrayAssert_usingComparator_Test.java000066400000000000000000000035041243020563200350360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.internal.IntArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class IntArrayAssert_usingComparator_Test extends IntArrayAssertBaseTest { @Mock private Comparator comparator; private IntArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected IntArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } IntArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034341243020563200363450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class IntArrayAssert_usingDefaultComparator_Test extends IntArrayAssertBaseTest { @Mock private Comparator comparator; private IntArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected IntArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } IntArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000034761243020563200376650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class IntArrayAssert_usingDefaultElementComparator_Test extends IntArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected IntArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), IntArrays.instance()); } } IntArrayAssert_usingElementComparator_Test.java000066400000000000000000000035211243020563200363470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/intarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.intarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntArrayAssert; import org.fest.assertions.api.IntArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class IntArrayAssert_usingElementComparator_Test extends IntArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected IntArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/000077500000000000000000000000001243020563200250445ustar00rootroot00000000000000IntegerAssert_isEqualTo_int_Test.java000066400000000000000000000023421243020563200342470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isEqualTo(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isEqualTo_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isEqualTo(8); } @Override protected void verify_internal_effects() { verify(integers).assertEqual(getInfo(assertions), getActual(assertions), 8); } } IntegerAssert_isGreaterThanOrEqualTo_int_Test.java000066400000000000000000000024301243020563200366730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isGreaterThanOrEqualTo(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isGreaterThanOrEqualTo_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo(6); } @Override protected void verify_internal_effects() { verify(integers).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 6); } } IntegerAssert_isGreaterThan_int_Test.java000066400000000000000000000023641243020563200351050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isGreaterThan(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isGreaterThan_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isGreaterThan(6); } @Override protected void verify_internal_effects() { verify(integers).assertGreaterThan(getInfo(assertions), getActual(assertions), 6); } } IntegerAssert_isLessThanOrEqualTo_int_Test.java000066400000000000000000000024141243020563200362120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isLessThanOrEqualTo(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isLessThanOrEqualTo_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isLessThanOrEqualTo(8); } @Override protected void verify_internal_effects() { verify(integers).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 8); } } IntegerAssert_isLessThan_int_Test.java000066400000000000000000000023501243020563200344150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isLessThan(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isLessThan_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isLessThan(8); } @Override protected void verify_internal_effects() { verify(integers).assertLessThan(getInfo(assertions), getActual(assertions), 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/IntegerAssert_isNegative_Test.java000066400000000000000000000023371243020563200336500ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isNegative()}. * * @author Alex Ruiz */ public class IntegerAssert_isNegative_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(integers).assertIsNegative(getInfo(assertions), getActual(assertions)); } } IntegerAssert_isNotEqualTo_int_Test.java000066400000000000000000000023561243020563200347350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isNotEqualTo(int)}. * * @author Alex Ruiz */ public class IntegerAssert_isNotEqualTo_int_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isNotEqualTo(8); } @Override protected void verify_internal_effects() { verify(integers).assertNotEqual(getInfo(assertions), getActual(assertions), 8); } } IntegerAssert_isNotNegative_Test.java000066400000000000000000000023631243020563200342510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isNotNegative()}. * * @author Nicolas François */ public class IntegerAssert_isNotNegative_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(integers).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } IntegerAssert_isNotPostitive_Test.java000066400000000000000000000023641243020563200344760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isNotPositive()}. * * @author Nicolas François */ public class IntegerAssert_isNotPostitive_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(integers).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/IntegerAssert_isNotZero_Test.java000066400000000000000000000023331243020563200335020ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isNotZero()}. * * @author Alex Ruiz */ public class IntegerAssert_isNotZero_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(integers).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/IntegerAssert_isPositive_Test.java000066400000000000000000000023371243020563200337100ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isPositive()}. * * @author Alex Ruiz */ public class IntegerAssert_isPositive_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(integers).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/IntegerAssert_isZero_Test.java000066400000000000000000000023171243020563200330230ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; /** * Tests for {@link IntegerAssert#isZero()}. * * @author Alex Ruiz */ public class IntegerAssert_isZero_Test extends IntegerAssertBaseTest { @Override protected IntegerAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(integers).assertIsZero(getInfo(assertions), getActual(assertions)); } } IntegerAssert_usingComparator_Test.java000066400000000000000000000032661243020563200346520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntegerAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class IntegerAssert_usingComparator_Test extends IntegerAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected IntegerAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getIntegers(assertions).getComparator(), comparator); } } IntegerAssert_usingDefaultComparator_Test.java000066400000000000000000000032671243020563200361600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/integer_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.integer_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.IntegerAssert; import org.fest.assertions.api.IntegerAssertBaseTest; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link IntegerAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class IntegerAssert_usingDefaultComparator_Test extends IntegerAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected IntegerAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getIntegers(assertions), Integers.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/000077500000000000000000000000001243020563200250375ustar00rootroot00000000000000IterableAssert_areAtLeast_Test.java000066400000000000000000000031641243020563200336440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areAtLeast(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areAtLeast_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_areAtMost_Test.java000066400000000000000000000031601243020563200335710ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areAtMost(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areAtMost_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_areExactly_Test.java000066400000000000000000000031641243020563200337200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areExactly(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areExactly_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areExactly(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreExactly(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_areNotAtLeast_Test.java000066400000000000000000000032001243020563200343140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areNotAtLeast(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areNotAtLeast_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areNotAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreNotAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_areNotAtMost_Test.java000066400000000000000000000031741243020563200342000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areNotAtMost(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areNotAtMost_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areNotAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreNotAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_areNotExactly_Test.java000066400000000000000000000032001243020563200343700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areNotExactly(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_areNotExactly_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areNotExactly(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreNotExactly(getInfo(assertions), getActual(assertions), 2, condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_areNot_Test.java000066400000000000000000000030741243020563200331260ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#areNot(org.fest.assertions.core.Condition)()}. * * @author Nicolas François */ public class IterableAssert_areNot_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.areNot(condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAreNot(getInfo(assertions), getActual(assertions), condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_are_Test.java000066400000000000000000000030601243020563200324400ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#are(org.fest.assertions.core.Condition)()}. * * @author Nicolas François */ public class IterableAssert_are_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.are(condition); } @Override protected void verify_internal_effects() { verify(iterables).assertAre(getInfo(assertions), getActual(assertions), condition); } } IterableAssert_containsAll_Test.java000066400000000000000000000027061243020563200340670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import java.util.ArrayList; import java.util.List; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#containsAll(Iterable)}. * * @author Joel Costigliola */ public class IterableAssert_containsAll_Test extends IterableAssertBaseTest { private List list = new ArrayList(); @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.containsAll(list); } @Override protected void verify_internal_effects() { verify(iterables).assertContainsAll(getInfo(assertions), getActual(assertions), list); } } IterableAssert_containsExactly_Test.java000066400000000000000000000026421243020563200347670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Jun 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#containsExactly(Object...)}. * * @author Nicolas François */ public class IterableAssert_containsExactly_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.containsExactly("Yoda", "Luke"); } @Override protected void verify_internal_effects() { Object[] values = { "Yoda", "Luke" }; verify(iterables).assertContainsExactly(getInfo(assertions), getActual(assertions), values); } } IterableAssert_containsNull_Test.java000066400000000000000000000025141243020563200342660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#containsNull()}. * * @author Joel Costigliola */ public class IterableAssert_containsNull_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.containsNull(); } @Override protected void verify_internal_effects() { verify(iterables).assertContainsNull(getInfo(assertions), getActual(assertions)); } } IterableAssert_containsOnly_Test.java000066400000000000000000000026561243020563200343040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Oct 1, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#containsOnly(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_containsOnly_Test extends IterableAssertBaseTest { private final Object[] values = { "Yoda", "Luke" }; @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.containsOnly(values); } @Override protected void verify_internal_effects() { verify(iterables).assertContainsOnly(getInfo(assertions), getActual(assertions), values); } } IterableAssert_containsSequence_Test.java000066400000000000000000000027111243020563200351230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#containsSequence(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_containsSequence_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.containsSequence("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(iterables).assertContainsSequence(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_contains_Test.java000066400000000000000000000026311243020563200335120ustar00rootroot00000000000000/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#contains(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_contains_Test extends IterableAssertBaseTest { private Object[] values = { "Yoda", "Luke" }; @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.contains(values); } @Override protected void verify_internal_effects() { verify(iterables).assertContains(getInfo(assertions), getActual(assertions), values); } } IterableAssert_doNotHaveAtLeast_Test.java000066400000000000000000000032141243020563200347600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#doNotHaveAtLeast(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_doNotHaveAtLeast_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doNotHaveAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertDoNotHaveAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_doNotHaveAtMost_Test.java000066400000000000000000000032101243020563200346260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#doNotHaveAtMost(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_doNotHaveAtMost_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doNotHaveAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertDoNotHaveAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_doNotHaveExactly_Test.java000066400000000000000000000032141243020563200350340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#doNotHaveExactly(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_doNotHaveExactly_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doNotHaveExactly(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertDoNotHaveExactly(getInfo(assertions), getActual(assertions), 2, condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_doNotHave_Test.java000066400000000000000000000031751243020563200335670ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#doNotHave(org.fest.assertions.core.Condition)}. * * @author Nicolas François */ public class IterableAssert_doNotHave_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doNotHave(condition); } @Override protected void verify_internal_effects() { verify(iterables).assertDoNotHave(getInfo(assertions), getActual(assertions), condition); } } IterableAssert_doesNotContainNull_Test.java000066400000000000000000000025441243020563200354020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#doesNotContainNull()}. * * @author Joel Costigliola */ public class IterableAssert_doesNotContainNull_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doesNotContainNull(); } @Override protected void verify_internal_effects() { verify(iterables).assertDoesNotContainNull(getInfo(assertions), getActual(assertions)); } } IterableAssert_doesNotContain_Test.java000066400000000000000000000026661243020563200345540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Oct 9, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#doesNotContain(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_doesNotContain_Test extends IterableAssertBaseTest { private final Object[] values = { "Yoda", "Luke" }; @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doesNotContain(values); } @Override protected void verify_internal_effects() { verify(iterables).assertDoesNotContain(getInfo(assertions), getActual(assertions), values); } } IterableAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000026051243020563200360530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Oct 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_doesNotHaveDuplicates_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(iterables).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_endsWith_Test.java000066400000000000000000000026501243020563200334620ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#endsWith(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_endsWith_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.endsWith("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(iterables).assertEndsWith(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } IterableAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000027551243020563200365150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Apr 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class IterableAssert_hasSameSizeAs_with_Array_Test extends IterableAssertBaseTest { String[] other = array("Solo, Leia"); @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(iterables).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } IterableAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000030331243020563200371540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Apr 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class IterableAssert_hasSameSizeAs_with_Iterable_Test extends IterableAssertBaseTest { List other = newArrayList("Solo, Leia"); @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(iterables).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_hasSize_Test.java000066400000000000000000000025731243020563200333070ustar00rootroot00000000000000/* * Created on Aug 3, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#hasSize(int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_hasSize_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(iterables).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } IterableAssert_haveAtLeast_Test.java000066400000000000000000000031701243020563200340150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#haveAtLeast(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_haveAtLeast_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.haveAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertHaveAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_haveAtMost_Test.java000066400000000000000000000031641243020563200336720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Tests for {@link AbstractIterableAssert#areAtMost(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_haveAtMost_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.haveAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertHaveAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } IterableAssert_haveExactly_Test.java000066400000000000000000000031701243020563200340710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#haveExactly(Condition, int)}. * * @author Nicolas François */ public class IterableAssert_haveExactly_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.haveExactly(2, condition); } @Override protected void verify_internal_effects() { verify(iterables).assertHaveExactly(getInfo(assertions), getActual(assertions), 2, condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_have_Test.java000066400000000000000000000030641243020563200326200ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.BeforeClass; /** * Tests for {@link AbstractIterableAssert#have(org.fest.assertions.core.Condition)()}. * * @author Nicolas François */ public class IterableAssert_have_Test extends IterableAssertBaseTest { private static Condition condition; @BeforeClass public static void beforeOnce() { condition = new TestCondition(); } @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.have(condition); } @Override protected void verify_internal_effects() { verify(iterables).assertHave(getInfo(assertions), getActual(assertions), condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/IterableAssert_isEmpty_Test.java000066400000000000000000000030131243020563200333210ustar00rootroot00000000000000/* * Created on Sep 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.junit.Test; /** * Tests for {@link AbstractIterableAssert#isEmpty()}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_isEmpty_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(iterables).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isEmpty is void } } IterableAssert_isNotEmpty_Test.java000066400000000000000000000026271243020563200337350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Sep 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#isNotEmpty()}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class IterableAssert_isNotEmpty_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(iterables).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } IterableAssert_isNullOrEmpty_Test.java000066400000000000000000000031221243020563200343770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; import org.junit.Test; /** * Tests for {@link AbstractIterableAssert#isNullOrEmpty()}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class IterableAssert_isNullOrEmpty_Test extends IterableAssertBaseTest { @Test public void should_verify_actual_is_null_or_empty() {} @Override protected ConcreteIterableAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(iterables).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isNullOrEmpty is void } } IterableAssert_isSubsetOf_Test.java000066400000000000000000000030231243020563200336770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Feb 18, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#isSubsetOf(Iterable)}. * * @author Alex Ruiz * @author Joel Costigliola * @author Maciej Jaskowski */ public class IterableAssert_isSubsetOf_Test extends IterableAssertBaseTest { private final List values = newArrayList("Yoda", "Luke"); @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.isSubsetOf(values); } @Override protected void verify_internal_effects() { verify(iterables).assertIsSubsetOf(getInfo(assertions), getActual(assertions), values); } } IterableAssert_startsWith_Test.java000066400000000000000000000026601243020563200337730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/iterable/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.iterable; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ConcreteIterableAssert; import org.fest.assertions.api.IterableAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#startsWith(Object...)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IterableAssert_startsWith_Test extends IterableAssertBaseTest { @Override protected ConcreteIterableAssert invoke_api_method() { return assertions.startsWith("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(iterables).assertStartsWith(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/000077500000000000000000000000001243020563200242235ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/ListAssert_contains_at_Index_Test.java000066400000000000000000000026421243020563200336770ustar00rootroot00000000000000/* * Created on Nov 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ListAssert#contains(Object, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ListAssert_contains_at_Index_Test extends ListAssertBaseTest { private final Index index = someIndex(); @Override protected ListAssert invoke_api_method() { return assertions.contains("Yoda", index); } @Override protected void verify_internal_effects() { verify(lists).assertContains(getInfo(assertions), getActual(assertions), "Yoda", index); } } ListAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026351243020563200347330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ListAssert#doesNotContain(Object, Index)}. * * @author Alex Ruiz */ public class ListAssert_doesNotContain_at_Index_Test extends ListAssertBaseTest { private final Index index = someIndex(); @Override protected ListAssert invoke_api_method() { return assertions.doesNotContain("Yoda", index); } @Override protected void verify_internal_effects() { verify(lists).assertDoesNotContain(getInfo(assertions), getActual(assertions), "Yoda", index); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/ListAssert_has_at_Index_Test.java000066400000000000000000000020241243020563200326260ustar00rootroot00000000000000package org.fest.assertions.api.list; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.fest.assertions.data.Index; /** * Tests for {@link ListAssert#has(Condition, Index)}. * * @author Bo Gotthardt */ public class ListAssert_has_at_Index_Test extends ListAssertBaseTest { private static Condition condition; private static Index index; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); index = someIndex(); } @Override protected ListAssert invoke_api_method() { return assertions.has(condition, index); } @Override protected void verify_internal_effects() { verify(lists).assertHas(getInfo(assertions), getActual(assertions), condition, index); } } ListAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031471243020563200361310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link AbstractIterableAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class ListAssert_isSortedAccordingToComparator_Test extends ListAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ListAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(lists).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/ListAssert_isSorted_Test.java000066400000000000000000000024201243020563200320340ustar00rootroot00000000000000/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractIterableAssert; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; /** * Tests for {@link AbstractIterableAssert#isSorted()}. * * @author Joel Costigliola */ public class ListAssert_isSorted_Test extends ListAssertBaseTest { @Override protected ListAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(lists).assertIsSorted(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/ListAssert_is_at_Index_Test.java000066400000000000000000000020201243020563200324620ustar00rootroot00000000000000package org.fest.assertions.api.list; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.fest.assertions.data.Index; /** * Tests for {@link ListAssert#is(Condition, Index)}. * * @author Bo Gotthardt */ public class ListAssert_is_at_Index_Test extends ListAssertBaseTest { private static Condition condition; private static Index index; @BeforeClass public static void setUpOnce() { condition = new TestCondition(); index = someIndex(); } @Override protected ListAssert invoke_api_method() { return assertions.is(condition, index); } @Override protected void verify_internal_effects() { verify(lists).assertIs(getInfo(assertions), getActual(assertions), condition, index); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/ListAssert_usingComparator_Test.java000066400000000000000000000031551243020563200334230ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import java.util.List; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ListAssert#usingComparator(java.util.Comparator)} and * {@link ListAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ListAssert_usingComparator_Test extends ListAssertBaseTest { @Mock private Comparator> comparator; @Before public void before() { initMocks(this); } @Override protected ListAssert invoke_api_method() { return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); } } ListAssert_usingDefaultComparator_Test.java000066400000000000000000000033021243020563200346430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/list/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.list; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import java.util.List; import org.fest.assertions.api.ListAssert; import org.fest.assertions.api.ListAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ListAssert#usingComparator(java.util.Comparator)} and * {@link ListAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ListAssert_usingDefaultComparator_Test extends ListAssertBaseTest { @Mock private Comparator> comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected ListAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/000077500000000000000000000000001243020563200243465ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isEqualTo_long_Test.java000066400000000000000000000023161243020563200333000ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isEqualTo(long)}. * * @author Alex Ruiz */ public class LongAssert_isEqualTo_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isEqualTo(8L); } @Override protected void verify_internal_effects() { verify(longs).assertEqual(getInfo(assertions), getActual(assertions), 8L); } } LongAssert_isGreaterThanOrEqualTo_long_Test.java000066400000000000000000000024031243020563200356440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isGreaterThanOrEqualTo(long)}. * * @author Alex Ruiz */ public class LongAssert_isGreaterThanOrEqualTo_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo(6); } @Override protected void verify_internal_effects() { verify(longs).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), 6L); } } LongAssert_isGreaterThan_long_Test.java000066400000000000000000000023371243020563200340560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isGreaterThan(long)}. * * @author Alex Ruiz */ public class LongAssert_isGreaterThan_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isGreaterThan(6); } @Override protected void verify_internal_effects() { verify(longs).assertGreaterThan(getInfo(assertions), getActual(assertions), 6L); } } LongAssert_isLessThanOrEqualTo_long_Test.java000066400000000000000000000023701243020563200351640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isLessThanOrEqualTo(long)}. * * @author Alex Ruiz */ public class LongAssert_isLessThanOrEqualTo_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isLessThanOrEqualTo(8L); } @Override protected void verify_internal_effects() { verify(longs).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), 8L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isLessThan_long_Test.java000066400000000000000000000023241243020563200334460ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isLessThan(long)}. * * @author Alex Ruiz */ public class LongAssert_isLessThan_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isLessThan(8L); } @Override protected void verify_internal_effects() { verify(longs).assertLessThan(getInfo(assertions), getActual(assertions), 8L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isNegative_Test.java000066400000000000000000000023071243020563200324510ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isNegative()}. * * @author Alex Ruiz */ public class LongAssert_isNegative_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(longs).assertIsNegative(getInfo(assertions), getActual(assertions)); } } LongAssert_isNotEqualTo_long_Test.java000066400000000000000000000023321243020563200337000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isNotEqualTo(long)}. * * @author Alex Ruiz */ public class LongAssert_isNotEqualTo_long_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isNotEqualTo(8L); } @Override protected void verify_internal_effects() { verify(longs).assertNotEqual(getInfo(assertions), getActual(assertions), 8L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isNotNegative_Test.java000066400000000000000000000023331243020563200331310ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isNotNegative()}. * * @author Nicolas François */ public class LongAssert_isNotNegative_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(longs).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isNotPositive_Test.java000066400000000000000000000023331243020563200331710ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isNotPositive()}. * * @author Nicolas François */ public class LongAssert_isNotPositive_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(longs).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isNotZero_Test.java000066400000000000000000000023031243020563200323030ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isNotZero()}. * * @author Alex Ruiz */ public class LongAssert_isNotZero_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(longs).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isPositive_Test.java000066400000000000000000000023071243020563200325110ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isPositive()}. * * @author Alex Ruiz */ public class LongAssert_isPositive_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(longs).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_isZero_Test.java000066400000000000000000000022671243020563200316330ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; /** * Tests for {@link LongAssert#isZero()}. * * @author Alex Ruiz */ public class LongAssert_isZero_Test extends LongAssertBaseTest { @Override protected LongAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(longs).assertIsZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/LongAssert_usingComparator_Test.java000066400000000000000000000032331243020563200335270ustar00rootroot00000000000000/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class LongAssert_usingComparator_Test extends LongAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected LongAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getLongs(assertions).getComparator(), comparator); } } LongAssert_usingDefaultComparator_Test.java000066400000000000000000000033431243020563200347570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/long_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.long_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongAssert; import org.fest.assertions.api.LongAssertBaseTest; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongAssert#usingComparator(java.util.Comparator)} and * {@link LongAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class LongAssert_usingDefaultComparator_Test extends LongAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected LongAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getLongs(assertions), Longs.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/000077500000000000000000000000001243020563200252465ustar00rootroot00000000000000LongArrayAssert_containsOnly_Test.java000066400000000000000000000025131243020563200346520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#containsOnly(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_containsOnly_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.containsOnly(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_containsSequence_Test.java000066400000000000000000000025331243020563200355030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#containsSequence(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_containsSequence_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.containsSequence(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_contains_Test.java000066400000000000000000000024731243020563200340150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#contains(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_contains_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.contains(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_contains_at_Index_Test.java000066400000000000000000000026301243020563200356230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link LongArrayAssert#contains(long, Index)}. * * @author Alex Ruiz */ public class LongArrayAssert_contains_at_Index_Test extends LongArrayAssertBaseTest { private final Index index = someIndex(); @Override protected LongArrayAssert invoke_api_method() { return assertions.contains(8L, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), 8L, index); } } LongArrayAssert_doesNotContain_Test.java000066400000000000000000000025231243020563200351220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#doesNotContain(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_doesNotContain_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.doesNotContain(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000026601243020563200367370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link LongArrayAssert#doesNotContain(long, Index)}. * * @author Alex Ruiz */ public class LongArrayAssert_doesNotContain_at_Index_Test extends LongArrayAssertBaseTest { private final Index index = someIndex(); @Override protected LongArrayAssert invoke_api_method() { return assertions.doesNotContain(8L, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), 8L, index); } } LongArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024261243020563200364320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class LongArrayAssert_doesNotHaveDuplicates_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } LongArrayAssert_endsWith_Test.java000066400000000000000000000024731243020563200337640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#endsWith(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_endsWith_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.endsWith(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026501243020563200370650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class LongArrayAssert_hasSameSizeAs_with_Array_Test extends LongArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected LongArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } LongArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027261243020563200375420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class LongArrayAssert_hasSameSizeAs_with_Iterable_Test extends LongArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected LongArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/LongArrayAssert_hasSize_Test.java000066400000000000000000000024131243020563200336560ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class LongArrayAssert_hasSize_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/LongArrayAssert_isEmpty_Test.java000066400000000000000000000026321243020563200337050ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link LongArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class LongArrayAssert_isEmpty_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isEmpty is void } } LongArrayAssert_isNotEmpty_Test.java000066400000000000000000000024161243020563200343070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class LongArrayAssert_isNotEmpty_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } LongArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026121243020563200347600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link LongArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class LongArrayAssert_isNullOrEmpty_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isNullOrEmpty is void } } LongArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000030761243020563200401400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class LongArrayAssert_isSortedAccordingToComparator_Test extends LongArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected LongArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } LongArrayAssert_isSorted_Test.java000066400000000000000000000023501243020563200337650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class LongArrayAssert_isSorted_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } LongArrayAssert_startsWith_Test.java000066400000000000000000000025031243020563200343450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; /** * Tests for {@link LongArrayAssert#startsWith(long...)}. * * @author Alex Ruiz */ public class LongArrayAssert_startsWith_Test extends LongArrayAssertBaseTest { @Override protected LongArrayAssert invoke_api_method() { return assertions.startsWith(6L, 8L); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6L, 8L)); } } LongArrayAssert_usingComparator_Test.java000066400000000000000000000035161243020563200353530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.internal.LongArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class LongArrayAssert_usingComparator_Test extends LongArrayAssertBaseTest { @Mock private Comparator comparator; private LongArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected LongArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } LongArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034461243020563200366620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.LongArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class LongArrayAssert_usingDefaultComparator_Test extends LongArrayAssertBaseTest { @Mock private Comparator comparator; private LongArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected LongArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } LongArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035041243020563200401670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.LongArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class LongArrayAssert_usingDefaultElementComparator_Test extends LongArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected LongArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), LongArrays.instance()); } } LongArrayAssert_usingElementComparator_Test.java000066400000000000000000000035251243020563200366650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/longarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.longarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.LongArrayAssert; import org.fest.assertions.api.LongArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link LongArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class LongArrayAssert_usingElementComparator_Test extends LongArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected LongArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/000077500000000000000000000000001243020563200240255ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_containsKey_Test.java000066400000000000000000000024231243020563200321360ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#containsKey(Object)}. * * @author Nicolas François */ public class MapAssert_containsKey_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.containsKey("key1"); } @Override protected void verify_internal_effects() { verify(maps).assertContainsKey(getInfo(assertions), getActual(assertions), "key1"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_containsValue_Test.java000066400000000000000000000024331243020563200324630ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#containsValue(Object)}. * * @author Nicolas François */ public class MapAssert_containsValue_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.containsValue("key1"); } @Override protected void verify_internal_effects() { verify(maps).assertContainsValue(getInfo(assertions), getActual(assertions), "key1"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_contains_Test.java000066400000000000000000000030651243020563200314700ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; import org.fest.assertions.data.MapEntry; /** * Tests for {@link MapAssert#contains(MapEntry...)}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_contains_Test extends MapAssertBaseTest { final MapEntry[] entries = array(entry("key1", "value1"), entry("key2", "value2")); @Override protected MapAssert invoke_api_method() { return assertions.contains(entry("key1", "value1"), entry("key2", "value2")); } @Override protected void verify_internal_effects() { verify(maps).assertContains(getInfo(assertions), getActual(assertions), entries); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_doesNotContainKey_Test.java000066400000000000000000000024531243020563200332520ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#doesNotContainKey(Object)}. * * @author Nicolas François */ public class MapAssert_doesNotContainKey_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.doesNotContainKey("key1"); } @Override protected void verify_internal_effects() { verify(maps).assertDoesNotContainKey(getInfo(assertions), getActual(assertions), "key1"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_doesNotContainValue_Test.java000066400000000000000000000024671243020563200336030ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#doesNotContainValue(Object)}. * * @author Nicolas François */ public class MapAssert_doesNotContainValue_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.doesNotContainValue("value1"); } @Override protected void verify_internal_effects() { verify(maps).assertDoesNotContainValue(getInfo(assertions), getActual(assertions), "value1"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_doesNotContain_Test.java000066400000000000000000000031071243020563200325760ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; import org.fest.assertions.data.MapEntry; /** * Tests for {@link MapAssert#doesNotContain(MapEntry...)}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_doesNotContain_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.doesNotContain(entry("key1", "value1"), entry("key2", "value2")); } @Override protected void verify_internal_effects() { MapEntry[] entries = array(entry("key1", "value1"), entry("key2", "value2")); verify(maps).assertDoesNotContain(getInfo(assertions), getActual(assertions), entries); } } MapAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026151243020563200344640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapsAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class MapAssert_hasSameSizeAs_with_Array_Test extends MapAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected MapAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(maps).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } MapAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000026731243020563200351410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.map; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapsAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class MapAssert_hasSameSizeAs_with_Iterable_Test extends MapAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected MapAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(maps).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_hasSize_Test.java000066400000000000000000000024151243020563200312560ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#hasSize(int)}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_hasSize_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(maps).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_isEmpty_Test.java000066400000000000000000000026341243020563200313050ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; import org.junit.Test; /** * Tests for {@link MapAssert#isEmpty()}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_isEmpty_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(maps).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isEmpty is void } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_isNotEmpty_Test.java000066400000000000000000000024201243020563200317570ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; /** * Tests for {@link MapAssert#isNotEmpty()}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_isNotEmpty_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(maps).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/map/MapAssert_isNullOrEmpty_Test.java000066400000000000000000000026721243020563200324430ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.map; import static org.mockito.Mockito.verify; import org.fest.assertions.api.MapAssert; import org.fest.assertions.api.MapAssertBaseTest; import org.junit.Test; /** * Tests for {@link MapAssert#isNullOrEmpty()}. * * @author Alex Ruiz * @author Nicolas François */ public class MapAssert_isNullOrEmpty_Test extends MapAssertBaseTest { @Override protected MapAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(maps).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test because isNullOrEmpty is void } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/000077500000000000000000000000001243020563200245165ustar00rootroot00000000000000ObjectAssert_isEqualsToByComparingFields_Test.java000066400000000000000000000026141243020563200363270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * * Created on May 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.object; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.test.Jedi; /** * Tests for {@link ObjectAssert#isEqualsToByComparingFields(Object)}. * * @author Nicolas François */ public class ObjectAssert_isEqualsToByComparingFields_Test extends ObjectAssertBaseTest { private Jedi other = new Jedi("Yoda", "Blue"); @Override protected ObjectAssert invoke_api_method() { return assertions.isEqualsToByComparingFields(other); } @Override protected void verify_internal_effects() { verify(objects).assertIsLenientEqualsToByIgnoringFields(getInfo(assertions), getActual(assertions), other); } } ObjectAssert_isLenientEqualsToByAcceptingFields_Test.java000066400000000000000000000027301243020563200376230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * * Created on Apr 9, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.object; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.test.Jedi; /** * Tests for {@link ObjectAssert#isLenientEqualsToByAcceptingFields(Object, String...)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectAssert_isLenientEqualsToByAcceptingFields_Test extends ObjectAssertBaseTest { private Jedi other = new Jedi("Yoda", "Blue"); @Override protected ObjectAssert invoke_api_method() { return assertions.isLenientEqualsToByAcceptingFields(other, "name"); } @Override protected void verify_internal_effects() { verify(objects).assertIsLenientEqualsToByAcceptingFields(getInfo(assertions), getActual(assertions), other, "name"); } } ObjectAssert_isLenientEqualsToByIgnoringFields_Test.java000066400000000000000000000027521243020563200375060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * * Created on Apr 9, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.object; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.test.Jedi; /** * Tests for {@link ObjectAssert#isLenientEqualsToByIgnoringFields(Object, String...)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectAssert_isLenientEqualsToByIgnoringFields_Test extends ObjectAssertBaseTest { private Jedi other = new Jedi("Yoda", "Blue"); @Override protected ObjectAssert invoke_api_method() { return assertions.isLenientEqualsToByIgnoringFields(other, "lightSaberColor"); } @Override protected void verify_internal_effects() { verify(objects).assertIsLenientEqualsToByIgnoringFields(getInfo(assertions), getActual(assertions), other, "lightSaberColor"); } } ObjectAssert_isLenientEqualsToByIgnoringNullFields_Test.java000066400000000000000000000027121243020563200403350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * * Created on Apr 9, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.object; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.test.Jedi; /** * Tests for {@link ObjectAssert#isLenientEqualsToByIgnoringNullFields(Object)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectAssert_isLenientEqualsToByIgnoringNullFields_Test extends ObjectAssertBaseTest { private Jedi other = new Jedi("Yoda", "Green"); @Override protected ObjectAssert invoke_api_method() { return assertions.isLenientEqualsToByIgnoringNullFields(other); } @Override protected void verify_internal_effects() { verify(objects).assertIsLenientEqualsToByIgnoringNullFields(getInfo(assertions), getActual(assertions), other); } } ObjectAssert_usingComparator_Test.java000066400000000000000000000033451243020563200341330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.object; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.test.Jedi; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectAssert#usingComparator(java.util.Comparator)} and * {@link ObjectAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectAssert_usingComparator_Test extends ObjectAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ObjectAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); } } ObjectAssert_usingDefaultComparator_Test.java000066400000000000000000000031751243020563200354410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/object/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.object; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectAssert; import org.fest.assertions.api.ObjectAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.test.Jedi; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectAssert_usingDefaultComparator_Test extends ObjectAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected ObjectAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/000077500000000000000000000000001243020563200255555ustar00rootroot00000000000000ObjectArrayAssert_areAtLeast_Test.java000066400000000000000000000030751243020563200350410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areAtLeast(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areAtLeast_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } }ObjectArrayAssert_areAtMost_Test.java000066400000000000000000000030721243020563200347100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areAtMost(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areAtMost_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_areExactly_Test.java000066400000000000000000000030761243020563200351160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areExactly(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areExactly_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areExactly(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreExactly(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_areNotAtLeast_Test.java000066400000000000000000000031121243020563200355120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areNotAtLeast(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areNotAtLeast_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areNotAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreNotAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_areNotAtMost_Test.java000066400000000000000000000031061243020563200353670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areNotAtMost(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areNotAtMost_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areNotAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreNotAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_areNotExactly_Test.java000066400000000000000000000031121243020563200355660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areNotExactly(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areNotExactly_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areNotExactly(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreNotExactly(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_areNot_Test.java000066400000000000000000000030731243020563200342420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#areNot(org.fest.assertions.core.Condition)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_areNot_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.areNot(condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAreNot(getInfo(assertions), getActual(assertions), condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/ObjectArrayAssert_are_Test.java000066400000000000000000000030571243020563200336420ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#are(org.fest.assertions.core.Condition)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_are_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.are(condition); } @Override protected void verify_internal_effects() { verify(arrays).assertAre(getInfo(assertions), getActual(assertions), condition); } } ObjectArrayAssert_containsAll_Test.java000066400000000000000000000025751243020563200352670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#containsAll(Iterable)}. * * @author Joel Costigliola */ public class ObjectArrayAssert_containsAll_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.containsAll(newArrayList("Yoda", "Luke")); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsAll(getInfo(assertions), getActual(assertions), newArrayList("Yoda", "Luke")); } } ObjectArrayAssert_containsExactly_Test.java000066400000000000000000000025131243020563200361600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Jun 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#containsExactly(Object...)}. * * @author Nicolas François */ public class ObjectArrayAssert_containsExactly_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.containsExactly("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(objects).assertEqual(getInfo(assertions), getActual(assertions), new String[] {"Yoda", "Luke"}); } } ObjectArrayAssert_containsNull_Test.java000066400000000000000000000024611243020563200354630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#doesNotContainNull()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_containsNull_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.containsNull(); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsNull(getInfo(assertions), getActual(assertions)); } } ObjectArrayAssert_containsOnly_Test.java000066400000000000000000000025741243020563200354770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#containsOnly(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_containsOnly_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.containsOnly("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), array("Yoda", "Luke")); } } ObjectArrayAssert_containsSequence_Test.java000066400000000000000000000026141243020563200363210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#containsSequence(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_containsSequence_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.containsSequence("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } ObjectArrayAssert_contains_Test.java000066400000000000000000000025541243020563200346330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#contains(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_contains_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.contains("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), array("Yoda", "Luke")); } } ObjectArrayAssert_contains_at_Index_Test.java000066400000000000000000000027241243020563200364450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ObjectArrayAssert#contains(Object, Index)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_contains_at_Index_Test extends ObjectArrayAssertBaseTest { private final Index index = someIndex(); @Override protected ObjectArrayAssert invoke_api_method() { return assertions.contains("Yoda", index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), "Yoda", index); } } ObjectArrayAssert_doNotHaveAtLeast_Test.java000066400000000000000000000031251243020563200361550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#doNotHaveAtLeas(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_doNotHaveAtLeast_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doNotHaveAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertDoNotHaveAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_doNotHaveAtMost_Test.java000066400000000000000000000031221243020563200360240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#doNotHaveAtMost(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_doNotHaveAtMost_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doNotHaveAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertDoNotHaveAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_doNotHaveExactly_Test.java000066400000000000000000000031261243020563200362320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#doNotHaveExactly(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_doNotHaveExactly_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doNotHaveExactly(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertDoNotHaveExactly(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_doNothave_Test.java000066400000000000000000000030701243020563200347360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#have(org.fest.assertions.core.Condition)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_doNothave_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.have(condition); } @Override protected void verify_internal_effects() { verify(arrays).assertHave(getInfo(assertions), getActual(assertions), condition); } } ObjectArrayAssert_doesNotContainNull_Test.java000066400000000000000000000025031243020563200365710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#doesNotContainNull()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_doesNotContainNull_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doesNotContainNull(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContainNull(getInfo(assertions), getActual(assertions)); } } ObjectArrayAssert_doesNotContain_Test.java000066400000000000000000000026041243020563200357400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#doesNotContain(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_doesNotContain_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doesNotContain("Yoda", "Luke"); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), array("Yoda", "Luke")); } } ObjectArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000027531243020563200375600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ObjectArrayAssert#doesNotContain(Object, Index)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_doesNotContain_at_Index_Test extends ObjectArrayAssertBaseTest { private final Index index = someIndex(); @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doesNotContain("Yoda", index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), "Yoda", index); } } ObjectArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000025101243020563200372420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_doesNotHaveDuplicates_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } ObjectArrayAssert_endsWith_Test.java000066400000000000000000000025531243020563200346010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#endsWith(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_endsWith_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.endsWith("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } ObjectArrayAssert_hasSameSizeAs_with_Arrays_Test.java000066400000000000000000000027261243020563200400720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#hasSameSizeAs(Object[]))}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_hasSameSizeAs_with_Arrays_Test extends ObjectArrayAssertBaseTest { private final String[] other = array("Yoda"); @Override protected ObjectArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } ObjectArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027751243020563200403640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#hasSameSizeAs(int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_hasSameSizeAs_with_Iterable_Test extends ObjectArrayAssertBaseTest { private final List other = newArrayList("Yoda"); @Override protected ObjectArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } ObjectArrayAssert_hasSize_Test.java000066400000000000000000000024761243020563200344260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#hasSize(int)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_hasSize_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } ObjectArrayAssert_haveAtLeast_Test.java000066400000000000000000000031021243020563200352040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#haveAtLeast(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_haveAtLeast_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.haveAtLeast(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertHaveAtLeast(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_haveAtMost_Test.java000066400000000000000000000030761243020563200350700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#haveAtMost(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_haveAtMost_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.haveAtMost(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertHaveAtMost(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_haveExactly_Test.java000066400000000000000000000031021243020563200352600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#haveExactly(Condition, int)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_haveExactly_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.haveExactly(2, condition); } @Override protected void verify_internal_effects() { verify(arrays).assertHaveExactly(getInfo(assertions), getActual(assertions), 2, condition); } } ObjectArrayAssert_have_Test.java000066400000000000000000000031021243020563200337260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; /** * Tests for {@link ObjectArrayAssert#doNotHave(org.fest.assertions.core.Condition)}. * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrayAssert_have_Test extends ObjectArrayAssertBaseTest { private static Condition condition; @Before public void before() { condition = new TestCondition(); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.doNotHave(condition); } @Override protected void verify_internal_effects() { verify(arrays).assertDoNotHave(getInfo(assertions), getActual(assertions), condition); } } ObjectArrayAssert_isEmpty_Test.java000066400000000000000000000027101243020563200344410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ObjectArrayAssert#isEmpty()}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_isEmpty_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, isEmpty is void } } ObjectArrayAssert_isNotEmpty_Test.java000066400000000000000000000025011243020563200351200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#isNotEmpty()}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_isNotEmpty_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } ObjectArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000027011243020563200355750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ObjectArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_isNullOrEmpty_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isNullOrEmpty method is void. } } ObjectArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031751243020563200407560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_isSortedAccordingToComparator_Test extends ObjectArrayAssertBaseTest { @Mock private Comparator mockComparator; @Before public void before() { initMocks(this); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(mockComparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), mockComparator); } } ObjectArrayAssert_isSorted_Test.java000066400000000000000000000024321243020563200346040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#isSorted()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_isSorted_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } ObjectArrayAssert_startsWith_Test.java000066400000000000000000000025631243020563200351710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; /** * Tests for {@link ObjectArrayAssert#startsWith(Object...)}. * * @author Alex Ruiz * @author Mikhail Mazursky */ public class ObjectArrayAssert_startsWith_Test extends ObjectArrayAssertBaseTest { @Override protected ObjectArrayAssert invoke_api_method() { return assertions.startsWith("Luke", "Yoda"); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), array("Luke", "Yoda")); } } ObjectArrayAssert_usingComparator_Test.java000066400000000000000000000033721243020563200361710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.internal.ObjectArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_usingComparator_Test extends ObjectArrayAssertBaseTest { @Mock private Comparator comparator; private ObjectArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } ObjectArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000035021243020563200374710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_usingDefaultComparator_Test extends ObjectArrayAssertBaseTest { @Mock private Comparator comparator; private ObjectArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); assertions.usingComparator(comparator); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } ObjectArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035561243020563200410140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_usingDefaultElementComparator_Test extends ObjectArrayAssertBaseTest { @Mock private Comparator elementComparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(elementComparator); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), ObjectArrays.instance()); } } ObjectArrayAssert_usingElementComparator_Test.java000066400000000000000000000034221243020563200374770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/objectarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.objectarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ObjectArrayAssert; import org.fest.assertions.api.ObjectArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ObjectArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrayAssert_usingElementComparator_Test extends ObjectArrayAssertBaseTest { @Mock private Comparator elementComparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected ObjectArrayAssert invoke_api_method() { return assertions.usingElementComparator(elementComparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), elementComparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/000077500000000000000000000000001243020563200245465ustar00rootroot00000000000000ShortAssert_isEqualTo_short_Test.java000066400000000000000000000023461243020563200340240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isEqualTo(short)}. * * @author Alex Ruiz */ public class ShortAssert_isEqualTo_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isEqualTo((short) 8); } @Override protected void verify_internal_effects() { verify(shorts).assertEqual(getInfo(assertions), getActual(assertions), (short) 8); } } ShortAssert_isGreaterThanOrEqualTo_short_Test.java000066400000000000000000000024341243020563200364500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isGreaterThanOrEqualTo(short)}. * * @author Alex Ruiz */ public class ShortAssert_isGreaterThanOrEqualTo_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isGreaterThanOrEqualTo((short) 6); } @Override protected void verify_internal_effects() { verify(shorts).assertGreaterThanOrEqualTo(getInfo(assertions), getActual(assertions), (short) 6); } } ShortAssert_isGreaterThan_short_Test.java000066400000000000000000000023701243020563200346530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isGreaterThan(short)}. * * @author Alex Ruiz */ public class ShortAssert_isGreaterThan_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isGreaterThan((short) 6); } @Override protected void verify_internal_effects() { verify(shorts).assertGreaterThan(getInfo(assertions), getActual(assertions), (short) 6); } } ShortAssert_isLessThanOrEqualTo_short_Test.java000066400000000000000000000024201243020563200357600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isLessThanOrEqualTo(short)}. * * @author Alex Ruiz */ public class ShortAssert_isLessThanOrEqualTo_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isLessThanOrEqualTo((short) 8); } @Override protected void verify_internal_effects() { verify(shorts).assertLessThanOrEqualTo(getInfo(assertions), getActual(assertions), (short) 8); } } ShortAssert_isLessThan_short_Test.java000066400000000000000000000023541243020563200341720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isLessThan(short)}. * * @author Alex Ruiz */ public class ShortAssert_isLessThan_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isLessThan((short) 8); } @Override protected void verify_internal_effects() { verify(shorts).assertLessThan(getInfo(assertions), getActual(assertions), (short) 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isNegative_Test.java000066400000000000000000000023171243020563200330520ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isNegative()}. * * @author Alex Ruiz */ public class ShortAssert_isNegative_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isNegative(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsNegative(getInfo(assertions), getActual(assertions)); } } ShortAssert_isNotEqualTo_short_Test.java000066400000000000000000000023621243020563200345030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isNotEqualTo(short)}. * * @author Alex Ruiz */ public class ShortAssert_isNotEqualTo_short_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isNotEqualTo((short) 8); } @Override protected void verify_internal_effects() { verify(shorts).assertNotEqual(getInfo(assertions), getActual(assertions), (short) 8); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isNotNegative_Test.java000066400000000000000000000023431243020563200335320ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isNotNegative()}. * * @author Nicolas François */ public class ShortAssert_isNotNegative_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isNotNegative(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsNotNegative(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isNotPositive_Test.java000066400000000000000000000023431243020563200335720ustar00rootroot00000000000000/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isNotPositive()}. * * @author Nicolas François */ public class ShortAssert_isNotPositive_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isNotPositive(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsNotPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isNotZero_Test.java000066400000000000000000000023131243020563200327040ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isNotZero()}. * * @author Alex Ruiz */ public class ShortAssert_isNotZero_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isNotZero(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsNotZero(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isPositive_Test.java000066400000000000000000000023171243020563200331120ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isPositive()}. * * @author Alex Ruiz */ public class ShortAssert_isPositive_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isPositive(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsPositive(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/ShortAssert_isZero_Test.java000066400000000000000000000022771243020563200322340ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; /** * Tests for {@link ShortAssert#isZero()}. * * @author Alex Ruiz */ public class ShortAssert_isZero_Test extends ShortAssertBaseTest { @Override protected ShortAssert invoke_api_method() { return assertions.isZero(); } @Override protected void verify_internal_effects() { verify(shorts).assertIsZero(getInfo(assertions), getActual(assertions)); } } ShortAssert_usingComparator_Test.java000066400000000000000000000032441243020563200340520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class ShortAssert_usingComparator_Test extends ShortAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ShortAssert invoke_api_method() { // in that, we don't care of the comparator, the point to check is that we switch correctly of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getShorts(assertions).getComparator(), comparator); } } ShortAssert_usingDefaultComparator_Test.java000066400000000000000000000032411243020563200353540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/short_/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.short_; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortAssert; import org.fest.assertions.api.ShortAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.Shorts; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class ShortAssert_usingDefaultComparator_Test extends ShortAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); } @Override protected ShortAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getShorts(assertions), Shorts.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/000077500000000000000000000000001243020563200254465ustar00rootroot00000000000000ShortArrayAssert_containsOnly_Test.java000066400000000000000000000025401243020563200352520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#containsOnly(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_containsOnly_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.containsOnly((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsOnly(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_containsSequence_Test.java000066400000000000000000000025601243020563200361030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#containsSequence(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_containsSequence_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.containsSequence((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContainsSequence(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_contains_Test.java000066400000000000000000000025201243020563200344060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#contains(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_contains_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.contains((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_contains_at_Index_Test.java000066400000000000000000000026561243020563200362330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ShortArrayAssert#contains(short, Index)}. * * @author Alex Ruiz */ public class ShortArrayAssert_contains_at_Index_Test extends ShortArrayAssertBaseTest { private final Index index = someIndex(); @Override protected ShortArrayAssert invoke_api_method() { return assertions.contains((short) 8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertContains(getInfo(assertions), getActual(assertions), (short) 8, index); } } ShortArrayAssert_doesNotContain_Test.java000066400000000000000000000025501243020563200355220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#doesNotContain(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_doesNotContain_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.doesNotContain((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_doesNotContain_at_Index_Test.java000066400000000000000000000027061243020563200373400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.TestData.someIndex; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.data.Index; /** * Tests for {@link ShortArrayAssert#doesNotContain(short, Index)}. * * @author Alex Ruiz */ public class ShortArrayAssert_doesNotContain_at_Index_Test extends ShortArrayAssertBaseTest { private final Index index = someIndex(); @Override protected ShortArrayAssert invoke_api_method() { return assertions.doesNotContain((short) 8, index); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotContain(getInfo(assertions), getActual(assertions), (short) 8, index); } } ShortArrayAssert_doesNotHaveDuplicates_Test.java000066400000000000000000000024351243020563200370320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#doesNotHaveDuplicates()}. * * @author Alex Ruiz */ public class ShortArrayAssert_doesNotHaveDuplicates_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.doesNotHaveDuplicates(); } @Override protected void verify_internal_effects() { verify(arrays).assertDoesNotHaveDuplicates(getInfo(assertions), getActual(assertions)); } } ShortArrayAssert_endsWith_Test.java000066400000000000000000000025201243020563200343550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#endsWith(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_endsWith_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.endsWith((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertEndsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000026571243020563200374740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class ShortArrayAssert_hasSameSizeAs_with_Array_Test extends ShortArrayAssertBaseTest { private final String[] other = array("Yoda", "Luke"); @Override protected ShortArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } ShortArrayAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000027351243020563200401420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class ShortArrayAssert_hasSameSizeAs_with_Iterable_Test extends ShortArrayAssertBaseTest { private final List other = newArrayList("Yoda", "Luke"); @Override protected ShortArrayAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } ShortArrayAssert_hasSize_Test.java000066400000000000000000000024221243020563200341770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#hasSize(int)}. * * @author Alex Ruiz */ public class ShortArrayAssert_hasSize_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(arrays).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } ShortArrayAssert_isEmpty_Test.java000066400000000000000000000026461243020563200342330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ShortArrayAssert#isEmpty()}. * * @author Alex Ruiz */ public class ShortArrayAssert_isEmpty_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isEmpty method is void. } } ShortArrayAssert_isNotEmpty_Test.java000066400000000000000000000024251243020563200347070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class ShortArrayAssert_isNotEmpty_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(arrays).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } ShortArrayAssert_isNullOrEmpty_Test.java000066400000000000000000000026341243020563200353640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.junit.Test; /** * Tests for {@link ShortArrayAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class ShortArrayAssert_isNullOrEmpty_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(arrays).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isNullOrEmpty method is void. } } ShortArrayAssert_isSortedAccordingToComparator_Test.java000066400000000000000000000031051243020563200405310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortArrayAssert#isSortedAccordingTo(Comparator)}. * * @author Joel Costigliola */ public class ShortArrayAssert_isSortedAccordingToComparator_Test extends ShortArrayAssertBaseTest { @Mock private Comparator comparator; @Before public void before() { initMocks(this); } @Override protected ShortArrayAssert invoke_api_method() { return assertions.isSortedAccordingTo(comparator); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSortedAccordingToComparator(getInfo(assertions), getActual(assertions), comparator); } } ShortArrayAssert_isSorted_Test.java000066400000000000000000000023571243020563200343740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#isSorted()}. * * @author Joel Costigliola */ public class ShortArrayAssert_isSorted_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.isSorted(); } @Override protected void verify_internal_effects() { verify(arrays).assertIsSorted(getInfo(assertions), getActual(assertions)); } } ShortArrayAssert_startsWith_Test.java000066400000000000000000000025301243020563200347450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; /** * Tests for {@link ShortArrayAssert#startsWith(short...)}. * * @author Alex Ruiz */ public class ShortArrayAssert_startsWith_Test extends ShortArrayAssertBaseTest { @Override protected ShortArrayAssert invoke_api_method() { return assertions.startsWith((short) 6, (short) 8); } @Override protected void verify_internal_effects() { verify(arrays).assertStartsWith(getInfo(assertions), getActual(assertions), arrayOf(6, 8)); } } ShortArrayAssert_usingComparator_Test.java000066400000000000000000000035301243020563200357470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.internal.ShortArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortArrayAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ShortArrayAssert_usingComparator_Test extends ShortArrayAssertBaseTest { @Mock private Comparator comparator; private ShortArrays arraysBefore; @Before public void before() { initMocks(this); arraysBefore = getArrays(assertions); } @Override protected ShortArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), comparator); assertSame(getArrays(assertions), arraysBefore); } } ShortArrayAssert_usingDefaultComparator_Test.java000066400000000000000000000034601243020563200372560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ShortArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortArrayAssert#usingDefaultComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ShortArrayAssert_usingDefaultComparator_Test extends ShortArrayAssertBaseTest { @Mock private Comparator comparator; private ShortArrays arraysBefore; @Before public void before() { initMocks(this); assertions.usingComparator(comparator); arraysBefore = getArrays(assertions); } @Override protected ShortArrayAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getArrays(assertions), arraysBefore); } } ShortArrayAssert_usingDefaultElementComparator_Test.java000066400000000000000000000035161243020563200405720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ShortArrays; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortArrayAssert#usingDefaultElementComparator()}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ShortArrayAssert_usingDefaultElementComparator_Test extends ShortArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); assertions.usingElementComparator(comparator); } @Override protected ShortArrayAssert invoke_api_method() { return assertions.usingDefaultElementComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions), ShortArrays.instance()); } } ShortArrayAssert_usingElementComparator_Test.java000066400000000000000000000035351243020563200372660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/shortarray/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.shortarray; import static junit.framework.Assert.assertSame; import static org.mockito.MockitoAnnotations.initMocks; import java.util.Comparator; import org.fest.assertions.api.ShortArrayAssert; import org.fest.assertions.api.ShortArrayAssertBaseTest; import org.fest.assertions.internal.Objects; import org.junit.Before; import org.mockito.Mock; /** * Tests for {@link ShortArrayAssert#usingElementComparator(Comparator)}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ShortArrayAssert_usingElementComparator_Test extends ShortArrayAssertBaseTest { @Mock private Comparator comparator; private Objects objectsBefore; @Before public void before() { initMocks(this); objectsBefore = getObjects(assertions); } @Override protected ShortArrayAssert invoke_api_method() { // in that test, the comparator type is not important, we only check that we correctly switch of comparator return assertions.usingElementComparator(comparator); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), objectsBefore); assertSame(getArrays(assertions).getComparator(), comparator); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/000077500000000000000000000000001243020563200245565ustar00rootroot00000000000000StringAssert_containsIgnoringCase_String_Test.java000066400000000000000000000024251243020563200365110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#containsIgnoringCase(String)}. * * @author Alex Ruiz */ public class StringAssert_containsIgnoringCase_String_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.containsIgnoringCase("od"); } @Override protected void verify_internal_effects() { verify(strings).assertContainsIgnoringCase(getInfo(assertions), getActual(assertions), "od"); } } StringAssert_containsOnlyOnce_Test.java000066400000000000000000000012341243020563200343360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/stringpackage org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#containsOnlyOnce(String)}. * * @author Pauline Iogna * @author Joel Costigliola */ public class StringAssert_containsOnlyOnce_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.containsOnlyOnce("od"); } @Override protected void verify_internal_effects() { verify(strings).assertContainsOnlyOnce(getInfo(assertions), getActual(assertions), "od"); } }StringAssert_contains_String_Test.java000066400000000000000000000023451243020563200342210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#contains(String)}. * * @author Alex Ruiz */ public class StringAssert_contains_String_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.contains("od"); } @Override protected void verify_internal_effects() { verify(strings).assertContains(getInfo(assertions), getActual(assertions), "od"); } } StringAssert_doesNotContain_Test.java000066400000000000000000000023721243020563200340040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#doesNotContain(String)}. * * @author Alex Ruiz */ public class StringAssert_doesNotContain_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.doesNotContain("Luke"); } @Override protected void verify_internal_effects() { verify(strings).assertDoesNotContain(getInfo(assertions), getActual(assertions), "Luke"); } } StringAssert_doesNotMatch_Pattern_Test.java000066400000000000000000000027651243020563200351500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.fest.assertions.test.TestData.matchAnything; import static org.mockito.Mockito.verify; import java.util.regex.Pattern; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#doesNotMatch(Pattern)}. * * @author Alex Ruiz */ public class StringAssert_doesNotMatch_Pattern_Test extends StringAssertBaseTest { private static String regex; @BeforeClass public static void setUpOnce() { regex = matchAnything().pattern(); } @Override protected StringAssert invoke_api_method() { return assertions.doesNotMatch(regex); } @Override protected void verify_internal_effects() { verify(strings).assertDoesNotMatch(getInfo(assertions), getActual(assertions), regex); } } StringAssert_doesNotMatch_String_Test.java000066400000000000000000000027621243020563200347760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.fest.assertions.test.TestData.matchAnything; import static org.mockito.Mockito.verify; import java.util.regex.Pattern; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#doesNotMatch(String)}. * * @author Alex Ruiz */ public class StringAssert_doesNotMatch_String_Test extends StringAssertBaseTest { private static Pattern pattern; @BeforeClass public static void setUpOnce() { pattern = matchAnything(); } @Override protected StringAssert invoke_api_method() { return assertions.doesNotMatch(pattern); } @Override protected void verify_internal_effects() { verify(strings).assertDoesNotMatch(getInfo(assertions), getActual(assertions), pattern); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_endsWith_Test.java000066400000000000000000000023401243020563200327140ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#endsWith(String)}. * * @author Alex Ruiz */ public class StringAssert_endsWith_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.endsWith("Yod"); } @Override protected void verify_internal_effects() { verify(strings).assertEndsWith(getInfo(assertions), getActual(assertions), "Yod"); } } StringAssert_hasSameSizeAs_with_Array_Test.java000066400000000000000000000027221243020563200357450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#hasSameSizeAs(Object[])}. * * @author Nicolas François */ public class StringAssert_hasSameSizeAs_with_Array_Test extends StringAssertBaseTest { private static Object[] other; @BeforeClass public static void setUpOnce() { other = new Object[] { "Luke" }; } @Override protected StringAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(strings).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } StringAssert_hasSameSizeAs_with_Iterable_Test.java000066400000000000000000000030431243020563200364130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.api.string; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#hasSameSizeAs(Iterable)}. * * @author Nicolas François */ public class StringAssert_hasSameSizeAs_with_Iterable_Test extends StringAssertBaseTest { private static List other; @BeforeClass public static void setUpOnce() { other = newArrayList("Luke"); } @Override protected StringAssert invoke_api_method() { return assertions.hasSameSizeAs(other); } @Override protected void verify_internal_effects() { verify(strings).assertHasSameSizeAs(getInfo(assertions), getActual(assertions), other); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_hasSize_Test.java000066400000000000000000000023671243020563200325460ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#hasSize(int)}. * * @author Alex Ruiz */ public class StringAssert_hasSize_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.hasSize(6); } @Override protected void verify_internal_effects() { verify(strings).assertHasSize(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_isEmpty_Test.java000066400000000000000000000026151243020563200325660ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.Test; /** * Tests for {@link StringAssert#isEmpty()}. * * @author Alex Ruiz */ public class StringAssert_isEmpty_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { assertions.isEmpty(); return null; } @Override protected void verify_internal_effects() { verify(strings).assertEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isEmpty method is void. } } StringAssert_isEqualToIgnoringCase_Test.java000066400000000000000000000024231243020563200352510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#isEqualToIgnoringCase(String)}. * * @author Alex Ruiz */ public class StringAssert_isEqualToIgnoringCase_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.isEqualToIgnoringCase("yoda"); } @Override protected void verify_internal_effects() { verify(strings).assertEqualsIgnoringCase(getInfo(assertions), getActual(assertions), "yoda"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_isNotEmpty_Test.java000066400000000000000000000023721243020563200332470ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#isNotEmpty()}. * * @author Alex Ruiz */ public class StringAssert_isNotEmpty_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.isNotEmpty(); } @Override protected void verify_internal_effects() { verify(strings).assertNotEmpty(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_isNullOrEmpty_Test.java000066400000000000000000000025751243020563200337270ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.Test; /** * Tests for {@link StringAssert#isNullOrEmpty()}. * * @author Alex Ruiz */ public class StringAssert_isNullOrEmpty_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { assertions.isNullOrEmpty(); return null; } @Override protected void verify_internal_effects() { verify(strings).assertNullOrEmpty(getInfo(assertions), getActual(assertions)); } @Override @Test public void should_return_this() { // Disable this test, the isNullOrEmpty method is void. } } StringAssert_matches_Pattern_Test.java000066400000000000000000000027401243020563200341750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.fest.assertions.test.TestData.matchAnything; import static org.mockito.Mockito.verify; import java.util.regex.Pattern; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#matches(Pattern)}. * * @author Alex Ruiz */ public class StringAssert_matches_Pattern_Test extends StringAssertBaseTest { private static Pattern pattern; @BeforeClass public static void setUpOnce() { pattern = matchAnything(); } @Override protected StringAssert invoke_api_method() { return assertions.matches(pattern); } @Override protected void verify_internal_effects() { verify(strings).assertMatches(getInfo(assertions), getActual(assertions), pattern); } } StringAssert_matches_String_Test.java000066400000000000000000000026761243020563200340360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.fest.assertions.test.TestData.matchAnything; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.junit.BeforeClass; /** * Tests for {@link StringAssert#matches(String)}. * * @author Alex Ruiz */ public class StringAssert_matches_String_Test extends StringAssertBaseTest { private static String regex; @BeforeClass public static void setUpOnce() { regex = matchAnything().pattern(); } @Override protected StringAssert invoke_api_method() { return assertions.matches(regex); } @Override protected void verify_internal_effects() { verify(strings).assertMatches(getInfo(assertions), getActual(assertions), regex); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/StringAssert_startsWith_Test.java000066400000000000000000000023501243020563200333040ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static org.mockito.Mockito.verify; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; /** * Tests for {@link StringAssert#startsWith(String)}. * * @author Alex Ruiz */ public class StringAssert_startsWith_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.startsWith("Yod"); } @Override protected void verify_internal_effects() { verify(strings).assertStartsWith(getInfo(assertions), getActual(assertions), "Yod"); } } StringAssert_usingCustomComparator_Test.java000066400000000000000000000027501243020563200354250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static junit.framework.Assert.assertSame; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link StringAssert#usingComparator(java.util.Comparator)}. * * @author Joel Costigliola */ public class StringAssert_usingCustomComparator_Test extends StringAssertBaseTest { @Override protected StringAssert invoke_api_method() { return assertions.usingComparator(CaseInsensitiveStringComparator.instance); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions).getComparator(), CaseInsensitiveStringComparator.instance); assertSame(getStrings(assertions).getComparator(), CaseInsensitiveStringComparator.instance); } } StringAssert_usingDefaultComparator_Test.java000066400000000000000000000031241243020563200355330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/string/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.string; import static junit.framework.Assert.assertSame; import org.fest.assertions.api.StringAssert; import org.fest.assertions.api.StringAssertBaseTest; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.Strings; import org.fest.assertions.util.CaseInsensitiveStringComparator; import org.junit.Before; /** * Tests for {@link StringAssert#usingDefaultComparator()}. * * @author Joel Costigliola */ public class StringAssert_usingDefaultComparator_Test extends StringAssertBaseTest { @Before public void before() { assertions.usingComparator(CaseInsensitiveStringComparator.instance); } @Override protected StringAssert invoke_api_method() { return assertions.usingDefaultComparator(); } @Override protected void verify_internal_effects() { assertSame(getObjects(assertions), Objects.instance()); assertSame(getStrings(assertions), Strings.instance()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/000077500000000000000000000000001243020563200252375ustar00rootroot00000000000000ThrowableAssert_hasMessageContaining_Test.java000066400000000000000000000024611243020563200363100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.throwable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ThrowableAssert; import org.fest.assertions.api.ThrowableAssertBaseTest; /** * Tests for {@link ThrowableAssert#hasMessageContaining(String)}. * * @author Joel Costigliola */ public class ThrowableAssert_hasMessageContaining_Test extends ThrowableAssertBaseTest { @Override protected ThrowableAssert invoke_api_method() { return assertions.hasMessageContaining("able"); } @Override protected void verify_internal_effects() { verify(throwables).assertHasMessageContaining(getInfo(assertions), getActual(assertions), "able"); } } ThrowableAssert_hasMessageEndingWith_Test.java000066400000000000000000000024571243020563200362640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.throwable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ThrowableAssert; import org.fest.assertions.api.ThrowableAssertBaseTest; /** * Tests for {@link ThrowableAssert#hasMessageEndingWith(String)}. * * @author Joel Costigliola */ public class ThrowableAssert_hasMessageEndingWith_Test extends ThrowableAssertBaseTest { @Override protected ThrowableAssert invoke_api_method() { return assertions.hasMessageEndingWith("age"); } @Override protected void verify_internal_effects() { verify(throwables).assertHasMessageEndingWith(getInfo(assertions), getActual(assertions), "age"); } } ThrowableAssert_hasMessageStartingWith_Test.java000066400000000000000000000024731243020563200366510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.throwable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ThrowableAssert; import org.fest.assertions.api.ThrowableAssertBaseTest; /** * Tests for {@link ThrowableAssert#hasMessageStartingWith(String)}. * * @author Joel Costigliola */ public class ThrowableAssert_hasMessageStartingWith_Test extends ThrowableAssertBaseTest { @Override protected ThrowableAssert invoke_api_method() { return assertions.hasMessageStartingWith("throw"); } @Override protected void verify_internal_effects() { verify(throwables).assertHasMessageStartingWith(getInfo(assertions), getActual(assertions), "throw"); } } ThrowableAssert_hasMessage_Test.java000066400000000000000000000024431243020563200342760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.throwable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ThrowableAssert; import org.fest.assertions.api.ThrowableAssertBaseTest; /** * Tests for {@link ThrowableAssert#hasMessage(String)}. * * @author Joel Costigliola */ public class ThrowableAssert_hasMessage_Test extends ThrowableAssertBaseTest { @Override protected ThrowableAssert invoke_api_method() { return assertions.hasMessage("throwable message"); } @Override protected void verify_internal_effects() { verify(throwables).assertHasMessage(getInfo(assertions), getActual(assertions), "throwable message"); } } ThrowableAssert_hasNoCause_Test.java000066400000000000000000000023651243020563200342520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/throwable/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.api.throwable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.ThrowableAssert; import org.fest.assertions.api.ThrowableAssertBaseTest; /** * Tests for {@link ThrowableAssert#hasNoCause()}. * * @author Joel Costigliola */ public class ThrowableAssert_hasNoCause_Test extends ThrowableAssertBaseTest { @Override protected ThrowableAssert invoke_api_method() { return assertions.hasNoCause(); } @Override protected void verify_internal_effects() { verify(throwables).assertHasNoCause(getInfo(assertions), getActual(assertions)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/api/unevencomparable/000077500000000000000000000000001243020563200265765ustar00rootroot00000000000000AbstractUnevenComparableAssert_isEqualToByComparingTo_Test.java000066400000000000000000000027001243020563200431000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/unevencomparable/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.unevencomparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractUnevenComparableAssert; import org.fest.assertions.api.AbstractUnevenComparableAssertBaseTest; import org.fest.assertions.api.ConcreteUnevenComparableAssert; /** * Tests for {@link AbstractUnevenComparableAssert#isEqualByComparingTo(Comparable)}. * * @author Yvonne Wang */ public class AbstractUnevenComparableAssert_isEqualToByComparingTo_Test extends AbstractUnevenComparableAssertBaseTest { @Override protected ConcreteUnevenComparableAssert invoke_api_method() { return assertions.isEqualByComparingTo(6); } @Override protected void verify_internal_effects() { verify(comparables).assertEqualByComparison(getInfo(assertions), getActual(assertions), 6); } } AbstractUnevenComparableAssert_isNotEqualToByComparingTo_Test.java000066400000000000000000000027141243020563200435660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/api/unevencomparable/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.api.unevencomparable; import static org.mockito.Mockito.verify; import org.fest.assertions.api.AbstractUnevenComparableAssert; import org.fest.assertions.api.AbstractUnevenComparableAssertBaseTest; import org.fest.assertions.api.ConcreteUnevenComparableAssert; /** * Tests for {@link AbstractUnevenComparableAssert#isNotEqualByComparingTo(Comparable)}. * * @author Yvonne Wang */ public class AbstractUnevenComparableAssert_isNotEqualToByComparingTo_Test extends AbstractUnevenComparableAssertBaseTest { @Override protected ConcreteUnevenComparableAssert invoke_api_method() { return assertions.isNotEqualByComparingTo(6); } @Override protected void verify_internal_effects() { verify(comparables).assertNotEqualByComparison(getInfo(assertions), getActual(assertions), 6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/000077500000000000000000000000001243020563200244655ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AllOf_allOf_with_Collection_Test.java000066400000000000000000000027771243020563200336640ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import java.util.*; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AllOf#allOf(Condition...)}. * * @author Yvonne Wang */ public class AllOf_allOf_with_Collection_Test { @Rule public ExpectedException thrown = none(); @Test public void should_create_new_AllOf_with_passed_Conditions() { Collection> conditions = new ArrayList>(); conditions.add(new TestCondition()); Condition created = AllOf.allOf(conditions); assertEquals(AllOf.class, created.getClass()); AllOf allOf = (AllOf) created; assertEquals(conditions, allOf.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AllOf_allOf_with_array_Test.java000066400000000000000000000031201243020563200326660ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AllOf#allOf(Condition...)}. * * @author Yvonne Wang */ public class AllOf_allOf_with_array_Test { @Rule public ExpectedException thrown = none(); @SuppressWarnings("unchecked") @Test public void should_create_new_AllOf_with_passed_Conditions() { Condition[] conditions = array(new TestCondition(), new TestCondition()); Condition created = AllOf.allOf(conditions); assertEquals(AllOf.class, created.getClass()); AllOf allOf = (AllOf) created; assertEquals(newArrayList(conditions), allOf.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AllOf_matches_Test.java000066400000000000000000000031751243020563200310360ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.*; import static org.fest.assertions.condition.AllOf.allOf; import org.fest.assertions.core.*; import org.junit.*; /** * Tests for {@link AllOf#matches(Object)}. * * @author Yvonne Wang */ public class AllOf_matches_Test { private TestCondition condition1; private TestCondition condition2; private Condition allOf; @SuppressWarnings("unchecked") @Before public void setUp() { condition1 = new TestCondition(); condition2 = new TestCondition(); allOf = allOf(condition1, condition2); } @Test public void should_match_if_all_Condition_match() { condition1.shouldMatch(true); condition2.shouldMatch(true); assertTrue(allOf.matches("Yoda")); } @Test public void should_not_match_if_at_least_one_Condition_does_not_match() { condition1.shouldMatch(true); condition2.shouldMatch(false); assertFalse(allOf.matches("Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AllOf_toString_Test.java000066400000000000000000000027661243020563200312300ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.AllOf.allOf; import org.fest.assertions.core.*; import org.junit.*; /** * Tests for {@link AllOf#toString()}. * * @author Yvonne Wang */ public class AllOf_toString_Test { private TestCondition condition1; private TestCondition condition2; private Condition allOf; @SuppressWarnings("unchecked") @Before public void setUp() { condition1 = new TestCondition("Condition 1"); condition2 = new TestCondition("Condition 2"); allOf = allOf(condition1, condition2); } @Test public void should_implement_toString_showing_descriptions_of_inner_Conditions() { String expected = "all of:<[Condition 1, Condition 2]>"; assertEquals(expected, allOf.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AnyOf_anyOf_with_Collection_Test.java000066400000000000000000000027771243020563200337220ustar00rootroot00000000000000/* * Created on Feb 6, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import java.util.*; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AnyOf#anyOf(Condition...)}. * * @author Yvonne Wang */ public class AnyOf_anyOf_with_Collection_Test { @Rule public ExpectedException thrown = none(); @Test public void should_create_new_AnyOf_with_passed_Conditions() { Collection> conditions = new ArrayList>(); conditions.add(new TestCondition()); Condition created = AnyOf.anyOf(conditions); assertEquals(AnyOf.class, created.getClass()); AnyOf anyOf = (AnyOf) created; assertEquals(conditions, anyOf.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AnyOf_anyOf_with_array_Test.java000066400000000000000000000031201243020563200327240ustar00rootroot00000000000000/* * Created on Feb 5, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link AnyOf#anyOf(Condition...)}. * * @author Yvonne Wang */ public class AnyOf_anyOf_with_array_Test { @Rule public ExpectedException thrown = none(); @SuppressWarnings("unchecked") @Test public void should_create_new_AnyOf_with_passed_Conditions() { Condition[] conditions = array(new TestCondition(), new TestCondition()); Condition created = AnyOf.anyOf(conditions); assertEquals(AnyOf.class, created.getClass()); AnyOf anyOf = (AnyOf) created; assertEquals(newArrayList(conditions), anyOf.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AnyOf_matches_Test.java000066400000000000000000000032011243020563200310430ustar00rootroot00000000000000/* * Created on Feb 6, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.*; import static org.fest.assertions.condition.AnyOf.anyOf; import org.fest.assertions.core.*; import org.junit.*; /** * Tests for {@link AnyOf#matches(Object)}. * * @author Yvonne Wang */ public class AnyOf_matches_Test { private TestCondition condition1; private TestCondition condition2; private Condition anyOf; @SuppressWarnings("unchecked") @Before public void setUp() { condition1 = new TestCondition(); condition2 = new TestCondition(); anyOf = anyOf(condition1, condition2); } @Test public void should_match_if_at_least_one_Condition_matches() { condition1.shouldMatch(false); condition2.shouldMatch(true); assertTrue(anyOf.matches("Yoda")); } @Test public void should_not_match_if_none_of_the_Conditions_match() { condition1.shouldMatch(false); condition2.shouldMatch(false); assertFalse(anyOf.matches("Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/AnyOf_toString_Test.java000066400000000000000000000027661243020563200312470ustar00rootroot00000000000000/* * Created on Feb 6, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.AnyOf.anyOf; import org.fest.assertions.core.*; import org.junit.*; /** * Tests for {@link AnyOf#toString()}. * * @author Yvonne Wang */ public class AnyOf_toString_Test { private TestCondition condition1; private TestCondition condition2; private Condition anyOf; @SuppressWarnings("unchecked") @Before public void setUp() { condition1 = new TestCondition("Condition 1"); condition2 = new TestCondition("Condition 2"); anyOf = anyOf(condition1, condition2); } @Test public void should_implement_toString_showing_descriptions_of_inner_Conditions() { String expected = "any of:<[Condition 1, Condition 2]>"; assertEquals(expected, anyOf.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/ConcreteJoin.java000066400000000000000000000020771243020563200277200ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import java.util.Collection; import org.fest.assertions.core.Condition; /** * @author Yvonne Wang */ public class ConcreteJoin extends Join { public ConcreteJoin(Condition... conditions) { super(conditions); } public ConcreteJoin(Collection> conditions) { super(conditions); } @Override public boolean matches(Object value) { return false; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/DoesNotHave_matches_Test.java000066400000000000000000000031271243020563200322150ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.*; import static org.fest.assertions.condition.DoesNotHave.doesNotHave; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Tests for {@link Not#matches(Object)}. * * @author Nicolas François */ public class DoesNotHave_matches_Test { private TestCondition condition; private Condition doesNotHave; @Before public void setUp() { condition = new TestCondition(); doesNotHave = doesNotHave(condition); } @Test public void should_match_if_Condition_not_match() { condition.shouldMatch(false); assertTrue(doesNotHave.matches("Yoda")); } @Test public void should_not_match_Conditions_match() { condition.shouldMatch(true); assertFalse(doesNotHave.matches("Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/DoesNotHave_toString_Test.java000066400000000000000000000027421243020563200324040ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.DoesNotHave.doesNotHave; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Tests for {@link DoesNotHave#toString()}. * * @author Nicolas François */ public class DoesNotHave_toString_Test { private TestCondition condition; private Condition doesNotHave; @Before public void setUp() { condition = new TestCondition("JediPower"); doesNotHave = doesNotHave(condition); } @Test public void should_implement_toString_showing_descriptions_of_inner_Conditions() { String expected = "does not have :"; assertEquals(expected, doesNotHave.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/DoesNotHave_with_condition.java000066400000000000000000000027301243020563200326120ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.DoesNotHave.doesNotHave; import org.junit.Test; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Tests for {@link DoesNotHave#doesNotHave(Condition)}. * * @author Nicolas François */ public class DoesNotHave_with_condition { @Test public void should_create_new_doesNotHave_with_passed_Condition() { TestCondition condition = new TestCondition(); Condition created = doesNotHave(condition); assertEquals(DoesNotHave.class, created.getClass()); DoesNotHave doesNotHave = (DoesNotHave) created; assertEquals(condition, doesNotHave.condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/JediCondition.java000066400000000000000000000023201243020563200300470ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.condition; import static org.fest.util.Sets.newLinkedHashSet; import java.util.Set; import org.fest.assertions.core.Condition; /** * * A {@code Condition} checking is a Jedi * * @author Nicolas François */ public class JediCondition extends Condition { private final Set jedis = newLinkedHashSet("Luke", "Yoda", "Obiwan"); JediCondition(String description) { super(description); } public JediCondition() { super("Jedi"); } @Override public boolean matches(String value) { return jedis.contains(value); }; } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/JediPowerCondition.java000066400000000000000000000016541243020563200310750ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.condition; /** * same as {@link JediCondition}, only the description is different, it works better on error message * * @author Nicolas François */ public class JediPowerCondition extends JediCondition { public JediPowerCondition() { super("Jedi Power"); } } Join_constructor_with_Collection_Test.java000066400000000000000000000037631243020563200350330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import java.util.*; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Join#Join(Condition...)}. * * @author Yvonne Wang */ public class Join_constructor_with_Collection_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_Collection_is_null() { thrown.expectNullPointerException("The given conditions should not be null"); Collection> conditions = null; new ConcreteJoin(conditions); } @Test public void should_throw_error_if_Collection_contains_nulls() { thrown.expectNullPointerException("The given conditions should not have null entries"); Collection> conditions = new ArrayList>(); conditions.add(new TestCondition()); conditions.add(null); new ConcreteJoin(conditions); } @Test public void should_create_new_Join_with_passed_Conditions() { Collection> conditions = new ArrayList>(); conditions.add(new TestCondition()); Join join = new ConcreteJoin(conditions); assertEquals(conditions, join.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/Join_constructor_with_array_Test.java000066400000000000000000000040021243020563200341200ustar00rootroot00000000000000/* * Created on Feb 7, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.core.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Join#Join(Condition...)}. * * @author Yvonne Wang */ public class Join_constructor_with_array_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_array_is_null() { thrown.expectNullPointerException("The given conditions should not be null"); Condition[] conditions = null; new ConcreteJoin(conditions); } @SuppressWarnings("unchecked") @Test public void should_throw_error_if_array_contains_nulls() { thrown.expectNullPointerException("The given conditions should not have null entries"); Condition[] conditions = array(new TestCondition(), null); new ConcreteJoin(conditions); } @SuppressWarnings("unchecked") @Test public void should_create_new_Join_with_passed_Conditions() { Condition[] conditions = array(new TestCondition(), new TestCondition()); Join join = new ConcreteJoin(conditions); assertEquals(newArrayList(conditions), join.conditions); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/Not_matches_Test.java000066400000000000000000000030401243020563200305700ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.*; import static org.fest.assertions.condition.Not.not; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Tests for {@link Not#matches(Object)}. * * @author Nicolas François */ public class Not_matches_Test { private TestCondition condition; private Condition not; @Before public void setUp() { condition = new TestCondition(); not = not(condition); } @Test public void should_match_if_condition_does_not_match() { condition.shouldMatch(false); assertTrue(not.matches("Yoda")); } @Test public void should_not_match_if_condition_matches() { condition.shouldMatch(true); assertFalse(not.matches("Yoda")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/Not_toString_Test.java000066400000000000000000000026141243020563200307630ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.Not.not; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Before; import org.junit.Test; /** * Tests for {@link Not#toString()}. * * @author Nicolas François */ public class Not_toString_Test { private TestCondition condition; private Condition not; @Before public void setUp() { condition = new TestCondition("Jedi"); not = not(condition); } @Test public void should_implement_toString_showing_descriptions_of_inner_Conditions() { String expected = "not :"; assertEquals(expected, not.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/condition/Not_with_condition.java000066400000000000000000000025671243020563200312030ustar00rootroot00000000000000/* * Created on Mar 22, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.condition; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.condition.Not.not; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.junit.Test; /** * Tests for {@link Not#not(Condition)}. * * @author Nicolas François */ public class Not_with_condition { @Test public void should_create_new_notOf_with_passed_Conditions() { TestCondition condition = new TestCondition(); Condition created = not(condition); assertEquals(Not.class, created.getClass()); Not not = (Not) created; assertEquals(condition, not.condition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/000077500000000000000000000000001243020563200234275ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/core/Condition_as_Description_Test.java000066400000000000000000000037361243020563200322560ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import static org.junit.Assert.assertSame; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#as(Description)}. * * @author Yvonne Wang */ public class Condition_as_Description_Test { @Rule public ExpectedException thrown = none(); private static Description description; @BeforeClass public static void setUpOnce() { description = new TestDescription(someTextDescription()); } private Condition condition; @Before public void setUp() { condition = new TestCondition(); } @Test public void should_set_description() { condition.as(description); assertSame(description, condition.description()); } @Test public void should_throw_error_of_description_is_null() { thrown.expectNullPointerException("The description to set should not be null"); condition.as((Description) null); } @Test public void should_return_same_condition() { Condition returnedCondition = condition.as(description); assertSame(condition, returnedCondition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/Condition_as_String_Test.java000066400000000000000000000034661243020563200312410ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import static org.junit.Assert.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#as(String)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class Condition_as_String_Test { @Rule public ExpectedException thrown = none(); private Condition condition; @Before public void setUp() { condition = new TestCondition(); } @Test public void should_set_description() { String description = someTextDescription(); condition.as(description); assertEquals(description, condition.description.value()); } @Test public void should_throw_error_of_description_is_null() { thrown.expectNullPointerException("The description to set should not be null"); String description = null; condition.as(description); } @Test public void should_return_same_condition() { Condition returnedCondition = condition.as(someTextDescription()); assertSame(condition, returnedCondition); } } Condition_constructor_with_description_Test.java000066400000000000000000000034351243020563200352500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/core/* * Created on Aug 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.description.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#Condition(Description)} * * @author Yvonne Wang * @author Alex Ruiz */ public class Condition_constructor_with_description_Test { @Rule public ExpectedException thrown = none(); @Test public void should_set_description() { Description d = new TextDescription("always in motion is the future"); Condition condition = new Condition(d) { @Override public boolean matches(Object value) { return false; } }; assertSame(d, condition.description); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); new Condition((Description) null) { @Override public boolean matches(Object value) { return false; } }; } } Condition_constructor_with_text_description_Test.java000066400000000000000000000033621243020563200363130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/core/* * Created on Jul 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.assertEquals; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#Condition(String)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class Condition_constructor_with_text_description_Test { @Rule public ExpectedException thrown = none(); @Test public void should_set_description() { String text = "your eyes can deceive you; don't trust them"; Condition condition = new Condition(text) { @Override public boolean matches(Object value) { return false; } }; assertEquals(text, condition.description.value()); } @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); new Condition((String) null) { @Override public boolean matches(Object value) { return false; } }; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/Condition_default_constructor_Test.java000066400000000000000000000023261243020563200333730ustar00rootroot00000000000000/* * Created on Jul 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static junit.framework.Assert.assertEquals; import org.junit.Test; /** * Tests for {@link Condition#Condition()}. * * @author Alex Ruiz * @author Yvonne Wang */ public class Condition_default_constructor_Test { @Test public void should_use_class_simple_name_as_description() { Condition condition = new Condition() { @Override public boolean matches(Object value) { return false; } }; assertEquals(condition.getClass().getSimpleName(), condition.description.value()); } } Condition_describedAs_Description_Test.java000066400000000000000000000040131243020563200337710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/core/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import static org.junit.Assert.assertSame; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#describedAs(Description)}. * * @author Yvonne Wang */ public class Condition_describedAs_Description_Test { @Rule public ExpectedException thrown = none(); private static Description description; @BeforeClass public static void setUpOnce() { description = new TestDescription(someTextDescription()); } private Condition condition; @Before public void setUp() { condition = new TestCondition(); } @Test public void should_set_description() { condition.describedAs(description); assertSame(description, condition.description()); } @Test public void should_throw_error_of_description_is_null() { thrown.expectNullPointerException("The description to set should not be null"); condition.describedAs((Description) null); } @Test public void should_return_same_condition() { Condition returnedCondition = condition.describedAs(description); assertSame(condition, returnedCondition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/Condition_describedAs_String_Test.java000066400000000000000000000035111243020563200330350ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.TestData.someTextDescription; import static org.junit.Assert.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Condition#describedAs(String)}. * * @author Yvonne Wang */ public class Condition_describedAs_String_Test { @Rule public ExpectedException thrown = none(); private Condition condition; @Before public void setUp() { condition = new TestCondition(); } @Test public void should_set_description() { String description = someTextDescription(); condition.describedAs(description); assertEquals(description, condition.description.value()); } @Test public void should_throw_error_of_description_is_null() { thrown.expectNullPointerException("The description to set should not be null"); String description = null; condition.describedAs(description); } @Test public void should_return_same_condition() { Condition returnedCondition = condition.describedAs(someTextDescription()); assertSame(condition, returnedCondition); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/Condition_description_Test.java000066400000000000000000000024551243020563200316300ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static org.junit.Assert.assertEquals; import org.fest.assertions.description.TextDescription; import org.junit.*; /** * Tests for {@link Condition#description()}. * * @author Yvonne Wang * @author Alex Ruiz */ public class Condition_description_Test { private Condition condition; @Before public void setUp() { condition = new TestCondition(); } @Test public void should_return_description() { String description = "do or do not, there is not try"; condition.description = new TextDescription(description); assertEquals(description, condition.description().value()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/DescriptionValidator_notNull_Test.java000066400000000000000000000040571243020563200331430ustar00rootroot00000000000000/* * Created on Jul 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; import static org.fest.assertions.test.ErrorMessages.descriptionIsNull; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.*; import org.fest.assertions.description.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link DescriptionValidations#checkIsNotNull(org.fest.assertions.description.Description)} and * {@link DescriptionValidations#checkIsNotNull(String)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class DescriptionValidator_notNull_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); Description d = null; DescriptionValidations.checkIsNotNull(d); } @Test public void should_throw_error_if_text_description_is_null() { thrown.expectNullPointerException(descriptionIsNull()); String d = null; DescriptionValidations.checkIsNotNull(d); } @Test public void should_return_description_with_given_text() { Description d = DescriptionValidations.checkIsNotNull("Yoda"); assertEquals("Yoda", d.value()); } @Test public void should_return_same_description() { Description e = new TextDescription("Yoda"); Description d = DescriptionValidations.checkIsNotNull(e); assertSame(e, d); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/TestCondition.java000066400000000000000000000022671243020563200270670ustar00rootroot00000000000000/* * Created on Jul 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.core; /** * A {@link Condition} for testing. * @param the type of object this condition accepts. * * @author Yvonne Wang * @author Alex Ruiz * @author Mikhail Mazursky */ public class TestCondition extends Condition { private boolean matches; public TestCondition() { super(); } public TestCondition(String description) { super(description); } public void shouldMatch(boolean val) { matches = val; } @Override public boolean matches(T value) { return matches; } } WritableAssertionInfo_descriptionText_Test.java000066400000000000000000000027701243020563200347450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/core/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.core; import static junit.framework.Assert.*; import static org.mockito.Mockito.*; import org.fest.assertions.description.Description; import org.junit.*; /** * Tests for {@link WritableAssertionInfo#descriptionText()}. * * @author Yvonne Wang */ public class WritableAssertionInfo_descriptionText_Test { private WritableAssertionInfo info; @Before public void setUp() { info = new WritableAssertionInfo(); } @Test public void should_return_null_if_description_is_null() { assertNull(info.descriptionText()); } @Test public void should_return_text_of_description() { Description description = mock(Description.class); info.description(description); when(description.value()).thenReturn("Yoda"); assertEquals("Yoda", info.descriptionText()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/core/WritableAssertionInfo_toString_Test.java000066400000000000000000000031241243020563200334370ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.core; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.*; import org.fest.assertions.description.Description; import org.junit.*; /** * Tests for {@link WritableAssertionInfo#toString()}. * * @author Alex Ruiz */ public class WritableAssertionInfo_toString_Test { private Description description; private String overridingErrorMessage; private WritableAssertionInfo info; @Before public void setUp() { description = mock(Description.class); overridingErrorMessage = "Jedi"; info = new WritableAssertionInfo(); info.description(description); info.overridingErrorMessage(overridingErrorMessage); } @Test public void should_implement_toString() { when(description.value()).thenReturn("Yoda"); assertEquals("WritableAssertionInfo[overridingErrorMessage='Jedi', description='Yoda']", info.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/000077500000000000000000000000001243020563200234105ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Index_atIndex_Test.java000066400000000000000000000025371243020563200300040ustar00rootroot00000000000000/* * Created on Oct 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Index#atIndex(int)}. * * @author Alex Ruiz */ public class Index_atIndex_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_value_is_negative() { thrown.expectIllegalArgumentException("The value of the index should not be negative"); Index.atIndex(-1); } @Test public void should_create_new_Index() { Index index = Index.atIndex(8); assertEquals(8, index.value); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Index_equals_hashCode_Test.java000066400000000000000000000037041243020563200314750ustar00rootroot00000000000000/* * Created on Oct 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertFalse; import static org.fest.assertions.data.Index.atIndex; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link Index#equals(Object)} and {@link Index#hashCode()}. * * @author Alex Ruiz */ public class Index_equals_hashCode_Test { private static Index index; @BeforeClass public static void setUpOnce() { index = atIndex(8); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(index); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(index, atIndex(8)); } @Test public void should_have_transitive_equals() { assertEqualsIsTransitive(index, atIndex(8), atIndex(8)); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(index, atIndex(8)); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(index.equals("8")); } @Test public void should_not_be_equal_to_null() { assertFalse(index.equals(null)); } @Test public void should_not_be_equal_to_Index_with_different_value() { assertFalse(index.equals(atIndex(6))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Index_toString_Test.java000066400000000000000000000022171243020563200302140ustar00rootroot00000000000000/* * Created on Oct 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Index.atIndex; import org.junit.*; /** * Tests for {@link Index#toString()}. * * @author Alex Ruiz */ public class Index_toString_Test { private static Index index; @BeforeClass public static void setUpOnce() { index = atIndex(8); } @Test public void should_implement_toString() { assertEquals("Index[value=8]", index.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/MapEntry_equals_hashCode_Test.java000066400000000000000000000040471243020563200321660ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertFalse; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link MapEntry#equals(Object)} and {@link MapEntry#hashCode()}. * * @author Alex Ruiz */ public class MapEntry_equals_hashCode_Test { private static MapEntry entry; @BeforeClass public static void setUpOnce() { entry = entry("key", "value"); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(entry); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(entry, entry("key", "value")); } @Test public void should_have_transitive_equals() { assertEqualsIsTransitive(entry, entry("key", "value"), entry("key", "value")); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(entry, entry("key", "value")); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(entry.equals("{'key', 'value'}")); } @Test public void should_not_be_equal_to_null() { assertFalse(entry.equals(null)); } @Test public void should_not_be_equal_to_MapEntry_with_different_value() { assertFalse(entry.equals(entry("key0", "value0"))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/MapEntry_toString_Test.java000066400000000000000000000022711243020563200307040ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.MapEntry.entry; import org.junit.*; /** * Tests for <{@link MapEntry#toString()}. * * @author Alex Ruiz */ public class MapEntry_toString_Test { private static MapEntry entry; @BeforeClass public static void setUpOnce() { entry = entry("name", "Yoda"); } @Test public void should_implement_toString() { assertEquals("MapEntry[key='name', value='Yoda']", entry.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Offset_equals_hashCode_Test.java000066400000000000000000000037251243020563200316570ustar00rootroot00000000000000/* * Created on Oct 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertFalse; import static org.fest.assertions.data.Offset.offset; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link Offset#equals(Object)} and {@link Offset#hashCode()}. * * @author Alex Ruiz */ public class Offset_equals_hashCode_Test { private static Offset offset; @BeforeClass public static void setUpOnce() { offset = offset(8); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(offset); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(offset, offset(8)); } @Test public void should_have_transitive_equals() { assertEqualsIsTransitive(offset, offset(8), offset(8)); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(offset, offset(8)); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(offset.equals("8")); } @Test public void should_not_be_equal_to_null() { assertFalse(offset.equals(null)); } @Test public void should_not_be_equal_to_Offset_with_different_value() { assertFalse(offset.equals(offset(6))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Offset_offset_with_Double_Test.java000066400000000000000000000031741243020563200324000ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.offsetValueIsNotPositive; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Offset#offset(Double)}. * * @author Alex Ruiz */ public class Offset_offset_with_Double_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_value_is_null() { thrown.expect(NullPointerException.class); Double value = null; Offset.offset(value); } @Test public void should_throw_error_if_value_is_negative() { thrown.expectIllegalArgumentException(offsetValueIsNotPositive()); Offset.offset(-1d); } @Test public void should_create_Offset() { Double value = 0.8d; Offset offset = Offset.offset(value); assertSame(value, offset.value); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Offset_offset_with_Float_Test.java000066400000000000000000000031671243020563200322350ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.offsetValueIsNotPositive; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Offset#offset(Float)}. * * @author Alex Ruiz */ public class Offset_offset_with_Float_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_value_is_null() { thrown.expect(NullPointerException.class); Float value = null; Offset.offset(value); } @Test public void should_throw_error_if_value_is_negative() { thrown.expectIllegalArgumentException(offsetValueIsNotPositive()); Offset.offset(-1f); } @Test public void should_create_Offset() { Float value = 0.8f; Offset offset = Offset.offset(value); assertSame(value, offset.value); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Offset_offset_with_Integer_Test.java000066400000000000000000000031771243020563200325660ustar00rootroot00000000000000/* * Created on Oct 23, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertSame; import static org.fest.assertions.test.ErrorMessages.offsetValueIsNotPositive; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Offset#offset(Integer)}. * * @author Yvonne Wang */ public class Offset_offset_with_Integer_Test { @Rule public ExpectedException thrown = none(); @Test public void should_throw_error_if_value_is_null() { thrown.expect(NullPointerException.class); Integer value = null; Offset.offset(value); } @Test public void should_throw_error_if_value_is_negative() { thrown.expectIllegalArgumentException(offsetValueIsNotPositive()); Offset.offset(-1); } @Test public void should_create_Offset() { Integer value = 8; Offset offset = Offset.offset(value); assertSame(value, offset.value); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/data/Offset_toString_Test.java000066400000000000000000000022361243020563200303740ustar00rootroot00000000000000/* * Created on Oct 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.data; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Offset.offset; import org.junit.*; /** * Tests for {@link Offset#toString()}. * * @author Alex Ruiz */ public class Offset_toString_Test { private static Offset offset; @BeforeClass public static void setUpOnce() { offset = offset(8); } @Test public void should_implement_toString() { assertEquals("Offset[value=8]", offset.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/description/000077500000000000000000000000001243020563200250225ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/description/Description_toString_Test.java000066400000000000000000000032161243020563200330420ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.description; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.*; import org.junit.*; /** * Tests for {@link Description#toString()}. * * @author Yvonne Wang */ public class Description_toString_Test { private ValueSource valueSource; private Description description; @Before public void setUp() { valueSource = mock(ValueSource.class); description = new TestDescription(valueSource); } @Test public void should_return_value_in_toString() { when(valueSource.value()).thenReturn("Yoda"); assertEquals("Yoda", description.toString()); } private static interface ValueSource { String value(); } private static class TestDescription extends Description { private final ValueSource source; TestDescription(ValueSource source) { this.source = source; } @Override public String value() { return source.value(); } } } EmptyTextDescription_emptyText_Test.java000066400000000000000000000024131243020563200350370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/description/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.description; import static junit.framework.Assert.*; import org.junit.Test; /** * Tests for {@link EmptyTextDescription#emptyText()}. * * @author Yvonne Wang */ public class EmptyTextDescription_emptyText_Test { @Test public void should_return_singleton_instance() { Description description = EmptyTextDescription.emptyText(); for (int i = 0; i < 6; i++) assertSame(description, EmptyTextDescription.emptyText()); } @Test public void should_have_empty_text_as_value() { assertEquals("", EmptyTextDescription.emptyText().value()); } } TextDescription_constructor_Test.java000066400000000000000000000030041243020563200343770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/description/* * Created on Jul 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.description; import static java.util.UUID.randomUUID; import static junit.framework.Assert.assertEquals; import static org.junit.rules.ExpectedException.none; import org.junit.*; import org.junit.rules.ExpectedException; /** * Tests for {@link TextDescription#TextDescription(String)}. * * @author Yvonne Wang * @author Alex Ruiz */ public class TextDescription_constructor_Test { @Rule public ExpectedException thrown = none(); @Test public void should_set_value() { String value = randomText(); TextDescription description = new TextDescription(value); assertEquals(value, description.value); } private static String randomText() { return randomUUID().toString(); } @Test public void should_throw_error_if_value_is_null() { thrown.expect(NullPointerException.class); new TextDescription(null); } } TextDescription_equals_hashCode_Test.java000066400000000000000000000042011243020563200351020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/description/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.description; import static junit.framework.Assert.assertFalse; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link TextDescription#equals(Object)} and {@link TextDescription#hashCode()}. * * @author Alex Ruiz */ public class TextDescription_equals_hashCode_Test { private static TextDescription description; @BeforeClass public static void setUpOnce() { description = new TextDescription("Yoda"); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(description); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(description, new TextDescription("Yoda")); } @Test public void should_have_transitive_equals() { assertEqualsIsTransitive(description, new TextDescription("Yoda"), new TextDescription("Yoda")); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(description, new TextDescription("Yoda")); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(description.equals("Yoda")); } @Test public void should_not_be_equal_to_null() { assertFalse(description.equals(null)); } @Test public void should_not_be_equal_to_TextDescription_with_different_value() { assertFalse(description.equals(new TextDescription("Luke"))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/description/TextDescription_toString_Test.java000066400000000000000000000021151243020563200337040ustar00rootroot00000000000000/* * Created on Jul 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.description; import static junit.framework.Assert.assertEquals; import org.junit.Test; /** * Tests for {@link TextDescription#toString()}. * * @author Yvonne Wang * @author Alex Ruiz */ public class TextDescription_toString_Test { @Test public void should_return_value() { TextDescription description = new TextDescription("Flash"); assertEquals(description.value, description.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/description/TextDescription_value_Test.java000066400000000000000000000021041243020563200332050ustar00rootroot00000000000000/* * Created on Jul 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.description; import static junit.framework.Assert.assertEquals; import org.junit.Test; /** * Tests for {@link TextDescription#value()}. * * @author Yvonne Wang * @author Alex Ruiz */ public class TextDescription_value_Test { @Test public void should_return_value() { TextDescription description = new TextDescription("Robin"); assertEquals(description.value, description.value()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/000077500000000000000000000000001243020563200236305ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/BasicErrorMessageFactory_create_Test.java000066400000000000000000000032361243020563200337110ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.*; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link BasicErrorMessageFactory#create(Description)}. * * @author Yvonne Wang */ public class BasicErrorMessageFactory_create_Test { private MessageFormatter formatter; private BasicErrorMessageFactory factory; @Before public void setUp() { formatter = mock(MessageFormatter.class); factory = new BasicErrorMessageFactory("Hello %s", "Yoda"); factory.formatter = formatter; } @Test public void should_implement_toString() { Description description = new TestDescription("Test"); String formattedMessage = "[Test] Hello Yoda"; when(formatter.format(description, "Hello %s", "Yoda")).thenReturn(formattedMessage); assertEquals(formattedMessage, factory.create(description)); } } BasicErrorMessageFactory_equals_hashCode_Test.java000066400000000000000000000050311243020563200354520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertFalse; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link BasicErrorMessageFactory#equals(Object)} and * {@link BasicErrorMessageFactory#hashCode()}. * * @author Yvonne Wang */ public class BasicErrorMessageFactory_equals_hashCode_Test { private static BasicErrorMessageFactory factory; @BeforeClass public static void setUpOnce() { factory = new BasicErrorMessageFactory("Hello %s", "Yoda"); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(factory); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(factory, new BasicErrorMessageFactory("Hello %s", "Yoda")); } @Test public void should_have_transitive_equals() { BasicErrorMessageFactory obj2 = new BasicErrorMessageFactory("Hello %s", "Yoda"); BasicErrorMessageFactory obj3 = new BasicErrorMessageFactory("Hello %s", "Yoda"); assertEqualsIsTransitive(factory, obj2, obj3); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(factory, new BasicErrorMessageFactory("Hello %s", "Yoda")); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(factory.equals("Yoda")); } @Test public void should_not_be_equal_to_null() { assertFalse(factory.equals(null)); } @Test public void should_not_be_equal_to_BasicErrorMessage_with_different_format() { assertFalse(factory.equals(new BasicErrorMessageFactory("How are you, %s?", "Yoda"))); } @Test public void should_not_be_equal_to_BasicErrorMessage_with_different_arguments() { assertFalse(factory.equals(new BasicErrorMessageFactory("Hello %s", "Luke"))); } } BasicErrorMessageFactory_toString_Test.java000066400000000000000000000023511243020563200341750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import org.junit.*; /** * Tests for {@link BasicErrorMessageFactory#toString()}. * * @author Yvonne Wang */ public class BasicErrorMessageFactory_toString_Test { private BasicErrorMessageFactory factory; @Before public void setUp() { factory = new BasicErrorMessageFactory("Hello %s", "Yoda"); } @Test public void should_implement_toString() { assertEquals("BasicErrorMessageFactory[format='Hello %s', arguments=['Yoda']]", factory.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ConstructorInvoker_newInstance_Test.java000066400000000000000000000025011243020563200337110ustar00rootroot00000000000000/* * Created on Feb 15, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2011 the original author or authors. */ package org.fest.assertions.error; import static org.junit.Assert.*; import org.junit.*; /** * Tests for {@link ConstructorInvoker#newInstance(String, Class[], Object[])}. * * @author Alex Ruiz */ public class ConstructorInvoker_newInstance_Test { private ConstructorInvoker invoker; @Before public void setUp() { invoker = new ConstructorInvoker(); } @Test public void should_create_Object_using_reflection() throws Exception { Object o = invoker.newInstance("java.lang.Exception", new Class[] { String.class }, new Object[] { "Hi" }); assertTrue(o instanceof Exception); Exception e = (Exception) o; assertEquals("Hi", e.getMessage()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/DescriptionFormatter_format_Test.java000066400000000000000000000024631243020563200332160ustar00rootroot00000000000000/* * Created on Aug 8, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link DescriptionFormatter#format(Description)}. * * @author Alex Ruiz */ public class DescriptionFormatter_format_Test { private static DescriptionFormatter formatter; @BeforeClass public static void setUpOnce() { formatter = DescriptionFormatter.instance(); } @Test public void should_format_description_if_value_is_not_empty_or_null() { assertEquals("[Leia] ", formatter.format(new TestDescription("Leia"))); } } DescriptionFormatter_format_expectingEmptyText_Test.java000066400000000000000000000035021243020563200370640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Jan 11, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.util.Lists.newArrayList; import java.util.List; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.*; import org.junit.runners.Parameterized.Parameters; /** * Tests for {@link DescriptionFormatter#format(Description)}. * * @author Alex Ruiz */ @RunWith(Parameterized.class) public class DescriptionFormatter_format_expectingEmptyText_Test { private final Description description; @Parameters public static List parameters() { return newArrayList(new Object[][] { { null }, { new TestDescription(null) }, { new TestDescription("") } }); } public DescriptionFormatter_format_expectingEmptyText_Test(Description description) { this.description = description; } private static DescriptionFormatter formatter; @BeforeClass public static void setUpOnce() { formatter = DescriptionFormatter.instance(); } @Test public void should_return_empty_String() { assertEquals("", formatter.format(description)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldBeAtLeast_create_Test.java000066400000000000000000000031641243020563200335010ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldBeAtLeast.elementsShouldBeAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldBeAtLeast#create(Description)}. * * @author Nicolas François * @author Joel Costigliola */ public class ElementsShouldBeAtLeast_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldBeAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n to be at least 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldBeAtMost_create_Test.java000066400000000000000000000031261243020563200333510ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldBeAtMost.elementsShouldBeAtMost; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldBeAtMost#create(Description)}. * * @author Nicolas François */ public class ElementsShouldBeAtMost_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldBeAtMost(newArrayList("Yoda", "Luke", "Obiwan"), 2, new TestCondition("a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Obiwan']>\n to be at most 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldBeExactly_create_Test.java000066400000000000000000000032471243020563200335570ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldBeExactly.elementsShouldBeExactly; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldBeExactly#create(Description)}. * * @author Nicolas François * @author Joel Costigliola */ public class ElementsShouldBeExactly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldBeExactly(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n to be exactly 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldBe_create_Test.java000066400000000000000000000031441243020563200322210ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldBe.elementsShouldBe; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldBe#create(Description)}. * * @author Nicolas François * @author Joel Costigliola */ public class ElementsShouldBe_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldBe(newArrayList("Yoda", "Luke", "Leia"), newArrayList("Leia"), new TestCondition("a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Leia']>\n of \n<['Yoda', 'Luke', 'Leia']>\n to be ", message); } } ElementsShouldHaveAtLeast_create_Test.java000066400000000000000000000032361243020563200337570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldBeExactly#create(Description)}. * * @author Nicolas François */ public class ElementsShouldHaveAtLeast_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldHaveAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n to have at least 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldHaveAtMost_create_Test.java000066400000000000000000000031521243020563200337050ustar00rootroot00000000000000/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldHaveAtMost.elementsShouldHaveAtMost; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldHaveAtMost#create(Description)}. * * @author Nicolas François */ public class ElementsShouldHaveAtMost_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldHaveAtMost(newArrayList("Yoda", "Luke", "Obiwan"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Obiwan']>\n to have at most 2 times ", message); } } ElementsShouldHaveExactly_create_Test.java000066400000000000000000000031541243020563200340320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldHaveAtLeast#create(Description)}. * * @author Nicolas François */ public class ElementsShouldHaveExactly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldHaveAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n to have at least 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldHave_create_Test.java000066400000000000000000000032201243020563200325510ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldHave.elementsShouldHave; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldHave#create(Description)}. * * @author Nicolas François */ public class ElementsShouldHave_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldHave(newArrayList("Yoda", "Luke", "Leia"), newArrayList("Leia"), new TestCondition("jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Leia']>\n of \n<['Yoda', 'Luke', 'Leia']>\n to have ", message); } } ElementsShouldNotBeAtLeast_create_Test.java000066400000000000000000000032471243020563200341050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotBeAtLeast#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotBeAtLeast_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotBeAtLeast(newArrayList("Yoda", "Luke", "Leia"), 2, new TestCondition("Not a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Leia']>\n not to be at least 2 times ", message); } } ElementsShouldNotBeAtMost_create_Test.java000066400000000000000000000032451243020563200337550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotBeAtMost#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotBeAtMost_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotBeAtMost(newArrayList("Yoda", "Luke", "Obiwan"), 2, new TestCondition("not a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Obiwan']>\n not to be at most 2 times ", message); } } ElementsShouldNotBeExactly_create_Test.java000066400000000000000000000032471243020563200341610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotBeAtLeast#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotBeExactly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotBeAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("Not a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n not to be at least 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldNotBe_create_Test.java000066400000000000000000000032551243020563200327050ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotBe.elementsShouldNotBe; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotBe#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotBe_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotBe(newArrayList("Darth Vader", "Leia", "Yoda"), newArrayList("Yoda"), new TestCondition("not a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda']>\n of \n<['Darth Vader', 'Leia', 'Yoda']>\n not to be ", message); } } ElementsShouldNotHaveAtLeast_create_Test.java000066400000000000000000000032631243020563200344400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotHaveAtLeast#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotHaveAtLeast_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotHaveAtLeast(newArrayList("Yoda", "Luke", "Leia"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Leia']>\n not to have at least 2 times ", message); } } ElementsShouldNotHaveAtMost_create_Test.java000066400000000000000000000032611243020563200343100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotHaveAtMost.elementsShouldNotHaveAtMost; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotHaveAtMost#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotHaveAtMost_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotHaveAtMost(newArrayList("Yoda", "Luke", "Obiwan"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Luke', 'Obiwan']>\n not to have at most 2 times ", message); } } ElementsShouldNotHaveExactly_create_Test.java000066400000000000000000000032631243020563200345140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotHaveAtLeast#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotHaveExactly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotHaveAtLeast(newArrayList("Yoda", "Solo", "Leia"), 2, new TestCondition("Jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Yoda', 'Solo', 'Leia']>\n not to have at least 2 times ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ElementsShouldNotHave_create_Test.java000066400000000000000000000032431243020563200332370ustar00rootroot00000000000000/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ElementsShouldNotHave#create(Description)}. * * @author Nicolas François */ public class ElementsShouldNotHave_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = elementsShouldNotHave(newArrayList("Yoda", "Luke", "Leia"), newArrayList("Leia"), new TestCondition("jedi power")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting elements:\n<['Leia']>\n of \n<['Yoda', 'Luke', 'Leia']>\n not to have ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/FakeFile.java000066400000000000000000000020471243020563200261440ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import java.io.File; /** * @author Yvonne Wang */ class FakeFile extends File { private final String absolutePath; FakeFile(String absolutePath) { super(absolutePath); this.absolutePath = absolutePath; } // ToStringOf uses absolute path instead of toString @Override public String getAbsolutePath() { return absolutePath; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/error/MessageFormatter_format_Test.java000066400000000000000000000040711243020563200323140ustar00rootroot00000000000000/* * Created on Jan 11, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.*; import org.fest.assertions.description.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link MessageFormatter#format(Description, String, Object...)}. * * @author Alex Ruiz */ public class MessageFormatter_format_Test { @Rule public ExpectedException thrown = none(); private DescriptionFormatter descriptionFormatter; private MessageFormatter messageFormatter; @Before public void setUp() { descriptionFormatter = spy(new DescriptionFormatter()); messageFormatter = new MessageFormatter(); messageFormatter.descriptionFormatter = descriptionFormatter; } @Test public void should_throw_error_if_format_string_is_null() { thrown.expect(NullPointerException.class); messageFormatter.format(null, null); } @Test public void should_throw_error_if_args_array_is_null() { thrown.expect(NullPointerException.class); Object[] args = null; messageFormatter.format(null, "", args); } @Test public void should_format_message() { Description description = new TextDescription("Test"); String s = messageFormatter.format(description, "Hello %s", "World"); assertEquals("[Test] Hello 'World'", s); verify(descriptionFormatter).format(description); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeAbsolutePath_create_Test.java000066400000000000000000000026271243020563200330450ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeAbsolutePath.shouldBeAbsolutePath; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeAbsolutePath#create(Description)}. * * @author Yvonne Wang */ public class ShouldBeAbsolutePath_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeAbsolutePath(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be an absolute path", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeAfterOrEqualsTo_create_Test.java000066400000000000000000000030671243020563200334710ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeAfterOrEqualsTo.shouldBeAfterOrEqualsTo; import static org.fest.util.Dates.parse; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeAfterOrEqualsTo#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeAfterOrEqualsTo_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeAfterOrEqualsTo(parse("2011-01-01"), parse("2012-01-01")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> to be after or equals to:<2012-01-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeAfter_create_Test.java000066400000000000000000000030011243020563200314760ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeAfter.shouldBeAfter; import static org.fest.util.Dates.parse; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeAfter#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeAfter_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeAfter(parse("2011-01-01"), parse("2012-01-01")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> to be strictly after:<2012-01-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeAtIndex_create_Test.java000066400000000000000000000017101243020563200317760ustar00rootroot00000000000000package org.fest.assertions.error; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldBeAtIndex.shouldBeAtIndex; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeAtIndex#create(org.fest.assertions.description.Description)}. * * @author Bo Gotthardt */ public class ShouldBeAtIndex_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeAtIndex(newArrayList("Yoda", "Luke"), new TestCondition("red lightsaber"), atIndex(1), "Luke"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Luke'> at index <1> to be: in:\n <['Yoda', 'Luke']>\n", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeBeforeOrEqualsTo_create_Test.java000066400000000000000000000030751243020563200336310ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeBeforeOrEqualsTo.shouldBeBeforeOrEqualsTo; import static org.fest.util.Dates.parse; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeBeforeOrEqualsTo#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeBeforeOrEqualsTo_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeBeforeOrEqualsTo(parse("2011-01-01"), parse("2012-01-01")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> to be before or equals to:<2012-01-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeBefore_create_Test.java000066400000000000000000000030071243020563200316450ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeBefore.shouldBeBefore; import static org.fest.util.Dates.parse; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeBefore#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeBefore_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeBefore(parse("2011-01-01"), parse("2012-01-01")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> to be strictly before:<2012-01-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeBetween_create_Test.java000066400000000000000000000052401243020563200320350ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeBetween.shouldBeBetween; import static org.fest.util.Dates.parse; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeBetween#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeBetween_create_Test { @Test public void should_create_error_message_with_period_boundaries_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, true); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2010-01-01T00:00:00> to be in period [2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_lower_boundary_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, false); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2010-01-01T00:00:00> to be in period [2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } @Test public void should_create_error_message_with_period_upper_boundary_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, true); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2010-01-01T00:00:00> to be in period ]2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_boundaries_excluded() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, false); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2010-01-01T00:00:00> to be in period ]2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeCloseTo_create_Test.java000066400000000000000000000033171243020563200320170ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeCloseTo.shouldBeCloseTo; import static org.fest.util.Dates.ISO_DATE_TIME_FORMAT_WITH_MS; import java.text.ParseException; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBeCloseTo#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeCloseTo_create_Test { @Test public void should_create_error_message_with_period_boundaries_included() throws ParseException { ErrorMessageFactory factory = shouldBeCloseTo(ISO_DATE_TIME_FORMAT_WITH_MS.parse("2011-01-01T00:00:00.000"), ISO_DATE_TIME_FORMAT_WITH_MS.parse("2011-01-01T00:00:00.101"), 100, 101); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expected '2011-01-01T00:00:00.000' to be close to '2011-01-01T00:00:00.101' by less than 100ms but difference was of 101ms", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeDirectory_create_Test.java000066400000000000000000000026151243020563200324130ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeDirectory.shouldBeDirectory; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeDirectory#create(Description)}. * * @author Yvonne Wang */ public class ShouldBeDirectory_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeDirectory(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be an existing directory", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeEmpty_create_Test.java000066400000000000000000000027141243020563200315450ustar00rootroot00000000000000/* * Created on Sep 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeEmpty#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldBeEmpty_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeEmpty(newArrayList("Luke", "Yoda")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting empty but was:<['Luke', 'Yoda']>", message); } } ShouldBeEqualIgnoringCase_create_Test.java000066400000000000000000000027721243020563200337340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeEqualIgnoringCase.shouldBeEqual; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeEqualIgnoringCase#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeEqualIgnoringCase_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeEqual("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting:\n<'Yoda'>\n to be equal to:\n<'Luke'>\n ignoring case considerations", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeEqualImages_create_Test.java000066400000000000000000000027071243020563200326460ustar00rootroot00000000000000/* * Created on Jan 24, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualImages.shouldBeEqualImages; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeEqualImages#create(Description)}. * * @author Yvonne Wang */ public class ShouldBeEqualImages_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeEqualImages(offset(6)); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting images to be equal within offset:<6>", message); } } ShouldBeEqualWithinOffset_create_Test.java000066400000000000000000000030361243020563200337670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeEqualWithinOffset#create(Description)}. * * @author Alex Ruiz */ public class ShouldBeEqualWithinOffset_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeEqual(8f, 6f, offset(1f), 2f); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting <8.0f> to be close to <6.0f> within offset <1.0f> but offset was <2.0f>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeEqual_equals_hashCode_Test.java000066400000000000000000000045171243020563200333460ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertFalse; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.test.EqualsHashCodeContractAssert.*; import org.junit.*; /** * Tests for {@link ShouldBeEqual#equals(Object)} and {@link ShouldBeEqual#hashCode()}. * * @author Yvonne Wang */ public class ShouldBeEqual_equals_hashCode_Test { private static ShouldBeEqual factory; @BeforeClass public static void setUpOnce() { factory = (ShouldBeEqual) shouldBeEqual("Yoda", "Luke"); } @Test public void should_have_reflexive_equals() { assertEqualsIsReflexive(factory); } @Test public void should_have_symmetric_equals() { assertEqualsIsSymmetric(factory, shouldBeEqual("Yoda", "Luke")); } @Test public void should_have_transitive_equals() { assertEqualsIsTransitive(factory, shouldBeEqual("Yoda", "Luke"), shouldBeEqual("Yoda", "Luke")); } @Test public void should_maintain_equals_and_hashCode_contract() { assertMaintainsEqualsAndHashCodeContract(factory, shouldBeEqual("Yoda", "Luke")); } @Test public void should_not_be_equal_to_Object_of_different_type() { assertFalse(factory.equals("Yoda")); } @Test public void should_not_be_equal_to_null() { assertFalse(factory.equals(null)); } @Test public void should_not_be_equal_to_IsNotEqual_with_different_actual() { assertFalse(factory.equals(shouldBeEqual("Leia", "Luke"))); } @Test public void should_not_be_equal_to_IsNotEqual_with_different_expected() { assertFalse(factory.equals(shouldBeEqual("Yoda", "Leia"))); } } ShouldBeEqual_fest_elements_stack_trace_filtering_Test.java000066400000000000000000000033651243020563200374420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Sep 16, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.api.Assertions.assertThat; import static org.fest.assertions.util.StackTraceUtils.hasStackTraceElementRelatedToFest; import org.junit.Test; import org.fest.assertions.api.Fail; /** * Tests for {@link ShouldBeEqual} related to AssertionError stack trace filtering. * * @author Joel Costigliola */ public class ShouldBeEqual_fest_elements_stack_trace_filtering_Test { @Test public void fest_elements_should_be_removed_from_assertion_error_stack_trace() { Fail.setRemoveFestRelatedElementsFromStackTrace(true); try { assertThat("Xavi").isEqualTo("Xabi"); } catch (AssertionError assertionError) { assertThat(hasStackTraceElementRelatedToFest(assertionError)).isFalse(); } } @Test public void fest_elements_should_be_kept_in_assertion_error_stack_trace() { Fail.setRemoveFestRelatedElementsFromStackTrace(false); try { assertThat("Messi").isEqualTo("Ronaldo"); } catch (AssertionError assertionError) { assertThat(hasStackTraceElementRelatedToFest(assertionError)).isTrue(); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeEqual_newAssertionError_Test.java000066400000000000000000000046221243020563200337460ustar00rootroot00000000000000/* * Created on Aug 6, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.*; import java.util.List; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.*; import org.junit.runners.Parameterized.Parameters; /** * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. * * @author Alex Ruiz */ @RunWith(Parameterized.class) public class ShouldBeEqual_newAssertionError_Test { private final String formattedDescription; @Parameters public static List parameters() { return newArrayList(new Object[][] { { "[Jedi]" }, { "[Jedi] " } }); } public ShouldBeEqual_newAssertionError_Test(String formattedDescription) { this.formattedDescription = formattedDescription; } private Description description; private ShouldBeEqual factory; private DescriptionFormatter formatter; @Before public void setUp() { description = new TestDescription("Jedi"); factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda"); factory.descriptionFormatter = mock(DescriptionFormatter.class); formatter = factory.descriptionFormatter; } @Test public void should_create_ComparisonFailure_if_JUnit4_is_present_and_trim_spaces_in_formatted_description() { when(formatter.format(description)).thenReturn(formattedDescription); AssertionError error = factory.newAssertionError(description); assertEquals(ComparisonFailure.class, error.getClass()); assertEquals("[Jedi] expected:<'[Yoda]'> but was:<'[Luke]'>", error.getMessage()); } } ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test.java000066400000000000000000000103701243020563200431420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Aug 6, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static java.lang.Integer.toHexString; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.Strings.concat; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.*; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.*; /** * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. * * @author Joel Costigliola (based on Tomasz Nurkiewicz ideas) */ public class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test { private String formattedDescription = "[my test]"; private Description description; private ShouldBeEqual shouldBeEqual; @Before public void setUp() { description = new TestDescription("my test"); } @Test public void should_create_AssertionError_with_message_differentiating_expected_double_and_actual_float() { Float actual = 42f; Double expected = 42d; shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); AssertionError error = shouldBeEqual.newAssertionError(description); assertEquals("[my test] expected:<42.0[]> but was:<42.0[f]>", error.getMessage()); } @Test public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons() { Person actual = new Person("Jake", 43); Person expected = new Person("Jake", 47); shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); AssertionError error = shouldBeEqual.newAssertionError(description); assertEquals("[my test] expected:\n<'Person[name=Jake] (Person@" + toHexString(expected.hashCode()) + ")'>\n but was:\n<'Person[name=Jake] (Person@" + toHexString(actual.hashCode()) + ")'>", error.getMessage()); } @Test public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons_even_if_a_comparator_based_comparison_strategy_is_used() { Person actual = new Person("Jake", 43); Person expected = new Person("Jake", 47); ComparisonStrategy ageComparisonStrategy = new ComparatorBasedComparisonStrategy(new PersonComparator()); shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, ageComparisonStrategy); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); AssertionError error = shouldBeEqual.newAssertionError(description); assertEquals("[my test] Expecting actual:\n<'Person[name=Jake] (Person@" + toHexString(actual.hashCode()) + ")'>\n to be equal to \n<'Person[name=Jake] (Person@" + toHexString(expected.hashCode()) + ")'>\n according to 'PersonComparator' comparator but was not.", error.getMessage()); } private static class Person { private final String name; private final int age; public Person(String name, int age) { this.name = name; this.age = age; } @Override public String toString() { return concat("Person[name=", name, "]"); } } private static class PersonComparator implements Comparator { public int compare(Person p1, Person p2) { return p1.age - p2.age; } } } ShouldBeEqual_newAssertionError_without_JUnit_Test.java000066400000000000000000000054461243020563200365700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Aug 6, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.*; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.*; import org.junit.Before; import org.junit.ComparisonFailure; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldBeEqual_newAssertionError_without_JUnit_Test { private Description description; private ShouldBeEqual factory; private ConstructorInvoker constructorInvoker; @Before public void setUp() { description = new TestDescription("Jedi"); factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda"); constructorInvoker = mock(ConstructorInvoker.class); factory.constructorInvoker = constructorInvoker; } @Test public void should_create_AssertionError_if_created_ComparisonFailure_is_null() throws Exception { when(createComparisonFailure()).thenReturn(null); AssertionError error = factory.newAssertionError(description); check(error); } @Test public void should_create_AssertionError_if_error_is_thrown_when_creating_ComparisonFailure() throws Exception { when(createComparisonFailure()).thenThrow(new AssertionError("Thrown on purpose")); AssertionError error = factory.newAssertionError(description); check(error); } private Object createComparisonFailure() throws Exception { return createComparisonFailure(constructorInvoker); } private void check(AssertionError error) throws Exception { createComparisonFailure(verify(constructorInvoker)); assertFalse(error instanceof ComparisonFailure); assertEquals("[Jedi] expected:\n<'Yoda'>\n but was:\n<'Luke'>", error.getMessage()); } private static Object createComparisonFailure(ConstructorInvoker invoker) throws Exception { return invoker.newInstance(ComparisonFailure.class.getName(), new Class[] { String.class, String.class, String.class }, array("[Jedi]", "'Yoda'", "'Luke'")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeExactlyInstance_create_Test.java000066400000000000000000000030351243020563200335420ustar00rootroot00000000000000/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeExactlyInstanceOf.shouldBeExactlyInstance; import java.io.File; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeExactlyInstanceOf#create(Description)}. * * @author Nicolas François */ public class ShouldBeExactlyInstance_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeExactlyInstance("Yoda", File.class); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> to have exactly the same type as: but was:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeExecutableTest.java000066400000000000000000000024431243020563200310450ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static org.junit.Assert.assertEquals; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeExecutable}. * * @author Olivier Demeijer * */ public class ShouldBeExecutableTest { ErrorMessageFactory factory; @Before public void setup() { factory = ShouldBeExecutable.shouldBeExecutable(new FakeFile("pathname")); } @Test public void createExpectedMessage() { String actualMessage = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be executable", actualMessage); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeFile_create_Test.java000066400000000000000000000025571243020563200313330ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeFile#create(Description)}. * * @author Yvonne Wang */ public class ShouldBeFile_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeFile(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be an existing file", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeGreaterOrEqual_create_Test.java000066400000000000000000000040361243020563200333300ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.AbsValueComparator; /** * Tests for {@link ShouldBeGreaterOrEqual#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeGreaterOrEqual_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeGreaterOrEqual(6, 8); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<6> to be greater than or equal to:<8>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeGreaterOrEqual(6, 8, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<6> to be greater than or equal to:<8> according to 'AbsValueComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeGreater_create_Test.java000066400000000000000000000037341243020563200320430ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.AbsValueComparator; /** * Tests for {@link ShouldBeGreater#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeGreater_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeGreater(6, 8); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<6> to be greater than:<8>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeGreater(6, 8, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<6> to be greater than:<8> according to 'AbsValueComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameDay_create_Test.java000066400000000000000000000026201243020563200322550ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameDay.shouldBeInSameDay; import static org.fest.util.Dates.parse; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameDay#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameDay_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameDay(parse("2010-01-01"), parse("2010-01-25")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected <2010-01-01T00:00:00> to be on same year, month and day as <2010-01-25T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameHour_create_Test.java000066400000000000000000000030571243020563200324620ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameHour.shouldBeInSameHour; import static org.fest.util.Dates.ISO_DATE_TIME_FORMAT; import java.text.ParseException; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameHour#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameHour_create_Test { @Test public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameHour(ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:00:00"), ISO_DATE_TIME_FORMAT.parse("2011-01-01T06:00:00")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected <2011-01-01T05:00:00> to be on same year, month, day and hour as <2011-01-01T06:00:00>", message); } } ShouldBeInSameMillisecond_create_Test.java000066400000000000000000000032221243020563200337220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameMillisecond.shouldBeInSameMillisecond; import java.text.*; import java.util.Date; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameMillisecond#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameMillisecond_create_Test { @Test public void should_create_error_message() throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss:SS"); Date date1 = dateFormat.parse("1994-08-26T22:35:17:29"); Date date2 = dateFormat.parse("1994-08-26T22:35:17:30"); String message = shouldBeInSameMillisecond(date1, date2).create(new TextDescription("Test")); assertEquals( "[Test] expected <1994-08-26T22:35:17:29> to be on same year, month, day, hour, minute, second and millisecond as <1994-08-26T22:35:17:30>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameMinute_create_Test.java000066400000000000000000000031021243020563200327750ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameMinute.shouldBeInSameMinute; import static org.fest.util.Dates.ISO_DATE_TIME_FORMAT; import java.text.ParseException; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameMinute#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameMinute_create_Test { @Test public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameMinute(ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:01:00"), ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:02:00")); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expected <2011-01-01T05:01:00> to be on same year, month, day, hour and minute as <2011-01-01T05:02:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameMonth_create_Test.java000066400000000000000000000026251243020563200326320ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameMonth.shouldBeInSameMonth; import static org.fest.util.Dates.parse; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameMonth#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameMonth_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameMonth(parse("2010-01-01"), parse("2010-02-01")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected <2010-01-01T00:00:00> to be on same year and month as <2010-02-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameSecond_create_Test.java000066400000000000000000000031221243020563200327510ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameSecond.shouldBeInSameSecond; import static org.fest.util.Dates.ISO_DATE_TIME_FORMAT; import java.text.ParseException; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameSecond#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameSecond_create_Test { @Test public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameSecond(ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:00:01"), ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:00:02")); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expected <2011-01-01T05:00:01> to be on same year, month, day, hour, minute and second as <2011-01-01T05:00:02>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInSameYear_create_Test.java000066400000000000000000000026061243020563200324440ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInSameYear.shouldBeInSameYear; import static org.fest.util.Dates.parse; import org.junit.Test; import org.fest.assertions.description.*; /** * Tests for {@link ShouldBeInSameYear#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeInSameYear_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameYear(parse("2010-01-01"), parse("2011-01-01")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected <2010-01-01T00:00:00> to be on same year as <2011-01-01T00:00:00>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeIn_create_Test.java000066400000000000000000000041661243020563200310200ustar00rootroot00000000000000/* * Created on Feb 3, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeIn.shouldBeIn; import static org.fest.util.Arrays.array; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldBeIn#create(Description)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldBeIn_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeIn("Yoda", array("Luke", "Leia")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n<'Yoda'>\n to be in:\n<['Luke', 'Leia']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeIn("Yoda", array("Luke", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n<'Yoda'>\n to be in:\n<['Luke', 'Leia']>\n " + "according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInstanceOfAny_create_Test.java000066400000000000000000000032221243020563200331430ustar00rootroot00000000000000/* * Created on Dec 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInstanceOfAny.shouldBeInstanceOfAny; import java.io.File; import java.util.regex.Pattern; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeInstanceOfAny#create(Description)}. * * @author Alex Ruiz */ public class ShouldBeInstanceOfAny_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { Class[] types = { File.class, Pattern.class }; factory = shouldBeInstanceOfAny("Yoda", types); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> to be an instance of any of:\n" + "<[java.io.File, java.util.regex.Pattern]>\n" + " but was instance of:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeInstance_create_Test.java000066400000000000000000000036741243020563200322210ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstanceButWasNull; import java.io.File; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeInstance#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeInstance_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeInstance("Yoda", File.class); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] expected <'Yoda'> to be an instance of:\n\nbut was instance of:\n", message); } @Test public void should_create_shouldBeInstanceButWasNull_error_message() { factory = shouldBeInstanceButWasNull("other", File.class); String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected 'other' object to be an instance of: but was null", message); } } ShouldBeLenientEqualByAccepting_create_Test.java000066400000000000000000000045171243020563200350720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Apr 23, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeLenientEqualByAccepting.shouldBeLenientEqualByAccepting; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.test.Jedi; /** * Tests for {@link ShouldBeLenientEqualByIgnoring#create(Description)}. * * @author Nicolas François */ public class ShouldBeLenientEqualByAccepting_create_Test { private ErrorMessageFactory factory; @Test public void should_create_error_message_with_all_fields_differences() { factory = shouldBeLenientEqualByAccepting(new Jedi("Luke", "blue"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Yoda", (Object) "green"), newArrayList("name", "lightSaberColor")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected values:\n" + "<['Yoda', 'green']>\n" + " in fields:\n" + "<['name', 'lightSaberColor']>\n" + " of .\n" + "Comparison was performed on fields <['name', 'lightSaberColor']>", message); } @Test public void should_create_error_message_with_single_field_difference() { factory = shouldBeLenientEqualByAccepting(new Jedi("Yoda", "green"), newArrayList("lightSaberColor"), newArrayList((Object) "green"), newArrayList("lightSaberColor")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected value <'green'> in field <'lightSaberColor'> of .\n" + "Comparison was performed on fields <['lightSaberColor']>", message); } } ShouldBeLenientEqualByIgnoring_create_Test.java000066400000000000000000000070271243020563200347500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeLenientEqualByIgnoring.shouldBeLenientEqualByIgnoring; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import java.util.List; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.test.Jedi; /** * Tests for {@link ShouldBeLenientEqualByIgnoring#create(Description)}. * * @author Nicolas François * @author Joel Costigliola */ public class ShouldBeLenientEqualByIgnoring_create_Test { private ErrorMessageFactory factory; @Test public void should_create_error_message_with_all_fields_differences() { factory = shouldBeLenientEqualByIgnoring(new Jedi("Yoda", "green"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Yoda", (Object) "green"), newArrayList("lightSaberColor")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected values:\n" + "<['Yoda', 'green']>\n" + " in fields:\n" + "<['name', 'lightSaberColor']>\n" + " of .\n" + "Comparison was performed on all fields but <['lightSaberColor']>", message); } @Test public void should_create_error_message_with_single_field_difference() { factory = shouldBeLenientEqualByIgnoring(new Jedi("Yoda", "green"), newArrayList("lightSaberColor"), newArrayList((Object) "green"), newArrayList("lightSaberColor")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected value <'green'> in field <'lightSaberColor'> of ." + "\nComparison was performed on all fields but <['lightSaberColor']>", message); } @Test public void should_create_error_message_with_all_fields_differences_without_ignored_fields() { List ignoredFields = newArrayList(); factory = shouldBeLenientEqualByIgnoring(new Jedi("Yoda", "green"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Yoda", (Object) "green"), ignoredFields); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected values:\n" + "<['Yoda', 'green']>\n" + " in fields:\n" + "<['name', 'lightSaberColor']>\n" + " of .\n" + "Comparison was performed on all fields", message); } @Test public void should_create_error_message_with_single_field_difference_without_ignored_fields() { List ignoredFields = newArrayList(); factory = shouldBeLenientEqualByIgnoring(new Jedi("Yoda", "green"), newArrayList("lightSaberColor"), newArrayList((Object) "green"), ignoredFields); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected value <'green'> in field <'lightSaberColor'> of ." + "\nComparison was performed on all fields", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeLess_create_Test.java000066400000000000000000000037041243020563200313550ustar00rootroot00000000000000/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.AbsValueComparator; /** * Tests for {@link ShouldBeLess#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldBeLess_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeLess(8, 6); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<8> to be less than:<6>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeLess(8, 6, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<8> to be less than:<6> according to 'AbsValueComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeLowerCase_create_Test.java000066400000000000000000000024721243020563200323340ustar00rootroot00000000000000/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeLowerCase.shouldBeLowerCase; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldBeLowerCase#create(Description)}. * * @author Alex Ruiz */ public class ShouldBeLowerCase_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeLowerCase('A'); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected: to be a lowercase character", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeNullOrEmpty_create_Test.java000066400000000000000000000026631243020563200327040ustar00rootroot00000000000000/* * Created on Sep 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldBeNullOrEmpty#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldBeNullOrEmpty_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeNullOrEmpty(newArrayList("Luke", "Yoda")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting null or empty but was:<['Luke', 'Yoda']>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeOfClassIn_Test.java000066400000000000000000000031131243020563200307370ustar00rootroot00000000000000/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeOfClassIn.shouldBeOfClassIn; import static org.fest.util.Lists.newArrayList; import java.io.File; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeOfClassIn#create(Description)}. * * @author Nicolas François */ public class ShouldBeOfClassIn_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeOfClassIn("Yoda", newArrayList(Long.class, File.class)); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> should have type in <[java.lang.Long, java.io.File]> but was:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeReadableTest.java000066400000000000000000000024301243020563200304570ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static org.junit.Assert.assertEquals; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeReadable}. * * @author Olivier Demeijer * */ public class ShouldBeReadableTest { ErrorMessageFactory factory; @Before public void setup() { factory = ShouldBeReadable.shouldBeReadable(new FakeFile("pathname")); } @Test public void createExpectedMessage() { String actualMessage = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be readable", actualMessage); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeRelativePath_create_Test.java000066400000000000000000000026261243020563200330410ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeRelativePath.shouldBeRelativePath; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldBeRelativePath#create(Description)}. * * @author Yvonne Wang */ public class ShouldBeRelativePath_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeRelativePath(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be a relative path", message); } } ShouldBeSameGenericBetweenIterableAndCondition_create_Test.java000066400000000000000000000034671243020563200400340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ConditionAndGroupGenericParameterTypeShouldBeTheSame.shouldBeSameGenericBetweenIterableAndCondition; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeSameGenericBetweenIterableAndCondition_create_Test#create(Description)}. * * @author Nicolas François */ public class ShouldBeSameGenericBetweenIterableAndCondition_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeSameGenericBetweenIterableAndCondition(newArrayList("Yoda", "Leia"), new TestCondition("Not a Jedi")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting: <['Yoda', 'Leia']> have the same generic type as condition ", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeSame_create_Test.java000066400000000000000000000025161243020563200313340ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSame.shouldBeSame; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldBeSame#create(Description)}. * * @author Alex Ruiz */ public class ShouldBeSame_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeSame("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<'Luke'> and actual:<'Yoda'> should refer to the same object", message); } } ShouldBeSortedAccordingToComparator_create_Test.java000066400000000000000000000046741243020563200360040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.Arrays.array; import java.util.Comparator; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldBeSorted#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeSortedAccordingToComparator_create_Test { @Test public void should_create_error_message_with_comparator() { ErrorMessageFactory factory = shouldBeSortedAccordingToGivenComparator(1, array("b", "c", "A"), new CaseInsensitiveStringComparator()); String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] group is not sorted according to 'CaseInsensitiveStringComparator' comparator because element 1:<'c'> is not less or equal than element 2:<'A'>.\n" + "group was:\n" + "<['b', 'c', 'A']>", message); } @Test public void should_create_error_message_with_private_static_comparator() { ErrorMessageFactory factory = shouldBeSortedAccordingToGivenComparator(1, array("b", "c", "a"), new StaticStringComparator()); String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] group is not sorted according to 'StaticStringComparator' comparator because element 1:<'c'> is not less or equal than element 2:<'a'>.\n" + "group was:\n" + "<['b', 'c', 'a']>", message); } private static class StaticStringComparator implements Comparator { public int compare(String s1, String s2) { return s1.compareTo(s2); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeSorted_create_Test.java000066400000000000000000000036071243020563200317110ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSorted; import static org.fest.util.Arrays.array; import static org.junit.rules.ExpectedException.none; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeSorted#create(Description)}. * * @author Joel Costigliola */ public class ShouldBeSorted_create_Test { @Rule public ExpectedException thrown = none(); private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeSorted(1, array("b", "c", "a")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] group is not sorted because element 1:<'c'> is not less or equal than element 2:<'a'>.\n" + "group was:\n" + "<['b', 'c', 'a']>", message); } @Test public void should_fail_if_object_parameter_is_not_an_array() { thrown.expect(IllegalArgumentException.class); shouldBeSorted(1, "not an array"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeSubsetOf_create_Test.java000066400000000000000000000045741243020563200322070ustar00rootroot00000000000000/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSubsetOf.shouldBeSubsetOf; import static org.fest.util.Lists.newArrayList; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldBeSubsetOf#create(Description)}. * * @author Maciej Jaskowski */ public class ShouldBeSubsetOf_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"), newArrayList("Yoda")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Luke']>\n" + " to be subset of\n" + "<['Han', 'Luke']>\n" + " but found those extra elements:\n" + "<['Yoda']>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting according to 'CaseInsensitiveStringComparator' comparator:\n" + "<['Yoda', 'Luke']>\n" + " to be subset of\n" + "<['Han', 'Luke']>\n" + " but found those extra elements:\n" + "<['Yoda']>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeUpperCase_create_Test.java000066400000000000000000000024721243020563200323370ustar00rootroot00000000000000/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeUpperCase.shouldBeUpperCase; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldBeUpperCase#create(Description)}. * * @author Alex Ruiz */ public class ShouldBeUpperCase_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBeUpperCase('a'); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected: to be a uppercase character", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBeWritableTest.java000066400000000000000000000024251243020563200305350ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static org.junit.Assert.assertEquals; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeWritable}. * * @author Olivier Demeijer */ public class ShouldBeWritableTest { ErrorMessageFactory factory; @Before public void setup() { factory = ShouldBeWritable.shouldBeWritable(new FakeFile("pathname")); } @Test public void createExpectedMessage() { String actualMessage = factory.create(new TestDescription("Test")); assertEquals("[Test] File: should be writable", actualMessage); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldBe_create_Test.java000066400000000000000000000027541243020563200305320ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldBe.shouldBe; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldBe#create(Description)}. * * @author Yvonne Wang */ public class ShouldBe_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldBe("Yoda", new TestCondition("green")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n<'Yoda'>\n to be:\n", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainAtIndex_create_Test.java000066400000000000000000000043521243020563200330500ustar00rootroot00000000000000/* * Created on Nov 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.Lists.newArrayList; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldContainAtIndex#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContainAtIndex_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldContainAtIndex(newArrayList("Yoda", "Luke"), "Leia", atIndex(1), "Luke"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Leia'> at index <1> but found <'Luke'> in:\n" + " <['Yoda', 'Luke']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainAtIndex(newArrayList("Yoda", "Luke"), "Leia", atIndex(1), "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Leia'> at index <1> but found <'Luke'> in:\n" + " <['Yoda', 'Luke']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainExactly_create_Test.java000066400000000000000000000073051243020563200331260ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContainExactly.shouldContainExactly; import static org.fest.util.Lists.newArrayList; import static org.fest.util.Sets.newLinkedHashSet; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldContainExactly#create(Description)}. * * @author Joel Costigliola */ public class ShouldContainExactly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldContainExactly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expecting:\n<['Yoda', 'Han']>\n to contain exactly (and in same order):\n" + "<['Luke', 'Yoda']>\n but some elements were not found:\n<['Luke']>\n and others were not expected:\n<['Han']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainExactly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Han']>\n to contain exactly (and in same order):\n" + "<['Luke', 'Yoda']>\n but some elements were not found:\n<['Luke']>\n and others were not expected:\n" + "<['Han']>\n according to 'CaseInsensitiveStringComparator' comparator", message); } @Test public void should_create_error_message_when_only_elements_order_differs() { factory = shouldContainExactly("Luke", "Han", 1); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] actual and expected have the same elements but not in the same order, at index 1 actual element was :\n" + "<'Luke'>\n whereas expected element was :\n<'Han'>\n", message); } @Test public void should_create_error_message_when_only_elements_order_differs_according_to_custom_comparison_strategy() { factory = shouldContainExactly("Luke", "Han", 1, new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] actual and expected have the same elements but not in the same order, at index 1 actual element was :\n" + "<'Luke'>\n whereas expected element was :\n<'Han'>\n according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainKey_create_Test.java000066400000000000000000000031201243020563200322340ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldContainKey.shouldContainKey; import static org.fest.assertions.test.Maps.mapOf; import java.util.Map; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.junit.Test; /** * Tests for {@link ShoulContainKey#create(Description)}. * * @author Nicolas François */ public class ShouldContainKey_create_Test { @Test public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldContainKey(map, "name"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<{'name'='Yoda', 'color'='green'}>\n" + " to contain key:\n" + "<'name'>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainOnlyOnce_Test.java000066400000000000000000000051571243020563200317230ustar00rootroot00000000000000package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContainStringOnlyOnce.shouldContainOnlyOnce; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.*; import org.fest.assertions.util.CaseInsensitiveStringComparator; public class ShouldContainOnlyOnce_Test { private ErrorMessageFactory factoryWithSeveralOccurences; private ErrorMessageFactory factoryWithNoOccurence; @Before public void setUp() { factoryWithSeveralOccurences = shouldContainOnlyOnce("aaamotifmotifaabbbmotifaaa", "motif", 3); factoryWithNoOccurence = shouldContainOnlyOnce("aaamodifmoifaabbbmotfaaa", "motif", 0); } @Test public void should_create_error_message_when_string_to_search_appears_several_times() { String message = factoryWithSeveralOccurences.create(new TestDescription("Test")); assertEquals( "[Test] expecting:\n<'motif'>\n to appear only once in:\n<'aaamotifmotifaabbbmotifaaa'>\n but it appeared 3 times.", message); } @Test public void should_create_error_message_when_string_to_search_does_not_appear() { String message = factoryWithNoOccurence.create(new TestDescription("Test")); assertEquals( "[Test] expecting:\n<'motif'>\n to appear only once in:\n<'aaamodifmoifaabbbmotfaaa'>\n but it did not appear.", message); } @Test public void should_create_error_message_when_string_to_search_does_not_appear_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnlyOnce("aaamoDifmoifaabbbmotfaaa", "MOtif", 0, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expecting:\n<'MOtif'>\n to appear only once in:\n<'aaamoDifmoifaabbbmotfaaa'>\n but it did not appear according to 'CaseInsensitiveStringComparator' comparator.", message); } @Test public void should_create_error_message_when_string_to_search_appears_several_times_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnlyOnce("aaamotIFmoTifaabbbmotifaaa", "MOtif", 3, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] expecting:\n<'MOtif'>\n to appear only once in:\n<'aaamotIFmoTifaabbbmotifaaa'>\n but it appeared 3 times according to 'CaseInsensitiveStringComparator' comparator.", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainOnly_create_Test.java000066400000000000000000000051701243020563200324340ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldContainOnly#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldContainOnly_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldContainOnly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Han']>\n" + " to contain only:\n" + "<['Luke', 'Yoda']>\n" + " elements not found:\n" + "<['Luke']>\n" + " and elements not expected:\n" + "<['Han']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Han']>\n" + " to contain only:\n" + "<['Luke', 'Yoda']>\n" + " elements not found:\n" + "<['Luke']>\n" + " and elements not expected:\n" + "<['Han']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainSequence_create_Test.java000066400000000000000000000044361243020563200332670ustar00rootroot00000000000000/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.Lists.newArrayList; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldContainSequence#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldContainSequence_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldContainSequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Luke']>\n" + " to contain sequence:\n" + "<['Han', 'Leia']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainSequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda', 'Luke']>\n" + " to contain sequence:\n" + "<['Han', 'Leia']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainString_create_Test.java000066400000000000000000000043501243020563200327600ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContainString.*; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldContainString#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldContainString_create_Test { private ErrorMessageFactory factory; @Test public void should_create_error_message() { factory = shouldContain("Yoda", "Luke"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> to contain:<'Luke'>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldContain("Yoda", "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> to contain:<'Luke'> " + "according to 'CaseInsensitiveStringComparator' comparator", message); } @Test public void should_create_error_message_when_ignoring_case() { factory = shouldContainIgnoringCase("Yoda", "Luke"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> to contain:<'Luke'> (ignoring case)", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContainValue_create_Test.java000066400000000000000000000031431243020563200325650ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldContainValue.shouldContainValue; import static org.fest.assertions.test.Maps.mapOf; import java.util.Map; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.junit.Test; /** * Tests for {@link ShouldContainValue#create(Description)}. * * @author Nicolas François */ public class ShouldContainValue_create_Test { @Test public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldContainValue(map, "VeryOld"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<{'name'='Yoda', 'color'='green'}>\n" + " to contain value:\n" + "<'VeryOld'>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldContain_create_Test.java000066400000000000000000000054371243020563200316000ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldContain#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldContain_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda']>\n" + " to contain:\n" + "<['Luke', 'Yoda']>\n" + " but could not find:\n" + "<['Luke']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<['Yoda']>\n" + " to contain:\n" + "<['Luke', 'Yoda']>\n" + " but could not find:\n" + "<['Luke']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } @Test public void should_create_error_message_differentiating_long_from_integer() { factory = shouldContain(newArrayList(5L, 7L), newArrayList(5, 7), newLinkedHashSet(5, 7)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<[5L, 7L]>\n" + " to contain:\n" + "<[5, 7]>\n" + " but could not find:\n" + "<[5, 7]>\n", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldEndWith_create_Test.java000066400000000000000000000042061243020563200315400ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.Lists.newArrayList; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldEndWith#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldEndWith_create_Test { private ErrorMessageFactory factory; @Test public void should_create_error_message() { factory = shouldEndWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda', 'Luke']>\n" + " to end with\n" + "<['Han', 'Leia']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldEndWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda', 'Luke']>\n" + " to end with\n" + "<['Han', 'Leia']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldExist_create_Test.java000066400000000000000000000025421243020563200312730ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldExist.shouldExist; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldExist#create(Description)}. * * @author Yvonne Wang */ public class ShouldExist_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldExist(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting file: to exist", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveAtIndex_create_Test.java000066400000000000000000000016461243020563200323430ustar00rootroot00000000000000package org.fest.assertions.error; import org.fest.assertions.core.TestCondition; import org.fest.assertions.data.Index; import org.fest.assertions.description.*; import org.junit.Test; import static org.fest.assertions.error.ShouldHaveAtIndex.shouldHaveAtIndex; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; /** * Tests for {@link ShouldHaveAtIndex#create(Description)}. * * @author Bo Gotthardt */ public class ShouldHaveAtIndex_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldHaveAtIndex(newArrayList("Yoda", "Luke"), new TestCondition("red lightsaber"), Index.atIndex(1), "Luke"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Luke'> at index <1> to have: in:\n" + " <['Yoda', 'Luke']>\n", message); } } ShouldHaveComparableElementsAccordingToComparator_create_Test.java000066400000000000000000000033651243020563200406370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSorted.shouldHaveComparableElementsAccordingToGivenComparator; import static org.fest.util.Arrays.array; import org.junit.*; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldBeSorted#create(Description)}. * * @author Joel Costigliola */ public class ShouldHaveComparableElementsAccordingToComparator_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHaveComparableElementsAccordingToGivenComparator(array("b", "c", "a"), new CaseInsensitiveStringComparator()); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] some elements are not mutually comparable according to 'CaseInsensitiveStringComparator' comparator in group:<['b', 'c', 'a']>", message); } } ShouldHaveComparableElements_create_Test.java000066400000000000000000000027341243020563200344710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeSorted.shouldHaveMutuallyComparableElements; import org.junit.*; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; /** * Tests for {@link ShouldBeSorted#create(Description)}. * * @author Joel Costigliola */ public class ShouldHaveComparableElements_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHaveMutuallyComparableElements(new Object[] { "b", new Integer(5), "a" }); } @Test public void should_create_error_message() { assertEquals("[Test] some elements are not mutually comparable in group:<['b', 5, 'a']>", factory.create(new TestDescription("Test"))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveEqualContent_create_Test.java000066400000000000000000000050041243020563200334010ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.util.Lists.newArrayList; import static org.fest.util.SystemProperties.LINE_SEPARATOR; import java.io.ByteArrayInputStream; import java.util.List; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldHaveEqualContent#create(Description)}. * * @author Yvonne Wang * @author Matthieu Baechler */ public class ShouldHaveEqualContent_create_Test { private ErrorMessageFactory factory; private List diffs; @Before public void setUp() { diffs = newArrayList("line:<0>, expected: but was:", "line:<1>, expected: but was:", "line:<2>, expected: but was:"); } @Test public void should_create_error_message_file_even_if_content_contains_format_specifier() { factory = ShouldHaveEqualContent.shouldHaveEqualContent(new FakeFile("abc"), new FakeFile("xyz"), diffs); StringBuilder b = new StringBuilder(); b.append("[Test] file: and file: do not have equal content:"); for (String diff : diffs) b.append(LINE_SEPARATOR).append(diff); assertEquals(b.toString(), factory.create(new TextDescription("Test"))); } @Test public void should_create_error_message_inputstream_even_if_content_contains_format_specifier() { factory = ShouldHaveEqualContent.shouldHaveEqualContent(new ByteArrayInputStream(new byte[] { 'a' }), new ByteArrayInputStream(new byte[] { 'b' }), diffs); StringBuilder b = new StringBuilder(); b.append("[Test] InputStreams do not have equal content:"); for (String diff : diffs) b.append(LINE_SEPARATOR).append(diff); assertEquals(b.toString(), factory.create(new TextDescription("Test"))); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveSameClass_create_Test.java000066400000000000000000000027731243020563200326640ustar00rootroot00000000000000/* * Created on Jun 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldHaveSameClass.shouldHaveSameClass; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldHaveSameClass#create(Description)}. * * @author Nicolas François */ public class ShouldHaveSameClass_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHaveSameClass("Yoda", 10L); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] expected <'Yoda'> to have the same class as:<10L>() but was of class:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveSameSizeAs_create_Test.java000066400000000000000000000030031243020563200330000ustar00rootroot00000000000000/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldHaveSameSizeAs#create(Description)}. * * @author Nicolas François */ public class ShouldHaveSameSizeAs_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHaveSameSizeAs(newArrayList("Luke", "Yoda"), 2, 8); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals( "[Test] actual and expected should have same size but actual size is:<2> while expected is:<8>, actual was:<['Luke', 'Yoda']>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveSize_create_Test.java000066400000000000000000000026411243020563200317150ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldHaveSize#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldHaveSize_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHaveSize(newArrayList("Luke", "Yoda"), 2, 8); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected size:<8> but was:<2> in:<['Luke', 'Yoda']>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHaveTime_create_Test.java000066400000000000000000000031221243020563200316740ustar00rootroot00000000000000/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldHaveTime.shouldHaveTime; import static org.fest.util.Dates.ISO_DATE_TIME_FORMAT; import java.text.ParseException; import java.util.Date; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldHaveTime#create(Description)}. * * @author Guillaume Girou * @author Nicolas François * @author Joel Costigliola */ public class ShouldHaveTime_create_Test { @Test public void should_create_error_message() throws ParseException { Date date = ISO_DATE_TIME_FORMAT.parse("2011-01-01T05:01:00"); String message = shouldHaveTime(date, 123).create(new TextDescription("Test")); assertEquals("[Test] expected <2011-01-01T05:01:00> to have time:\n<123L>\n but was:\n<" + date.getTime() + "L>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldHave_create_Test.java000066400000000000000000000026511243020563200310630ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldHave.shouldHave; import static org.junit.Assert.assertEquals; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldHave#create(Description)}. * * @author Yvonne Wang */ public class ShouldHave_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldHave("Yoda", new TestCondition("green lightsaber")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> to have:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldMatchPattern_create_Test.java000066400000000000000000000025011243020563200325640ustar00rootroot00000000000000/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldMatchPattern.shouldMatch; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldMatchPattern#create(Description)}. * * @author Alex Ruiz */ public class ShouldMatchPattern_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldMatch("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] 'Yoda' does not match the pattern 'Luke'", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeBetween_create_Test.java000066400000000000000000000054121243020563200325170ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeBetween.shouldNotBeBetween; import static org.fest.util.Dates.parse; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; /** * Tests for {@link ShouldNotBeBetween#create(Description)}. * * @author Joel Costigliola */ public class ShouldNotBeBetween_create_Test { @Test public void should_create_error_message_with_period_boundaries_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2009-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, true); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2009-01-01T00:00:00> not to be in period [2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_lower_boundary_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2012-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, false); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2012-01-01T00:00:00> not to be in period [2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } @Test public void should_create_error_message_with_period_upper_boundary_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2011-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, true); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> not to be in period ]2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_boundaries_excluded() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2011-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, false); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expected:<2011-01-01T00:00:00> not to be in period ]2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeEmpty_create_Test.java000066400000000000000000000026051243020563200322250ustar00rootroot00000000000000/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldNotBeEmpty#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldNotBeEmpty_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeEmpty(); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting actual not to be empty", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeEqualImages_create_Test.java000066400000000000000000000026111243020563200333210ustar00rootroot00000000000000/* * Created on Jan 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeEqualImages.shouldNotBeEqualImages; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldNotBeEqualImages#create(Description)}. * * @author Yvonne Wang */ public class ShouldNotBeEqualImages_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeEqualImages(); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting images not to be equal", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeEqual_create_Test.java000066400000000000000000000036451243020563200322030ustar00rootroot00000000000000/* * Created on Sep 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.internal.*; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldNotBeEqual#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotBeEqual_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeEqual("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Jedi")); assertEquals("[Jedi] <'Yoda'> should not be equal to:<'Luke'>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotBeEqual("Yoda", "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TestDescription("Jedi")); assertEquals( "[Jedi] <'Yoda'> should not be equal to:<'Luke'>" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } ShouldNotBeExactlyInstance_create_Test.java000066400000000000000000000030631243020563200341450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/error/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeExactlyInstanceOf.shouldNotBeExactlyInstance; import java.io.File; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeExactlyInstance#create(Description)}. * * @author Nicolas François */ public class ShouldNotBeExactlyInstance_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeExactlyInstance("Yoda", File.class); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> to have not exactly the same type as: but was:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeIn_create_Test.java000066400000000000000000000042561243020563200315010ustar00rootroot00000000000000/* * Created on Feb 3, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldNotBeIn.shouldNotBeIn; import static org.fest.util.Arrays.array; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldNotBeIn#create(Description)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldNotBeIn_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeIn("Luke", array("Luke", "Leia")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<'Luke'>\n" + " not to be in:\n" + "<['Luke', 'Leia']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotBeIn("Luke", array("Luke", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<'Luke'>\n" + " not to be in:\n" + "<['Luke', 'Leia']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeInstanceOfAny_create_Test.java000066400000000000000000000030551243020563200336300ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeInstanceOfAny.shouldNotBeInstanceOfAny; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldBeInstanceOfAny#create(Description)}. * * @author Alex Ruiz */ public class ShouldNotBeInstanceOfAny_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { Class[] types = { String.class, Object.class }; factory = shouldNotBeInstanceOfAny("Yoda", types); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> to be an instance of any of:\n" + "<[java.lang.String, java.lang.Object]>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeInstance_create_Test.java000066400000000000000000000027211243020563200326720ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeInstance.shouldNotBeInstance; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldNotBeInstance#create(Description)}. * * @author Nicolas François */ public class ShouldNotBeInstance_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeInstance("Yoda", String.class); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> not to be an instance of:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeNull_create_Test.java000066400000000000000000000025771243020563200320510ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeNull.shouldNotBeNull; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldNotBeNull#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldNotBeNull_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeNull(); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting actual not to be null", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeOfClassIn_Test.java000066400000000000000000000031271243020563200314250ustar00rootroot00000000000000/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeOfClassIn.shouldNotBeOfClassIn; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldNotBeOfClassIn#create(Description)}. * * @author Nicolas François */ public class ShouldNotBeOfClassIn_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeOfClassIn("Yoda", newArrayList(Long.class, String.class)); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals( "[Test] expected <'Yoda'> should not have type in <[java.lang.Long, java.lang.String]> but was:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBeSame_create_Test.java000066400000000000000000000026001243020563200320070ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotBeSame.shouldNotBeSame; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldNotBeSame#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class ShouldNotBeSame_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBeSame("Yoda"); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected not same:<'Yoda'>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotBe_create_Test.java000066400000000000000000000026231243020563200312060ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldNotBe.shouldNotBe; import static org.junit.Assert.assertEquals; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldNotBe#create(Description)}. * * @author Yvonne Wang */ public class ShouldNotBe_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotBe("Yoda", new TestCondition("Sith")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> not to be:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotContainAtIndex_create_Test.java000066400000000000000000000045161243020563200335330ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.Lists.newArrayList; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldNotContainAtIndex#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotContainAtIndex_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotContainAtIndex(newArrayList("Yoda", "Luke"), "Luke", atIndex(1)); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting \n" + "<['Yoda', 'Luke']>\n" + " not to contain \n" + "<'Luke'>\n" + " at index <1>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotContainAtIndex(newArrayList("Yoda", "Luke"), "Luke", atIndex(1), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting \n" + "<['Yoda', 'Luke']>\n" + " not to contain \n" + "<'Luke'>\n" + " at index <1>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotContainKey_create_Test.java000066400000000000000000000031421243020563200327210ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotContainKey.shouldNotContainKey; import static org.fest.assertions.test.Maps.mapOf; import java.util.Map; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.junit.Test; /** * Tests for {@link ShouldNotContainKey#create(Description)}. * * @author Nicolas François */ public class ShouldNotContainKey_create_Test { @Test public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldNotContainKey(map, "age"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<{'name'='Yoda', 'color'='green'}>\n" + " not to contain key:\n" + "<'age'>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotContainString_create_Test.java000066400000000000000000000037451243020563200334500ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotContainString.shouldNotContain; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldNotContainString#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldNotContainString_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldNotContain("Yoda", "od"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> not to contain:<'od'>", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldNotContain("Yoda", "od", new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> not to contain:<'od'> according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotContainValue_create_Test.java000066400000000000000000000031701243020563200332460ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotContainValue.shouldNotContainValue; import static org.fest.assertions.test.Maps.mapOf; import java.util.Map; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.junit.Test; /** * Tests for {@link ShouldNotContainKey#create(Description)}. * * @author Nicolas François */ public class ShouldNotContainValue_create_Test { @Test public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldNotContainValue(map, "green"); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:\n" + "<{'name'='Yoda', 'color'='green'}>\n" + " not to contain value:\n" + "<'green'>", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotContain_create_Test.java000066400000000000000000000045121243020563200322520ustar00rootroot00000000000000/* * Created on Oct 12, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.Lists.newArrayList; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; import org.junit.Test; /** * Tests for {@link ShouldNotContain#create(Description)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class ShouldNotContain_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldNotContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Yoda")); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda']>\n" + " not to contain\n" + "<['Luke', 'Yoda']>\n" + " but found\n" + "<['Yoda']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldNotContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda']>\n" + " not to contain\n" + "<['Luke', 'Yoda']>\n" + " but found\n" + "<['Yoda']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotExist_create_Test.java000066400000000000000000000025651243020563200317610ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotExist.shouldNotExist; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link ShouldNotExist#create(Description)}. * * @author Yvonne Wang */ public class ShouldNotExist_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotExist(new FakeFile("xyz")); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expecting file: not to exist", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotHaveDuplicates_create_Test.java000066400000000000000000000044071243020563200335630ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.Lists.newArrayList; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldNotHaveDuplicates#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldNotHaveDuplicates_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotHaveDuplicates(newArrayList("Yoda", "Yoda", "Luke"), newArrayList("Yoda")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] found duplicate(s)\n" + "<['Yoda']>\n" + " in\n" + "<['Yoda', 'Yoda', 'Luke']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotHaveDuplicates(newArrayList("Yoda", "Yoda", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] found duplicate(s)\n" + "<['Yoda']>\n" + " in\n" + "<['Yoda', 'Yoda', 'Luke']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotHaveSameClass_create_Test.java000066400000000000000000000027541243020563200333440ustar00rootroot00000000000000/* * Created on Jun 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotHaveSameClass.shouldNotHaveSameClass; import org.fest.assertions.description.Description; import org.fest.assertions.internal.TestDescription; import org.junit.Before; import org.junit.Test; /** * Tests for {@link ShouldNotHaveSameClass#create(Description)}. * * @author Nicolas François */ public class ShouldNotHaveSameClass_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotHaveSameClass("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TestDescription("Test")); assertEquals("[Test] expected <'Yoda'> not to have not the same class as:<'Luke'> (java.lang.String)", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotHave_create_Test.java000066400000000000000000000026631243020563200315470ustar00rootroot00000000000000/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.error; import static org.fest.assertions.error.ShouldNotHave.shouldNotHave; import static org.junit.Assert.assertEquals; import org.fest.assertions.core.TestCondition; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldNotHave#create(Description)}. * * @author Yvonne Wang */ public class ShouldNotHave_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotHave("Yoda", new TestCondition("red lightsaber")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting:<'Yoda'> not to have:", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldNotMatchPattern_create_Test.java000066400000000000000000000025111243020563200332460ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldNotMatchPattern.shouldNotMatch; import org.fest.assertions.description.*; import org.junit.*; /** * Tests for {@link ShouldNotMatchPattern#create(Description)}. * * @author Alex Ruiz */ public class ShouldNotMatchPattern_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldNotMatch("Yoda", "Luke"); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] 'Yoda' matches the pattern 'Luke'", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/error/ShouldStartWith_create_Test.java000066400000000000000000000043261243020563200321320ustar00rootroot00000000000000/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.error; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.Lists.newArrayList; import org.junit.Before; import org.junit.Test; import org.fest.assertions.description.Description; import org.fest.assertions.description.TextDescription; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Tests for {@link ShouldStartWith#create(Description)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShouldStartWith_create_Test { private ErrorMessageFactory factory; @Before public void setUp() { factory = shouldStartWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia")); } @Test public void should_create_error_message() { String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda', 'Luke']>\n" + " to start with\n" + "<['Han', 'Leia']>\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldStartWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); String message = factory.create(new TextDescription("Test")); assertEquals("[Test] expecting\n" + "<['Yoda', 'Luke']>\n" + " to start with\n" + "<['Han', 'Leia']>\n" + " according to 'CaseInsensitiveStringComparator' comparator", message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/groups/000077500000000000000000000000001243020563200240165ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/groups/Properties_extractProperty_Test.java000066400000000000000000000034031243020563200333130ustar00rootroot00000000000000/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.groups; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link Properties#extractProperty(String, Class)}. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class Properties_extractProperty_Test { @Rule public ExpectedException thrown = none(); @Test public void should_create_a_new_Properties() { Properties properties = Properties.extractProperty("id", Object.class); assertEquals("id", properties.propertyName); } @Test public void should_throw_error_if_property_name_is_null() { thrown.expectNullPointerException("The name of the property to read should not be null"); Properties.extractProperty(null, Object.class); } @Test public void should_throw_error_if_property_name_is_empty() { thrown.expectIllegalArgumentException("The name of the property to read should not be empty"); Properties.extractProperty("", Object.class); } } Properties_from_with_Collection_Test.java000066400000000000000000000040171243020563200341700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/groups/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.groups; import static junit.framework.Assert.assertSame; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.*; import java.util.*; import org.fest.assertions.groups.Properties; import org.fest.assertions.internal.PropertySupport; import org.fest.test.*; import org.junit.*; /** * Tests for {@link Properties#from(Collection)}. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class Properties_from_with_Collection_Test { private static Employee yoda; private static List employees; @BeforeClass public static void setUpOnce() { yoda = new Employee(6000L, new Name("Yoda"), 800); employees = newArrayList(yoda); } private PropertySupport propertySupport; private String propertyName; private Properties properties; @Before public void setUp() { propertySupport = mock(PropertySupport.class); propertyName = "id"; properties = new Properties(propertyName, Long.class); properties.propertySupport = propertySupport; } @Test public void should_return_values_of_property() { List ids = new ArrayList(); ids.add(yoda.getId()); when(propertySupport.propertyValues(propertyName, Long.class, employees)).thenReturn(ids); assertSame(ids, properties.from(employees)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/groups/Properties_from_with_array_Test.java000066400000000000000000000040131243020563200332660ustar00rootroot00000000000000/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.groups; import static junit.framework.Assert.assertSame; import static org.fest.assertions.util.ArrayWrapperList.wrap; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.*; import java.util.*; import org.fest.assertions.internal.PropertySupport; import org.fest.test.*; import org.junit.*; /** * Tests for {@link Properties#from(Object[])}. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class Properties_from_with_array_Test { private static Employee yoda; private static Object[] employees; @BeforeClass public static void setUpOnce() { yoda = new Employee(6000L, new Name("Yoda"), 800); employees = array(yoda); } private PropertySupport propertySupport; private String propertyName; private Properties properties; @Before public void setUp() { propertySupport = mock(PropertySupport.class); propertyName = "id"; properties = new Properties(propertyName, Long.class); properties.propertySupport = propertySupport; } @Test public void should_return_values_of_property() { List ids = new ArrayList(); ids.add(yoda.getId()); when(propertySupport.propertyValues(propertyName, Long.class, wrap(employees))).thenReturn(ids); assertSame(ids, properties.from(employees)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/groups/Properties_ofType_Test.java000066400000000000000000000022401243020563200313400ustar00rootroot00000000000000/* * Created on Jul 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.groups; import static junit.framework.Assert.assertEquals; import org.junit.Test; /** * Tests for {@link Properties#ofType(Class)}. * * @author Olivier Michallat */ public class Properties_ofType_Test { @Test public void should_create_a_new_Properties() { Properties properties = Properties.extractProperty("id").ofType(String.class); assertEquals("id", properties.propertyName); assertEquals(String.class, properties.propertyType); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/000077500000000000000000000000001243020563200243135ustar00rootroot00000000000000AbstractTest_ComparatorBasedComparisonStrategy.java000066400000000000000000000012061243020563200364050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internalpackage org.fest.assertions.internal; import static org.junit.rules.ExpectedException.none; import java.util.Comparator; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Rule; import org.junit.rules.ExpectedException; public class AbstractTest_ComparatorBasedComparisonStrategy { @Rule public ExpectedException thrown = none(); protected Comparator caseInsensitiveStringComparator = CaseInsensitiveStringComparator.instance; protected ComparatorBasedComparisonStrategy caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy( caseInsensitiveStringComparator); }AbstractTest_StandardComparisonStrategy.java000066400000000000000000000007001243020563200350750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internalpackage org.fest.assertions.internal; import static org.junit.rules.ExpectedException.none; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Rule; import org.junit.rules.ExpectedException; public class AbstractTest_StandardComparisonStrategy { @Rule public ExpectedException thrown = none(); protected static StandardComparisonStrategy standardComparisonStrategy = StandardComparisonStrategy.instance(); }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/BigDecimalsBaseTest.java000066400000000000000000000041031243020563200307520ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.util.BigDecimalComparator.BIG_DECIMAL_COMPARATOR; import static org.mockito.Mockito.spy; import java.math.BigDecimal; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; import org.fest.assertions.util.BigDecimalComparator; /** * Base class for {@link BigDecimals} unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link BigDecimals#failures} appropriately. * * @author Joel Costigliola * */ public class BigDecimalsBaseTest { protected static final BigDecimal ONE_WITH_3_DECIMALS = new BigDecimal("1.000"); @Rule public ExpectedException thrown = none(); protected Failures failures; protected BigDecimals bigDecimals; protected ComparatorBasedComparisonStrategy comparatorComparisonStrategy; /** * {@link BigDecimals} using a comparison strategy based on {@link BigDecimalComparator}. */ protected BigDecimals bigDecimalsWithComparatorComparisonStrategy; // another BigDecimals with a custom ComparisonStrategy other than bigDecimalsWithComparatorComparisonStrategy protected BigDecimals bigDecimalsWithAbsValueComparisonStrategy; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); bigDecimals = new BigDecimals(); bigDecimals.setFailures(failures); comparatorComparisonStrategy = new ComparatorBasedComparisonStrategy(BIG_DECIMAL_COMPARATOR); bigDecimalsWithComparatorComparisonStrategy = new BigDecimals(comparatorComparisonStrategy); bigDecimalsWithComparatorComparisonStrategy.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); bigDecimalsWithAbsValueComparisonStrategy = new BigDecimals(absValueComparisonStrategy); bigDecimalsWithAbsValueComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/BooleanArraysBaseTest.java000066400000000000000000000020001243020563200313420ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.BooleanArrays.arrayOf; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * Base class for testing {@link BooleanArrays}, set up an instance with {@link StandardComparisonStrategy} and * another with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link BooleanArrays#failures} appropriately. * * @author Joel Costigliola */ public class BooleanArraysBaseTest { @Rule public ExpectedException thrown = none(); protected boolean[] actual; protected Failures failures; protected BooleanArrays arrays; @Before public void setUp() { actual = arrayOf(true, false); failures = spy(new Failures()); arrays = new BooleanArrays(); arrays.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/BooleansBaseTest.java000066400000000000000000000013641243020563200303570ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * Base class for testing {@link Booleans}. *

* Is in org.fest.assertions.internal package to be able to set {@link Booleans#failures} appropriately. * * @author Joel Costigliola */ public class BooleansBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Booleans booleans; @Before public void setUp() { failures = spy(new Failures()); booleans = new Booleans(); booleans.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ByteArraysBaseTest.java000066400000000000000000000046461243020563200307100ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ByteArrays.arrayOf; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link ByteArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link ByteArrays#failures} appropriately. * * @author Joel Costigliola */ public class ByteArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6, 8, 10} */ protected byte[] actual; protected Failures failures; protected ByteArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected ByteArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new ByteArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new ByteArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6, 8, 10); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/BytesBaseTest.java000066400000000000000000000022031243020563200276740ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for {@link Bytes} unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link Bytes#failures} appropriately. * * @author Joel Costigliola * */ public class BytesBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Bytes bytes; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Bytes bytesWithAbsValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); bytes = new Bytes(); bytes.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); bytesWithAbsValueComparisonStrategy = new Bytes(absValueComparisonStrategy); bytesWithAbsValueComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/CaseInsensitiveStringComparator.java000066400000000000000000000006651243020563200335000ustar00rootroot00000000000000package org.fest.assertions.internal; import java.util.Comparator; public class CaseInsensitiveStringComparator implements Comparator { public final static CaseInsensitiveStringComparator instance = new CaseInsensitiveStringComparator(); public int compare(String s1, String s2) { if (s1 == null) return s2 == null ? 0 : 1; if (s2 == null) return -1; return s1.toLowerCase().compareTo(s2.toLowerCase()); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/CharArraysBaseTest.java000066400000000000000000000047671243020563200306660ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveCharacterComparator; /** * Base class for testing {@link CharArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link CharArrays#failures} appropriately. * * @author Joel Costigliola */ public class CharArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {'a', 'b', 'c'} */ protected char[] actual; protected Failures failures; protected CharArrays arrays; protected ComparatorBasedComparisonStrategy caseInsensitiveComparisonStrategy; protected CharArrays arraysWithCustomComparisonStrategy; private CaseInsensitiveCharacterComparator caseInsensitiveComparator = new CaseInsensitiveCharacterComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new CharArrays(); arrays.failures = failures; caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new CharArrays(caseInsensitiveComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf('a', 'b', 'c'); } protected Comparator comparatorForCustomComparisonStrategy() { return caseInsensitiveComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/CharactersBaseTest.java000066400000000000000000000024011243020563200306650ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveCharacterComparator; /** * Base class for Characters unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link Characters#failures} appropriately. * * @author Joel Costigliola * */ public class CharactersBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Characters characters; protected ComparatorBasedComparisonStrategy caseInsensitiveComparisonStrategy; protected Characters charactersWithCaseInsensitiveComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); characters = new Characters(); characters.failures = failures; caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveCharacterComparator.instance); charactersWithCaseInsensitiveComparisonStrategy = new Characters(caseInsensitiveComparisonStrategy); charactersWithCaseInsensitiveComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ComparablesBaseTest.java000066400000000000000000000042271243020563200310460ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link Comparables}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Comparables#failures} appropriately. * * @author Joel Costigliola */ public class ComparablesBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Comparables comparables; protected ComparatorBasedComparisonStrategy customComparisonStrategy; protected Comparables comparablesWithCustomComparisonStrategy; public ComparablesBaseTest() { super(); } @Before public void setUp() { failures = spy(new Failures()); comparables = new Comparables(); comparables.failures = failures; customComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); comparablesWithCustomComparisonStrategy = new Comparables(customComparisonStrategy); comparablesWithCustomComparisonStrategy.failures = failures; } protected Comparator comparatorForCustomComparisonStrategy() { return new AbsValueComparator(); } }ComparatorBasedComparisonStrategy_areEqual_Test.java000066400000000000000000000043201243020563200365400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#areEqual(Object, Object)}.
* * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_areEqual_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_return_true_if_objects_are_equal_according_to_comparison_strategy() { assertTrue(caseInsensitiveComparisonStrategy.areEqual("Yoda", "Yoda")); assertTrue(caseInsensitiveComparisonStrategy.areEqual("Yoda", "YODA")); assertTrue(caseInsensitiveComparisonStrategy.areEqual("YOda", "YodA")); } @Test public void should_return_true_if_both_objects_are_null() { assertTrue(caseInsensitiveComparisonStrategy.areEqual(null, null)); } @Test public void should_return_false_if_first_object_is_null_and_second_is_not() { assertFalse(caseInsensitiveComparisonStrategy.areEqual(null, "Yoda")); } @Test public void should_return_false_if_second_object_is_null_and_first_is_not() { assertFalse(caseInsensitiveComparisonStrategy.areEqual("Yoda", null)); } @Test public void should_return_false_if_objects_are_not_equal_according_to_comparison_strategy() { assertFalse(caseInsensitiveComparisonStrategy.areEqual("Yoda", "Yod")); } @Test public void should_fail_if_objects_are_not_mutually_comparable() { thrown.expect(ClassCastException.class); assertFalse(caseInsensitiveComparisonStrategy.areEqual("Yoda", 5)); } } ComparatorBasedComparisonStrategy_arrayContains_Test.java000066400000000000000000000044241243020563200376230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Arrays.array; import static org.junit.Assert.*; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#arrayContains(Object, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_arrayContains_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_return_true_if_array_contains_value_according_to_comparison_strategy() { String[] hobbits = array("Merry", "Frodo", "Merry", "Sam"); assertTrue(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "Sam")); assertTrue(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "SAM")); assertTrue(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "Merry")); assertTrue(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "MerRy")); } @Test public void should_return_false_if_array_does_not_contain_value_according_to_comparison_strategy() { String[] hobbits = array("Merry", "Frodo", "Merry", "Sam"); assertFalse(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "Pippin")); assertFalse(caseInsensitiveComparisonStrategy.arrayContains(hobbits, "Sam ")); } @Test public void should_return_false_if_array_is_empty() { assertFalse(caseInsensitiveComparisonStrategy.arrayContains(new String[] {}, "Pippin")); } @Test public void should_fail_if_first_parameter_is_not_an_array() { thrown.expect(IllegalArgumentException.class); caseInsensitiveComparisonStrategy.arrayContains("not an array", "Pippin"); } } ComparatorBasedComparisonStrategy_duplicatesFrom_Test.java000066400000000000000000000046661243020563200377770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Iterables.sizeOf; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.ArrayList; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#caseInsensitiveComparisonStrategy.duplicatesFrom(java.util.Collection)}.
* * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_duplicatesFrom_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_return_existing_duplicates() { Iterable duplicates = caseInsensitiveComparisonStrategy.duplicatesFrom(newArrayList("Merry", "Frodo", "Merry", "Sam", "FrODO", null, null)); assertEquals(3, sizeOf(duplicates)); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(duplicates, "frodo")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(duplicates, "MERRY")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(duplicates, null)); } @Test public void should_not_return_any_duplicates() { Iterable duplicates = caseInsensitiveComparisonStrategy.duplicatesFrom(newArrayList("Frodo", "Sam", "Gandalf")); assertTrue(isNullOrEmpty(duplicates)); } @Test public void should_not_return_any_duplicates_if_collection_is_empty() { Iterable duplicates = caseInsensitiveComparisonStrategy.duplicatesFrom(new ArrayList()); assertTrue(isNullOrEmpty(duplicates)); } @Test public void should_not_return_any_duplicates_if_collection_is_null() { Iterable duplicates = caseInsensitiveComparisonStrategy.duplicatesFrom(null); assertTrue(isNullOrEmpty(duplicates)); } } ComparatorBasedComparisonStrategy_isGreaterThanOrEqualTo_Test.java000066400000000000000000000040271243020563200413410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#isGreaterThanOrEqualTo(Object, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_isGreaterThanOrEqualTo_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { String string = "stringA"; String lesserUpperString = "STRING"; assertTrue(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(string, string)); assertTrue(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(string, "STRINGA")); assertTrue(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(string, lesserUpperString)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(lesserUpperString, string)); String lesserLowerString = "string"; assertTrue(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(string, lesserLowerString)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(lesserLowerString, string)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(ClassCastException.class); caseInsensitiveComparisonStrategy.isGreaterThanOrEqualTo(new Rectangle(), new Rectangle()); } } ComparatorBasedComparisonStrategy_isGreaterThan_Test.java000066400000000000000000000046651243020563200375550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.awt.Rectangle; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#isGreaterThan(Object, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_isGreaterThan_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void verify_that_isGreaterThan_delegates_to_compare_method() { caseInsensitiveStringComparator = mock(CaseInsensitiveStringComparator.class); caseInsensitiveComparisonStrategy = new ComparatorBasedComparisonStrategy(caseInsensitiveStringComparator); String s1 = "string1"; String s2 = "string2"; caseInsensitiveComparisonStrategy.isGreaterThan(s1, s2); verify(caseInsensitiveStringComparator).compare(s1, s2); } @Test public void should_pass() { String string = "stringA"; String lesserUpperString = "STRING"; assertTrue(caseInsensitiveComparisonStrategy.isGreaterThan(string, lesserUpperString)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThan(lesserUpperString, string)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThan(string, string)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThan(string, "STRINGA")); String lowerLesserString = "string"; assertTrue(caseInsensitiveComparisonStrategy.isGreaterThan(string, lowerLesserString)); assertFalse(caseInsensitiveComparisonStrategy.isGreaterThan(lowerLesserString, string)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(ClassCastException.class); caseInsensitiveComparisonStrategy.isGreaterThan(new Rectangle(), new Rectangle()); } } ComparatorBasedComparisonStrategy_isLessThanOrEqualTo_Test.java000066400000000000000000000037361243020563200406640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#isLessThanOrEqualTo(Object, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_isLessThanOrEqualTo_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { String string = "string"; String greaterString = "STRINGA"; assertTrue(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(string, greaterString)); assertTrue(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(string, "STRING")); assertTrue(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(string, string)); assertFalse(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(greaterString, string)); String lowerString = "stringA"; assertTrue(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(string, lowerString)); assertFalse(caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(lowerString, string)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(ClassCastException.class); caseInsensitiveComparisonStrategy.isLessThanOrEqualTo(new Rectangle(), new Rectangle()); } } ComparatorBasedComparisonStrategy_isLessThan_Test.java000066400000000000000000000036171243020563200370660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#isLessThan(Object, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_isLessThan_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { String string = "string"; String greaterString = "STRINGA"; assertTrue(caseInsensitiveComparisonStrategy.isLessThan(string, greaterString)); assertFalse(caseInsensitiveComparisonStrategy.isLessThan(greaterString, string)); assertFalse(caseInsensitiveComparisonStrategy.isLessThan(string, string)); assertFalse(caseInsensitiveComparisonStrategy.isLessThan(string, "STRING")); String lowerString = "stringA"; assertTrue(caseInsensitiveComparisonStrategy.isLessThan(string, lowerString)); assertFalse(caseInsensitiveComparisonStrategy.isLessThan(lowerString, string)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(ClassCastException.class); caseInsensitiveComparisonStrategy.isLessThan(new Rectangle(), new Rectangle()); } } ComparatorBasedComparisonStrategy_iterableContains_Test.java000066400000000000000000000045711243020563200402770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.List; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#iterableContains(java.util.Collection, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_iterableContains_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_return_true_if_collections_contains_value_according_to_given_comparator() { List hobbits = newArrayList("Merry", "Frodo", null, "Merry", "Sam"); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "Sam")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "sAm")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "sam")); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, null)); } @Test public void should_return_false_if_collections_does_not_contain_value_according_to_given_comparator() { List hobbits = newArrayList("Merry", "Frodo", "Merry", null, "Sam"); assertFalse(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "Pippin")); assertFalse(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM ")); assertFalse(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "Sam ")); } @Test public void should_return_false_if_collections_is_empty_whatever_given_comparator_is() { assertFalse(caseInsensitiveComparisonStrategy.iterableContains(newArrayList(), "anyone")); } } ComparatorBasedComparisonStrategy_iterableRemove_Test.java000066400000000000000000000046711243020563200377570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.List; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#iterableRemoves(Iterable, Object)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_iterableRemove_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_remove_value_from_collections_since_it_matches_one_collections_element_according_to_given_comparator() { List hobbits = newArrayList("Merry", "Frodo", null, "Merry", "Sam"); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM")); caseInsensitiveComparisonStrategy.iterableRemoves(hobbits, "Sam"); assertFalse(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM")); caseInsensitiveComparisonStrategy.iterableRemoves(hobbits, null); assertFalse(caseInsensitiveComparisonStrategy.iterableContains(hobbits, null)); } @Test public void should_not_remove_value_from_collections_since_it_does_not_match_any_collections_elements_according_to_given_comparator() { List hobbits = newArrayList("Merry", "Frodo", null, "Merry", "Sam"); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM")); caseInsensitiveComparisonStrategy.iterableRemoves(hobbits, "SAM "); assertTrue(caseInsensitiveComparisonStrategy.iterableContains(hobbits, "SAM")); } @Test public void should_not_fail_if_collections_is_empty_or_null() { List hobbits = newArrayList(); caseInsensitiveComparisonStrategy.iterableRemoves(hobbits, "SAM"); caseInsensitiveComparisonStrategy.iterableRemoves(null, "SAM "); } } ComparatorBasedComparisonStrategy_stringContains_Test.java000066400000000000000000000033531243020563200400130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_stringContains_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { assertTrue(caseInsensitiveComparisonStrategy.stringContains("Frodo", "ro")); assertTrue(caseInsensitiveComparisonStrategy.stringContains("Frodo", "RO")); assertTrue(caseInsensitiveComparisonStrategy.stringContains("Frodo", "")); assertFalse(caseInsensitiveComparisonStrategy.stringContains("Frodo", "Fra")); assertFalse(caseInsensitiveComparisonStrategy.stringContains("Frodo", "Frodoo")); assertFalse(caseInsensitiveComparisonStrategy.stringContains("Frodo", "Froda")); assertFalse(caseInsensitiveComparisonStrategy.stringContains("Frodo", "abcdefg")); assertFalse(caseInsensitiveComparisonStrategy.stringContains("Frodo", "a")); } } ComparatorBasedComparisonStrategy_stringEndsWith_Test.java000066400000000000000000000026371243020563200377660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_stringEndsWith_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { assertTrue(caseInsensitiveComparisonStrategy.stringEndsWith("Frodo", "do")); assertTrue(caseInsensitiveComparisonStrategy.stringEndsWith("Frodo", "DO")); assertFalse(caseInsensitiveComparisonStrategy.stringEndsWith("Frodo", "d")); assertFalse(caseInsensitiveComparisonStrategy.stringEndsWith("Frodo", "Mr Frodo")); } } ComparatorBasedComparisonStrategy_stringStartsWith_Test.java000066400000000000000000000026501243020563200403500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_stringStartsWith_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void should_pass() { assertTrue(caseInsensitiveComparisonStrategy.stringStartsWith("Frodo", "Fro")); assertTrue(caseInsensitiveComparisonStrategy.stringStartsWith("Frodo", "FRO")); assertFalse(caseInsensitiveComparisonStrategy.stringStartsWith("rodo", "Fro")); assertFalse(caseInsensitiveComparisonStrategy.stringStartsWith("rodo", "rodoo")); } } ComparatorBasedComparisonStrategy_toString_Test.java000066400000000000000000000031511243020563200366130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.assertEquals; import java.util.Comparator; import org.fest.assertions.internal.ComparatorBasedComparisonStrategy; import org.junit.Test; /** * Tests for {@link ComparatorBasedComparisonStrategy#toString()}. * * @author Joel Costigliola */ public class ComparatorBasedComparisonStrategy_toString_Test extends AbstractTest_ComparatorBasedComparisonStrategy { @Test public void toString_with_anonymous_comparator() { ComparatorBasedComparisonStrategy lengthComparisonStrategy = new ComparatorBasedComparisonStrategy(new Comparator() { public int compare(String s1, String s2) { return s1.length() - s2.length(); } }); assertEquals("'anonymous comparator class'", lengthComparisonStrategy.toString()); } @Test public void toString_with_non_anonymous_comparator() { assertEquals("'CaseInsensitiveStringComparator'", caseInsensitiveComparisonStrategy.toString()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ConditionsBaseTest.java000066400000000000000000000015511243020563200307240ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.fest.assertions.core.TestCondition; import org.fest.assertions.test.ExpectedException; public class ConditionsBaseTest { protected static Object actual; @Rule public ExpectedException thrown = none(); @BeforeClass public static void setUpOnce() { actual = "Yoda"; } protected Failures failures; protected TestCondition condition; protected Conditions conditions; public ConditionsBaseTest() { super(); } @Before public void setUp() { failures = spy(new Failures()); condition = new TestCondition(); conditions = new Conditions(); conditions.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/DatesBaseTest.java000066400000000000000000000042671243020563200276620ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import java.util.Date; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.YearAndMonthComparator; /** * Base class for {@link Dates} unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link Dates#failures} appropriately. * * @author Joel Costigliola */ public abstract class DatesBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Dates dates; protected ComparatorBasedComparisonStrategy yearAndMonthComparisonStrategy; protected Dates datesWithCustomComparisonStrategy; protected Date actual; private YearAndMonthComparator yearAndMonthComparator = new YearAndMonthComparator(); @Before public void setUp() { failures = spy(new Failures()); dates = new Dates(); dates.failures = failures; yearAndMonthComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); datesWithCustomComparisonStrategy = new Dates(yearAndMonthComparisonStrategy); datesWithCustomComparisonStrategy.failures = failures; initActualDate(); } protected void initActualDate() { actual = parseDate("2011-01-01"); } /** * Simply delegate to {@link org.fest.util.Dates#parse(String)} * @param dateAsString see {@link org.fest.util.Dates#parse(String)} * @return see {@link org.fest.util.Dates#parse(String)} */ protected static Date parseDate(String dateAsString) { return org.fest.util.Dates.parse(dateAsString); } /** * Simply delegate to {@link org.fest.util.Dates#parseDatetime(String)} * @param dateAsString see {@link org.fest.util.Dates#parseDatetime(String)} * @return see {@link org.fest.util.Dates#parseDatetime(String)} */ protected static Date parseDatetime(String dateAsString) { return org.fest.util.Dates.parseDatetime(dateAsString); } protected Comparator comparatorForCustomComparisonStrategy() { return yearAndMonthComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/DoubleArraysBaseTest.java000066400000000000000000000047101243020563200312070ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.DoubleArrays.arrayOf; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link DoubleArrays}, set up an instance with {@link StandardComparisonStrategy} and * another with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link DoubleArrays#failures} appropriately. * * @author Joel Costigliola */ public class DoubleArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6.0, 8.0, 10.0} */ protected double[] actual; protected Failures failures; protected DoubleArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected DoubleArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new DoubleArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new DoubleArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6.0, 8.0, 10.0); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/DoublesBaseTest.java000066400000000000000000000023331243020563200302070ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for tests involving {@link Doubles} *

* Is in org.fest.assertions.internal package to be able to set {@link Doubles#failures} appropriately. * * @author Joel Costigliola */ public class DoublesBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Doubles doubles; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Doubles doublesWithAbsValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); doubles = new Doubles(); doubles.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); doublesWithAbsValueComparisonStrategy = new Doubles(absValueComparisonStrategy); doublesWithAbsValueComparisonStrategy.failures = failures; } protected Double NaN() { return doubles.NaN(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/Employee.java000066400000000000000000000026051243020563200267400ustar00rootroot00000000000000/* * Created on Jun 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal; /** * @author Joel Costigliola */ public class Employee implements Comparable { // field public getter => valid property private final int age; public int getAge() { return age; } // fields without public getter => not a property private final String company = "google"; String getCompany() { return company; } private boolean firstJob; boolean isFirstJob() { return firstJob; } // field without getter => not a property @SuppressWarnings("unused") private final double salary; public Employee(double salary, int age) { super(); this.salary = salary; this.age = age; } @Override public int compareTo(Employee other) { return age - other.age; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/FilesBaseTest.java000066400000000000000000000020021243020563200276450ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import java.io.File; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * Base class for testing {@link Files}, set up diff and failures attributes (which is why it is in * org.fest.assertions.internal package. * * @author Joel Costigliola */ public class FilesBaseTest { @Rule public ExpectedException thrown = none(); protected File actual; protected Failures failures; protected Files files; protected Diff diff; protected BinaryDiff binaryDiff; @Before public void setUp() { actual = mock(File.class); failures = spy(new Failures()); files = new Files(); files.failures = failures; diff = mock(Diff.class); files.diff = diff; binaryDiff = mock(BinaryDiff.class); files.binaryDiff = binaryDiff; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/FloatArraysBaseTest.java000066400000000000000000000047031243020563200310440ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.FloatArrays.arrayOf; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link FloatArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link FloatArrays#failures} appropriately. * * @author Joel Costigliola */ public class FloatArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6.0f, 8.0f, 10.0f} */ protected float[] actual; protected Failures failures; protected FloatArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected FloatArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new FloatArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new FloatArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6.0f, 8.0f, 10.0f); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/FloatsBaseTest.java000066400000000000000000000026321243020563200300440ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link Floats}, set up an instance with {@link StandardComparisonStrategy} and another with * {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Floats#failures} appropriately and to use * {@link Floats#NaN()}. * * @author Joel Costigliola */ public class FloatsBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Floats floats; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Floats floatsWithAbsValueComparisonStrategy; public FloatsBaseTest() { super(); } @Before public void setUp() { failures = spy(new Failures()); floats = new Floats(); floats.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); floatsWithAbsValueComparisonStrategy = new Floats(absValueComparisonStrategy); floatsWithAbsValueComparisonStrategy.failures = failures; } protected Float NaN() { return floats.NaN(); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/InputStreamsBaseTest.java000066400000000000000000000023321243020563200312470ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * Base class for {@link InputStreams} unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link InputStreams} attributes appropriately. * * @author Joel Costigliola * */ public class InputStreamsBaseTest { @Rule public ExpectedException thrown = none(); protected Diff diff; protected Failures failures; protected InputStreams inputStreams; protected static InputStream actual; protected static InputStream expected; @BeforeClass public static void setUpOnce() { actual = new ByteArrayInputStream(new byte[0]); expected = new ByteArrayInputStream(new byte[0]); } @Before public void setUp() { diff = mock(Diff.class); failures = spy(new Failures()); inputStreams = new InputStreams(); inputStreams.diff = diff; inputStreams.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/IntArraysBaseTest.java000066400000000000000000000046431243020563200305340ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.IntArrays.arrayOf; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link IntArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link IntArrays#failures} appropriately. * * @author Joel Costigliola */ public class IntArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6, 8, 10} */ protected int[] actual; protected Failures failures; protected IntArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected IntArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new IntArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new IntArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6, 8, 10); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/IntegersBaseTest.java000066400000000000000000000024621243020563200303750ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link Integers}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Integers#failures} appropriately. * * @author Joel Costigliola * */ public class IntegersBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Integers integers; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Integers integersWithAbsValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); integers = new Integers(); integers.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); integersWithAbsValueComparisonStrategy = new Integers(absValueComparisonStrategy); integersWithAbsValueComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/IterablesBaseTest.java000066400000000000000000000027521243020563200305310ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.spy; import java.util.List; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Base class for testing {@link Iterables}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Iterables#failures} appropriately. * * @author Joel Costigliola * */ public class IterablesBaseTest { @Rule public ExpectedException thrown = none(); protected List actual; protected Failures failures; protected Iterables iterables; protected ComparatorBasedComparisonStrategy comparisonStrategy; protected Iterables iterablesWithCaseInsensitiveComparisonStrategy; @Before public void setUp() { actual = newArrayList("Luke", "Yoda", "Leia"); failures = spy(new Failures()); iterables = new Iterables(); iterables.failures = failures; comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); iterablesWithCaseInsensitiveComparisonStrategy = new Iterables(comparisonStrategy); iterablesWithCaseInsensitiveComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/IterablesWithConditionsBaseTest.java000066400000000000000000000020501243020563200334060ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.mockito.Mockito.spy; import org.junit.Before; import org.fest.assertions.condition.JediCondition; import org.fest.assertions.condition.JediPowerCondition; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Base class for testing {@link Iterables} with {@link Conditions}. *

* Is in org.fest.assertions.internal package to be able to set {@link Iterables#conditions} appropriately. * * @author Joel Costigliola */ public class IterablesWithConditionsBaseTest extends IterablesBaseTest { protected Condition jediPower; protected Condition jedi; protected TestCondition testCondition; protected Conditions conditions; @Override @Before public void setUp() { super.setUp(); testCondition = new TestCondition(); conditions = spy(new Conditions()); jedi = new JediCondition(); jediPower = new JediPowerCondition(); iterables.conditions = conditions; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ListsBaseTest.java000066400000000000000000000024321243020563200277100ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Base class for testing {@link Lists}, set up an instance with {@link StandardComparisonStrategy} and another with * {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Lists#failures} appropriately. * * @author Joel Costigliola * */ public class ListsBaseTest { @Rule public ExpectedException thrown = none(); protected ComparatorBasedComparisonStrategy comparisonStrategy; protected Lists listsWithCaseInsensitiveComparisonStrategy; protected Failures failures; protected Lists lists; @Before public void setUp() { failures = spy(new Failures()); lists = new Lists(); lists.failures = failures; comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); listsWithCaseInsensitiveComparisonStrategy = new Lists(comparisonStrategy); listsWithCaseInsensitiveComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/LongArraysBaseTest.java000066400000000000000000000050071243020563200306740ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.LongArrays.arrayOf; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.internal.Failures; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link LongArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link LongArrays#failures} appropriately. * * @author Joel Costigliola */ public class LongArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6, 8, 10} */ protected long[] actual; protected Failures failures; protected LongArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected LongArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new LongArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new LongArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6L, 8L, 10L); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/LongsBaseTest.java000066400000000000000000000024101243020563200276700ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link Longs}, set up an instance with {@link StandardComparisonStrategy} and another with * {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Longs#failures} appropriately. * * @author Joel Costigliola * */ public class LongsBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Longs longs; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Longs longsWithAbsValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); longs = new Longs(); longs.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); longsWithAbsValueComparisonStrategy = new Longs(absValueComparisonStrategy); longsWithAbsValueComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/MapsBaseTest.java000066400000000000000000000017621243020563200275170ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.Maps.mapOf; import static org.mockito.Mockito.spy; import java.util.Map; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * Base class for {@link Maps} unit tests *

* Is in org.fest.assertions.internal package to be able to set {@link Maps} attributes appropriately. * * @author Joel Costigliola * */ public class MapsBaseTest { @Rule public ExpectedException thrown = none(); protected Map actual; protected Failures failures; protected Maps maps; @SuppressWarnings("unchecked") @Before public void setUp() { actual = (Map) mapOf(entry("name", "Yoda"), entry("color", "green")); failures = spy(new Failures()); maps = new Maps(); maps.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ObjectArraysBaseTest.java000066400000000000000000000051701243020563200312040ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Base class for testing {@link ObjectArrays}, set up an instance with {@link StandardComparisonStrategy} and * another with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link ObjectArrays#failures} appropriately. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} */ protected String[] actual; protected Failures failures; protected ObjectArrays arrays; protected Conditions conditions; protected ComparatorBasedComparisonStrategy caseInsensitiveStringComparisonStrategy; protected ObjectArrays arraysWithCustomComparisonStrategy; private CaseInsensitiveStringComparator caseInsensitiveStringComparator = new CaseInsensitiveStringComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new ObjectArrays(); arrays.failures = failures; caseInsensitiveStringComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new ObjectArrays(caseInsensitiveStringComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; conditions = spy(new Conditions()); arrays.conditions = conditions; initActualArray(); } protected void initActualArray() { actual = array("Luke", "Yoda", "Leia"); } protected Comparator comparatorForCustomComparisonStrategy() { return caseInsensitiveStringComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ObjectArraysWithConditionBaseTest.java000066400000000000000000000032621243020563200337070ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.mockito.Mockito.spy; import org.junit.Before; import org.fest.assertions.condition.JediCondition; import org.fest.assertions.condition.JediPowerCondition; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; /** * Base class for testing {@link ObjectArrays} with {@link Conditions}. *

* Is in org.fest.assertions.internal package to be able to set {@link ObjectArrays#conditions} appropriately. * * @author Joel Costigliola */ public class ObjectArraysWithConditionBaseTest extends ObjectArraysBaseTest { protected Conditions conditions; protected Condition jediPower; protected TestCondition testCondition; protected Condition jedi; @Override @Before public void setUp() { super.setUp(); conditions = spy(new Conditions()); arrays.conditions = conditions; jediPower = new JediPowerCondition(); jedi = new JediCondition(); testCondition = new TestCondition(); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ObjectsBaseTest.java000066400000000000000000000041601243020563200302030ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * Base class for testing {@link Objects}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. *

* Is in org.fest.assertions.internal package to be able to set {@link Objects#failures} appropriately. * * @author Joel Costigliola */ public class ObjectsBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Objects objects; protected ComparatorBasedComparisonStrategy customComparisonStrategy; protected Objects objectsWithCustomComparisonStrategy; public ObjectsBaseTest() { super(); } @Before public void setUp() { failures = spy(new Failures()); objects = new Objects(); objects.failures = failures; customComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); objectsWithCustomComparisonStrategy = new Objects(customComparisonStrategy); objectsWithCustomComparisonStrategy.failures = failures; } protected Comparator comparatorForCustomComparisonStrategy() { return new CaseInsensitiveStringComparator(); } }PropertySupport_propertyValues_Test.java000066400000000000000000000073011243020563200344440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.util.Lists.newArrayList; import java.util.Collection; import java.util.List; import org.fest.assertions.test.ExpectedException; import org.fest.test.Employee; import org.fest.test.Name; import org.fest.util.IntrospectionError; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; /** * Tests for {@link PropertySupport#propertyValues(String, Collection)}. * * @author Yvonne Wang * @author Nicolas François * @author Mikhail Mazursky * @author Florent Biville */ public class PropertySupport_propertyValues_Test { private static Employee yoda; private static Employee luke; private static Iterable employees; private static PropertySupport propertySupport; @BeforeClass public static void setUpOnce() { yoda = new Employee(6000L, new Name("Yoda"), 800); luke = new Employee(8000L, new Name("Luke", "Skywalker"), 26); employees = newArrayList(yoda, luke); propertySupport = new PropertySupport(); } @Rule public ExpectedException thrown = none(); @Test public void should_return_empty_List_if_given_Iterable_is_null() { Iterable ids = propertySupport.propertyValues("ids", Long.class, null); assertEquals(emptyList(), ids); } @Test public void should_return_empty_List_if_given_Iterable_is_empty() { Iterable ids = propertySupport.propertyValues("ids", Long.class, emptySet()); assertEquals(emptyList(), ids); } @Test public void should_return_empty_List_if_given_Iterable_contains_only_nulls() { Iterable ids = propertySupport.propertyValues("ids", Long.class, newArrayList(null, null)); assertEquals(emptyList(), ids); } @Test public void should_remove_null_values_from_given_Iterable() { List anotherList = newArrayList(yoda, null, luke, null); Iterable ids = propertySupport.propertyValues("id", Long.class, anotherList); assertEquals(newArrayList(6000L, 8000L), ids); } @Test public void should_return_values_of_simple_property() { Iterable ids = propertySupport.propertyValues("id", Long.class, employees); assertEquals(newArrayList(6000L, 8000L), ids); } @Test public void should_return_values_of_nested_property() { Iterable firstNames = propertySupport.propertyValues("name.first", String.class, employees); assertEquals(newArrayList("Yoda", "Luke"), firstNames); } @Test public void should_throw_error_if_property_not_found() { thrown.expect(IntrospectionError.class); propertySupport.propertyValues("id.", Long.class, employees); } @Test public void should_extract_property() { Long id = propertySupport.propertyValue("id", Long.class, yoda); assertEquals(Long.valueOf(6000L), id); } } PropertySupport_propertyValues_with_mocks_Test.java000066400000000000000000000050271243020563200366760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Feb 22, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal; import static junit.framework.Assert.*; import static org.fest.util.Introspection.getProperty; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; import java.beans.PropertyDescriptor; import java.util.*; import org.fest.test.*; import org.fest.test.Employee; import org.fest.util.IntrospectionError; import org.junit.*; /** * Tests for {@link PropertySupport#propertyValues(String, Collection)}. * * @author Yvonne Wang * @author Mikhail Mazursky */ public class PropertySupport_propertyValues_with_mocks_Test { private static Employee yoda; private static List employees; @BeforeClass public static void setUpOnce() { yoda = new Employee(6000L, new Name("Yoda"), 800); employees = newArrayList(yoda); } private JavaBeanDescriptor descriptor; private PropertySupport propertySupport; @Before public void setUp() { descriptor = mock(JavaBeanDescriptor.class); propertySupport = new PropertySupport(); propertySupport.javaBeanDescriptor = descriptor; } @Test public void should_throw_error_if_PropertyDescriptor_cannot_invoke_read_method() throws Exception { RuntimeException thrownOnPurpose = new RuntimeException("Thrown on purpose"); PropertyDescriptor real = getProperty("id", yoda); when(descriptor.invokeReadMethod(real, yoda)).thenThrow(thrownOnPurpose); try { propertySupport.propertyValues("id", Long.class, employees); fail("expecting an IntrospectionError to be thrown"); } catch (IntrospectionError expected) { assertSame(thrownOnPurpose, expected.getCause()); String msg = String.format("Unable to obtain the value of the property <'id'> from <%s>", yoda.toString()); assertEquals(msg, expected.getMessage()); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ShortArraysBaseTest.java000066400000000000000000000046631243020563200311030ustar00rootroot00000000000000/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.mockito.Mockito.spy; import java.util.Comparator; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * Base class for testing {@link ShortArrays}, set up an instance with {@link StandardComparisonStrategy} and another * with {@link ComparatorBasedComparisonStrategy}. * *

* Is in org.fest.assertions.internal package to be able to set {@link ShortArrays#failures} appropriately. * * @author Joel Costigliola */ public class ShortArraysBaseTest { @Rule public ExpectedException thrown = none(); /** * is initialized with {@link #initActualArray()} with default value = {6, 8, 10} */ protected short[] actual; protected Failures failures; protected ShortArrays arrays; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected ShortArrays arraysWithCustomComparisonStrategy; private AbsValueComparator absValueComparator = new AbsValueComparator(); @Before public void setUp() { failures = spy(new Failures()); arrays = new ShortArrays(); arrays.failures = failures; absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(comparatorForCustomComparisonStrategy()); arraysWithCustomComparisonStrategy = new ShortArrays(absValueComparisonStrategy); arraysWithCustomComparisonStrategy.failures = failures; initActualArray(); } protected void initActualArray() { actual = arrayOf(6, 8, 10); } protected Comparator comparatorForCustomComparisonStrategy() { return absValueComparator; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ShortsBaseTest.java000066400000000000000000000023531243020563200300760ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.internal.Failures; import org.fest.assertions.internal.Shorts; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.AbsValueComparator; /** * * Base class for {@link Shorts} tests. *

* Is in org.fest.assertions.internal package to be able to set {@link Shorts#failures} appropriately. * * @author Joel Costigliola * */ public class ShortsBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Shorts shorts; protected ComparatorBasedComparisonStrategy absValueComparisonStrategy; protected Shorts shortsWithAbsValueComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); shorts = new Shorts(); shorts.setFailures(failures); absValueComparisonStrategy = new ComparatorBasedComparisonStrategy(new AbsValueComparator()); shortsWithAbsValueComparisonStrategy = new Shorts(absValueComparisonStrategy); shortsWithAbsValueComparisonStrategy.failures = failures; } }StandardComparisonStrategy_areEqual_Test.java000066400000000000000000000061071243020563200352370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.StandardComparisonStrategy; import org.fest.util.Objects; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#areEqual(Object, Object)}.
* Conceptually the same as {@link Objects#areEqual(Object, Object)} but I don't know how to verify/test that * {@link StandardComparisonStrategy#areEqual(Object, Object)} simply calls {@link Objects#areEqual(Object, Object)} * * @author Joel Costigliola */ public class StandardComparisonStrategy_areEqual_Test { private static StandardComparisonStrategy standardComparisonStrategy = StandardComparisonStrategy.instance(); @Test public void should_return_true_if_both_Objects_are_null_with_verify() { assertTrue(standardComparisonStrategy.areEqual(null, null)); } @Test public void should_return_true_if_both_Objects_are_null() { assertTrue(standardComparisonStrategy.areEqual(null, null)); } @Test public void should_return_true_if_Objects_are_equal() { assertTrue(standardComparisonStrategy.areEqual("Yoda", "Yoda")); } @Test public void should_return_are_not_equal_if_first_Object_is_null_and_second_is_not() { assertFalse(standardComparisonStrategy.areEqual(null, "Yoda")); } @Test public void should_return_are_not_equal_if_second_Object_is_null_and_first_is_not() { assertFalse(standardComparisonStrategy.areEqual("Yoda", null)); } @Test public void should_return_are_not_equal_if_Objects_are_not_equal() { assertFalse(standardComparisonStrategy.areEqual("Yoda", 2)); } @Test public void should_return_true_if_arrays_of_Objects_are_equal() { Object[] a1 = { "Luke", "Yoda", "Leia" }; Object[] a2 = { "Luke", "Yoda", "Leia" }; assertTrue(standardComparisonStrategy.areEqual(a1, a2)); } @Test public void should_return_true_if_arrays_of_primitives_are_equal() { int[] a1 = { 6, 8, 10 }; int[] a2 = { 6, 8, 10 }; assertTrue(standardComparisonStrategy.areEqual(a1, a2)); } @Test public void should_return_false_if_arrays_of_Objects_are_not_equal() { Object[] a1 = { "Luke", "Yoda", "Leia" }; Object[] a2 = new Object[0]; assertFalse(standardComparisonStrategy.areEqual(a1, a2)); } @Test public void should_return_false_if_arrays_of_primitives_are_not_equal() { int[] a1 = { 6, 8, 10 }; boolean[] a2 = { true }; assertFalse(standardComparisonStrategy.areEqual(a1, a2)); } } StandardComparisonStrategy_arrayContains_Test.java000066400000000000000000000042001243020563200363050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Arrays.array; import static org.junit.Assert.*; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#arrayContains(Object, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_arrayContains_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_return_true_if_array_contains_value() { String[] hobbits = array("Merry", "Frodo", null, "Merry", "Sam"); assertTrue(standardComparisonStrategy.arrayContains(hobbits, "Sam")); assertTrue(standardComparisonStrategy.arrayContains(hobbits, "Merry")); assertTrue(standardComparisonStrategy.arrayContains(hobbits, null)); } @Test public void should_return_false_if_array_does_not_contain_value() { String[] hobbits = array("Merry", "Frodo", "Merry", "Sam"); assertFalse(standardComparisonStrategy.arrayContains(hobbits, "Pippin")); assertFalse(standardComparisonStrategy.arrayContains(hobbits, "SAM ")); assertFalse(standardComparisonStrategy.arrayContains(hobbits, null)); } @Test public void should_return_false_if_array_is_empty() { assertFalse(standardComparisonStrategy.arrayContains(new String[] {}, "Pippin")); } @Test public void should_fail_if_first_parameter_is_not_an_array() { thrown.expect(IllegalArgumentException.class); standardComparisonStrategy.arrayContains("not an array", "Pippin"); } } StandardComparisonStrategy_duplicatesFrom_Test.java000066400000000000000000000045431243020563200364630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Iterables.isNullOrEmpty; import static org.fest.util.Iterables.sizeOf; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.ArrayList; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#standardComparisonStrategy.duplicatesFrom(java.util.Collection)}.
* * @author Joel Costigliola */ public class StandardComparisonStrategy_duplicatesFrom_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_return_existing_duplicates() { Iterable duplicates = standardComparisonStrategy .duplicatesFrom(newArrayList("Merry", "Frodo", null, null, "Merry", "Sam", "Frodo")); assertEquals(3, sizeOf(duplicates)); assertTrue(standardComparisonStrategy.iterableContains(duplicates, "Frodo")); assertTrue(standardComparisonStrategy.iterableContains(duplicates, "Merry")); assertTrue(standardComparisonStrategy.iterableContains(duplicates, null)); } @Test public void should_not_return_any_duplicates() { Iterable duplicates = standardComparisonStrategy.duplicatesFrom(newArrayList("Frodo", "Sam", "Gandalf")); assertTrue(isNullOrEmpty(duplicates)); } @Test public void should_not_return_any_duplicates_if_collection_is_empty() { Iterable duplicates = standardComparisonStrategy.duplicatesFrom(new ArrayList()); assertTrue(isNullOrEmpty(duplicates)); } @Test public void should_not_return_any_duplicates_if_collection_is_null() { Iterable duplicates = standardComparisonStrategy.duplicatesFrom(null); assertTrue(isNullOrEmpty(duplicates)); } } StandardComparisonStrategy_isGreaterThanOrEqualTo_Test.java000066400000000000000000000032011243020563200400240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#isGreaterThanOrEqualTo(Object, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_isGreaterThanOrEqualTo_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { Employee boss = new Employee(10000, 35); Employee young = new Employee(10000, 25); assertTrue(standardComparisonStrategy.isGreaterThanOrEqualTo(boss, young)); assertTrue(standardComparisonStrategy.isGreaterThanOrEqualTo(boss, boss)); assertFalse(standardComparisonStrategy.isGreaterThanOrEqualTo(young, boss)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(IllegalArgumentException.class); Rectangle r1 = new Rectangle(10, 20); Rectangle r2 = new Rectangle(20, 10); standardComparisonStrategy.isGreaterThanOrEqualTo(r1, r2); } } StandardComparisonStrategy_isGreaterThan_Test.java000066400000000000000000000034731243020563200362430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.awt.Rectangle; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#isGreaterThan(Object, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_isGreaterThan_Test extends AbstractTest_StandardComparisonStrategy { @Test public void verify_that_isGreaterThan_delegates_to_compare_method() { Employee boss = mock(Employee.class); Employee young = new Employee(10000, 25); standardComparisonStrategy.isGreaterThan(boss, young); verify(boss).compareTo(young); } @Test public void should_pass() { Employee boss = new Employee(10000, 35); Employee young = new Employee(10000, 25); assertTrue(standardComparisonStrategy.isGreaterThan(boss, young)); assertFalse(standardComparisonStrategy.isGreaterThan(young, boss)); assertFalse(standardComparisonStrategy.isGreaterThan(boss, boss)); } @Test public void should_fail_if_first_parameter_is_not_comparable() { thrown.expect(IllegalArgumentException.class); standardComparisonStrategy.isGreaterThan(new Rectangle(), "foo"); } } StandardComparisonStrategy_isLessThanOrEqualTo_Test.java000066400000000000000000000031571243020563200373530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#isLessThanOrEqualTo(Object, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_isLessThanOrEqualTo_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { Employee boss = new Employee(10000, 35); Employee young = new Employee(10000, 25); assertTrue(standardComparisonStrategy.isLessThanOrEqualTo(young, boss)); assertFalse(standardComparisonStrategy.isLessThanOrEqualTo(boss, young)); assertTrue(standardComparisonStrategy.isLessThanOrEqualTo(boss, boss)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(IllegalArgumentException.class); Rectangle r1 = new Rectangle(10, 20); Rectangle r2 = new Rectangle(20, 10); standardComparisonStrategy.isLessThanOrEqualTo(r1, r2); } } StandardComparisonStrategy_isLessThan_Test.java000066400000000000000000000030721243020563200355530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import java.awt.Rectangle; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#isLessThan(Object, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_isLessThan_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { Employee boss = new Employee(10000, 35); Employee young = new Employee(10000, 25); assertTrue(standardComparisonStrategy.isLessThan(young, boss)); assertFalse(standardComparisonStrategy.isLessThan(boss, young)); assertFalse(standardComparisonStrategy.isLessThan(boss, boss)); } @Test public void should_fail_if_a_parameter_is_not_comparable() { thrown.expect(IllegalArgumentException.class); Rectangle r1 = new Rectangle(10, 20); Rectangle r2 = new Rectangle(20, 10); standardComparisonStrategy.isLessThan(r1, r2); } } StandardComparisonStrategy_iterableContains_Test.java000066400000000000000000000031131243020563200367600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.List; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#iterableContains(java.util.Collection, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_iterableContains_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { List list = newArrayList("Sam", "Merry", null, "Frodo"); assertTrue(standardComparisonStrategy.iterableContains(list, "Frodo")); assertTrue(standardComparisonStrategy.iterableContains(list, null)); assertFalse(standardComparisonStrategy.iterableContains(list, "Sauron")); } @Test public void should_return_false_if_iterable_is_null() { assertFalse(standardComparisonStrategy.iterableContains(null, "Sauron")); } } StandardComparisonStrategy_iterableRemove_Test.java000066400000000000000000000030731243020563200364440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.*; import java.util.List; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#iterableRemoves(Iterable, Object)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_iterableRemove_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { List list = newArrayList("Sam", "Merry", null, "Frodo"); assertTrue(list.contains("Frodo")); standardComparisonStrategy.iterableRemoves(list, "Frodo"); assertFalse(list.contains("Frodo")); standardComparisonStrategy.iterableRemoves(list, null); assertFalse(list.contains(null)); } @Test public void should_do_nothing_if_iterable_is_null() { standardComparisonStrategy.iterableRemoves(null, "Sauron"); } } StandardComparisonStrategy_stringContains_Test.java000066400000000000000000000023141243020563200365010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_stringContains_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { assertTrue(standardComparisonStrategy.stringContains("Frodo", "ro")); assertFalse(standardComparisonStrategy.stringContains("rodo", "Fr")); } } StandardComparisonStrategy_stringEndsWith_Test.java000066400000000000000000000023141243020563200364500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_stringEndsWith_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { assertTrue(standardComparisonStrategy.stringEndsWith("Frodo", "do")); assertFalse(standardComparisonStrategy.stringEndsWith("Frodo", "d")); } } StandardComparisonStrategy_stringStartsWith_Test.java000066400000000000000000000023241243020563200370400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/* * Created on Sep 23, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2011 the original author or authors. */ package org.fest.assertions.internal; import static org.junit.Assert.*; import org.fest.assertions.internal.StandardComparisonStrategy; import org.junit.Test; /** * Tests for {@link StandardComparisonStrategy#stringContains(String, String)}. * * @author Joel Costigliola */ public class StandardComparisonStrategy_stringStartsWith_Test extends AbstractTest_StandardComparisonStrategy { @Test public void should_pass() { assertTrue(standardComparisonStrategy.stringStartsWith("Frodo", "Fro")); assertFalse(standardComparisonStrategy.stringStartsWith("rodo", "Fro")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/StringsBaseTest.java000066400000000000000000000022571243020563200302500ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; import org.fest.assertions.util.CaseInsensitiveStringComparator; /** * * Base class for {@link Strings} tests. *

* Is in org.fest.assertions.internal package to be able to set {@link Strings#failures} appropriately. * * @author Joel Costigliola * */ public class StringsBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Strings strings; protected ComparatorBasedComparisonStrategy comparisonStrategy; protected Strings stringsWithCaseInsensitiveComparisonStrategy; @Before public void setUp() { failures = spy(new Failures()); strings = new Strings(); strings.failures = failures; comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance); stringsWithCaseInsensitiveComparisonStrategy = new Strings(comparisonStrategy); stringsWithCaseInsensitiveComparisonStrategy.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/TestDescription.java000066400000000000000000000017761243020563200303140ustar00rootroot00000000000000/* * Created on Aug 7, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal; import org.fest.assertions.description.Description; /** * A description to be used for testing. * * @author Alex Ruiz */ public class TestDescription extends Description { private final String value; public TestDescription(String value) { this.value = value; } @Override public String value() { return value; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/ThrowablesBaseTest.java000066400000000000000000000016571243020563200307340ustar00rootroot00000000000000package org.fest.assertions.internal; import static org.fest.assertions.test.ExpectedException.none; import static org.mockito.Mockito.spy; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.fest.assertions.test.ExpectedException; /** * * Base class for {@link Throwables} tests. *

* Is in org.fest.assertions.internal package to be able to set {@link Throwables#failures} appropriately. * * @author Joel Costigliola */ public class ThrowablesBaseTest { @Rule public ExpectedException thrown = none(); protected Failures failures; protected Throwables throwables; protected static Throwable actual; @BeforeClass public static void setUpOnce() { actual = new NullPointerException("Throwable message"); } @Before public void setUp() { failures = spy(new Failures()); throwables = new Throwables(); throwables.failures = failures; } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/000077500000000000000000000000001243020563200265565ustar00rootroot00000000000000BigDecimals_assertEqualByComparison_Test.java000066400000000000000000000061331243020563200374060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertEqualByComparison(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertEqualByComparison_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertEqualByComparison(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_equal_by_comparison() { bigDecimals.assertEqualByComparison(someInfo(), new BigDecimal("5.0"), new BigDecimal("5.00")); } @Test public void should_fail_if_big_decimals_are_not_equal_by_comparison() { AssertionInfo info = someInfo(); try { bigDecimals.assertEqualByComparison(info, TEN, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(TEN, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bigDecimalsWithAbsValueComparisonStrategy.assertEqualByComparison(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_equal_by_comparison_whatever_custom_comparison_strategy_is() { bigDecimalsWithAbsValueComparisonStrategy.assertEqualByComparison(someInfo(), new BigDecimal("5.0"), new BigDecimal("5")); } @Test public void should_fail_if_big_decimals_are_not_equal_by_comparison_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertEqualByComparison(info, TEN, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(TEN, ONE, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertEqual_Test.java000066400000000000000000000060101243020563200350520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertEqual(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertEqual_Test extends BigDecimalsBaseTest { private static final BigDecimal ONE_WITH_3_DECIMALS = new BigDecimal("1.000"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertEqual(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_equal() { bigDecimals.assertEqual(someInfo(), ONE, ONE); } @Test public void should_fail_if_big_decimals_are_not_equal() { AssertionInfo info = someInfo(); try { bigDecimals.assertEqual(info, ONE_WITH_3_DECIMALS, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(ONE_WITH_3_DECIMALS, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bigDecimalsWithComparatorComparisonStrategy.assertEqual(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_equal_according_to_custom_comparison_strategy() { bigDecimalsWithComparatorComparisonStrategy.assertEqual(someInfo(), ONE_WITH_3_DECIMALS, ONE); } @Test public void should_fail_if_big_decimals_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithComparatorComparisonStrategy.assertEqual(info, TEN, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(TEN, ONE, comparatorComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000067121243020563200400140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertGreaterThanOrEqualTo(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertGreaterThanOrEqualTo_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertGreaterThanOrEqualTo(someInfo(), null, ONE); } @Test public void should_pass_if_actual_is_greater_than_other() { bigDecimals.assertGreaterThanOrEqualTo(someInfo(), TEN, ONE); } @Test public void should_pass_if_actual_is_equal_to_other() { bigDecimals.assertGreaterThanOrEqualTo(someInfo(), ONE, ONE); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertGreaterThanOrEqualTo(info, ONE, TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(ONE, TEN)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), TEN.negate(), ONE); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), ONE.negate(), ONE); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, ONE, TEN.negate()); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(ONE, TEN.negate(), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertGreaterThan_Test.java000066400000000000000000000074561243020563200362260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertGreaterThan(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertGreaterThan_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertGreaterThan(someInfo(), null, ONE); } @Test public void should_pass_if_actual_is_greater_than_other() { bigDecimals.assertGreaterThan(someInfo(), TEN, ONE); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertGreaterThan(info, TEN, TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(TEN, TEN)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertGreaterThan(info, ONE, TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(ONE, TEN)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), TEN.negate(), ONE); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThan(info, TEN.negate(), TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(TEN.negate(), TEN, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertGreaterThan(info, ONE, TEN.negate()); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(ONE, TEN.negate(), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertIsNegative_Test.java000066400000000000000000000037441243020563200360540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsNegative(AssertionInfo, BigDecimal)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class BigDecimals_assertIsNegative_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_negative() { bigDecimals.assertIsNegative(someInfo(), new BigDecimal("-1.0")); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<1> to be less than:<0>"); bigDecimals.assertIsNegative(someInfo(), BigDecimal.ONE); } @Test public void should_succeed_since_actual_is_negative_according_to_custom_comparison_strategy() { bigDecimalsWithComparatorComparisonStrategy.assertIsNegative(someInfo(), new BigDecimal("-1.0")); } @Test public void should_fail_since_actual_is_not_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than:<0>"); bigDecimalsWithComparatorComparisonStrategy.assertIsNegative(someInfo(), BigDecimal.ONE); } } BigDecimals_assertIsNotNegative_Test.java000066400000000000000000000037361243020563200365360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsNotNegative(AssertionInfo, BigDecimal))}. * * @author Nicolas François */ public class BigDecimals_assertIsNotNegative_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { bigDecimals.assertIsNotNegative(someInfo(), new BigDecimal(6)); } @Test public void should_succeed_since_actual_is_zero() { bigDecimals.assertIsNotNegative(someInfo(), BigDecimal.ZERO); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6> to be greater than or equal to:<0>"); bigDecimals.assertIsNotNegative(someInfo(), new BigDecimal(-6)); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), new BigDecimal(-1)); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), BigDecimal.ONE); } } BigDecimals_assertIsNotPositive_Test.java000066400000000000000000000043041243020563200365660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsNotPositive(AssertionInfo, BigDecimal))}. * * @author Nicolas François */ public class BigDecimals_assertIsNotPositive_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { bigDecimals.assertIsNotPositive(someInfo(), new BigDecimal(-6)); } @Test public void should_succeed_since_actual_is_zero() { bigDecimals.assertIsNotPositive(someInfo(), BigDecimal.ZERO); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6> to be less than or equal to:<0>"); bigDecimals.assertIsNotPositive(someInfo(), new BigDecimal(6)); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); bigDecimalsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), new BigDecimal(-1)); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); bigDecimalsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), BigDecimal.ONE); } } BigDecimals_assertIsNotZero_Test.java000066400000000000000000000041241243020563200357030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsNotZero(AssertionInfo, BigDecimal)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class BigDecimals_assertIsNotZero_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_zero() { bigDecimals.assertIsNotZero(someInfo(), BigDecimal.ONE); } @Test public void should_fail_since_actual_is_not_zero() { try { bigDecimals.assertIsNotZero(someInfo(), BigDecimal.ZERO); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { bigDecimalsWithComparatorComparisonStrategy.assertIsNotZero(someInfo(), BigDecimal.ONE); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { bigDecimalsWithComparatorComparisonStrategy.assertIsNotZero(someInfo(), BigDecimal.ZERO); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } BigDecimals_assertIsPositive_Test.java000066400000000000000000000040131243020563200361020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsPositive(AssertionInfo, BigDecimal)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class BigDecimals_assertIsPositive_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_positive() { bigDecimals.assertIsPositive(someInfo(), BigDecimal.ONE); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<0> to be greater than:<0>"); bigDecimals.assertIsPositive(someInfo(), BigDecimal.ZERO); } @Test public void should_succeed_since_actual_is_positive_according_to_custom_comparison_strategy() { bigDecimalsWithComparatorComparisonStrategy.assertIsPositive(someInfo(), BigDecimal.ONE); } @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<0> to be greater than:<0> according to 'BigDecimalComparator' comparator"); bigDecimalsWithComparatorComparisonStrategy.assertIsPositive(someInfo(), BigDecimal.ZERO); } } BigDecimals_assertIsZero_Test.java000066400000000000000000000040761243020563200352300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Feb 8, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertIsZero(AssertionInfo, BigDecimal)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class BigDecimals_assertIsZero_Test extends BigDecimalsBaseTest { @Test public void should_succeed_since_actual_is_zero() { bigDecimals.assertIsZero(someInfo(), BigDecimal.ZERO); } @Test public void should_fail_since_actual_is_not_zero() { try { bigDecimals.assertIsZero(someInfo(), BigDecimal.ONE); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]> but was:<[1]>"); } } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { bigDecimalsWithComparatorComparisonStrategy.assertIsZero(someInfo(), BigDecimal.ZERO); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { bigDecimalsWithComparatorComparisonStrategy.assertIsZero(someInfo(), BigDecimal.ONE); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]> but was:<[1]>"); } } } BigDecimals_assertLessThanOrEqualTo_Test.java000066400000000000000000000066351243020563200373350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertLessThanOrEqualTo(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertLessThanOrEqualTo_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertLessThanOrEqualTo(someInfo(), null, ONE); } @Test public void should_pass_if_actual_is_less_than_other() { bigDecimals.assertLessThanOrEqualTo(someInfo(), ONE, TEN); } @Test public void should_pass_if_actual_is_equal_to_other() { bigDecimals.assertLessThanOrEqualTo(someInfo(), ONE, ONE); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertLessThanOrEqualTo(info, TEN, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(TEN, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), ONE, TEN.negate()); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), ONE.negate(), ONE); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, TEN.negate(), ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(TEN.negate(), ONE, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertLessThan_Test.java000066400000000000000000000073731243020563200355410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertLessThan(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertLessThan_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertLessThan(someInfo(), null, ONE); } @Test public void should_pass_if_actual_is_less_than_other() { bigDecimals.assertLessThan(someInfo(), ONE, TEN); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertLessThan(info, TEN, TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(TEN, TEN)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bigDecimals.assertLessThan(info, TEN, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(TEN, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { bigDecimalsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), ONE, TEN.negate()); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertLessThan(info, TEN.negate(), TEN); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(TEN.negate(), TEN, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertLessThan(info, TEN.negate(), ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(TEN.negate(), ONE, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertNotEqualByComparison_Test.java000066400000000000000000000061341243020563200400700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertNotEqualByComparison(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertNotEqualByComparison_Test extends BigDecimalsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertNotEqualByComparison(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_not_equal_by_comparison() { bigDecimals.assertNotEqualByComparison(someInfo(), TEN, ONE); } @Test public void should_fail_if_big_decimals_are_equal_by_comparison() { AssertionInfo info = someInfo(); try { bigDecimals.assertNotEqualByComparison(info, ONE_WITH_3_DECIMALS, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(ONE_WITH_3_DECIMALS, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bigDecimalsWithAbsValueComparisonStrategy.assertNotEqualByComparison(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_not_equal_by_comparison_whatever_custom_comparison_strategy_is() { bigDecimalsWithAbsValueComparisonStrategy.assertNotEqualByComparison(someInfo(), TEN, ONE); } @Test public void should_fail_if_big_decimals_are_equal_by_comparison_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { bigDecimalsWithAbsValueComparisonStrategy.assertNotEqualByComparison(info, ONE_WITH_3_DECIMALS, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(ONE_WITH_3_DECIMALS, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BigDecimals_assertNotEqual_Test.java000066400000000000000000000060541243020563200355430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bigdecimals/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bigdecimals; import static java.math.BigDecimal.*; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BigDecimals; import org.fest.assertions.internal.BigDecimalsBaseTest; /** * Tests for {@link BigDecimals#assertNotEqual(AssertionInfo, BigDecimal, bigdecimal)}. * * @author Joel Costigliola */ public class BigDecimals_assertNotEqual_Test extends BigDecimalsBaseTest { private static final BigDecimal ONE_WITH_3_DECIMALS = new BigDecimal("1.000"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bigDecimals.assertNotEqual(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_not_equal() { bigDecimals.assertNotEqual(someInfo(), ONE, ONE_WITH_3_DECIMALS); } @Test public void should_fail_if_big_decimals_are_equal() { AssertionInfo info = someInfo(); try { bigDecimals.assertNotEqual(info, ONE, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(ONE, ONE)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bigDecimalsWithComparatorComparisonStrategy.assertNotEqual(someInfo(), null, ONE); } @Test public void should_pass_if_big_decimals_are_not_equal_according_to_custom_comparison_strategy() { bigDecimalsWithComparatorComparisonStrategy.assertNotEqual(someInfo(), TEN, ONE); } @Test public void should_fail_if_big_decimals_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bigDecimalsWithComparatorComparisonStrategy.assertNotEqual(info, ONE_WITH_3_DECIMALS, ONE); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(ONE_WITH_3_DECIMALS, ONE, comparatorComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/000077500000000000000000000000001243020563200271545ustar00rootroot00000000000000BooleanArrays_assertContainsOnly_Test.java000066400000000000000000000067111243020563200374270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertContainsOnly(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertContainsOnly_Test extends BooleanArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(true, false)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(false, true)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(true, false, true, false); arrays.assertContainsOnly(someInfo(), actual, arrayOf(true, false)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(true, false, true, false)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(true)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); actual = arrayOf(true); boolean[] expected = { false }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(false), newLinkedHashSet(true))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertContainsSequence_Test.java000066400000000000000000000077001243020563200402550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertContainsSequence(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertContainsSequence_Test extends BooleanArraysBaseTest { @Override @Before public void setUp() { super.setUp(); actual = arrayOf(true, false, false, true); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(true)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); boolean[] sequence = { true, true, true, false, false, false }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); boolean[] sequence = { false, true }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); boolean[] sequence = { true, true }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, boolean[] sequence) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(true, false)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(true, false, false, true)); } } BooleanArrays_assertContains_Test.java000066400000000000000000000067331243020563200365710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertContains(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertContains_Test extends BooleanArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(true)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(false, true)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(true, false)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(true, true, false, false); arrays.assertContains(someInfo(), actual, arrayOf(true)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(true, true)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(true)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); actual = arrayOf(true); boolean[] expected = { false }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(false))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertContains_at_Index_Test.java000066400000000000000000000060641243020563200404010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.actualIsEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertContains(AssertionInfo, boolean[], boolean, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertContains_at_Index_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, true, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), true, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, true, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <1> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, true, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); boolean value = true; Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, false)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, false, atIndex(1)); } } BooleanArrays_assertDoesNotContain_Test.java000066400000000000000000000061741243020563200377010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertDoesNotContain(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertDoesNotContain_Test extends BooleanArraysBaseTest { @Before public void setUpOnce() { super.setUp(); actual = arrayOf(true, true); } @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(false)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(false, false)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(true)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); boolean[] expected = arrayOf(true); try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(true))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000056051243020563200415120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertDoesNotContain(AssertionInfo, boolean[], boolean, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertDoesNotContain_at_Index_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, true, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, true, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), true, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, true, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, true, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); boolean value = true; Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, value, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000047031243020563200412030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertDoesNotHaveDuplicates(AssertionInfo, boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertDoesNotHaveDuplicates_Test extends BooleanArraysBaseTest { @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { actual = arrayOf(true, true, false); AssertionInfo info = someInfo(); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(true))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertEmpty_Test.java000066400000000000000000000040751243020563200361060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertEmpty(AssertionInfo, boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertEmpty_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); boolean[] actual = { true, false }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } BooleanArrays_assertEndsWith_Test.java000066400000000000000000000075501243020563200365360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertEndsWith(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertEndsWith_Test extends BooleanArraysBaseTest { @Override @Before public void setUp() { super.setUp(); actual = arrayOf(true, false, false, true); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(true)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); boolean[] sequence = { true, false, false, true, true, false }; try { arrays.assertEndsWith(someInfo(), actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); boolean[] sequence = { true, false }; try { arrays.assertEndsWith(someInfo(), actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); boolean[] sequence = { false, false }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, boolean[] sequence) { verify(failures).failure(info, shouldEndWith(actual, sequence)); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(false, true)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(true, false, false, true)); } } BooleanArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044111243020563200416330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class BooleanArrays_assertHasSameSizeAs_with_Array_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia")); } } BooleanArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045311243020563200423070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class BooleanArrays_assertHasSameSizeAs_with_Iterable_Test extends BooleanArraysBaseTest { private final List other = newArrayList("Solo", "Leia"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } BooleanArrays_assertHasSize_Test.java000066400000000000000000000040551243020563200363540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertHasSize(AssertionInfo, boolean[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertHasSize_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 6); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 2); } } BooleanArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000072731243020563200427140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertIsSortedAccordingToComparator(AssertionInfo, boolean[], Comparator)} * * @author Joel Costigliola */ public class BooleanArrays_assertIsSortedAccordingToComparator_Test extends BooleanArraysBaseTest { private Comparator booleanDescendingOrderComparator; private Comparator booleanAscendingOrderComparator; @Override @Before public void setUp() { super.setUp(); actual = new boolean[] { true, true, false, false }; booleanDescendingOrderComparator = new Comparator() { public int compare(Boolean boolean1, Boolean boolean2) { return -boolean1.compareTo(boolean2); } }; booleanAscendingOrderComparator = new Comparator() { public int compare(Boolean boolean1, Boolean boolean2) { return boolean1.compareTo(boolean2); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, booleanDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), booleanDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), booleanAscendingOrderComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, booleanDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new boolean[] { true, true, false, true }; try { arrays.assertIsSortedAccordingToComparator(info, actual, booleanDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, booleanDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertIsSorted_Test.java000066400000000000000000000051121243020563200365350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSorted; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class BooleanArrays_assertIsSorted_Test extends BooleanArraysBaseTest { @Override @Before public void setUp() { super.setUp(); actual = new boolean[] { false, false, true, true, true }; } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(true)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (boolean[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(false, true, false); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } BooleanArrays_assertNotEmpty_Test.java000066400000000000000000000040451243020563200365640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertNotEmpty(AssertionInfo, boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertNotEmpty_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(true)); } } BooleanArrays_assertNullOrEmpty_Test.java000066400000000000000000000040171243020563200372360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.BooleanArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertNullOrEmpty(AssertionInfo, boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertNullOrEmpty_Test extends BooleanArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); boolean[] actual = { true, false }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } BooleanArrays_assertStartsWith_Test.java000066400000000000000000000074331243020563200371250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleanarrays/* * Created on Dec 15, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleanarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.BooleanArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BooleanArrays; import org.fest.assertions.internal.BooleanArraysBaseTest; /** * Tests for {@link BooleanArrays#assertStartsWith(AssertionInfo, boolean[], boolean[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class BooleanArrays_assertStartsWith_Test extends BooleanArraysBaseTest { @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(true)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); boolean[] sequence = { true, false, false, true, true, false }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); boolean[] sequence = { false, true }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); boolean[] sequence = { true, true }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, boolean[] sequence) { verify(failures).failure(info, shouldStartWith(actual, sequence)); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(true, false)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { actual = arrayOf(true, false, false, true); arrays.assertStartsWith(someInfo(), actual, arrayOf(true, false, false, true)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleans/000077500000000000000000000000001243020563200261155ustar00rootroot00000000000000Booleans_assertEqual_Test.java000066400000000000000000000040421243020563200340130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleans/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleans; import static java.lang.Boolean.TRUE; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Booleans; import org.fest.assertions.internal.BooleansBaseTest; /** * Tests for {@link Booleans#assertEqual(AssertionInfo, Boolean, boolean)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Booleans_assertEqual_Test extends BooleansBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); booleans.assertEqual(someInfo(), null, true); } @Test public void should_pass_if_booleans_are_equal() { booleans.assertEqual(someInfo(), TRUE, true); } @Test public void should_fail_if_booleans_are_not_equal() { AssertionInfo info = someInfo(); boolean expected = false; try { booleans.assertEqual(info, TRUE, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(TRUE, expected)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Booleans_assertNotEqual_Test.java000066400000000000000000000040201243020563200344700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/booleans/* * Created on Oct 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.booleans; import static java.lang.Boolean.TRUE; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Booleans; import org.fest.assertions.internal.BooleansBaseTest; /** * Tests for {@link Booleans#assertNotEqual(AssertionInfo, Boolean, boolean)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Booleans_assertNotEqual_Test extends BooleansBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); booleans.assertNotEqual(someInfo(), null, false); } @Test public void should_pass_if_bytes_are_not_equal() { booleans.assertNotEqual(someInfo(), TRUE, false); } @Test public void should_fail_if_bytes_are_equal() { AssertionInfo info = someInfo(); try { booleans.assertNotEqual(info, TRUE, true); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(TRUE, true)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/000077500000000000000000000000001243020563200265005ustar00rootroot00000000000000ByteArrays_assertContainsOnly_Test.java000066400000000000000000000133631243020563200363000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertContainsOnly(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertContainsOnly_Test extends ByteArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10, 8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6, 8, 10, 8, 8, 8); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10, 6, 8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); byte[] expected = { 6, 8, 20 }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet((byte) 20), newLinkedHashSet((byte) 10))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10, -8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, -8, 10, -8, 8, -8); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10, 6, -8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet((byte) 20), newLinkedHashSet((byte) 10), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertContainsSequence_Test.java000066400000000000000000000145651243020563200371340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertContainsSequence(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertContainsSequence_Test extends ByteArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } ByteArrays_assertContains_Test.java000066400000000000000000000134771243020563200354440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertContains(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertContains_Test extends ByteArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6, 8, 10, 10, 8); arrays.assertContains(someInfo(), actual, arrayOf(8)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6, 6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); byte[] expected = { 6, 8, 9 }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet((byte) 9))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, -8, 10, 10, -8); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, 6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] expected = { 6, -8, 9 }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet((byte) 9), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertContains_at_Index_Test.java000066400000000000000000000113631243020563200372470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertContains(AssertionInfo, byte[], byte, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertContains_at_Index_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, (byte) 8, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), (byte) 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, (byte) 8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, (byte) 8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); byte value = 6; Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { byte found = 8; verify(failures).failure(info, shouldContainAtIndex(actual, value, index, found)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, (byte) 8, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, (byte) -8, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), (byte) -8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (byte) -8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (byte) -8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte value = 6; Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, value, index); } catch (AssertionError e) { byte found = 8; verify(failures).failure(info, shouldContainAtIndex(actual, value, index, found, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (byte) -8, atIndex(1)); } } ByteArrays_assertDoesNotContain_Test.java000066400000000000000000000114331243020563200365430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertDoesNotContain(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertDoesNotContain_Test extends ByteArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); byte[] expected = { 6, 8, 20 }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet((byte) 6, (byte) 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet((byte) 6, (byte) -8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000107311243020563200403560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertDoesNotContain(AssertionInfo, byte[], byte, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertDoesNotContain_at_Index_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, (byte) 8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, (byte) 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), (byte) 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, (byte) 8, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, (byte) 8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); byte value = 6; Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, value, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, (byte) -8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (byte) 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), (byte) -8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (byte) -8, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (byte) -8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte value = 6; Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, value, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072561243020563200400610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertDoesNotHaveDuplicates(AssertionInfo, byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertDoesNotHaveDuplicates_Test extends ByteArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6, 8, 6, 8); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet((byte) 6, (byte) 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6, -8, 6, -8); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet((byte) 6, (byte) -8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertEmpty_Test.java000066400000000000000000000040331243020563200347500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertEmpty(AssertionInfo, byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertEmpty_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); byte[] actual = { 6, 8 }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } ByteArrays_assertEndsWith_Test.java000066400000000000000000000142651243020563200354070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertEndsWith(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertEndsWith_Test extends ByteArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); byte[] sequence = { 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } ByteArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000043661243020563200405140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertHasSameSizeAs(AssertionInfo, Object[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class ByteArrays_assertHasSameSizeAs_with_Array_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } ByteArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000044601243020563200411600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertHasSameSizeAs(AssertionInfo, Object[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class ByteArrays_assertHasSameSizeAs_with_Iterable_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, newArrayList("Solo", "Leia", "Luke")); } } ByteArrays_assertHasSize_Test.java000066400000000000000000000040301243020563200352150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertHasSize(AssertionInfo, byte[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertHasSize_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 2); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } ByteArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000070671243020563200415650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertIsSortedAccordingToComparator(AssertionInfo, byte[], Comparator)} * * @author Joel Costigliola */ public class ByteArrays_assertIsSortedAccordingToComparator_Test extends ByteArraysBaseTest { private Comparator byteDescendingOrderComparator; private Comparator byteAscendingOrderComparator; @Override @Before public void setUp() { super.setUp(); actual = new byte[] { 4, 3, 2, 2, 1 }; byteDescendingOrderComparator = new Comparator() { public int compare(Byte byte1, Byte byte2) { return -byte1.compareTo(byte2); } }; byteAscendingOrderComparator = new Comparator() { public int compare(Byte byte1, Byte byte2) { return byte1.compareTo(byte2); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, byteDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), byteDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), byteAscendingOrderComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, byteDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new byte[] { 3, 2, 1, 9 }; try { arrays.assertIsSortedAccordingToComparator(info, actual, byteDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, byteDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertIsSorted_Test.java000066400000000000000000000075201243020563200354120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class ByteArrays_assertIsSorted_Test extends ByteArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(1, 2, 3, 4, 4); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (byte[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = arrayOf(1, -2, 3, -4, 4); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (byte[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ByteArrays_assertNotEmpty_Test.java000066400000000000000000000040121243020563200354260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertNotEmpty(AssertionInfo, byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertNotEmpty_Test extends ByteArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8)); } } ByteArrays_assertNullOrEmpty_Test.java000066400000000000000000000037551243020563200361160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.ByteArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertNullOrEmpty(AssertionInfo, byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertNullOrEmpty_Test extends ByteArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); byte[] actual = { 6, 8 }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } ByteArrays_assertStartsWith_Test.java000066400000000000000000000143521243020563200357730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytearrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytearrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ByteArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ByteArrays; import org.fest.assertions.internal.ByteArraysBaseTest; /** * Tests for {@link ByteArrays#assertStartsWith(AssertionInfo, byte[], byte[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ByteArrays_assertStartsWith_Test extends ByteArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); byte[] sequence = { 8, 10 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { -8, 10 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); byte[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/000077500000000000000000000000001243020563200254415ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertEqual_Test.java000066400000000000000000000054451243020563200327520ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertEqual(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertEqual_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertEqual(someInfo(), null, (byte) 8); } @Test public void should_pass_if_bytes_are_equal() { bytes.assertEqual(someInfo(), (byte) 8, (byte) 8); } @Test public void should_fail_if_bytes_are_not_equal() { AssertionInfo info = someInfo(); try { bytes.assertEqual(info, (byte) 6, (byte) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bytesWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, (byte) 8); } @Test public void should_pass_if_bytes_are_equal_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertEqual(someInfo(), (byte) 8, (byte) -8); } @Test public void should_fail_if_bytes_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertEqual(info, (byte) 6, (byte) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Bytes_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000065121243020563200356200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertGreaterThanOrEqualTo(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertGreaterThanOrEqualTo_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertGreaterThanOrEqualTo(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_greater_than_other() { bytes.assertGreaterThanOrEqualTo(someInfo(), (byte) 8, (byte) 6); } @Test public void should_pass_if_actual_is_equal_to_other() { bytes.assertGreaterThanOrEqualTo(someInfo(), (byte) 6, (byte) 6); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bytes.assertGreaterThanOrEqualTo(info, (byte) 6, (byte) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual((byte) 6, (byte) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bytesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), (byte) -8, (byte) 6); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), (byte) -6, (byte) 6); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, (byte) 6, (byte) -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual((byte) 6, (byte) -8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Bytes_assertGreaterThan_Test.java000066400000000000000000000072631243020563200340300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertGreaterThan(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertGreaterThan_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertGreaterThan(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_greater_than_other() { bytes.assertGreaterThan(someInfo(), (byte) 8, (byte) 6); } @Test public void should_fail_if_actual_is_equal_to_other() { try { bytes.assertGreaterThan(someInfo(), (byte) 6, (byte) 6); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldBeGreater((byte) 6, (byte) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { bytes.assertGreaterThan(info, (byte) 6, (byte) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((byte) 6, (byte) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), (byte) -8, (byte) 6); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { try { bytesWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), (byte) -6, (byte) 6); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldBeGreater((byte) -6, (byte) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertGreaterThan(info, (byte) -6, (byte) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((byte) -6, (byte) 8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertIsNegative_Test.java000066400000000000000000000040201243020563200337250ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsNegative(AssertionInfo, Byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertIsNegative_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_negative() { bytes.assertIsNegative(someInfo(), (byte) -6); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6> to be less than:<0>"); bytes.assertIsNegative(someInfo(), (byte) 6); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy() { thrown.expectAssertionError("expected:<-6> to be less than:<0> according to 'AbsValueComparator' comparator"); bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) -6); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy2() { thrown.expectAssertionError("expected:<6> to be less than:<0> according to 'AbsValueComparator' comparator"); bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) 6); } } Bytes_assertIsNotNegative_Test.java000066400000000000000000000035271243020563200343420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsNotNegative(AssertionInfo, Bytes))}. * * @author Nicolas François */ public class Bytes_assertIsNotNegative_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { bytes.assertIsNotNegative(someInfo(), (byte) 6); } @Test public void should_succeed_since_actual_is_zero() { bytes.assertIsNotNegative(someInfo(), (byte) 0); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6> to be greater than or equal to:<0>"); bytes.assertIsNotNegative(someInfo(), (byte) -6); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), (byte) -1); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), (byte) 1); } } Bytes_assertIsNotPositive_Test.java000066400000000000000000000040751243020563200344010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsNotPositive(AssertionInfo, Bytes))}. * * @author Nicolas François */ public class Bytes_assertIsNotPositive_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { bytes.assertIsNotPositive(someInfo(), (byte) -6); } @Test public void should_succeed_since_actual_is_zero() { bytes.assertIsNotPositive(someInfo(), (byte) 0); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6> to be less than or equal to:<0>"); bytes.assertIsNotPositive(someInfo(), (byte) 6); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) -1); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) 1); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertIsNotZero_Test.java000066400000000000000000000036441243020563200335760ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsNotZero(AssertionInfo, Byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertIsNotZero_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { bytes.assertIsNotZero(someInfo(), (byte) 2); } @Test public void should_fail_since_actual_is_zero() { thrown.expectAssertionError("<0> should not be equal to:<0>"); bytes.assertIsNotZero(someInfo(), (byte) 0); } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 1); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertIsPositive_Test.java000066400000000000000000000036211243020563200337730ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsPositive(AssertionInfo, Byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertIsPositive_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_positive() { bytes.assertIsPositive(someInfo(), (byte) 6); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6> to be greater than:<0>"); bytes.assertIsPositive(someInfo(), (byte) -6); } @Test public void should_succeed_since_actual_is_positive_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (byte) -1); } @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<0> to be greater than:<0> according to 'AbsValueComparator' comparator"); bytesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (byte) 0); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertIsZero_Test.java000066400000000000000000000037141243020563200331130ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertIsZero(AssertionInfo, Byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertIsZero_Test extends BytesBaseTest { @Test public void should_succeed_since_actual_is_zero() { bytes.assertIsZero(someInfo(), (byte) 0); } @Test public void should_fail_since_actual_is_not_zero() { try { bytes.assertIsZero(someInfo(), (byte) 2); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]> but was:<[2]>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 1); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } Bytes_assertLessThanOrEqualTo_Test.java000066400000000000000000000064401243020563200351350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertLessThanOrEqualTo(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertLessThanOrEqualTo_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertLessThanOrEqualTo(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_less_than_other() { bytes.assertLessThanOrEqualTo(someInfo(), (byte) 6, (byte) 8); } @Test public void should_pass_if_actual_is_equal_to_other() { bytes.assertLessThanOrEqualTo(someInfo(), (byte) 6, (byte) 6); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { bytes.assertLessThanOrEqualTo(info, (byte) 8, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual((byte) 8, (byte) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bytesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), (byte) 6, (byte) -8); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), (byte) 6, (byte) -6); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, (byte) -8, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual((byte) -8, (byte) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertLessThan_Test.java000066400000000000000000000072011243020563200334140ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertLessThan(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertLessThan_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertLessThan(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_less_than_other() { bytes.assertLessThan(someInfo(), (byte) 6, (byte) 8); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { bytes.assertLessThan(info, (byte) 6, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((byte) 6, (byte) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { bytes.assertLessThan(info, (byte) 8, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((byte) 8, (byte) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bytesWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, (byte) 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertLessThan(someInfo(), (byte) 6, (byte) -8); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertLessThan(info, (byte) 6, (byte) -6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((byte) 6, (byte) -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertLessThan(info, (byte) -8, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((byte) -8, (byte) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/bytes/Bytes_assertNotEqual_Test.java000066400000000000000000000055121243020563200334260ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.bytes; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Bytes; import org.fest.assertions.internal.BytesBaseTest; /** * Tests for {@link Bytes#assertNotEqual(AssertionInfo, Byte, byte)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Bytes_assertNotEqual_Test extends BytesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); bytes.assertNotEqual(someInfo(), null, (byte) 8); } @Test public void should_pass_if_bytes_are_not_equal() { bytes.assertNotEqual(someInfo(), (byte) 8, (byte) 6); } @Test public void should_fail_if_bytes_are_equal() { AssertionInfo info = someInfo(); try { bytes.assertNotEqual(info, (byte) 6, (byte) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual((byte) 6, (byte) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); bytesWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, (byte) 8); } @Test public void should_pass_if_bytes_are_not_equal_according_to_custom_comparison_strategy() { bytesWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), (byte) 8, (byte) 6); } @Test public void should_fail_if_bytes_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { bytesWithAbsValueComparisonStrategy.assertNotEqual(info, (byte) 6, (byte) -6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual((byte) 6, (byte) -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/000077500000000000000000000000001243020563200264325ustar00rootroot00000000000000Characters_assertEqual_Test.java000066400000000000000000000056771243020563200346640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertEqual(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertEqual_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertEqual(someInfo(), null, 'a'); } @Test public void should_pass_if_characters_are_equal() { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(someInfo(), 'a', 'a'); } @Test public void should_fail_if_characters_are_not_equal() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(info, 'b', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual('b', 'a')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_according_to_custom_comparison_strategy() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertEqual(someInfo(), null, 'a'); } @Test public void should_pass_if_characters_are_equal_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(someInfo(), 'a', 'A'); } @Test public void should_fail_if_characters_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(info, 'b', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual('b', 'a', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000065331243020563200376050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertGreaterThanOrEqualTo(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertGreaterThanOrEqualTo_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertGreaterThanOrEqualTo(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_greater_than_other() { characters.assertGreaterThanOrEqualTo(someInfo(), 'b', 'a'); } @Test public void should_pass_if_actual_is_equal_to_other() { characters.assertGreaterThanOrEqualTo(someInfo(), 'b', 'b'); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { characters.assertGreaterThanOrEqualTo(info, 'a', 'b'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual('a', 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_according_to_custom_comparison_strategy() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), 'B', 'a'); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), 'B', 'b'); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThanOrEqualTo(info, 'a', 'B'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual('a', 'B', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertGreaterThan_Test.java000066400000000000000000000073701243020563200360110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertGreaterThan(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertGreaterThan_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertGreaterThan(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_greater_than_other() { characters.assertGreaterThan(someInfo(), 'b', 'a'); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo someInfo = someInfo(); try { characters.assertGreaterThan(someInfo, 'b', 'b'); } catch (AssertionError e) { verify(failures).failure(someInfo, shouldBeGreater('b', 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { characters.assertGreaterThan(info, 'a', 'b'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater('a', 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThan(someInfo(), 'B', 'a'); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo someInfo = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThan(someInfo, 'B', 'b'); } catch (AssertionError e) { verify(failures).failure(someInfo, shouldBeGreater('B', 'b', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertGreaterThan(info, 'A', 'b'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater('A', 'b', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertLessThanOrEqualTo_Test.java000066400000000000000000000064611243020563200371220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertLessThanOrEqualTo(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertLessThanOrEqualTo_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertLessThanOrEqualTo(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_less_than_other() { characters.assertLessThanOrEqualTo(someInfo(), 'a', 'b'); } @Test public void should_pass_if_actual_is_equal_to_other() { characters.assertLessThanOrEqualTo(someInfo(), 'b', 'b'); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { characters.assertLessThanOrEqualTo(info, 'b', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual('b', 'a')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_according_to_custom_comparison_strategy() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 'a', 'B'); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 'b', 'B'); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertLessThanOrEqualTo(info, 'B', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual('B', 'a', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertLessThan_Test.java000066400000000000000000000072041243020563200353220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertLessThan(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertLessThan_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertLessThan(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_less_than_other() { characters.assertLessThan(someInfo(), 'a', 'b'); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { characters.assertLessThan(info, 'b', 'b'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess('b', 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { characters.assertLessThan(info, 'b', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess('b', 'a')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_according_to_custom_comparison_strategy() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertLessThan(someInfo(), null, 'a'); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertLessThan(someInfo(), 'A', 'b'); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertLessThan(info, 'b', 'B'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess('b', 'B', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertLessThan(info, 'B', 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess('B', 'a', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertLowerCase_Test.java000066400000000000000000000054451243020563200354720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeLowerCase.shouldBeLowerCase; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertLowerCase(AssertionInfo, Character)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Characters_assertLowerCase_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertLowerCase(someInfo(), null); } @Test public void should_pass_if_actual_is_lowercase() { characters.assertLowerCase(someInfo(), 'a'); } @Test public void should_fail_if_actual_is_not_lowercase() { AssertionInfo info = someInfo(); try { characters.assertLowerCase(info, 'A'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLowerCase('A')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertLowerCase(someInfo(), null); } @Test public void should_pass_if_actual_is_lowercase_whatever_custom_comparison_strategy_is() { charactersWithCaseInsensitiveComparisonStrategy.assertLowerCase(someInfo(), 'a'); } @Test public void should_fail_if_actual_is_not_lowercase_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertLowerCase(info, 'A'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLowerCase('A')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertNotEqual_Test.java000066400000000000000000000055631243020563200353370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertNotEqual(AssertionInfo, Character, char)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Characters_assertNotEqual_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertNotEqual(someInfo(), null, 'a'); } @Test public void should_pass_if_characters_are_not_equal() { characters.assertNotEqual(someInfo(), 'a', 'b'); } @Test public void should_fail_if_characters_are_equal() { AssertionInfo info = someInfo(); try { characters.assertNotEqual(info, 'b', 'b'); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual('b', 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertNotEqual(someInfo(), null, 'a'); } @Test public void should_pass_if_characters_are_not_equal_according_to_custom_comparison_strategy() { charactersWithCaseInsensitiveComparisonStrategy.assertNotEqual(someInfo(), 'a', 'b'); } @Test public void should_fail_if_characters_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertNotEqual(info, 'b', 'B'); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual('b', 'B', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Characters_assertUpperCase_Test.java000066400000000000000000000054451243020563200354750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/characters/* * Created on Jan 25, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.characters; import static org.fest.assertions.error.ShouldBeUpperCase.shouldBeUpperCase; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Characters; import org.fest.assertions.internal.CharactersBaseTest; /** * Tests for {@link Characters#assertUpperCase(AssertionInfo, Character)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Characters_assertUpperCase_Test extends CharactersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); characters.assertUpperCase(someInfo(), null); } @Test public void should_pass_if_actual_is_uppercase() { characters.assertUpperCase(someInfo(), 'A'); } @Test public void should_fail_if_actual_is_not_uppercase() { AssertionInfo info = someInfo(); try { characters.assertUpperCase(info, 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeUpperCase('a')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); charactersWithCaseInsensitiveComparisonStrategy.assertUpperCase(someInfo(), null); } @Test public void should_pass_if_actual_is_uppercase_whatever_custom_comparison_strategy_is() { charactersWithCaseInsensitiveComparisonStrategy.assertUpperCase(someInfo(), 'A'); } @Test public void should_fail_if_actual_is_not_uppercase_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { charactersWithCaseInsensitiveComparisonStrategy.assertUpperCase(info, 'a'); } catch (AssertionError e) { verify(failures).failure(info, shouldBeUpperCase('a')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/000077500000000000000000000000001243020563200264525ustar00rootroot00000000000000CharArrays_assertContainsOnly_Test.java000066400000000000000000000134311243020563200362200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertContainsOnly(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertContainsOnly_Test extends CharArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf('a', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf('c', 'b', 'a')); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf('a', 'b', 'c', 'c', 'c'); arrays.assertContainsOnly(someInfo(), actual, arrayOf('a', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf('a', 'b', 'c', 'a', 'b', 'c')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf('a')); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); char[] expected = { 'a', 'b', 'd' }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet('d'), newLinkedHashSet('c'))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf('A', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf('c', 'b', 'A')); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf('A', 'b', 'c', 'c', 'c'); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf('A', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf('A', 'b', 'c', 'A', 'b', 'c')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf('A')); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] expected = { 'A', 'b', 'd' }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet('d'), newLinkedHashSet('c'), caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertContainsSequence_Test.java000066400000000000000000000146561243020563200370610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertContainsSequence(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertContainsSequence_Test extends CharArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf('a', 'b', 'c', 'd'); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf('a')); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); char[] sequence = { 'a', 'b', 'c', 12, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); char[] sequence = { 6, 20 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); char[] sequence = { 6, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf('a', 'b')); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf('a', 'b', 'c', 'd')); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf('A')); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'A', 'b', 'c', 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf('A', 'b')); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf('A', 'b', 'c', 'd')); } } CharArrays_assertContains_Test.java000066400000000000000000000135651243020563200353660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertContains(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertContains_Test extends CharArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf('a')); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf('c', 'b')); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf('a', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf('a', 'b', 'c', 'c', 'b'); arrays.assertContains(someInfo(), actual, arrayOf('b')); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf('a', 'a')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf('a')); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); char[] expected = { 'a', 'b', 'd' }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet('d'))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf('A')); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf('c', 'b')); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf('A', 'b', 'c')); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf('A', 'b', 'c', 'c', 'b'); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf('b')); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf('A', 'A')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf('A')); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] expected = { 'A', 'b', 'd' }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet('d'), caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertContains_at_Index_Test.java000066400000000000000000000111431243020563200371670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertContains(AssertionInfo, char[], char, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertContains_at_Index_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, 'a', someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), 'a', someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, 'a', null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, 'a', atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arrays.assertContains(info, actual, 'a', index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, 'a', index, 'b')); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, 'b', atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, 'A', someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), 'A', someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, 'A', null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, 'A', atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, 'a', index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, 'a', index, 'b', caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, 'b', atIndex(1)); } } CharArrays_assertDoesNotContain_Test.java000066400000000000000000000114411243020563200364660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertDoesNotContain(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertDoesNotContain_Test extends CharArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf('d')); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf('d', 'd', 'e')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf('a')); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); char[] expected = { 'a', 'b', 'd' }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet('a', 'b'))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf('d')); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf('d', 'd', 'e')); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf('A')); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] expected = { 'A', 'b', 'd' }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet('A', 'b'), caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000105721243020563200403050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertDoesNotContain(AssertionInfo, char[], char, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertDoesNotContain_at_Index_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, 'a', someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, 'a', atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), 'a', someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, 'a', null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, 'a', atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, 'a', index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 'a', index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, 'A', someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 'A', atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), 'A', someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 'A', null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 'A', atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, 'A', index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 'A', index, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072621243020563200400020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertDoesNotHaveDuplicates(AssertionInfo, char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertDoesNotHaveDuplicates_Test extends CharArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf('a', 'b'); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf('a', 'b', 'a', 'b'); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet('a', 'b'))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf('A', 'b', 'A', 'b'); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet('A', 'b'), caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertEmpty_Test.java000066400000000000000000000040371243020563200347000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertEmpty(AssertionInfo, char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertEmpty_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); char[] actual = { 'a', 'b' }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } CharArrays_assertEndsWith_Test.java000066400000000000000000000144121243020563200353250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertEndsWith(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertEndsWith_Test extends CharArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf('a', 'b', 'c', 'd'); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf('a')); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); char[] sequence = { 'a', 'b', 'c', 'd', 'e', 'f' }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); char[] sequence = { 'x', 'y', 'z' }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); char[] sequence = { 'b', 'y', 'z' }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf('b', 'c', 'd')); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf('a', 'b', 'c', 'd')); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf('A')); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'A', 'b', 'c', 'd', 'e', 'f' }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'x', 'y', 'z' }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'b', 'y', 'z' }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf('b', 'c', 'd')); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf('A', 'b', 'c', 'd')); } } CharArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000043671243020563200404410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class CharArrays_assertHasSameSizeAs_with_Array_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } CharArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045071243020563200411060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class CharArrays_assertHasSameSizeAs_with_Iterable_Test extends CharArraysBaseTest { private final List other = newArrayList("Solo", "Leia", "Luke"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } CharArrays_assertHasSize_Test.java000066400000000000000000000040301243020563200351410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertHasSize(AssertionInfo, char[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertHasSize_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 6); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } CharArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000071621243020563200415050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertIsSortedAccordingToComparator(AssertionInfo, char[], Comparator)} * * @author Joel Costigliola */ public class CharArrays_assertIsSortedAccordingToComparator_Test extends CharArraysBaseTest { private Comparator charDescendingOrderComparator; private Comparator charAscendingOrderComparator; @Override @Before public void setUp() { super.setUp(); actual = new char[] { 'd', 'c', 'b', 'b', 'a' }; charDescendingOrderComparator = new Comparator() { public int compare(Character char1, Character char2) { return -char1.compareTo(char2); } }; charAscendingOrderComparator = new Comparator() { public int compare(Character char1, Character char2) { return -char1.compareTo(char2); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, charDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), charDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), charAscendingOrderComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, charDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new char[] { 'c', 'b', 'a', 'z' }; try { arrays.assertIsSortedAccordingToComparator(info, actual, charDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, charDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertIsSorted_Test.java000066400000000000000000000075041243020563200353400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0f (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0f * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class CharArrays_assertIsSorted_Test extends CharArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf('a', 'b', 'c', 'd', 'd'); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf('d')); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (char[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf('a', 'c', 'b'); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf('d')); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (char[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf('A', 'c', 'b'); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } CharArrays_assertNotEmpty_Test.java000066400000000000000000000037601243020563200353630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertNotEmpty(AssertionInfo, char[])}. * * @author Alex Ruiz */ public class CharArrays_assertNotEmpty_Test extends CharArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf('a')); } } CharArrays_assertNullOrEmpty_Test.java000066400000000000000000000037541243020563200360410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.CharArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertNullOrEmpty(AssertionInfo, char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertNullOrEmpty_Test extends CharArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); char[] actual = { 'a' }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } CharArrays_assertStartsWith_Test.java000066400000000000000000000144661243020563200357250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/chararrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.chararrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.CharArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.CharArrays; import org.fest.assertions.internal.CharArraysBaseTest; /** * Tests for {@link CharArrays#assertStartsWith(AssertionInfo, char[], char[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class CharArrays_assertStartsWith_Test extends CharArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf('a', 'b', 'c', 'd'); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf('a')); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); char[] sequence = { 'a', 'b', 'c', 'd', 'e', 'f' }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); char[] sequence = { 'b', 'c' }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); char[] sequence = { 'a', 'x' }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf('a', 'b', 'c')); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf('a', 'b', 'c', 'd')); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf('A')); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'A', 'b', 'c', 'd', 'e', 'f' }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'b', 'c' }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); char[] sequence = { 'A', 'x' }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf('A', 'b', 'c')); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf('A', 'b', 'c', 'd')); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/000077500000000000000000000000001243020563200266035ustar00rootroot00000000000000Comparables_assertEqualByComparison_Test.java000066400000000000000000000100101243020563200375050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.verify; import java.math.BigDecimal; import java.util.Comparator; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; import org.fest.assertions.util.AbsValueComparator; /** * Tests for {@link Comparables#assertEqualByComparison(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertEqualByComparison_Test extends ComparablesBaseTest { @Override protected Comparator comparatorForCustomComparisonStrategy() { return new AbsValueComparator(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertEqualByComparison(someInfo(), null, 8); } @Test public void should_pass_if_objects_are_equal() { BigDecimal a = new BigDecimal("10.0"); BigDecimal e = new BigDecimal("10.000"); // we use BigDecimal to ensure that 'compareTo' is being called, since BigDecimal is the only Comparable where // 'compareTo' is not consistent with 'equals' assertFalse(a.equals(e)); comparables.assertEqualByComparison(someInfo(), a, e); } @Test public void should_fail_if_objects_are_not_equal() { AssertionInfo info = someInfo(); try { comparables.assertEqualByComparison(info, "Luke", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); comparablesWithCustomComparisonStrategy.assertEqualByComparison(someInfo(), null, BigDecimal.ONE); } @Test public void should_pass_if_objects_are_equal_whatever_custom_comparison_strategy_is() { BigDecimal a = new BigDecimal("10.0"); BigDecimal e = new BigDecimal("10.000"); // we use BigDecimal to ensure that 'compareTo' is being called, since BigDecimal is the only Comparable where // 'compareTo' is not consistent with 'equals' assertFalse(a.equals(e)); comparablesWithCustomComparisonStrategy.assertEqualByComparison(someInfo(), a, e); } @Test public void should_fail_if_objects_are_not_equal_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertEqualByComparison(info, "Luke", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Comparables_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000065321243020563200401260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; /** * Tests for {@link Comparables#assertGreaterThanOrEqualTo(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertGreaterThanOrEqualTo_Test extends ComparablesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertGreaterThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_greater_than_other() { comparables.assertGreaterThanOrEqualTo(someInfo(), 8, 6); } @Test public void should_pass_if_actual_is_equal_to_other() { comparables.assertGreaterThanOrEqualTo(someInfo(), "Yoda", "Yoda"); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { comparables.assertGreaterThanOrEqualTo(info, 6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), 8, -6); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -8, 8); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertGreaterThanOrEqualTo(info, 6, -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6, -8, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Comparables_assertGreaterThan_Test.java000066400000000000000000000072661243020563200363370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; /** * Tests for {@link Comparables#assertGreaterThan(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertGreaterThan_Test extends ComparablesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertGreaterThan(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_greater_than_other() { comparables.assertGreaterThan(someInfo(), 8, 6); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { comparables.assertGreaterThan(info, "Yoda", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater("Yoda", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { comparables.assertGreaterThan(info, 6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertGreaterThan(someInfo(), -8, 6); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertGreaterThan(info, 7, -7); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(7, -7, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertGreaterThan(info, -6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6, 8, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Comparables_assertLessThanOrEqualTo_Test.java000066400000000000000000000064511243020563200374430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; /** * Tests for {@link Comparables#assertLessThanOrEqualTo(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertLessThanOrEqualTo_Test extends ComparablesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertLessThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other() { comparables.assertLessThanOrEqualTo(someInfo(), 6, 8); } @Test public void should_pass_if_actual_is_equal_to_other() { comparables.assertLessThanOrEqualTo(someInfo(), 6, 6); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { comparables.assertLessThanOrEqualTo(info, 8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(8, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertLessThanOrEqualTo(someInfo(), -6, 8); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertLessThanOrEqualTo(someInfo(), -6, 6); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertLessThanOrEqualTo(info, -8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(-8, 6, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Comparables_assertLessThan_Test.java000066400000000000000000000072101243020563200356410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Oct 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; /** * Tests for {@link Comparables#assertLessThan(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertLessThan_Test extends ComparablesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertLessThan(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other() { comparables.assertLessThan(someInfo(), 6, 8); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { comparables.assertLessThan(info, "Yoda", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess("Yoda", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { comparables.assertLessThan(info, 8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { comparablesWithCustomComparisonStrategy.assertLessThan(someInfo(), 6, 8); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertLessThan(info, -7, 7); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(-7, 7, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertLessThan(info, 8, -6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8, -6, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Comparables_assertNotEqualByComparison_Test.java000066400000000000000000000073511243020563200402040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/comparables/* * Created on Sep 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.comparables; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.*; import java.util.Comparator; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Comparables; import org.fest.assertions.internal.ComparablesBaseTest; import org.fest.test.Person; import org.fest.test.PersonCaseInsensitiveNameComparator; /** * Tests for {@link Comparables#assertNotEqualByComparison(AssertionInfo, Comparable, Comparable)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Comparables_assertNotEqualByComparison_Test extends ComparablesBaseTest { @Override protected Comparator comparatorForCustomComparisonStrategy() { return new PersonCaseInsensitiveNameComparator(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); comparables.assertNotEqualByComparison(someInfo(), null, 8); } @Test public void should_pass_if_objects_are_not_equal() { Person a = spy(new Person("Han")); Person o = new Person("Yoda"); comparables.assertNotEqualByComparison(someInfo(), a, o); verify(a).compareTo(o); } @Test public void should_fail_if_objects_are_equal() { AssertionInfo info = someInfo(); try { comparables.assertNotEqualByComparison(info, "Yoda", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual("Yoda", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(someInfo(), null, new Person("Yoda")); } @Test public void should_pass_if_objects_are_not_equal_whatever_custom_comparison_strategy_is() { Person actual = spy(new Person("YODA")); Person other = new Person("Yoda"); comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(someInfo(), actual, other); verify(actual).compareTo(other); } @Test public void should_fail_if_objects_are_equal_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(info, new Person("Yoda"), new Person("Yoda")); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(new Person("Yoda"), new Person("Yoda"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/000077500000000000000000000000001243020563200264645ustar00rootroot00000000000000Conditions_assertDoesNotHave_Test.java000066400000000000000000000043161243020563200360450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.conditions; import static org.fest.assertions.error.ShouldNotHave.shouldNotHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.ConditionsBaseTest; /** * Tests for {@link Conditions#assertDoesNotHave(AssertionInfo, Object, Condition)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class Conditions_assertDoesNotHave_Test extends ConditionsBaseTest { @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); conditions.assertDoesNotHave(someInfo(), actual, null); } @Test public void should_pass_if_Condition_is_not_met() { condition.shouldMatch(false); conditions.assertDoesNotHave(someInfo(), actual, condition); } @Test public void should_fail_if_Condition_is_met() { condition.shouldMatch(true); AssertionInfo info = someInfo(); try { conditions.assertDoesNotHave(info, actual, condition); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHave(actual, condition)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Conditions_assertHas_Test.java000066400000000000000000000042071243020563200344000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/* * Created on Jan 30, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.conditions; import static org.fest.assertions.error.ShouldHave.shouldHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.ConditionsBaseTest; /** * Tests for {@link Conditions#assertHas(AssertionInfo, Object, Condition)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Conditions_assertHas_Test extends ConditionsBaseTest { @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); conditions.assertHas(someInfo(), actual, null); } @Test public void should_pass_if_Condition_is_met() { condition.shouldMatch(true); conditions.assertHas(someInfo(), actual, condition); } @Test public void should_fail_if_Condition_is_not_met() { condition.shouldMatch(false); AssertionInfo info = someInfo(); try { conditions.assertHas(info, actual, condition); } catch (AssertionError e) { verify(failures).failure(info, shouldHave(actual, condition)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Conditions_assertIsNotNull_Test.java000066400000000000000000000026511243020563200355550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.conditions; import org.junit.Test; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.ConditionsBaseTest; /** * Tests for {@link Conditions#assertIsNotNull(Condition)}. * * @author Nicolas François * @author Joel Costigliola */ public class Conditions_assertIsNotNull_Test extends ConditionsBaseTest { @Test public void should_pass_if_condition_is_not_null() { conditions.assertIsNotNull(new TestCondition()); } @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); conditions.assertIsNotNull(null); } } Conditions_assertIsNot_Test.java000066400000000000000000000042571243020563200347260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.conditions; import static org.fest.assertions.error.ShouldNotBe.shouldNotBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.ConditionsBaseTest; /** * Tests for {@link Conditions#assertIsNot(AssertionInfo, Object, Condition)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class Conditions_assertIsNot_Test extends ConditionsBaseTest { @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); conditions.assertIsNot(someInfo(), actual, null); } @Test public void should_pass_if_Condition_is_not_met() { condition.shouldMatch(false); conditions.assertIsNot(someInfo(), actual, condition); } @Test public void should_fail_if_Condition_is_met() { condition.shouldMatch(true); AssertionInfo info = someInfo(); try { conditions.assertIsNot(info, actual, condition); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBe(actual, condition)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Conditions_assertIs_Test.java000066400000000000000000000042271243020563200342420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/conditions/* * Created on Sep 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.conditions; import static org.fest.assertions.error.ShouldBe.shouldBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Conditions; import org.fest.assertions.internal.ConditionsBaseTest; /** * Tests for {@link Conditions#assertIs(AssertionInfo, Object, Condition)}. * * @author Alex Ruiz * @author Yvonne Wang * @author Joel Costigliola */ public class Conditions_assertIs_Test extends ConditionsBaseTest { @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); conditions.assertIs(someInfo(), actual, null); } @Test public void should_pass_if_Condition_is_met() { condition.shouldMatch(true); conditions.assertIs(someInfo(), actual, condition); } @Test public void should_fail_if_Condition_is_not_met() { condition.shouldMatch(false); AssertionInfo info = someInfo(); try { conditions.assertIs(info, actual, condition); } catch (AssertionError e) { verify(failures).failure(info, shouldBe(actual, condition)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/000077500000000000000000000000001243020563200254135ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertHasTime_Test.java000066400000000000000000000040731243020563200331550ustar00rootroot00000000000000/* * Created on Jul 20,2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldHaveTime.shouldHaveTime; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertHasTime(AssertionInfo, Date, long)}. * * @author Guillaume Girou * @author Nicolas François */ public class Dates_assertHasTime_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = new Date(42); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertHasTime(someInfo(), null, 1); } @Test public void should_pass_if_actual_has_same_time() { dates.assertHasTime(someInfo(), actual, 42L); } @Test() public void should_fail_if_actual_has_not_same_time() { AssertionInfo info = someInfo(); try { dates.assertHasTime(someInfo(), actual, 24L); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveTime(actual, 24L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Dates_assertIsAfterOrEqualsTo_Test.java000066400000000000000000000100451243020563200350540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeAfterOrEqualsTo.shouldBeAfterOrEqualsTo; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsAfterOrEqualsTo(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsAfterOrEqualsTo_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_strictly_after_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2022-01-01"); try { dates.assertIsAfterOrEqualsTo(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfterOrEqualsTo(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsAfterOrEqualsTo(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsAfterOrEqualsTo(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_after_given_date() { dates.assertIsAfterOrEqualsTo(someInfo(), actual, parseDate("2000-01-01")); } @Test public void should_pass_if_actual_is_equals_to_given_date() { dates.assertIsAfterOrEqualsTo(someInfo(), actual, parseDate("2011-01-01")); } @Test public void should_fail_if_actual_is_not_strictly_after_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2022-01-01"); try { datesWithCustomComparisonStrategy.assertIsAfterOrEqualsTo(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfterOrEqualsTo(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsAfterOrEqualsTo(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsAfterOrEqualsTo(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_after_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsAfterOrEqualsTo(someInfo(), actual, parseDate("2000-01-01")); } @Test public void should_pass_if_actual_is_equals_to_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsAfterOrEqualsTo(someInfo(), actual, parseDate("2011-01-31")); } } Dates_assertIsAfterYear_Test.java000066400000000000000000000073521243020563200337250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeAfter.shouldBeAfter; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsAfterYear(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsAfterYear_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_strictly_after_given_year() { AssertionInfo info = someInfo(); int year = 2020; try { dates.assertIsAfterYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_year_is_equals_to_given_year() { AssertionInfo info = someInfo(); parseDate("2011-01-01"); int year = 2011; try { dates.assertIsAfterYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsAfterYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_strictly_after_given_year() { dates.assertIsAfterYear(someInfo(), actual, 2000); } @Test public void should_fail_if_actual_is_not_strictly_after_given_year_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int year = 2020; try { datesWithCustomComparisonStrategy.assertIsAfterYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_year_is_equals_to_given_year_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); parseDate("2011-01-01"); int year = 2011; try { datesWithCustomComparisonStrategy.assertIsAfterYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsAfterYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_strictly_after_given_year_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsAfterYear(someInfo(), actual, 2000); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertIsAfter_Test.java000066400000000000000000000107661243020563200331660ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeAfter.shouldBeAfter; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsAfter(AssertionInfo, java.util.Date, java.util.Date)}. * * @author Joel Costigliola */ public class Dates_assertIsAfter_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDate("2011-01-15"); } @Test public void should_fail_if_actual_is_not_strictly_after_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2022-01-01"); try { dates.assertIsAfter(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-15"); try { dates.assertIsAfter(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsAfter(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsAfter(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_after_given_date() { dates.assertIsAfter(someInfo(), actual, parseDate("2000-01-01")); } @Test public void should_fail_if_actual_is_not_strictly_after_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2022-01-01"); try { datesWithCustomComparisonStrategy.assertIsAfter(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-31"); try { datesWithCustomComparisonStrategy.assertIsAfter(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAfter(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsAfter(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsAfter(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_after_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsAfter(someInfo(), actual, parseDate("2000-01-01")); } } Dates_assertIsBeforeOrEqualsTo_Test.java000066400000000000000000000100711243020563200352140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeBeforeOrEqualsTo.shouldBeBeforeOrEqualsTo; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsBeforeOrEqualsTo(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsBeforeOrEqualsTo_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_strictly_before_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { dates.assertIsBeforeOrEqualsTo(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBeforeOrEqualsTo(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsBeforeOrEqualsTo(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsBeforeOrEqualsTo(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_before_given_date() { dates.assertIsBeforeOrEqualsTo(someInfo(), actual, parseDate("2020-01-01")); } @Test public void should_pass_if_actual_is_equals_to_given_date() { dates.assertIsBeforeOrEqualsTo(someInfo(), actual, parseDate("2011-01-01")); } @Test public void should_fail_if_actual_is_not_strictly_before_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { datesWithCustomComparisonStrategy.assertIsBeforeOrEqualsTo(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBeforeOrEqualsTo(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsBeforeOrEqualsTo(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsBeforeOrEqualsTo(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_before_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsBeforeOrEqualsTo(someInfo(), actual, parseDate("2020-01-01")); } @Test public void should_pass_if_actual_is_equals_to_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsBeforeOrEqualsTo(someInfo(), actual, parseDate("2011-01-31")); } } Dates_assertIsBeforeYear_Test.java000066400000000000000000000073761243020563200340740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeBefore.shouldBeBefore; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsBeforeYear(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsBeforeYear_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_strictly_before_given_year() { AssertionInfo info = someInfo(); int year = 2010; try { dates.assertIsBeforeYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_year_is_equals_to_given_year() { AssertionInfo info = someInfo(); parseDate("2011-01-01"); int year = 2011; try { dates.assertIsBeforeYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsBeforeYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_strictly_before_given_year() { dates.assertIsBeforeYear(someInfo(), actual, 2020); } @Test public void should_fail_if_actual_is_not_strictly_before_given_year_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int year = 2010; try { datesWithCustomComparisonStrategy.assertIsBeforeYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_year_is_equals_to_given_year_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); parseDate("2011-01-01"); int year = 2011; try { datesWithCustomComparisonStrategy.assertIsBeforeYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsBeforeYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_strictly_before_given_year_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsBeforeYear(someInfo(), actual, 2020); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertIsBefore_Test.java000066400000000000000000000106351243020563200333220ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeBefore.shouldBeBefore; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsBefore(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsBefore_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_strictly_before_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { dates.assertIsBefore(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-01"); try { dates.assertIsBefore(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsBefore(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsBefore(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_before_given_date() { dates.assertIsBefore(someInfo(), actual, parseDate("2020-01-01")); } @Test public void should_fail_if_actual_is_not_strictly_before_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { datesWithCustomComparisonStrategy.assertIsBefore(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_given_date_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-31"); try { datesWithCustomComparisonStrategy.assertIsBefore(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBefore(actual, other, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsBefore(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsBefore(someInfo(), null, parseDate("2010-01-01")); } @Test public void should_pass_if_actual_is_strictly_before_given_date_according_to_custom_comparison_strategy() { datesWithCustomComparisonStrategy.assertIsBefore(someInfo(), actual, parseDate("2020-01-01")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertIsBetween_Test.java000066400000000000000000000234171243020563200335130ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeBetween.shouldBeBetween; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsBetween(AssertionInfo, Date, Date, Date, boolean, boolean)}. * * @author Joel Costigliola */ public class Dates_assertIsBetween_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDate("2011-09-27"); } @Test public void should_fail_if_actual_is_not_between_given_period() { AssertionInfo info = someInfo(); actual = parseDate("2011-10-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = true; try { dates.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_start_of_given_period_and_start_is_not_included_in_given_period() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = false; boolean inclusiveEnd = true; try { dates.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_end_of_given_period_and_end_is_not_included_in_given_period() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-30"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = false; try { dates.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_start_date_is_null() { thrown.expectNullPointerException(startDateToCompareActualWithIsNull()); Date end = parseDate("2011-09-30"); dates.assertIsBetween(someInfo(), actual, null, end, true, true); } @Test public void should_throw_error_if_end_date_is_null() { thrown.expectNullPointerException(endDateToCompareActualWithIsNull()); Date start = parseDate("2011-09-01"); dates.assertIsBetween(someInfo(), actual, start, null, true, true); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsBetween(someInfo(), null, start, end, true, true); } @Test public void should_pass_if_actual_is_strictly_between_given_period() { Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsBetween(someInfo(), actual, start, end, false, false); } @Test public void should_pass_if_actual_is_equals_to_start_of_given_period_and_start_is_included_in_given_period() { actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsBetween(someInfo(), actual, start, end, true, false); dates.assertIsBetween(someInfo(), actual, start, end, true, true); } @Test public void should_pass_if_actual_is_equals_to_end_of_given_period_and_end_is_included_in_given_period() { actual = parseDate("2011-09-30"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsBetween(someInfo(), actual, start, end, false, true); dates.assertIsBetween(someInfo(), actual, start, end, true, true); } @Test public void should_fail_if_actual_is_not_between_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = parseDate("2011-10-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = true; try { datesWithCustomComparisonStrategy.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_start_of_given_period_and_start_is_not_included_in_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-31"); // = 2011-09-01 according to comparison strategy Date end = parseDate("2011-10-30"); boolean inclusiveStart = false; boolean inclusiveEnd = true; try { datesWithCustomComparisonStrategy.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_end_of_given_period_and_end_is_not_included_in_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-01"); Date start = parseDate("2011-08-01"); Date end = parseDate("2011-09-30"); // = 2011-09-01 according to comparison strategy boolean inclusiveStart = true; boolean inclusiveEnd = false; try { datesWithCustomComparisonStrategy.assertIsBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_start_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(startDateToCompareActualWithIsNull()); Date end = parseDate("2011-09-30"); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, null, end, true, true); } @Test public void should_throw_error_if_end_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(endDateToCompareActualWithIsNull()); Date start = parseDate("2011-09-01"); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, null, true, true); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), null, start, end, true, true); } @Test public void should_pass_if_actual_is_strictly_between_given_period_according_to_custom_comparison_strategy() { Date start = parseDate("2011-08-30"); Date end = parseDate("2011-10-01"); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, end, false, false); } @Test public void should_pass_if_actual_is_equals_to_start_of_given_period_and_start_is_included_in_given_period_according_to_custom_comparison_strategy() { actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-10"); // = 2011-09-01 according to comparison strategy Date end = parseDate("2011-10-01"); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, end, true, false); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, end, true, true); } @Test public void should_pass_if_actual_is_equals_to_end_of_given_period_and_end_is_included_in_given_period_according_to_custom_comparison_strategy() { actual = parseDate("2011-09-15"); Date start = parseDate("2011-08-30"); Date end = parseDate("2011-09-30"); // = 2011-09-01 according to comparison strategy datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, end, false, true); datesWithCustomComparisonStrategy.assertIsBetween(someInfo(), actual, start, end, true, true); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertIsCloseTo_Test.java000066400000000000000000000075641243020563200334770ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeCloseTo.shouldBeCloseTo; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsCloseTo(AssertionInfo, Date, Date, long)}. * * @author Joel Costigliola */ public class Dates_assertIsCloseTo_Test extends DatesBaseTest { private Date other; private int delta; @Override @Before public void setUp() { super.setUp(); actual = parseDatetime("2011-01-01T03:15:05"); delta = 100; other = new Date(actual.getTime() + delta + 1); } @Test public void should_fail_if_actual_is_not_close_to_given_date_by_less_than_given_delta() { AssertionInfo info = someInfo(); try { dates.assertIsCloseTo(info, actual, other, delta); } catch (AssertionError e) { verify(failures).failure(info, shouldBeCloseTo(actual, other, delta, 101)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsCloseTo(someInfo(), actual, null, 10); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsCloseTo(someInfo(), null, parseDate("2010-01-01"), 10); } @Test public void should_pass_if_actual_is_close_to_given_date_by_less_than_given_delta() { dates.assertIsCloseTo(someInfo(), actual, parseDatetime("2011-01-01T03:15:05"), delta); } @Test public void should_fail_if_actual_is_not_close_to_given_date_by_less_than_given_delta_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { datesWithCustomComparisonStrategy.assertIsCloseTo(info, actual, other, delta); } catch (AssertionError e) { verify(failures).failure(info, shouldBeCloseTo(actual, other, delta, 101)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsCloseTo(someInfo(), actual, null, 10); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsCloseTo(someInfo(), null, parseDate("2010-01-01"), 10); } @Test public void should_pass_if_actual_is_close_to_given_date_by_less_than_given_delta_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsCloseTo(someInfo(), actual, parseDatetime("2011-01-01T03:15:05"), delta); } } Dates_assertIsInSameDayAs_Test.java000066400000000000000000000070531243020563200341370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameDay.shouldBeInSameDay; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameDayAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameDayAs_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_in_same_day_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-02"); try { dates.assertIsInSameDayAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameDay(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameDayAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameDayAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_day_as_given_date() { dates.assertIsInSameDayAs(someInfo(), actual, parseDate("2011-01-01")); } @Test public void should_fail_if_actual_is_not_in_same_day_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDate("2011-01-02"); try { datesWithCustomComparisonStrategy.assertIsInSameDayAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameDay(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameDayAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameDayAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_day_as_given_date_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsInSameDayAs(someInfo(), actual, parseDate("2011-01-01")); } } Dates_assertIsInSameHourAs_Test.java000066400000000000000000000073311243020563200343360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameHour.shouldBeInSameHour; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameHourAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameHourAs_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:01:02"); } @Test public void should_fail_if_actual_is_not_in_same_hour_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T04:01:02"); try { dates.assertIsInSameHourAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameHour(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameHourAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameHourAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_hour_as_given_date() { dates.assertIsInSameHourAs(someInfo(), actual, parseDatetime("2011-01-01T03:59:02")); } @Test public void should_fail_if_actual_is_not_in_same_hour_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T04:01:02"); try { datesWithCustomComparisonStrategy.assertIsInSameHourAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameHour(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameHourAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameHourAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_hour_as_given_date_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsInSameHourAs(someInfo(), actual, parseDatetime("2011-01-01T03:59:02")); } } Dates_assertIsInSameMinuteAs_Test.java000066400000000000000000000073751243020563200346720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameMinute.shouldBeInSameMinute; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameMinuteAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameMinuteAs_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:15:00"); } @Test public void should_fail_if_actual_is_not_in_same_minute_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T03:14:02"); try { dates.assertIsInSameMinuteAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameMinute(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameMinuteAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameMinuteAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_minute_as_given_date() { dates.assertIsInSameMinuteAs(someInfo(), actual, parseDatetime("2011-01-01T03:15:59")); } @Test public void should_fail_if_actual_is_not_in_same_minute_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T03:14:02"); try { datesWithCustomComparisonStrategy.assertIsInSameMinuteAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameMinute(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameMinuteAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameMinuteAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_minute_as_given_date_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsInSameMinuteAs(someInfo(), actual, parseDatetime("2011-01-01T03:15:59")); } } Dates_assertIsInSameMonthAs_Test.java000066400000000000000000000071171243020563200345100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameMonth.shouldBeInSameMonth; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameMonthAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameMonthAs_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_in_same_month_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2011-02-01"); try { dates.assertIsInSameMonthAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameMonth(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameMonthAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameMonthAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_month_as_given_date() { dates.assertIsInSameMonthAs(someInfo(), actual, parseDate("2011-01-11")); } @Test public void should_fail_if_actual_is_not_in_same_month_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDate("2011-02-01"); try { datesWithCustomComparisonStrategy.assertIsInSameMonthAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameMonth(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameMonthAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameMonthAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_month_as_given_date_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsInSameMonthAs(someInfo(), actual, parseDate("2011-01-11")); } } Dates_assertIsInSameSecondAs_Test.java000066400000000000000000000077671243020563200346510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameSecond.shouldBeInSameSecond; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameSecondAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameSecondAs_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:15:05"); } @Test public void should_fail_if_actual_is_not_in_same_second_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T03:15:02"); try { dates.assertIsInSameSecondAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameSecond(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameSecondAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameSecondAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_second_as_given_date() { Date other = parseDatetime("2011-01-01T03:15:05"); dates.assertIsInSameSecondAs(someInfo(), actual, other); dates.assertIsInSameSecondAs(someInfo(), actual, new Date(other.getTime() + 999)); } @Test public void should_fail_if_actual_is_not_in_same_second_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDatetime("2011-01-01T03:15:02"); try { datesWithCustomComparisonStrategy.assertIsInSameSecondAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameSecond(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameSecondAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameSecondAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_second_as_given_date_whatever_custom_comparison_strategy_is() { Date other = parseDatetime("2011-01-01T03:15:05"); datesWithCustomComparisonStrategy.assertIsInSameSecondAs(someInfo(), actual, other); datesWithCustomComparisonStrategy.assertIsInSameSecondAs(someInfo(), actual, new Date(other.getTime() + 999)); } } Dates_assertIsInSameYearAs_Test.java000066400000000000000000000070751243020563200343260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInSameYear.shouldBeInSameYear; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.dateToCompareActualWithIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInSameYearAs(AssertionInfo, Date, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInSameYearAs_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_in_same_year_as_given_date() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { dates.assertIsInSameYearAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameYear(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInSameYearAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); dates.assertIsInSameYearAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_year_as_given_date() { dates.assertIsInSameYearAs(someInfo(), actual, parseDate("2011-05-11")); } @Test public void should_fail_if_actual_is_not_in_same_year_as_given_date_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Date other = parseDate("2000-01-01"); try { datesWithCustomComparisonStrategy.assertIsInSameYearAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInSameYear(actual, other)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInSameYearAs(someInfo(), null, new Date()); } @Test public void should_throw_error_if_given_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(dateToCompareActualWithIsNull()); datesWithCustomComparisonStrategy.assertIsInSameYearAs(someInfo(), actual, null); } @Test public void should_pass_if_actual_is_in_same_year_as_given_date_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsInSameYearAs(someInfo(), actual, parseDate("2011-05-11")); } } Dates_assertIsInTheFuture_Test.java000066400000000000000000000104111243020563200342330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInTheFuture.shouldBeInTheFuture; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Dates.monthOf; import static org.mockito.Mockito.verify; import java.util.Calendar; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInTheFuture(AssertionInfo, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInTheFuture_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_in_the_future() { AssertionInfo info = someInfo(); try { dates.assertIsInTheFuture(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInTheFuture(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_today() { AssertionInfo info = someInfo(); try { actual = new Date(); dates.assertIsInTheFuture(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInTheFuture(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInTheFuture(someInfo(), null); } @Test public void should_pass_if_actual_is_in_the_future() { actual = parseDate("2111-01-01"); dates.assertIsInTheFuture(someInfo(), actual); } @Test public void should_fail_if_actual_is_not_in_the_future_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { datesWithCustomComparisonStrategy.assertIsInTheFuture(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInTheFuture(actual, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_today_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { // we want actual to be different from today but still in the same month so that it is = today according to our // comparison strategy (that compares only month and year) // => if we are at the end of the month we subtract one day instead of adding one Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, 1); Date tomorrow = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, -2); Date yesterday = cal.getTime(); actual = monthOf(tomorrow) == monthOf(new Date()) ? tomorrow : yesterday; datesWithCustomComparisonStrategy.assertIsInTheFuture(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInTheFuture(actual, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInTheFuture(someInfo(), null); } @Test public void should_pass_if_actual_is_in_the_future_according_to_custom_comparison_strategy() { actual = parseDate("2111-01-01"); datesWithCustomComparisonStrategy.assertIsInTheFuture(someInfo(), actual); } } Dates_assertIsInThePast_Test.java000066400000000000000000000104611243020563200336750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeInThePast.shouldBeInThePast; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Dates.monthOf; import static org.mockito.Mockito.verify; import java.util.Calendar; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsInThePast(AssertionInfo, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsInThePast_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_in_the_past() { AssertionInfo info = someInfo(); try { actual = parseDate("2111-01-01"); dates.assertIsInThePast(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInThePast(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_today() { AssertionInfo info = someInfo(); try { actual = new Date(); dates.assertIsInThePast(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInThePast(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsInThePast(someInfo(), null); } @Test public void should_pass_if_actual_is_in_the_past() { actual = parseDate("2000-01-01"); dates.assertIsInThePast(someInfo(), actual); } @Test public void should_fail_if_actual_is_not_in_the_past_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { actual = parseDate("2111-01-01"); datesWithCustomComparisonStrategy.assertIsInThePast(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInThePast(actual, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_today_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { // we want actual to be different from today but still in the same month so that it is = today according to our // comparison strategy (that compares only month and year) // => if we are at the end of the month we subtract one day instead of adding one Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, 1); Date tomorrow = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, -2); Date yesterday = cal.getTime(); actual = monthOf(tomorrow) == monthOf(new Date()) ? tomorrow : yesterday; datesWithCustomComparisonStrategy.assertIsInThePast(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeInThePast(actual, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsInThePast(someInfo(), null); } @Test public void should_pass_if_actual_is_in_the_past_according_to_custom_comparison_strategy() { actual = parseDate("2000-01-01"); datesWithCustomComparisonStrategy.assertIsInThePast(someInfo(), actual); } } Dates_assertIsNotBetween_Test.java000066400000000000000000000235411243020563200341130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldNotBeBetween.shouldNotBeBetween; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsNotBetween(AssertionInfo, Date, Date, Date, boolean, boolean)}. * * @author Joel Costigliola */ public class Dates_assertIsNotBetween_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDate("2011-09-27"); } @Test public void should_fail_if_actual_is_between_given_period() { AssertionInfo info = someInfo(); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = true; try { dates.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_start_of_given_period_and_start_is_included_in_given_period() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = false; try { dates.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_end_of_given_period_and_end_is_included_in_given_period() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-30"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = false; boolean inclusiveEnd = true; try { dates.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_start_date_is_null() { thrown.expectNullPointerException(startDateToCompareActualWithIsNull()); Date end = parseDate("2011-09-30"); dates.assertIsNotBetween(someInfo(), actual, null, end, true, true); } @Test public void should_throw_error_if_end_date_is_null() { thrown.expectNullPointerException(endDateToCompareActualWithIsNull()); Date start = parseDate("2011-09-01"); dates.assertIsNotBetween(someInfo(), actual, start, null, true, true); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsNotBetween(someInfo(), null, start, end, true, true); } @Test public void should_pass_if_actual_is_not_between_given_period() { actual = parseDate("2011-12-31"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsNotBetween(someInfo(), actual, start, end, true, true); } @Test public void should_pass_if_actual_is_equals_to_start_of_given_period_and_start_is_not_included_in_given_period() { actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsNotBetween(someInfo(), actual, start, end, false, false); dates.assertIsNotBetween(someInfo(), actual, start, end, false, true); } @Test public void should_pass_if_actual_is_equals_to_end_of_given_period_and_end_is_not_included_in_given_period() { actual = parseDate("2011-09-30"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); dates.assertIsNotBetween(someInfo(), actual, start, end, false, false); dates.assertIsNotBetween(someInfo(), actual, start, end, true, false); } @Test public void should_fail_if_actual_is_between_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Date start = parseDate("2011-08-31"); Date end = parseDate("2011-09-30"); boolean inclusiveStart = true; boolean inclusiveEnd = true; try { datesWithCustomComparisonStrategy.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_start_of_given_period_and_start_is_included_in_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-15"); Date start = parseDate("2011-09-01"); // = 2011-09-15 according to comparison strategy Date end = parseDate("2011-10-01"); boolean inclusiveStart = true; boolean inclusiveEnd = false; try { datesWithCustomComparisonStrategy.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_equals_to_end_of_given_period_and_end_is_included_in_given_period_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = parseDate("2011-09-15"); Date start = parseDate("2011-08-31"); Date end = parseDate("2011-09-30"); // = 2011-09-15 according to comparison strategy boolean inclusiveStart = false; boolean inclusiveEnd = true; try { datesWithCustomComparisonStrategy.assertIsNotBetween(info, actual, start, end, inclusiveStart, inclusiveEnd); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeBetween(actual, start, end, inclusiveStart, inclusiveEnd, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_start_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(startDateToCompareActualWithIsNull()); Date end = parseDate("2011-09-30"); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, null, end, true, true); } @Test public void should_throw_error_if_end_date_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(endDateToCompareActualWithIsNull()); Date start = parseDate("2011-09-01"); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, null, true, true); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-30"); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), null, start, end, true, true); } @Test public void should_pass_if_actual_is_not_between_given_period_according_to_custom_comparison_strategy() { actual = parseDate("2011-12-31"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-11-30"); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, end, true, true); } @Test public void should_pass_if_actual_is_equals_to_start_of_given_period_and_start_is_not_included_in_given_period_according_to_custom_comparison_strategy() { actual = parseDate("2011-09-01"); Date start = parseDate("2011-09-15"); // = 2011-09-01 according to comparison strategy Date end = parseDate("2011-09-30"); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, end, false, false); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, end, false, true); } @Test public void should_pass_if_actual_is_equals_to_end_of_given_period_and_end_is_not_included_in_given_period_according_to_custom_comparison_strategy() { actual = parseDate("2011-09-30"); Date start = parseDate("2011-09-01"); Date end = parseDate("2011-09-15"); // = 2011-09-30 according to comparison strategy datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, end, false, false); datesWithCustomComparisonStrategy.assertIsNotBetween(someInfo(), actual, start, end, true, false); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/Dates_assertIsToday_Test.java000066400000000000000000000062621243020563200332010ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeToday.shouldBeToday; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Dates.*; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsToday(AssertionInfo, Date)}. * * @author Joel Costigliola */ public class Dates_assertIsToday_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_today() { AssertionInfo info = someInfo(); try { actual = parseDate("2111-01-01"); dates.assertIsToday(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeToday(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsToday(someInfo(), null); } @Test public void should_pass_if_actual_is_today() { dates.assertIsToday(someInfo(), new Date()); } @Test public void should_fail_if_actual_is_not_today_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { actual = parseDate("2111-01-01"); datesWithCustomComparisonStrategy.assertIsToday(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeToday(actual, yearAndMonthComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsToday(someInfo(), null); } @Test public void should_pass_if_actual_is_today_according_to_custom_comparison_strategy() { // we want actual to be different from today but still in the same month so that it is equal to today // according to our comparison strategy (that compares only month and year). // => if we are at the end of the month we subtract one day instead of adding one actual = monthOf(tomorrow()) == monthOf(new Date()) ? tomorrow() : yesterday(); datesWithCustomComparisonStrategy.assertIsToday(someInfo(), actual); } } Dates_assertIsWithinDayOfMonth_Test.java000066400000000000000000000057731243020563200352430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinDayOfMonth(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinDayOfMonth_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_within_given_day_of_month() { AssertionInfo info = someInfo(); int day_of_month = 5; try { dates.assertIsWithinDayOfMonth(info, actual, day_of_month); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "day of month", day_of_month)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinDayOfMonth(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_day_of_month() { dates.assertIsWithinDayOfMonth(someInfo(), actual, 1); } @Test public void should_fail_if_actual_is_not_within_given_day_of_month_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int day_of_month = 5; try { datesWithCustomComparisonStrategy.assertIsWithinDayOfMonth(info, actual, day_of_month); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "day of month", day_of_month)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinDayOfMonth(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_day_of_month_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinDayOfMonth(someInfo(), actual, 1); } } Dates_assertIsWithinDayOfWeek_Test.java000066400000000000000000000060441243020563200350410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static java.util.Calendar.*; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinDayOfWeek(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinDayOfWeek_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_within_given_day_of_week() { AssertionInfo info = someInfo(); int day_of_week = SUNDAY; try { dates.assertIsWithinDayOfWeek(info, actual, day_of_week); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "day of week", day_of_week)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinDayOfWeek(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_day_of_week() { dates.assertIsWithinDayOfWeek(someInfo(), actual, SATURDAY); } @Test public void should_fail_if_actual_is_not_within_given_day_of_week_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int day_of_week = SUNDAY; try { datesWithCustomComparisonStrategy.assertIsWithinDayOfWeek(info, actual, day_of_week); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "day of week", day_of_week)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinDayOfWeek(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_day_of_week_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinDayOfWeek(someInfo(), actual, SATURDAY); } } Dates_assertIsWithinHourOfDay_Test.java000066400000000000000000000061011243020563200350550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinHourOfDay(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinHourOfDay_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:01:02"); } @Test public void should_fail_if_actual_is_not_within_given_hour_of_day() { AssertionInfo info = someInfo(); int hour_of_day = 5; try { dates.assertIsWithinHourOfDay(info, actual, hour_of_day); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "hour", hour_of_day)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinHourOfDay(someInfo(), null, 3); } @Test public void should_pass_if_actual_is_within_given_hour_of_day() { dates.assertIsWithinHourOfDay(someInfo(), actual, 3); } @Test public void should_fail_if_actual_is_not_within_given_hour_of_day_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int hour_of_day = 5; try { datesWithCustomComparisonStrategy.assertIsWithinHourOfDay(info, actual, hour_of_day); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "hour", hour_of_day)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinHourOfDay(someInfo(), null, 3); } @Test public void should_pass_if_actual_is_within_given_hour_of_day_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinHourOfDay(someInfo(), actual, 3); } } Dates_assertIsWithinMillisecond_Test.java000066400000000000000000000061741243020563200354710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinMillisecond(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinMillisecond_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = new Date(parseDatetime("2011-01-01T03:49:17").getTime() + 13); } @Test public void should_fail_if_actual_is_not_within_given_millisecond() { AssertionInfo info = someInfo(); int millisecond = 5; try { dates.assertIsWithinMillisecond(info, actual, millisecond); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "millisecond", millisecond)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinMillisecond(someInfo(), null, 13); } @Test public void should_pass_if_actual_is_within_given_millisecond() { dates.assertIsWithinMillisecond(someInfo(), actual, 13); } @Test public void should_fail_if_actual_is_not_within_given_millisecond_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int millisecond = 5; try { datesWithCustomComparisonStrategy.assertIsWithinMillisecond(info, actual, millisecond); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "millisecond", millisecond)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinMillisecond(someInfo(), null, 13); } @Test public void should_pass_if_actual_is_within_given_millisecond_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinMillisecond(someInfo(), actual, 13); } } Dates_assertIsWithinMinute_Test.java000066400000000000000000000057771243020563200345000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinMinute(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinMinute_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:49:02"); } @Test public void should_fail_if_actual_is_not_within_given_minute() { AssertionInfo info = someInfo(); int minute = 5; try { dates.assertIsWithinMinute(info, actual, minute); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "minute", minute)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinMinute(someInfo(), null, 49); } @Test public void should_pass_if_actual_is_within_given_minute() { dates.assertIsWithinMinute(someInfo(), actual, 49); } @Test public void should_fail_if_actual_is_not_within_given_minute_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int minute = 5; try { datesWithCustomComparisonStrategy.assertIsWithinMinute(info, actual, minute); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "minute", minute)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinMinute(someInfo(), null, 49); } @Test public void should_pass_if_actual_is_within_given_minute_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinMinute(someInfo(), actual, 49); } } Dates_assertIsWithinMonth_Test.java000066400000000000000000000055771243020563200343220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinMonth(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinMonth_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_within_given_month() { AssertionInfo info = someInfo(); int month = 5; try { dates.assertIsWithinMonth(info, actual, month); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "month", month)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinMonth(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_month() { dates.assertIsWithinMonth(someInfo(), actual, 1); } @Test public void should_fail_if_actual_is_not_within_given_month_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int month = 5; try { datesWithCustomComparisonStrategy.assertIsWithinMonth(info, actual, month); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "month", month)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinMonth(someInfo(), null, 1); } @Test public void should_pass_if_actual_is_within_given_month_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinMonth(someInfo(), actual, 1); } } Dates_assertIsWithinSecond_Test.java000066400000000000000000000057771243020563200344520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinSecond(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinSecond_Test extends DatesBaseTest { @Override protected void initActualDate() { actual = parseDatetime("2011-01-01T03:49:17"); } @Test public void should_fail_if_actual_is_not_within_given_second() { AssertionInfo info = someInfo(); int second = 5; try { dates.assertIsWithinSecond(info, actual, second); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "second", second)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinSecond(someInfo(), null, 17); } @Test public void should_pass_if_actual_is_within_given_second() { dates.assertIsWithinSecond(someInfo(), actual, 17); } @Test public void should_fail_if_actual_is_not_within_given_second_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int second = 5; try { datesWithCustomComparisonStrategy.assertIsWithinSecond(info, actual, second); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "second", second)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinSecond(someInfo(), null, 17); } @Test public void should_pass_if_actual_is_within_given_second_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinSecond(someInfo(), actual, 17); } } Dates_assertIsWithinYear_Test.java000066400000000000000000000055751243020563200341330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/dates/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.dates; import static org.fest.assertions.error.ShouldBeWithin.shouldBeWithin; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Date; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Dates; import org.fest.assertions.internal.DatesBaseTest; /** * Tests for {@link Dates#assertIsWithinYear(AssertionInfo, Date, int)}. * * @author Joel Costigliola */ public class Dates_assertIsWithinYear_Test extends DatesBaseTest { @Test public void should_fail_if_actual_is_not_within_given_year() { AssertionInfo info = someInfo(); int year = 2010; try { dates.assertIsWithinYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "year", year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); dates.assertIsWithinYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_within_given_year() { dates.assertIsWithinYear(someInfo(), actual, 2011); } @Test public void should_fail_if_actual_is_not_within_given_year_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); int year = 2010; try { datesWithCustomComparisonStrategy.assertIsWithinYear(info, actual, year); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWithin(actual, "year", year)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); datesWithCustomComparisonStrategy.assertIsWithinYear(someInfo(), null, 2010); } @Test public void should_pass_if_actual_is_within_given_year_whatever_custom_comparison_strategy_is() { datesWithCustomComparisonStrategy.assertIsWithinYear(someInfo(), actual, 2011); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/000077500000000000000000000000001243020563200270075ustar00rootroot00000000000000DoubleArrays_assertContainsOnly_Test.java000066400000000000000000000134311243020563200371120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertContainsOnly(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertContainsOnly_Test extends DoubleArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6d, 8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10d, 8d, 6d)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6d, 8d, 10d, 8d, 8d, 8d); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6d, 8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6d, 8d, 10d, 6d, 8d, 10d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(8d)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); double[] expected = { 6d, 8d, 20d }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20d), newLinkedHashSet(10d))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6d, -8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10d, -8d, 6d)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6d, -8d, 10d, -8d, -8d, -8d); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6d, -8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6d, -8d, 10d, 6d, -8d, 10d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(-8d)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] expected = { 6d, -8d, 20d }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20d), newLinkedHashSet(10d), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertContainsSequence_Test.java000066400000000000000000000146731243020563200377520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertContainsSequence(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertContainsSequence_Test extends DoubleArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6d, 8d, 10d, 12d); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8d)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 8d, 10d, 12d, 20d, 22d }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d, 22d }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6d, 8d)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6d, 8d, 10d, 12d)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8d)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, -8d, 10d, 12d, 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6d, -8d)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6d, -8d, 10d, 12d)); } } DoubleArrays_assertContains_Test.java000066400000000000000000000135551243020563200362570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertContains(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertContains_Test extends DoubleArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6d)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8d, 10d)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6d, 8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6d, 8d, 10d, 10d, 8d); arrays.assertContains(someInfo(), actual, arrayOf(8d)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6d, 6d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8d)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); double[] expected = { 6d, 8d, 9d }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9d))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6d)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8d, 10d)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6d, -8d, 10d)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6d, -8d, 10d, 10d, -8d); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8d)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6d, 6d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(-8d)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] expected = { 6d, -8d, 9d }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9d), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertContains_at_Index_Test.java000066400000000000000000000112331243020563200400610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertContains(AssertionInfo, double[], double, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertContains_at_Index_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, 8d, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), 8d, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, 8d, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, 8d, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); double value = 6; Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, 8d, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, -8d, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), -8d, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8d, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8d, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double value = 6; Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8d, atIndex(1)); } } DoubleArrays_assertDoesNotContain_Test.java000066400000000000000000000116071243020563200373640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertDoesNotContain(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertDoesNotContain_Test extends DoubleArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6d, 8d, 10d); } @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12d)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12d, 12d, 20d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8d)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); double[] expected = { 6d, 8d, 20d }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6d, 8d))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12d)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12d, 12d, 20d)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8d)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] expected = { 6d, -8d, 20d }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6d, -8d), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000105731243020563200412000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertDoesNotContain(AssertionInfo, double[], double, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertDoesNotContain_at_Index_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, 8d, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, 6d, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), 8d, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, 8d, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, 8d, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, 6d, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6d, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, -8d, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 6d, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), -8d, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8d, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8d, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, 6d, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6d, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000071271243020563200406740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertDoesNotHaveDuplicates(AssertionInfo, double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertDoesNotHaveDuplicates_Test extends DoubleArraysBaseTest { @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6d, 8d, 6d, 8d); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6d, 8d))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6d, -8d, 6d, -8d); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6d, -8d), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertEmpty_Test.java000066400000000000000000000040571243020563200355740ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertEmpty(AssertionInfo, double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertEmpty_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); double[] actual = { 6d, 8d }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } DoubleArrays_assertEndsWith_Test.java000066400000000000000000000143751243020563200362270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertEndsWith(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertEndsWith_Test extends DoubleArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6d, 8d, 10d, 12d); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8d)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 8d, 10d, 12d, 20d, 22d }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); double[] sequence = { 20d, 22d }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d, 22d }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8d, 10d, 12d)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6d, 8d, 10d, 12d)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8d)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, -8d, 10d, 12d, 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8d, 10d, 12d)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6d, -8d, 10d, 12d)); } } DoubleArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044131243020563200413230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class DoubleArrays_assertHasSameSizeAs_with_Array_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia", "Luke")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } DoubleArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045231243020563200417760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class DoubleArrays_assertHasSameSizeAs_with_Iterable_Test extends DoubleArraysBaseTest { private final List other = newArrayList("Solo", "Leia", "Luke"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } DoubleArrays_assertHasSize_Test.java000066400000000000000000000040461243020563200360420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertHasSize(AssertionInfo, double[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertHasSize_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 2); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } DoubleArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000072451243020563200424010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertIsSortedAccordingToComparator(AssertionInfo, double[], Comparator)} * * @author Joel Costigliola */ public class DoubleArrays_assertIsSortedAccordingToComparator_Test extends DoubleArraysBaseTest { private Comparator doubleDescendingOrderComparator; private Comparator doubleSquareComparator; @Override @Before public void setUp() { super.setUp(); actual = new double[] { 4.0, 3.0, 2.0, 2.0, 1.0 }; doubleDescendingOrderComparator = new Comparator() { public int compare(Double double1, Double double2) { return -double1.compareTo(double2); } }; doubleSquareComparator = new Comparator() { public int compare(Double double1, Double double2) { return new Double(double1 * double1).compareTo(new Double(double2 * double2)); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, doubleDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), doubleDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), doubleSquareComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, doubleDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new double[] { 3.0, 2.0, 1.0, 9.0 }; try { arrays.assertIsSortedAccordingToComparator(info, actual, doubleDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, doubleDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertIsSorted_Test.java000066400000000000000000000076061243020563200362350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class DoubleArrays_assertIsSorted_Test extends DoubleArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(1.0, 2.0, 3.0, 4.0, 4.0); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1.0)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (double[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1.0, 3.0, 2.0); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = arrayOf(1.0, -2.0, 3.0, -4.0, 4.0); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1.0)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (double[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1.0, 3.0, 2.0); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } DoubleArrays_assertNotEmpty_Test.java000066400000000000000000000040331243020563200362470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertNotEmpty(AssertionInfo, double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertNotEmpty_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8d)); } } DoubleArrays_assertNullOrEmpty_Test.java000066400000000000000000000040011243020563200367150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.DoubleArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertNullOrEmpty(AssertionInfo, double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertNullOrEmpty_Test extends DoubleArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); double[] actual = { 6d, 8d }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } DoubleArrays_assertStartsWith_Test.java000066400000000000000000000144571243020563200366170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doublearrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doublearrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.DoubleArrays.*; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.DoubleArrays; import org.fest.assertions.internal.DoubleArraysBaseTest; /** * Tests for {@link DoubleArrays#assertStartsWith(AssertionInfo, double[], double[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class DoubleArrays_assertStartsWith_Test extends DoubleArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6d, 8d, 10d, 12d); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(8d)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 8d, 10d, 12d, 20d, 22d }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); double[] sequence = { 8d, 10d }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6d, 8d, 10d)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6d, 8d, 10d, 12d)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(-8d)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, -8d, 10d, 12d, 20d, 22d }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { -8d, 10d }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); double[] sequence = { 6d, 20d }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6d, -8d, 10d)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6d, -8d, 10d, 12d)); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/000077500000000000000000000000001243020563200257505ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/Doubles_NaN_Test.java000066400000000000000000000020711243020563200317430ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import org.junit.Assert; import org.junit.Test; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#NaN()}. * * @author Joel Costigliola */ public class Doubles_NaN_Test extends DoublesBaseTest { @Test public void check_double_NaN_method() { Assert.assertEquals(Double.NaN, NaN(), 0d); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/Doubles_assertEqual_Test.java000066400000000000000000000053651243020563200335710ustar00rootroot00000000000000/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertEqual(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertEqual_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertEqual(someInfo(), null, 8d); } @Test public void should_pass_if_doubles_are_equal() { doubles.assertEqual(someInfo(), 8d, 8d); } @Test public void should_fail_if_doubles_are_not_equal() { AssertionInfo info = someInfo(); try { doubles.assertEqual(info, 6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, 8d); } @Test public void should_pass_if_doubles_are_equal_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), 8d, -8d); } @Test public void should_fail_if_doubles_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertEqual(info, 6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Doubles_assertEqual_double_with_offset_Test.java000066400000000000000000000106161243020563200374400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.api.Assertions.*; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.assertions.test.ErrorMessages.offsetIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertEqual(AssertionInfo, Double, double, Offset)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertEqual_double_with_offset_Test extends DoublesBaseTest { @Test public void should_throw_error_if_offset_is_null() { thrown.expectNullPointerException(offsetIsNull()); doubles.assertEqual(someInfo(), new Double(8d), 8d, null); } @Test public void should_pass_if_doubles_are_equal() { doubles.assertEqual(someInfo(), new Double(8d), 8d, offset(1d)); } @Test public void should_pass_if_doubles_are_equal_within_offset() { doubles.assertEqual(someInfo(), new Double(6d), 8d, offset(2d)); } @Test public void should_fail_if_doubles_are_not_equal_within_offset() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doubles.assertEqual(info, new Double(6d), 8d, offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d, offset, 2d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_second_double_is_null_but_not_the_first() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doubles.assertEqual(info, 6d, null, offset); failBecauseExceptionWasNotThrown(NullPointerException.class); } catch (NullPointerException e) { assertThat(e).hasMessage("The given number should not be null"); } } @Test public void should_throw_error_if_offset_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(offsetIsNull()); doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(8d), 8d, null); } @Test public void should_pass_if_doubles_are_equal_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(8d), 8d, offset(1d)); } @Test public void should_pass_if_doubles_are_equal_within_offset_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(6d), 8d, offset(2d)); } @Test public void should_fail_if_doubles_are_not_equal_within_offset_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doublesWithAbsValueComparisonStrategy.assertEqual(info, new Double(6d), 8d, offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d, offset, 2d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_second_double_is_null_but_not_the_first_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doublesWithAbsValueComparisonStrategy.assertEqual(info, 6d, null, offset); failBecauseExceptionWasNotThrown(NullPointerException.class); } catch (NullPointerException e) { assertThat(e).hasMessage("The given number should not be null"); } } } Doubles_assertEqual_with_offset_Test.java000066400000000000000000000070761243020563200361140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.assertions.test.ErrorMessages.offsetIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertEqual(AssertionInfo, Double, Double, Offset)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertEqual_with_offset_Test extends DoublesBaseTest { @Test public void should_throw_error_if_offset_is_null() { thrown.expectNullPointerException(offsetIsNull()); doubles.assertEqual(someInfo(), new Double(8d), new Double(8d), null); } @Test public void should_pass_if_doubles_are_equal() { doubles.assertEqual(someInfo(), new Double(8d), new Double(8d), offset(1d)); } @Test public void should_pass_if_doubles_are_equal_within_offset() { doubles.assertEqual(someInfo(), new Double(6d), new Double(8d), offset(2d)); } @Test public void should_fail_if_doubles_are_not_equal_within_offset() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doubles.assertEqual(info, new Double(6d), new Double(8d), offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d, offset, 2d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_offset_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(offsetIsNull()); doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(8d), new Double(8d), null); } @Test public void should_pass_if_doubles_are_equal_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(8d), new Double(8d), offset(1d)); } @Test public void should_pass_if_doubles_are_equal_within_offset_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Double(6d), new Double(8d), offset(2d)); } @Test public void should_fail_if_doubles_are_not_equal_within_offset_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1d); try { doublesWithAbsValueComparisonStrategy.assertEqual(info, new Double(6d), new Double(8d), offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6d, 8d, offset, 2d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Doubles_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000063761243020563200364460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertGreaterThanOrEqualTo(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertGreaterThanOrEqualTo_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertGreaterThanOrEqualTo(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_greater_than_other() { doubles.assertGreaterThanOrEqualTo(someInfo(), 8d, 6d); } @Test public void should_pass_if_actual_is_equal_to_other() { doubles.assertGreaterThanOrEqualTo(someInfo(), 6d, 6d); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { doubles.assertGreaterThanOrEqualTo(info, 6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6d, 8d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); doublesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -8d, 6d); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -6d, 6d); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, -6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(-6d, 8d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Doubles_assertGreaterThan_Test.java000066400000000000000000000072051243020563200346420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertGreaterThan(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertGreaterThan_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertGreaterThan(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_greater_than_other() { doubles.assertGreaterThan(someInfo(), 8d, 6d); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { doubles.assertGreaterThan(info, 6d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6d, 6d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { doubles.assertGreaterThan(info, 6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6d, 8d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), -8d, 6d); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertGreaterThan(info, -6d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6d, 6d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertGreaterThan(info, -6d, 8d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6d, 8d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/Doubles_assertIsNaN_Test.java000066400000000000000000000037571243020563200334750ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNaN(AssertionInfo, Double)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Doubles_assertIsNaN_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_equal_to_NaN() { doubles.assertIsNaN(someInfo(), Double.NaN); } @Test public void should_fail_since_actual_is_not_equal_to_NaN() { try { doubles.assertIsNaN(someInfo(), 6d); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[NaN]> but was:<[6.0]>"); } } @Test public void should_succeed_since_actual_is_equal_to_NaN_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertIsNaN(someInfo(), Double.NaN); } @Test public void should_fail_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { try { doublesWithAbsValueComparisonStrategy.assertIsNaN(someInfo(), 6d); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[NaN]> but was:<[6.0]>"); } } }Doubles_assertIsNegative_Test.java000066400000000000000000000040421243020563200344700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNegative(AssertionInfo, Double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertIsNegative_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_negative() { doubles.assertIsNegative(someInfo(), -6.0d); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6.0> to be less than:<0.0>"); doubles.assertIsNegative(someInfo(), 6.0d); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy() { thrown.expectAssertionError("expected:<-6.0> to be less than:<0.0> according to 'AbsValueComparator' comparator"); doublesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), -6.0d); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy2() { thrown.expectAssertionError("expected:<6.0> to be less than:<0.0> according to 'AbsValueComparator' comparator"); doublesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), 6.0d); } } Doubles_assertIsNotNaN_Test.java000066400000000000000000000037751243020563200340770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNotNan(AssertionInfo, Double)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Doubles_assertIsNotNaN_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_not_equal_to_NaN() { doubles.assertIsNotNaN(someInfo(), 6d); } @Test public void should_fail_since_actual_is_not_equal_to_NaN() { try { doubles.assertIsNotNaN(someInfo(), 6d); } catch (AssertionError e) { assertEquals(e.getMessage(), "<6.0> should not be equal to:"); } } @Test public void should_succeed_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertIsNotNaN(someInfo(), 6d); } @Test public void should_fail_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { try { doublesWithAbsValueComparisonStrategy.assertIsNotNaN(someInfo(), 6d); } catch (AssertionError e) { assertEquals(e.getMessage(), "<6.0> should not be equal to:"); } } }Doubles_assertIsNotNegative_Test.java000066400000000000000000000035221243020563200351530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNotNegative(AssertionInfo, Double))}. * * @author Nicolas François */ public class Doubles_assertIsNotNegative_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { doubles.assertIsNotNegative(someInfo(), 6d); } @Test public void should_succeed_since_actual_is_zero() { doubles.assertIsNotNegative(someInfo(), 0d); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6.0> to be greater than or equal to:<0.0>"); doubles.assertIsNotNegative(someInfo(), -6d); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), -1d); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), 1d); } } Doubles_assertIsNotPositive_Test.java000066400000000000000000000041311243020563200352100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNotPositive(org.fest.assertions.core.AssertionInfo, Double))}. * * @author Nicolas François */ public class Doubles_assertIsNotPositive_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { doubles.assertIsNotPositive(someInfo(), -6d); } @Test public void should_succeed_since_actual_is_zero() { doubles.assertIsNotPositive(someInfo(), 0d); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6.0> to be less than or equal to:<0.0>"); doubles.assertIsNotPositive(someInfo(), 6d); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1.0> to be less than or equal to:<0.0> according to 'AbsValueComparator' comparator"); doublesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), -1d); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1.0> to be less than or equal to:<0.0> according to 'AbsValueComparator' comparator"); doublesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), 1d); } } Doubles_assertIsNotZero_Test.java000066400000000000000000000037471243020563200343410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNegative(AssertionInfo, Double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertIsNotZero_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { doubles.assertIsNotZero(someInfo(), 2.0); } @Test public void should_fail_since_actual_is_zero() { try { doubles.assertIsNotZero(someInfo(), 0.0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0.0> should not be equal to:<0.0>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 2.0d); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { doublesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0.0d); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0.0> should not be equal to:<0.0>"); } } } Doubles_assertIsPositive_Test.java000066400000000000000000000034751243020563200345410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsPositive(AssertionInfo, Double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertIsPositive_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_positive() { doubles.assertIsPositive(someInfo(), (double) 6); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6.0> to be greater than:<0.0>"); doubles.assertIsPositive(someInfo(), -6.0d); } @Test public void should_succeed_since_actual_is_positive_according_to_absolute_value_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), 6.0d); } @Test public void should_succeed_since_actual_is_positive_according_to_absolute_value_comparison_strategy2() { doublesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), -6.0d); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/Doubles_assertIsZero_Test.java000066400000000000000000000037261243020563200337340ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertIsNegative(AssertionInfo, Double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertIsZero_Test extends DoublesBaseTest { @Test public void should_succeed_since_actual_is_zero() { doubles.assertIsZero(someInfo(), 0.0d); } @Test public void should_fail_since_actual_is_not_zero() { try { doubles.assertIsZero(someInfo(), 2.0d); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0].0> but was:<[2].0>"); } } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { doublesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), 0.0d); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { doublesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), 2.0d); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0].0> but was:<[2].0>"); } } } Doubles_assertLessThanOrEqualTo_Test.java000066400000000000000000000063241243020563200357540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertLessThanOrEqualTo(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertLessThanOrEqualTo_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertLessThanOrEqualTo(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_less_than_other() { doubles.assertLessThanOrEqualTo(someInfo(), 6d, 8d); } @Test public void should_pass_if_actual_is_equal_to_other() { doubles.assertLessThanOrEqualTo(someInfo(), 6d, 6d); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { doubles.assertLessThanOrEqualTo(info, 8d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(8d, 6d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); doublesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6d, -8d); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), -6d, 6d); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, -8d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(-8d, 6d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Doubles_assertLessThan_Test.java000066400000000000000000000070351243020563200341600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertLessThan(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertLessThan_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertLessThan(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_less_than_other() { doubles.assertLessThan(someInfo(), 6d, 8d); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { doubles.assertLessThan(info, 6d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6d, 6d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { doubles.assertLessThan(info, 8d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8d, 6d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); doublesWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, 8d); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertLessThan(someInfo(), 6d, -8d); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertLessThan(info, 6d, -6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6d, -6d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertLessThan(info, -8d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(-8d, 6d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Doubles_assertNotEqual_Test.java000066400000000000000000000054321243020563200341660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/doubles/* * Created on Oct 28, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.doubles; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Doubles; import org.fest.assertions.internal.DoublesBaseTest; /** * Tests for {@link Doubles#assertNotEqual(AssertionInfo, Double, double)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Doubles_assertNotEqual_Test extends DoublesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); doubles.assertNotEqual(someInfo(), null, 8d); } @Test public void should_pass_if_doubles_are_not_equal() { doubles.assertNotEqual(someInfo(), 8d, 6d); } @Test public void should_fail_if_doubles_are_equal() { AssertionInfo info = someInfo(); try { doubles.assertNotEqual(info, 6d, 6d); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6d, 6d)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); doublesWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, 8d); } @Test public void should_pass_if_doubles_are_not_equal_according_to_custom_comparison_strategy() { doublesWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), 8d, 6d); } @Test public void should_fail_if_doubles_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { doublesWithAbsValueComparisonStrategy.assertNotEqual(info, 6d, -6d); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6d, -6d, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/failures/000077500000000000000000000000001243020563200261255ustar00rootroot00000000000000Failures_failure_with_AssertionErrorFactory_Test.java000066400000000000000000000046731243020563200406270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/failures/* * Created on Aug 7, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.failures; import static junit.framework.Assert.*; import static org.mockito.Mockito.*; import org.fest.assertions.core.*; import org.fest.assertions.description.Description; import org.fest.assertions.error.AssertionErrorFactory; import org.fest.assertions.internal.Failures; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link Failures#failure(AssertionInfo, AssertionErrorFactory)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class Failures_failure_with_AssertionErrorFactory_Test { private WritableAssertionInfo info; private AssertionErrorFactory errorFactory; private Failures failures; @Before public void setUp() { info = new WritableAssertionInfo(); errorFactory = mock(AssertionErrorFactory.class); failures = Failures.instance(); } @Test public void should_create_own_AssertionError_when_overriding_error_message_is_specified() { info.overridingErrorMessage("my message"); AssertionError failure = failures.failure(info, errorFactory); assertEquals("my message", failure.getMessage()); } @Test public void should_use_AssertionErrorFactory_when_overriding_error_message_is_not_specified() { MyOwnAssertionError expectedError = new MyOwnAssertionError("[description] my message"); Description description = new TestDescription("description"); info.description(description); when(errorFactory.newAssertionError(description)).thenReturn(expectedError); AssertionError failure = failures.failure(info, errorFactory); assertSame(expectedError, failure); } private static class MyOwnAssertionError extends AssertionError { private static final long serialVersionUID = 1L; MyOwnAssertionError(String message) { super(message); } } } Failures_failure_with_ErrorMessage_Test.java000066400000000000000000000042041243020563200367020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/failures/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.failures; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.*; import org.fest.assertions.core.*; import org.fest.assertions.description.Description; import org.fest.assertions.error.ErrorMessageFactory; import org.fest.assertions.internal.Failures; import org.fest.assertions.internal.TestDescription; import org.junit.*; /** * Tests for {@link Failures#failure(AssertionInfo, ErrorMessageFactory)}. * * @author Alex Ruiz */ public class Failures_failure_with_ErrorMessage_Test { private WritableAssertionInfo info; private ErrorMessageFactory errorMessage; private Failures failures; @Before public void setUp() { info = new WritableAssertionInfo(); errorMessage = mock(ErrorMessageFactory.class); failures = Failures.instance(); } @Test public void should_create_use_overriding_error_message_if_it_is_specified() { info.overridingErrorMessage("my message"); AssertionError failure = failures.failure(info, errorMessage); assertEquals("my message", failure.getMessage()); } @Test public void should_use_ErrorMessage_when_overriding_error_message_is_not_specified() { Description description = new TestDescription("description"); info.description(description); when(errorMessage.create(description)).thenReturn("[description] my message"); AssertionError failure = failures.failure(info, errorMessage); assertEquals("[description] my message", failure.getMessage()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/000077500000000000000000000000001243020563200254155ustar00rootroot00000000000000BinaryDiff_diff_File_byteArray_Test.java000066400000000000000000000065401243020563200351730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.fest.assertions.internal.BinaryDiff; import org.fest.assertions.internal.BinaryDiffResult; import org.fest.util.TextFileWriter; /** * Tests for {@link BinaryDiff#diff(java.io.File, byte[])}. * * @author Olivier Michallat * @author Joel Costigliola */ public class BinaryDiff_diff_File_byteArray_Test { private static final String LINE_SEPARATOR = System.getProperty("line.separator"); @Rule public TemporaryFolder folder = new TemporaryFolder(); private static BinaryDiff binaryDiff; private static TextFileWriter writer; @BeforeClass public static void setUpOnce() { binaryDiff = new BinaryDiff(); writer = TextFileWriter.instance(); } private File actual; private byte[] expected; @Before public void setUp() throws IOException { actual = folder.newFile("actual.txt"); } @Test public void should_return_no_diff_if_file_and_array_have_equal_content() throws IOException { writer.write(actual, "test"); // Note: writer inserts a new line after each line so we need it in our expected content expected = ("test" + LINE_SEPARATOR).getBytes(); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertTrue(result.hasNoDiff()); } @Test public void should_return_diff_if_inputstreams_differ_on_one_byte() throws IOException { writer.write(actual, "test"); expected = ("fest" + LINE_SEPARATOR).getBytes(); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(0, result.offset); assertEquals("0x74", result.actual); assertEquals("0x66", result.expected); } @Test public void should_return_diff_if_actual_is_shorter() throws IOException { writer.write(actual, "foo"); expected = ("foo" + LINE_SEPARATOR + "bar").getBytes(); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(3 + LINE_SEPARATOR.length(), result.offset); assertEquals("EOF", result.actual); assertEquals("0x62", result.expected); } @Test public void should_return_diff_if_expected_is_shorter() throws IOException { writer.write(actual, "foobar"); expected = "foo".getBytes(); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(3, result.offset); assertEquals("0x62", result.actual); assertEquals("EOF", result.expected); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Diff_diff_File_String_Test.java000066400000000000000000000065571243020563200334210ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertEquals; import static org.fest.util.Arrays.array; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.List; import org.fest.assertions.internal.Diff; import org.fest.util.TextFileWriter; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; /** * Tests for {@link Diff#diff(File, String, java.nio.charset.Charset)}. * * @author Olivier Michallat */ public class Diff_diff_File_String_Test { private static final Charset UTF8 = Charset.forName("UTF-8"); private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); @Rule public TemporaryFolder folder = new TemporaryFolder(); private static Diff diff; private static TextFileWriter writer; @BeforeClass public static void setUpOnce() { diff = new Diff(); writer = TextFileWriter.instance(); } private File actual; @Before public void setUp() throws IOException { actual = folder.newFile("actual.txt"); } @Test public void should_return_empty_diff_list_if_file_and_string_have_equal_content() throws IOException { String[] content = array("line0", "line1"); writer.write(actual, content); String expected = "line0\nline1"; List diffs = diff.diff(actual, expected, Charset.defaultCharset()); assertEquals(0, diffs.size()); } @Test public void should_return_diffs_if_file_and_string_do_not_have_equal_content() throws IOException { writer.write(actual, UTF8, "Touché"); String expected = "Touché"; List diffs = diff.diff(actual, expected, ISO_8859_1); assertEquals(1, diffs.size()); assertEquals("line:<0>, expected: but was:", diffs.get(0)); } @Test public void should_return_diffs_if_content_of_actual_is_shorter_than_content_of_expected() throws IOException { writer.write(actual, "line_0"); String expected = "line_0\nline_1"; List diffs = diff.diff(actual, expected, Charset.defaultCharset()); System.out.println(diffs); assertEquals(1, diffs.size()); assertEquals("line:<1>, expected: but was:", diffs.get(0)); } @Test public void should_return_diffs_if_content_of_actual_is_longer_than_content_of_expected() throws IOException { writer.write(actual, "line_0", "line_1"); String expected = "line_0"; List diffs = diff.diff(actual, expected, Charset.defaultCharset()); assertEquals(1, diffs.size()); assertEquals("line:<1>, expected: but was:", diffs.get(0)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Diff_diff_File_Test.java000066400000000000000000000062771243020563200320720ustar00rootroot00000000000000/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertEquals; import static org.fest.util.Arrays.array; import java.io.File; import java.io.IOException; import java.util.List; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.fest.assertions.internal.Diff; import org.fest.util.TextFileWriter; /** * Tests for {@link Diff#diff(File, File)}. * * @author Yvonne Wang */ public class Diff_diff_File_Test { @Rule public TemporaryFolder folder = new TemporaryFolder(); private static Diff diff; private static TextFileWriter writer; @BeforeClass public static void setUpOnce() { diff = new Diff(); writer = TextFileWriter.instance(); } private File actual; private File expected; @Before public void setUp() throws IOException { actual = folder.newFile("actual.txt"); expected = folder.newFile("expected.txt"); } @Test public void should_return_empty_diff_list_if_files_have_equal_content() throws IOException { String[] content = array("line0", "line1"); writer.write(actual, content); writer.write(expected, content); List diffs = diff.diff(actual, expected); assertEquals(0, diffs.size()); } @Test public void should_return_diffs_if_files_do_not_have_equal_content() throws IOException { writer.write(actual, "line_0", "line_1"); writer.write(expected, "line0", "line1"); List diffs = diff.diff(actual, expected); assertEquals(2, diffs.size()); assertEquals("line:<0>, expected: but was:", diffs.get(0)); assertEquals("line:<1>, expected: but was:", diffs.get(1)); } @Test public void should_return_diffs_if_content_of_actual_is_shorter_than_content_of_expected() throws IOException { writer.write(actual, "line_0"); writer.write(expected, "line_0", "line_1"); List diffs = diff.diff(actual, expected); assertEquals(1, diffs.size()); assertEquals("line:<1>, expected: but was:", diffs.get(0)); } @Test public void should_return_diffs_if_content_of_actual_is_longer_than_content_of_expected() throws IOException { writer.write(actual, "line_0", "line_1"); writer.write(expected, "line_0"); List diffs = diff.diff(actual, expected); assertEquals(1, diffs.size()); assertEquals("line:<1>, expected: but was:", diffs.get(0)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertCanRead_Test.java000066400000000000000000000041071243020563200331220ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeReadable.shouldBeReadable; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertCanRead(AssertionInfo, File)}. * * @author Olivier Demeijer * @author Joel Costigliola * */ public class Files_assertCanRead_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertCanRead(someInfo(), null); } @Test public void should_fail_if_can_not_read() { when(actual.canRead()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertCanRead(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeReadable(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_can_read() { when(actual.canRead()).thenReturn(true); files.assertCanRead(someInfo(), actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertCanWrite_Test.java000066400000000000000000000041201243020563200333340ustar00rootroot00000000000000/* * Created on Jul 05, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeWritable.shouldBeWritable; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertCanWrite(AssertionInfo, File)}. * * @author Olivier Demeijer * @author Joel Costigliola * */ public class Files_assertCanWrite_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertCanWrite(someInfo(), null); } @Test public void should_fail_if_can_not_write() { when(actual.canWrite()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertCanWrite(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeWritable(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_can_write() { when(actual.canWrite()).thenReturn(true); files.assertCanWrite(someInfo(), actual); } } Files_assertDoesNotExist_Test.java000066400000000000000000000042211243020563200341330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldNotExist.shouldNotExist; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertDoesNotExist(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertDoesNotExist_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertDoesNotExist(someInfo(), null); } @Test public void should_fail_if_actual_exists() { when(actual.exists()).thenReturn(true); AssertionInfo info = someInfo(); try { files.assertDoesNotExist(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotExist(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_exist() { when(actual.exists()).thenReturn(false); files.assertDoesNotExist(someInfo(), actual); } } Files_assertEqualContent_Test.java000066400000000000000000000104111243020563200341430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/* * Created on Jan 27, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.fail; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import static org.fest.assertions.error.ShouldHaveEqualContent.shouldHaveEqualContent; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; import org.fest.util.FilesException; /** * Tests for {@link Files#assertEqualContent(AssertionInfo, File, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertEqualContent_Test extends FilesBaseTest { private static File actual; private static File expected; @BeforeClass public static void setUpOnce() { actual = new File("src/test/resources/actual_file.txt"); expected = new File("src/test/resources/expected_file.txt"); } @Test public void should_throw_error_if_expected_is_null() { thrown.expectNullPointerException("The file to compare to should not be null"); files.assertEqualContent(someInfo(), actual, null); } @Test public void should_throw_error_if_expected_is_not_file() { thrown.expectIllegalArgumentException("Expected file:<'xyz'> should be an existing file"); File notAFile = new File("xyz"); files.assertEqualContent(someInfo(), actual, notAFile); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertEqualContent(someInfo(), null, expected); } @Test public void should_fail_if_actual_is_not_file() { AssertionInfo info = someInfo(); File notAFile = new File("xyz"); try { files.assertEqualContent(info, notAFile, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldBeFile(notAFile)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_files_have_equal_content() throws IOException { when(diff.diff(actual, expected)).thenReturn(new ArrayList()); files.assertEqualContent(someInfo(), actual, expected); } @Test public void should_throw_error_wrapping_catched_IOException() throws IOException { IOException cause = new IOException(); when(diff.diff(actual, expected)).thenThrow(cause); try { files.assertEqualContent(someInfo(), actual, expected); fail("Expected a FilesException to be thrown"); } catch (FilesException e) { assertSame(cause, e.getCause()); } } @Test public void should_fail_if_files_do_not_have_equal_content() throws IOException { List diffs = newArrayList("line:1, expected: but was:"); when(diff.diff(actual, expected)).thenReturn(diffs); AssertionInfo info = someInfo(); try { files.assertEqualContent(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveEqualContent(actual, expected, diffs)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertExists_Test.java000066400000000000000000000041521243020563200331040ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldExist.shouldExist; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertExists(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertExists_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertExists(someInfo(), null); } @Test public void should_fail_if_actual_does_not_exist() { when(actual.exists()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertExists(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldExist(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_exists() { when(actual.exists()).thenReturn(true); files.assertExists(someInfo(), actual); } } Files_assertHasBinaryContent_Test.java000066400000000000000000000101631243020563200347600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.fail; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import static org.fest.assertions.error.ShouldHaveBinaryContent.shouldHaveBinaryContent; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.BinaryDiffResult; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; import org.fest.util.FilesException; /** * Tests for {@link Files#assertHasBinaryContent(org.fest.assertions.core.WritableAssertionInfo, File, byte[])}. * * @author Olivier Michallat * @author Joel Costigliola */ public class Files_assertHasBinaryContent_Test extends FilesBaseTest { private static File actual; private static byte[] expected; @BeforeClass public static void setUpOnce() { // Does not matter if the values differ, the actual comparison is mocked in this test actual = new File("src/test/resources/actual_file.txt"); expected = new byte[] {}; } @Test public void should_throw_error_if_expected_is_null() { thrown.expectNullPointerException("The binary content to compare to should not be null"); files.assertHasBinaryContent(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertHasBinaryContent(someInfo(), null, expected); } @Test public void should_fail_if_actual_is_not_file() { AssertionInfo info = someInfo(); File notAFile = new File("xyz"); try { files.assertHasBinaryContent(info, notAFile, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldBeFile(notAFile)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_file_has_expected_binary_content() throws IOException { when(binaryDiff.diff(actual, expected)).thenReturn(BinaryDiffResult.noDiff()); files.assertHasBinaryContent(someInfo(), actual, expected); } @Test public void should_throw_error_wrapping_catched_IOException() throws IOException { IOException cause = new IOException(); when(binaryDiff.diff(actual, expected)).thenThrow(cause); try { files.assertHasBinaryContent(someInfo(), actual, expected); fail("Expected a FilesException to be thrown"); } catch (FilesException e) { assertSame(cause, e.getCause()); } } @Test public void should_fail_if_file_does_not_have_expected_binary_content() throws IOException { BinaryDiffResult diff = new BinaryDiffResult(15, (byte) 0xCA, (byte) 0xFE); when(binaryDiff.diff(actual, expected)).thenReturn(diff); AssertionInfo info = someInfo(); try { files.assertHasBinaryContent(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveBinaryContent(actual, diff)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertHasContent_Test.java000066400000000000000000000103401243020563200336670ustar00rootroot00000000000000/* * Created on Jul 21, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.fail; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import static org.fest.assertions.error.ShouldHaveContent.shouldHaveContent; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; import org.fest.util.FilesException; /** * Tests for {@link Files#assertHasContent(AssertionInfo, File, String, Charset)}. * * @author Olivier Michallat * @author Joel Costigliola */ public class Files_assertHasContent_Test extends FilesBaseTest { private static File actual; private static String expected; private static Charset charset; @BeforeClass public static void setUpOnce() { // Does not matter if the values differ, the actual comparison is mocked in this test actual = new File("src/test/resources/actual_file.txt"); expected = "xyz"; charset = Charset.defaultCharset(); } @Test public void should_throw_error_if_expected_is_null() { thrown.expectNullPointerException("The text to compare to should not be null"); files.assertHasContent(someInfo(), actual, null, charset); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertHasContent(someInfo(), null, expected, charset); } @Test public void should_fail_if_actual_is_not_file() { AssertionInfo info = someInfo(); File notAFile = new File("xyz"); try { files.assertHasContent(info, notAFile, expected, charset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeFile(notAFile)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_file_has_text_content() throws IOException { when(diff.diff(actual, expected, charset)).thenReturn(new ArrayList()); files.assertHasContent(someInfo(), actual, expected, charset); } @Test public void should_throw_error_wrapping_catched_IOException() throws IOException { IOException cause = new IOException(); when(diff.diff(actual, expected, charset)).thenThrow(cause); try { files.assertHasContent(someInfo(), actual, expected, charset); fail("Expected a FilesException to be thrown"); } catch (FilesException e) { assertSame(cause, e.getCause()); } } @Test public void should_fail_if_file_does_not_have_expected_text_content() throws IOException { List diffs = newArrayList("line:1, expected: but was:"); when(diff.diff(actual, expected, charset)).thenReturn(diffs); AssertionInfo info = someInfo(); try { files.assertHasContent(info, actual, expected, charset); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveContent(actual, charset, diffs)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertIsAbsolute_Test.java000066400000000000000000000042611243020563200337000ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeAbsolutePath.shouldBeAbsolutePath; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertIsAbsolute(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertIsAbsolute_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertIsAbsolute(someInfo(), null); } @Test public void should_fail_if_actual_is_not_absolute_path() { when(actual.isAbsolute()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertIsAbsolute(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAbsolutePath(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_absolute_path() { when(actual.isAbsolute()).thenReturn(true); files.assertIsAbsolute(someInfo(), actual); } } Files_assertIsDirectory_Test.java000066400000000000000000000042471243020563200340130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeDirectory.shouldBeDirectory; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertIsDirectory(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertIsDirectory_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertIsDirectory(someInfo(), null); } @Test public void should_fail_if_actual_is_not_directory() { when(actual.isDirectory()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertIsDirectory(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeDirectory(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_directory() { when(actual.isDirectory()).thenReturn(true); files.assertIsDirectory(someInfo(), actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertIsFile_Test.java000066400000000000000000000041531243020563200330010ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeFile.shouldBeFile; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertIsFile(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertIsFile_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertIsFile(someInfo(), null); } @Test public void should_fail_if_actual_is_not_file() { when(actual.isFile()).thenReturn(false); AssertionInfo info = someInfo(); try { files.assertIsFile(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeFile(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_file() { when(actual.isFile()).thenReturn(true); files.assertIsFile(someInfo(), actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/files/Files_assertIsRelative_Test.java000066400000000000000000000042611243020563200336750ustar00rootroot00000000000000/* * Created on Jan 29, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.files; import static org.fest.assertions.error.ShouldBeRelativePath.shouldBeRelativePath; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.File; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Files; import org.fest.assertions.internal.FilesBaseTest; /** * Tests for {@link Files#assertIsRelative(AssertionInfo, File)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Files_assertIsRelative_Test extends FilesBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); files.assertIsRelative(someInfo(), null); } @Test public void should_fail_if_actual_is_not_relative_path() { when(actual.isAbsolute()).thenReturn(true); AssertionInfo info = someInfo(); try { files.assertIsRelative(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeRelativePath(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_relative_path() { when(actual.isAbsolute()).thenReturn(false); files.assertIsRelative(someInfo(), actual); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/000077500000000000000000000000001243020563200266425ustar00rootroot00000000000000FloatArrays_assertContainsOnly_Test.java000066400000000000000000000134151243020563200366020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertContainsOnly(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertContainsOnly_Test extends FloatArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6f, 8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10f, 8f, 6f)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6f, 8f, 10f, 8f, 8f, 8f); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6f, 8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6f, 8f, 10f, 6f, 8f, 10f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(6f)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); float[] expected = { 6f, 8f, 20f }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20f), newLinkedHashSet(10f))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6f, -8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10f, -8f, 6f)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6f, -8f, 10f, -8f, -8f, -8f); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6f, -8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6f, -8f, 10f, 6f, -8f, 10f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(6f)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] expected = { 6f, -8f, 20f }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20f), newLinkedHashSet(10f), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertContainsSequence_Test.java000066400000000000000000000146541243020563200374370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertContainsSequence(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertContainsSequence_Test extends FloatArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6f, 8f, 10f, 12f); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8f)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 8f, 10f, 12f, 20f, 22f }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f, 22f }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6f, 8f)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6f, 8f, 10f, 12f)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8f)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, -8f, 10f, 12f, 20f, 22f }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f, 22f }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6f, -8f)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6f, -8f, 10f, 12f)); } } FloatArrays_assertContains_Test.java000066400000000000000000000135421243020563200357410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertContains(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertContains_Test extends FloatArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6f)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8f, 10f)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6f, 8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6f, 8f, 10f, 10f, 8f); arrays.assertContains(someInfo(), actual, arrayOf(8f)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6f, 6f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8f)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); float[] expected = { 6f, 8f, 9f }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9f))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6f)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8f, 10f)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6f, -8f, 10f)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6f, -8f, 10f, 10f, -8f); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8f)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6f, 6f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(-8f)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] expected = { 6f, -8f, 9f }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9f), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertContains_at_Index_Test.java000066400000000000000000000112221243020563200375450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertContains(AssertionInfo, float[], float, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertContains_at_Index_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, 8f, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), 8f, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, 8f, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, 8f, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { float value = 6f; AssertionInfo info = someInfo(); Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, 8f, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, -8f, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), -8f, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8f, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8f, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { float value = 6f; AssertionInfo info = someInfo(); Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8f, atIndex(1)); } } FloatArrays_assertDoesNotContain_Test.java000066400000000000000000000114361243020563200370520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertDoesNotContain(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertDoesNotContain_Test extends FloatArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12f)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12f, 12f, 20f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8f)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); float[] expected = { 6f, 8f, 20f }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6f, 8f))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12f)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12f, 12f, 20f)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8f)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] expected = { 6f, -8f, 20f }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6f, -8f), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000105621243020563200406640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertDoesNotContain(AssertionInfo, float[], float, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertDoesNotContain_at_Index_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, 8f, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, 6f, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), 8f, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, 8f, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, 8f, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, 6f, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6f, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, -8f, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 6f, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), -8f, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8f, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8f, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, 6f, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6f, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072501243020563200403570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertDoesNotHaveDuplicates(AssertionInfo, float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertDoesNotHaveDuplicates_Test extends FloatArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6f, 8f); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6f, 8f, 6f, 8f); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6f, 8f))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6f, -8f, 6f, -8f); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6f, -8f), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertEmpty_Test.java000066400000000000000000000040461243020563200352600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertEmpty(AssertionInfo, float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertEmpty_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); float[] actual = { 6f, 8f }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } FloatArrays_assertEndsWith_Test.java000066400000000000000000000143561243020563200357140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertEndsWith(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertEndsWith_Test extends FloatArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6f, 8f, 10f, 12f); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8f)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 8f, 10f, 12f, 20f, 22f }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); float[] sequence = { 20f, 22f }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f, 22f }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8f, 10f, 12f)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6f, 8f, 10f, 12f)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8f)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, -8f, 10f, 12f, 20f, 22f }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 20f, 22f }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f, 22f }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8f, 10f, 12f)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6f, -8f, 10f, 12f)); } } FloatArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044251243020563200410140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class FloatArrays_assertHasSameSizeAs_with_Array_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia", "Luke")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } FloatArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045351243020563200414670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class FloatArrays_assertHasSameSizeAs_with_Iterable_Test extends FloatArraysBaseTest { private final List other = newArrayList("Solo", "Leia", "Luke"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } FloatArrays_assertHasSize_Test.java000066400000000000000000000040371243020563200355300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertHasSize(AssertionInfo, float[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertHasSize_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 4); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 4)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } FloatArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000072061243020563200420640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertIsSortedAccordingToComparator(AssertionInfo, float[], Comparator)} * * @author Joel Costigliola */ public class FloatArrays_assertIsSortedAccordingToComparator_Test extends FloatArraysBaseTest { private Comparator floatDescendingOrderComparator; private Comparator floatSquareComparator; @Override @Before public void setUp() { super.setUp(); actual = new float[] { 4.0f, 3.0f, 2.0f, 2.0f, 1.0f }; floatDescendingOrderComparator = new Comparator() { public int compare(Float float1, Float float2) { return -float1.compareTo(float2); } }; floatSquareComparator = new Comparator() { public int compare(Float float1, Float float2) { return new Float(float1 * float1).compareTo(new Float(float2 * float2)); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, floatDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), floatDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), floatSquareComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, floatDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new float[] { 3.0f, 2.0f, 1.0f, 9.0f }; try { arrays.assertIsSortedAccordingToComparator(info, actual, floatDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, floatDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertIsSorted_Test.java000066400000000000000000000076221243020563200357210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0f (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0f * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class FloatArrays_assertIsSorted_Test extends FloatArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(1.0f, 2.0f, 3.0f, 4.0f, 4.0f); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1.0f)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (float[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1.0f, 3.0f, 2.0f); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = arrayOf(-1.0f, 2.0f, -3.0f, 4.0f, -4.0f); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1.0f)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (float[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1.0f, 3.0f, 2.0f); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } FloatArrays_assertNotEmpty_Test.java000066400000000000000000000040231243020563200357340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertNotEmpty(AssertionInfo, float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertNotEmpty_Test extends FloatArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8f)); } } FloatArrays_assertNullOrEmpty_Test.java000066400000000000000000000037701243020563200364170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.FloatArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertNullOrEmpty(AssertionInfo, float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertNullOrEmpty_Test extends FloatArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); float[] actual = { 6f, 8f }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } FloatArrays_assertStartsWith_Test.java000066400000000000000000000145101243020563200362730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floatarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floatarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.FloatArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.FloatArrays; import org.fest.assertions.internal.FloatArraysBaseTest; /** * Tests for {@link FloatArrays#assertStartsWith(AssertionInfo, float[], float[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class FloatArrays_assertStartsWith_Test extends FloatArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6f, 8f, 10f, 12f); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(6f)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { float[] sequence = { 6f, 8f, 10f, 12f, 20f, 22f }; try { AssertionInfo inof = someInfo(); arrays.assertStartsWith(inof, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); float[] sequence = { 8f, 10f }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6f, 8f, 10f)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6f, 8f, 10f, 12f)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(6f)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { float[] sequence = { 6f, -8f, 10f, 12f, 20f, 22f }; try { AssertionInfo inof = someInfo(); arraysWithCustomComparisonStrategy.assertStartsWith(inof, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { -8f, 10f }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); float[] sequence = { 6f, 20f }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(someInfo(), shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6f, -8f, 10f)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6f, -8f, 10f, 12f)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/000077500000000000000000000000001243020563200256035ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_NaN_Test.java000066400000000000000000000020771243020563200314370ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#NaN()}. * * @author Joel Costigliola */ public class Floats_NaN_Test extends FloatsBaseTest { @Test public void check_float_NaN_method() { assertEquals(Float.NaN, NaN(), 0d); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertEqual_Test.java000066400000000000000000000053451243020563200332550ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertEqual(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertEqual_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertEqual(someInfo(), null, 8f); } @Test public void should_pass_if_floats_are_equal() { floats.assertEqual(someInfo(), 8f, 8f); } @Test public void should_fail_if_floats_are_not_equal() { AssertionInfo info = someInfo(); try { floats.assertEqual(info, 6f, 8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, 8f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, 8f); } @Test public void should_pass_if_floats_are_equal_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), -8f, 8f); } @Test public void should_fail_if_floats_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertEqual(info, 6f, -8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, -8f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Floats_assertEqual_float_with_offset_Test.java000066400000000000000000000115461243020563200367640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.api.Assertions.*; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.offsetIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertEqual(AssertionInfo, Float, float, Offset)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertEqual_float_with_offset_Test extends FloatsBaseTest { @Test public void should_throw_error_if_offset_is_null() { thrown.expectNullPointerException(offsetIsNull()); floats.assertEqual(someInfo(), new Float(8f), 8f, null); } @Test public void should_pass_if_floats_are_equal() { floats.assertEqual(someInfo(), new Float(8f), 8f, offset(1f)); } @Test public void should_pass_if_floats_are_equal_within_offset() { floats.assertEqual(someInfo(), new Float(6f), 8f, offset(2f)); } @Test public void should_fail_if_floats_are_not_equal_within_offset() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floats.assertEqual(info, new Float(6f), 8f, offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, 8f, offset, 2f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_first_float_is_null_but_not_the_second() { thrown.expectAssertionError(actualIsNull()); floats.assertEqual(someInfo(), null, 8f, offset(1f)); } @Test public void should_fail_if_second_float_is_null_but_not_the_first() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floats.assertEqual(info, 6f, null, offset); failBecauseExceptionWasNotThrown(NullPointerException.class); } catch (NullPointerException e) { assertThat(e).hasMessage("The given number should not be null"); } } @Test public void should_throw_error_if_offset_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(offsetIsNull()); floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(8f), 8f, null); } @Test public void should_pass_if_floats_are_equal_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(8f), 8f, offset(1f)); } @Test public void should_pass_if_floats_are_equal_within_offset_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(6f), 8f, offset(2f)); } @Test public void should_fail_if_floats_are_not_equal_within_offset_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floatsWithAbsValueComparisonStrategy.assertEqual(info, new Float(6f), 8f, offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, 8f, offset, 2f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_first_float_is_null_but_not_the_second_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, 8f, offset(1f)); } @Test public void should_fail_if_second_float_is_null_but_not_the_first_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floatsWithAbsValueComparisonStrategy.assertEqual(info, 6f, null, offset); failBecauseExceptionWasNotThrown(NullPointerException.class); } catch (NullPointerException e) { assertThat(e).hasMessage("The given number should not be null"); } } } Floats_assertEqual_with_offset_Test.java000066400000000000000000000070261243020563200355750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.data.Offset.offset; import static org.fest.assertions.error.ShouldBeEqualWithinOffset.shouldBeEqual; import static org.fest.assertions.test.ErrorMessages.offsetIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Offset; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertEqual(AssertionInfo, Float, Float, Offset)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertEqual_with_offset_Test extends FloatsBaseTest { @Test public void should_throw_error_if_offset_is_null() { thrown.expectNullPointerException(offsetIsNull()); floats.assertEqual(someInfo(), new Float(8f), new Float(8f), null); } @Test public void should_pass_if_floats_are_equal() { floats.assertEqual(someInfo(), new Float(8f), new Float(8f), offset(1f)); } @Test public void should_pass_if_floats_are_equal_within_offset() { floats.assertEqual(someInfo(), new Float(6f), new Float(8f), offset(2f)); } @Test public void should_fail_if_floats_are_not_equal_within_offset() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floats.assertEqual(info, new Float(6f), new Float(8f), offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, 8f, offset, 2f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_offset_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(offsetIsNull()); floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(8f), new Float(8f), null); } @Test public void should_pass_if_floats_are_equal_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(8f), new Float(8f), offset(1f)); } @Test public void should_pass_if_floats_are_equal_within_offset_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertEqual(someInfo(), new Float(6f), new Float(8f), offset(2f)); } @Test public void should_fail_if_floats_are_not_equal_within_offset_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Offset offset = offset(1f); try { floatsWithAbsValueComparisonStrategy.assertEqual(info, new Float(6f), new Float(8f), offset); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6f, 8f, offset, 2f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Floats_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000066401243020563200361260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertGreaterThanOrEqualTo(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertGreaterThanOrEqualTo_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertGreaterThanOrEqualTo(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_greater_than_other() { floats.assertGreaterThanOrEqualTo(someInfo(), 8f, 6f); } @Test public void should_pass_if_actual_is_equal_to_other() { floats.assertGreaterThanOrEqualTo(someInfo(), 6f, 6f); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { floats.assertGreaterThanOrEqualTo(info, 6f, 8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6f, 8f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -8f, 6f); floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), 8f, 6f); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -6f, 6f); floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), 6f, 6f); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, 6f, -8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6f, -8f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Floats_assertGreaterThan_Test.java000066400000000000000000000071661243020563200343360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertGreaterThan(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertGreaterThan_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertGreaterThan(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_greater_than_other() { floats.assertGreaterThan(someInfo(), 8f, 6f); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { floats.assertGreaterThan(info, 6f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6f, 6f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { floats.assertGreaterThan(info, 6f, 8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6f, 8f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), -8f, 6f); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertGreaterThan(info, -6f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6f, 6f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertGreaterThan(info, -6f, 8f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6f, 8f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertIsNaN_Test.java000066400000000000000000000037521243020563200331560ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNaN(AssertionInfo, Float)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Floats_assertIsNaN_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_equal_to_NaN() { floats.assertIsNaN(someInfo(), Float.NaN); } @Test public void should_fail_since_actual_is_not_equal_to_NaN() { try { floats.assertIsNaN(someInfo(), 6.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[NaN]f> but was:<[6.0]f>"); } } @Test public void should_succeed_since_actual_is_equal_to_NaN_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertIsNaN(someInfo(), Float.NaN); } @Test public void should_fail_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { try { floatsWithAbsValueComparisonStrategy.assertIsNaN(someInfo(), 6.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[NaN]f> but was:<[6.0]f>"); } } }Floats_assertIsNegative_Test.java000066400000000000000000000037721243020563200341670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNegative(AssertionInfo, Float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertIsNegative_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_negative() { floats.assertIsNegative(someInfo(), (float) -6); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6.0f> to be less than:<0.0f>"); floats.assertIsNegative(someInfo(), 6.0f); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy() { thrown.expectAssertionError("expected:<-6.0f> to be less than:<0.0f> according to 'AbsValueComparator' comparator"); floatsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (float) -6); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy2() { thrown.expectAssertionError("expected:<6.0f> to be less than:<0.0f>"); floatsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), 6.0f); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertIsNotNaN_Test.java000066400000000000000000000037621243020563200336400ustar00rootroot00000000000000/* * Created on Jan 14, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNotNan(AssertionInfo, Float)}. * * @author Yvonne Wang * @author Joel Costigliola */ public class Floats_assertIsNotNaN_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_not_equal_to_NaN() { floats.assertIsNotNaN(someInfo(), 6f); } @Test public void should_fail_since_actual_is_not_equal_to_NaN() { try { floats.assertIsNotNaN(someInfo(), 6f); } catch (AssertionError e) { assertEquals(e.getMessage(), "<6.0> should not be equal to:"); } } @Test public void should_succeed_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertIsNotNaN(someInfo(), 6f); } @Test public void should_fail_since_actual_is_not_equal_to_NaN_whatever_custom_comparison_strategy_is() { try { floatsWithAbsValueComparisonStrategy.assertIsNotNaN(someInfo(), 6f); } catch (AssertionError e) { assertEquals(e.getMessage(), "<6.0> should not be equal to:"); } } }Floats_assertIsNotNegative_Test.java000066400000000000000000000035111243020563200346370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNotNegative(AssertionInfo, Float))}. * * @author Nicolas François */ public class Floats_assertIsNotNegative_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { floats.assertIsNotNegative(someInfo(), 6f); } @Test public void should_succeed_since_actual_is_zero() { floats.assertIsNotNegative(someInfo(), 0f); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6.0f> to be greater than or equal to:<0.0f>"); floats.assertIsNotNegative(someInfo(), -6f); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), -1f); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), 1f); } } Floats_assertIsNotPositive_Test.java000066400000000000000000000041461243020563200347040ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNotPositive(org.fest.assertions.core.AssertionInfo, Float))}. * * @author Nicolas François */ public class Floats_assertIsNotPositive_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { floats.assertIsNotPositive(someInfo(), -6f); } @Test public void should_succeed_since_actual_is_zero() { floats.assertIsNotPositive(someInfo(), 0f); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6.0f> to be less than or equal to:<0.0f>"); floats.assertIsNotPositive(someInfo(), 6f); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown .expectAssertionError("expected:<-1.0f> to be less than or equal to:<0.0f> according to 'AbsValueComparator' comparator"); floatsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), -1f); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown .expectAssertionError("expected:<1.0f> to be less than or equal to:<0.0f> according to 'AbsValueComparator' comparator"); floatsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), 1f); } } Floats_assertIsNotZero_Test.java000066400000000000000000000037421243020563200340220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNegative(AssertionInfo, Float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertIsNotZero_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { floats.assertIsNotZero(someInfo(), 2.0f); } @Test public void should_fail_since_actual_is_zero() { try { floats.assertIsNotZero(someInfo(), 0.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0.0f> should not be equal to:<0.0f>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 2.0f); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { floatsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0.0f> should not be equal to:<0.0f>"); } } } Floats_assertIsPositive_Test.java000066400000000000000000000034661243020563200342270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Ungreater required by applicable law or agreed to in writing, software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific * language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsPositive(AssertionInfo, Float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertIsPositive_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_positive() { floats.assertIsPositive(someInfo(), 6.0f); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6.0f> to be greater than:<0.0f>"); floats.assertIsPositive(someInfo(), -6.0f); } @Test public void should_succeed_since_actual_is_positive_according_to_absolute_value_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (float) 6); } @Test public void should_succeed_since_actual_is_positive_according_to_absolute_value_comparison_strategy2() { floatsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), -6.0f); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertIsZero_Test.java000066400000000000000000000037171243020563200334220ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertIsNegative(AssertionInfo, Float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertIsZero_Test extends FloatsBaseTest { @Test public void should_succeed_since_actual_is_zero() { floats.assertIsZero(someInfo(), 0.0f); } @Test public void should_fail_since_actual_is_not_zero() { try { floats.assertIsZero(someInfo(), 2.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0].0f> but was:<[2].0f>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { floatsWithAbsValueComparisonStrategy.assertIsZero(someInfo(), 0.0f); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { floatsWithAbsValueComparisonStrategy.assertIsZero(someInfo(), 2.0f); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0].0f> but was:<[2].0f>"); } } } Floats_assertLessThanOrEqualTo_Test.java000066400000000000000000000063041243020563200354400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertLessThanOrEqualTo(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertLessThanOrEqualTo_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertLessThanOrEqualTo(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_less_than_other() { floats.assertLessThanOrEqualTo(someInfo(), 6f, 8f); } @Test public void should_pass_if_actual_is_equal_to_other() { floats.assertLessThanOrEqualTo(someInfo(), 6f, 6f); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { floats.assertLessThanOrEqualTo(info, 8f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(8f, 6f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6f, -8f); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6f, -6f); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, -8f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(-8f, 6f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertLessThan_Test.java000066400000000000000000000070151243020563200337230ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertLessThan(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertLessThan_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertLessThan(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_less_than_other() { floats.assertLessThan(someInfo(), 6f, 8f); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { floats.assertLessThan(info, 6f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6f, 6f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { floats.assertLessThan(info, 8f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8f, 6f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, 8f); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), 6f, -8f); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertLessThan(info, 6f, -6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6f, -6f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertLessThan(info, -8f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(-8f, 6f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/floats/Floats_assertNotEqual_Test.java000066400000000000000000000054101243020563200337270ustar00rootroot00000000000000/* * Created on Oct 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.floats; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Floats; import org.fest.assertions.internal.FloatsBaseTest; /** * Tests for {@link Floats#assertNotEqual(AssertionInfo, Float, float)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Floats_assertNotEqual_Test extends FloatsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); floats.assertNotEqual(someInfo(), null, 8f); } @Test public void should_pass_if_floats_are_not_equal() { floats.assertNotEqual(someInfo(), 8f, 6f); } @Test public void should_fail_if_floats_are_equal() { AssertionInfo info = someInfo(); try { floats.assertNotEqual(info, 6f, 6f); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6f, 6f)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); floatsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, 8f); } @Test public void should_pass_if_floats_are_not_equal_according_to_custom_comparison_strategy() { floatsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), 8f, 6f); } @Test public void should_fail_if_floats_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { floatsWithAbsValueComparisonStrategy.assertNotEqual(info, 6f, -6f); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6f, -6f, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/inputstreams/000077500000000000000000000000001243020563200270515ustar00rootroot00000000000000BinaryDiff_diff_InputStream_Test.java000066400000000000000000000061411243020563200361760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/inputstreams/* * Created on Jul 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.inputstreams; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.internal.BinaryDiff; import org.fest.assertions.internal.BinaryDiffResult; /** * Tests for {@link BinaryDiff#diff(java.io.InputStream, java.io.InputStream)}. * * @author Olivier Michallat */ public class BinaryDiff_diff_InputStream_Test { private static BinaryDiff binaryDiff; @BeforeClass public static void setUpOnce() { binaryDiff = new BinaryDiff(); } private InputStream actual; private InputStream expected; @Test public void should_return_no_diff_if_inputstreams_have_equal_content() throws IOException { actual = stream(0xCA, 0xFE, 0xBA, 0xBE); expected = stream(0xCA, 0xFE, 0xBA, 0xBE); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertTrue(result.hasNoDiff()); } @Test public void should_return_diff_if_inputstreams_differ_on_one_byte() throws IOException { actual = stream(0xCA, 0xFE, 0xBA, 0xBE); expected = stream(0xCA, 0xFE, 0xBE, 0xBE); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(2, result.offset); assertEquals("0xBA", result.actual); assertEquals("0xBE", result.expected); } @Test public void should_return_diff_if_actual_is_shorter() throws IOException { actual = stream(0xCA, 0xFE, 0xBA); expected = stream(0xCA, 0xFE, 0xBA, 0xBE); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(3, result.offset); assertEquals("EOF", result.actual); assertEquals("0xBE", result.expected); } @Test public void should_return_diff_if_expected_is_shorter() throws IOException { actual = stream(0xCA, 0xFE, 0xBA, 0xBE); expected = stream(0xCA, 0xFE, 0xBA); BinaryDiffResult result = binaryDiff.diff(actual, expected); assertEquals(3, result.offset); assertEquals("0xBE", result.actual); assertEquals("EOF", result.expected); } private InputStream stream(int... contents) { byte[] byteContents = new byte[contents.length]; for (int i = 0; i < contents.length; i++) { byteContents[i] = (byte) contents[i]; } return new ByteArrayInputStream(byteContents); } } Diff_diff_InputStream_Test.java000066400000000000000000000064201243020563200350310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/inputstreams/* * Created on Jan 28, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.inputstreams; import static junit.framework.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.internal.Diff; /** * Tests for {@link Diff#diff(InputStream, InputStream)}. * * @author Matthieu Baechler */ public class Diff_diff_InputStream_Test { private final static String LINE_SEPARATOR = System.getProperty("line.separator"); private static Diff diff; @BeforeClass public static void setUpOnce() { diff = new Diff(); } private InputStream actual; private InputStream expected; private InputStream stream(String... lines) throws UnsupportedEncodingException { StringBuilder stringBuilder = new StringBuilder(); for (String line : lines) { stringBuilder.append(line).append(LINE_SEPARATOR); } return new ByteArrayInputStream(stringBuilder.toString().getBytes("ASCII")); } @Test public void should_return_empty_diff_list_if_inputstreams_have_equal_content() throws IOException { actual = stream("base", "line0", "line1"); expected = stream("base", "line0", "line1"); List diffs = diff.diff(actual, expected); assertEquals(0, diffs.size()); } @Test public void should_return_diffs_if_inputstreams_do_not_have_equal_content() throws IOException { actual = stream("base", "line_0", "line_1"); expected = stream("base", "line0", "line1"); List diffs = diff.diff(actual, expected); assertEquals(2, diffs.size()); assertEquals("line:<1>, expected: but was:", diffs.get(0)); assertEquals("line:<2>, expected: but was:", diffs.get(1)); } @Test public void should_return_diffs_if_content_of_actual_is_shorter_than_content_of_expected() throws IOException { actual = stream("base", "line_0"); expected = stream("base", "line_0", "line_1"); List diffs = diff.diff(actual, expected); assertEquals(1, diffs.size()); assertEquals("line:<2>, expected: but was:", diffs.get(0)); } @Test public void should_return_diffs_if_content_of_actual_is_longer_than_content_of_expected() throws IOException { actual = stream("base", "line_0", "line_1"); expected = stream("base", "line_0"); List diffs = diff.diff(actual, expected); assertEquals(1, diffs.size()); assertEquals("line:<2>, expected: but was:", diffs.get(0)); } } InputStreams_assertEqualContent_Test.java000066400000000000000000000066301243020563200372030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/inputstreams/* * Created on Jan 27, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.internal.inputstreams; import static junit.framework.Assert.assertSame; import static junit.framework.Assert.fail; import static org.fest.assertions.error.ShouldHaveEqualContent.shouldHaveEqualContent; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.InputStreams; import org.fest.assertions.internal.InputStreamsBaseTest; import org.fest.assertions.internal.InputStreamsException; /** * Tests for {@link InputStreams#assertEqualContent(AssertionInfo, InputStream, InputStream)}. * * @author Matthieu Baechler */ public class InputStreams_assertEqualContent_Test extends InputStreamsBaseTest { @Test public void should_throw_error_if_expected_is_null() { thrown.expectNullPointerException("The InputStream to compare to should not be null"); inputStreams.assertEqualContent(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); inputStreams.assertEqualContent(someInfo(), null, expected); } @Test public void should_pass_if_inputstreams_have_equal_content() throws IOException { when(diff.diff(actual, expected)).thenReturn(new ArrayList()); inputStreams.assertEqualContent(someInfo(), actual, expected); } @Test public void should_throw_error_wrapping_catched_IOException() throws IOException { IOException cause = new IOException(); when(diff.diff(actual, expected)).thenThrow(cause); try { inputStreams.assertEqualContent(someInfo(), actual, expected); fail("Expected a InputStreamsException to be thrown"); } catch (InputStreamsException e) { assertSame(cause, e.getCause()); } } @Test public void should_fail_if_inputstreams_do_not_have_equal_content() throws IOException { List diffs = newArrayList("line:1, expected: but was:"); when(diff.diff(actual, expected)).thenReturn(diffs); AssertionInfo info = someInfo(); try { inputStreams.assertEqualContent(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveEqualContent(actual, expected, diffs)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/000077500000000000000000000000001243020563200263275ustar00rootroot00000000000000IntArrays_assertContainsOnly_Test.java000066400000000000000000000133021243020563200357470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertContainsOnly(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertContainsOnly_Test extends IntArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10, 8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6, 8, 10, 8, 8, 8); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10, 6, 8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); int[] expected = { 6, 8, 20 }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20), newLinkedHashSet(10))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10, -8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, -8, 10, -8, -8, -8); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10, 6, -8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20), newLinkedHashSet(10), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertContainsSequence_Test.java000066400000000000000000000145461243020563200366110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertContainsSequence(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertContainsSequence_Test extends IntArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); int[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } IntArrays_assertContains_Test.java000066400000000000000000000134461243020563200351160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertContains(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertContains_Test extends IntArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6, 8, 10, 10, 8); arrays.assertContains(someInfo(), actual, arrayOf(8)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6, 6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); int[] expected = { 6, 8, 9 }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, -8, 10, 10, -8); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, 6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] expected = { 6, -8, 9 }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertContains_at_Index_Test.java000066400000000000000000000110701243020563200367200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertContains(AssertionInfo, int[], int, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertContains_at_Index_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, 8, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, 8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, 8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arrays.assertContains(info, actual, 6, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, 6, index, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, 8, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, -8, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), -8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, 6, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, 6, index, 8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8, atIndex(1)); } } IntArrays_assertDoesNotContain_Test.java000066400000000000000000000113641243020563200362240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertDoesNotContain(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertDoesNotContain_Test extends IntArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); int[] expected = { 6, 8, 20 }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6, 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6, -8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000105221243020563200400320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertDoesNotContain(AssertionInfo, int[], int, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertDoesNotContain_at_Index_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, 8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, 8, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, 8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, 6, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, -8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), -8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, 6, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072101243020563200375250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertDoesNotHaveDuplicates(AssertionInfo, int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertDoesNotHaveDuplicates_Test extends IntArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6, 8, 6, 8); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6, 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6, -8, 6, 8); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6, 8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertEmpty_Test.java000066400000000000000000000040221243020563200344240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertEmpty(AssertionInfo, int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertEmpty_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); int[] actual = { 6, 8 }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } IntArrays_assertEndsWith_Test.java000066400000000000000000000142461243020563200350640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertEndsWith(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertEndsWith_Test extends IntArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); int[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); int[] sequence = { 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } IntArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044011243020563200401600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class IntArrays_assertHasSameSizeAs_with_Array_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } IntArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045211243020563200406340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class IntArrays_assertHasSameSizeAs_with_Iterable_Test extends IntArraysBaseTest { private final List other = newArrayList("Solo", "Leia", "Luke"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } IntArrays_assertHasSize_Test.java000066400000000000000000000040211243020563200346730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertHasSize(AssertionInfo, int[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertHasSize_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 2); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } IntArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000071031243020563200412320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertIsSortedAccordingToComparator(AssertionInfo, int[], Comparator)} * * @author Joel Costigliola */ public class IntArrays_assertIsSortedAccordingToComparator_Test extends IntArraysBaseTest { private Comparator intDescendingOrderComparator; private Comparator intSquareComparator; @Override @Before public void setUp() { super.setUp(); actual = new int[] { 4, 3, 2, 2, 1 }; intDescendingOrderComparator = new Comparator() { public int compare(Integer int1, Integer int2) { return -int1.compareTo(int2); } }; intSquareComparator = new Comparator() { public int compare(Integer int1, Integer int2) { return new Integer(int1 * int1).compareTo(new Integer(int2 * int2)); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, intDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), intDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), intSquareComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, intDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new int[] { 3, 2, 1, 9 }; try { arrays.assertIsSortedAccordingToComparator(info, actual, intDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, intDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertIsSorted_Test.java000066400000000000000000000075071243020563200350750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class IntArrays_assertIsSorted_Test extends IntArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(1, 2, 3, 4, 4); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (int[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = arrayOf(1, -2, 3, 4, -4); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (int[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } IntArrays_assertNotEmpty_Test.java000066400000000000000000000040021243020563200351030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertNotEmpty(AssertionInfo, int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertNotEmpty_Test extends IntArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8)); } } IntArrays_assertNullOrEmpty_Test.java000066400000000000000000000037441243020563200355720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertNullOrEmpty(AssertionInfo, int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertNullOrEmpty_Test extends IntArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); int[] actual = { 6, 8 }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } IntArrays_assertStartsWith_Test.java000066400000000000000000000145461243020563200354560ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/intarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.intarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.IntArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.IntArrays; import org.fest.assertions.internal.IntArraysBaseTest; /** * Tests for {@link IntArrays#assertStartsWith(AssertionInfo, int[], int[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class IntArrays_assertStartsWith_Test extends IntArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); int[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); int[] sequence = { 8, 10 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, int[] sequence) { verify(failures).failure(info, shouldStartWith(actual, sequence)); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { -8, 10 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); int[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/000077500000000000000000000000001243020563200261335ustar00rootroot00000000000000Integers_assertEqual_Test.java000066400000000000000000000053671243020563200340620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 19, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertEqual(AssertionInfo, Integer, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertEqual_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertEqual(someInfo(), null, 8); } @Test public void should_pass_if_integers_are_equal() { integers.assertEqual(someInfo(), 8, 8); } @Test public void should_fail_if_integers_are_not_equal() { AssertionInfo info = someInfo(); try { integers.assertEqual(info, 6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); integersWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, 8); } @Test public void should_pass_if_integers_are_equal_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertEqual(someInfo(), 8, -8); } @Test public void should_fail_if_integers_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertEqual(info, 6, -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6, -8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Integers_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000063701243020563200370060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertGreaterThanOrEqualTo(AssertionInfo, Integer, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertGreaterThanOrEqualTo_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertGreaterThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_greater_than_other() { integers.assertGreaterThanOrEqualTo(someInfo(), 8, 6); } @Test public void should_pass_if_actual_is_equal_to_other() { integers.assertGreaterThanOrEqualTo(someInfo(), 6, 6); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { integers.assertGreaterThanOrEqualTo(info, 6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); integersWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -8, 6); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -6, 6); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, 6, -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6, -8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Integers_assertGreaterThan_Test.java000066400000000000000000000071471243020563200352150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.*; /** * Tests for {@link Integers#assertGreaterThan(AssertionInfo, Integer, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertGreaterThan_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertGreaterThan(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_greater_than_other() { integers.assertGreaterThan(someInfo(), 8, 6); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { integers.assertGreaterThan(info, 6, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6, 6, StandardComparisonStrategy.instance())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { integers.assertGreaterThan(info, 6, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6, 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), -8, 6); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertGreaterThan(info, 6, -6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6, -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertGreaterThan(info, -6, -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6, -8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Integers_assertIsNegative_Test.java000066400000000000000000000037331243020563200350440ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsNegative(AssertionInfo, Integer)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertIsNegative_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_negative() { integers.assertIsNegative(someInfo(), -6); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6> to be less than:<0>"); integers.assertIsNegative(someInfo(), 6); } @Test public void should_fail_since_actual_can_not_be_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than:<0> according to 'AbsValueComparator' comparator"); integersWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), -1); } @Test public void should_fail_since_actual_is_not_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than:<0>"); integersWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), 1); } } Integers_assertIsNotNegative_Test.java000066400000000000000000000035241243020563200355230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsNotNegative(AssertionInfo, Integer))}. * * @author Nicolas François */ public class Integers_assertIsNotNegative_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { integers.assertIsNotNegative(someInfo(), 6); } @Test public void should_succeed_since_actual_is_zero() { integers.assertIsNotNegative(someInfo(), 0); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6> to be greater than or equal to:<0>"); integers.assertIsNotNegative(someInfo(), -6); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), -1); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), 1); } } Integers_assertIsNotPositive_Test.java000066400000000000000000000041231243020563200355570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsNotPositive(org.fest.assertions.core.AssertionInfo, Integer))}. * * @author Nicolas François */ public class Integers_assertIsNotPositive_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { integers.assertIsNotPositive(someInfo(), -6); } @Test public void should_succeed_since_actual_is_zero() { integers.assertIsNotPositive(someInfo(), 0); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6> to be less than or equal to:<0>"); integers.assertIsNotPositive(someInfo(), 6); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); integersWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), -1); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); integersWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), 1); } } Integers_assertIsNotZero_Test.java000066400000000000000000000036521243020563200347020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsNegative(AssertionInfo, Integer)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertIsNotZero_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { integers.assertIsNotZero(someInfo(), 2); } @Test public void should_fail_since_actual_is_zero() { thrown.expectAssertionError("<0> should not be equal to:<0>"); integers.assertIsNotZero(someInfo(), 0); } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { integersWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 1); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { integersWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } Integers_assertIsPositive_Test.java000066400000000000000000000036271243020563200351060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsPositive(AssertionInfo, Integer)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertIsPositive_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_positive() { integers.assertIsPositive(someInfo(), 6); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6> to be greater than:<0>"); integers.assertIsPositive(someInfo(), -6); } @Test public void should_succeed_since_actual_is_positive_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), -1); } @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<0> to be greater than:<0> according to 'AbsValueComparator' comparator"); integersWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), 0); } } Integers_assertIsZero_Test.java000066400000000000000000000037251243020563200342220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertIsNegative(AssertionInfo, Integer)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertIsZero_Test extends IntegersBaseTest { @Test public void should_succeed_since_actual_is_zero() { integers.assertIsZero(someInfo(), 0); } @Test public void should_fail_since_actual_is_not_zero() { try { integers.assertIsZero(someInfo(), 2); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]> but was:<[2]>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { integersWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 1); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { integersWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } Integers_assertLessThanOrEqualTo_Test.java000066400000000000000000000063161243020563200363230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertLessThanOrEqualTo(AssertionInfo, Integer, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertLessThanOrEqualTo_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertLessThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other() { integers.assertLessThanOrEqualTo(someInfo(), 6, 8); } @Test public void should_pass_if_actual_is_equal_to_other() { integers.assertLessThanOrEqualTo(someInfo(), 6, 6); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { integers.assertLessThanOrEqualTo(info, 8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(8, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); integersWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6, -8); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6, -6); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, -8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(-8, 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Integers_assertLessThan_Test.java000066400000000000000000000067671243020563200345410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertLessThan(AssertionInfo, Integer, int)}. * * @author Alex Ruiz */ public class Integers_assertLessThan_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertLessThan(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other() { integers.assertLessThan(someInfo(), 6, 8); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { integers.assertLessThan(info, 6, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { integers.assertLessThan(info, 8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); integersWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertLessThan(someInfo(), 6, -8); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertLessThan(info, 6, -6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6, -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertLessThan(info, -8, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(-8, 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Integers_assertNotEqual_Test.java000066400000000000000000000054321243020563200345340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/integers/* * Created on Sep 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.integers; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Integers; import org.fest.assertions.internal.IntegersBaseTest; /** * Tests for {@link Integers#assertNotEqual(AssertionInfo, Integer, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Integers_assertNotEqual_Test extends IntegersBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); integers.assertNotEqual(someInfo(), null, 8); } @Test public void should_pass_if_integers_are_not_equal() { integers.assertNotEqual(someInfo(), 8, 6); } @Test public void should_fail_if_integers_are_equal() { AssertionInfo info = someInfo(); try { integers.assertNotEqual(info, 6, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); integersWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, 8); } @Test public void should_pass_if_integers_are_not_equal_according_to_custom_comparison_strategy() { integersWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), 8, 6); } @Test public void should_fail_if_integers_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { integersWithAbsValueComparisonStrategy.assertNotEqual(info, 6, -6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6, -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/000077500000000000000000000000001243020563200262655ustar00rootroot00000000000000Iterables_assertAreAtLeast_Test.java000066400000000000000000000054071243020563200352570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldBeAtLeast.elementsShouldBeAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreAtLeast(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreAtLeast_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertAreAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_all_satisfies_condition_() { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertAreAtLeast(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeAtLeast(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreAtMost_Test.java000066400000000000000000000054141243020563200351270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreAtMost(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreAtMost_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_at_most_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertAreAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_never_satisfies_condition_() { actual = newArrayList("Chewbacca", "Leia", "Obiwan"); iterables.assertAreAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreAtMost(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeAtMost(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreExactly_Test.java000066400000000000000000000060301243020563200353240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldBeExactly.elementsShouldBeExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreExactly(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreExactly_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_exactly_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertAreExactly(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertAreExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreNotAtLeast_Test.java000066400000000000000000000054571243020563200357450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreNotAtLeast(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreNotAtLeast_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_at_least_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertAreNotAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_all_not_satisfies_condition_() { actual = newArrayList("Leia", "Chewbacca", "Solo"); iterables.assertAreNotAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreNotAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreNotAtLeast(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeAtLeast(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreNotAtMost_Test.java000066400000000000000000000054401243020563200356070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreNotAtMost(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreNotAtMost_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_at_most_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertAreNotAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_never_satisfies_condition_() { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreNotAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreNotAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Solo", "Leia", "Chewbacca"); iterables.assertAreNotAtMost(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeAtMost(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreNotExactly_Test.java000066400000000000000000000061031243020563200360060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotBeExactly.elementsShouldNotBeExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreNotExactly(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreNotExactly_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_exactly_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertAreNotExactly(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAreNotExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Chewbacca", "Solo", "Leia"); iterables.assertAreNotExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertAreNotExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAreNot_Test.java000066400000000000000000000047361243020563200344660ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotBe.elementsShouldNotBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAreNot(AssertionInfo, Iterable, org.fest.assertions.core.Condition)} * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAreNot_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_each_element_not_satisfies_condition() { actual = newArrayList("Solo", "Leia"); iterables.assertAreNot(someInfo(), actual, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Solo", "Leia"); iterables.assertAreNot(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Solo", "Leia", "Yoda"); iterables.assertAreNot(someInfo(), actual, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBe(actual, newArrayList("Yoda"), jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertAre_Test.java000066400000000000000000000047111243020563200337760ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 15, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldBe.elementsShouldBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertAre(AssertionInfo, Iterable, org.fest.assertions.core.Condition)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertAre_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = newArrayList("Yoda", "Luke"); iterables.assertAre(someInfo(), actual, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertAre(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertAre(someInfo(), actual, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBe(actual, newArrayList("Leia"), jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertContainsAll_Test.java000066400000000000000000000124051243020563200354750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.test.ErrorMessages.iterableToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertContainsAll(AssertionInfo, Iterable, Iterable)}. * * @author Joel Costigliola */ public class Iterables_assertContainsAll_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_contains_all_iterable_values() { iterables.assertContainsAll(someInfo(), actual, newArrayList("Luke")); // order does not matter iterables.assertContainsAll(someInfo(), actual, newArrayList("Leia", "Yoda")); } @Test public void should_pass_if_actual_contains_all_iterable_values_more_than_once() { actual.addAll(newArrayList("Luke", "Luke")); iterables.assertContainsAll(someInfo(), actual, newArrayList("Luke")); } @Test public void should_pass_if_actual_contains_all_iterable_values_even_if_duplicated() { iterables.assertContainsAll(someInfo(), actual, newArrayList("Luke", "Luke")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(iterableToLookForIsNull()); iterables.assertContainsAll(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContainsAll(someInfo(), null, newArrayList("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); List expected = newArrayList("Han", "Luke"); try { iterables.assertContainsAll(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected.toArray(), newLinkedHashSet("Han"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_contains_all_iterable_values_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUKE")); } @Test public void should_pass_if_actual_contains_all_iterable_values_in_different_order_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LEIA", "yODa")); } @Test public void should_pass_if_actual_contains_all_all_iterable_values_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("luke", "YODA")); } @Test public void should_pass_if_actual_contains_all_iterable_values_more_than_once_according_to_custom_comparison_strategy() { actual.addAll(newArrayList("Luke", "Luke")); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUke")); } @Test public void should_pass_if_actual_contains_all_iterable_values_even_if_duplicated_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUke", "LuKe")); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); List expected = newArrayList("Han", "LUKE"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsAll(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected.toArray(), newLinkedHashSet("Han"), comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertContainsExactly_Test.java000066400000000000000000000140061243020563200363750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Oct 3, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldContainExactly.shouldContainExactly; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.*; import org.junit.Test; /** * Tests for {@link Iterables#assertContainsExactly(AssertionInfo, Iterable, Object[])}. * * @author Joel Costigliola */ public class Iterables_assertContainsExactly_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_contains_exactly_given_values() { iterables.assertContainsExactly(someInfo(), actual, array("Luke", "Yoda", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_exactly_with_null_elements() { iterables.assertContainsExactly(someInfo(), actual, array("Luke", "Yoda", "Leia")); actual.add(null); iterables.assertContainsExactly(someInfo(), actual, array("Luke", "Yoda", "Leia", null)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertContainsExactly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertContainsExactly(someInfo(), emptyList(), null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContainsExactly(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_given_values_exactly() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { iterables.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainExactly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_all_given_values_in_different_order() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Leia", "Yoda" }; try { iterables.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainExactly("Yoda", "Leia", 1)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_all_given_values_but_size_differ() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Leia", "Luke"); Object[] expected = { "Luke", "Leia" }; try { iterables.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, 3, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_contains_given_values_exactly_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsExactly(someInfo(), actual, array("LUKE", "YODA", "Leia")); } @Test public void should_fail_if_actual_does_not_contain_given_values_exactly_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { verify(failures) .failure( info, shouldContainExactly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"), comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_all_given_values_in_different_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Leia", "Yoda" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainExactly("Yoda", "Leia", 1, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertContainsNull_Test.java000066400000000000000000000077341243020563200357100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldContainNull.shouldContainNull; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertContainsNull(AssertionInfo, Collection)}. * * @author Joel Costigliola */ public class Iterables_assertContainsNull_Test extends IterablesBaseTest { private List actual = newArrayList("Luke", "Yoda", null); @Test public void should_pass_if_actual_contains_null() { iterables.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_only_null_values() { actual = newArrayList(null, null); iterables.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_null_more_than_once() { actual.add(null); iterables.assertContainsNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContainsNull(someInfo(), null); } @Test public void should_fail_if_actual_does_not_contain_null() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda"); try { iterables.assertContainsNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_null_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_only_null_values_whatever_custom_comparison_strategy_is() { actual = newArrayList(null, null); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_null_more_than_once_whatever_custom_comparison_strategy_is() { actual.add(null); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(someInfo(), null); } @Test public void should_fail_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertContainsOnly_Test.java000066400000000000000000000137351243020563200357150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Oct 3, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertContainsOnly(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertContainsOnly_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { iterables.assertContainsOnly(someInfo(), actual, array("Luke", "Yoda", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_only_with_null_elements() { iterables.assertContainsOnly(someInfo(), actual, array("Luke", "Yoda", "Leia")); actual.add(null); actual.add(null); iterables.assertContainsOnly(someInfo(), actual, array("Luke", null, "Yoda", "Leia", null)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { iterables.assertContainsOnly(someInfo(), actual, array("Leia", "Yoda", "Luke")); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual.addAll(newArrayList("Luke", "Luke")); iterables.assertContainsOnly(someInfo(), actual, array("Luke", "Yoda", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { iterables.assertContainsOnly(someInfo(), actual, array("Luke", "Luke", "Luke", "Yoda", "Leia")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertContainsOnly(someInfo(), emptyList(), null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContainsOnly(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { iterables.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LUKE", "YODA", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LEIA", "yoda", "LukE")); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual.addAll(newArrayList("Luke", "Luke")); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnly(someInfo(), actual, array("luke", "YOda", "LeIA")); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { actual.addAll(newArrayList("LUKE")); iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LUke", "LUke", "lukE", "YOda", "Leia")); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"), comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertContainsSequence_Test.java000066400000000000000000000143011243020563200365320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertContainsSequence(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertContainsSequence_Test extends IterablesBaseTest { @Override @Before public void setUp() { super.setUp(); actual = newArrayList("Yoda", "Luke", "Leia", "Obi-Wan"); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContainsSequence(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { iterables.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterables.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_but_not_whole_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Luke", "Leia", "Han" }; try { iterables.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, Object[] sequence) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); } @Test public void should_pass_if_actual_contains_sequence() { iterables.assertContainsSequence(someInfo(), actual, array("Luke", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { iterables.assertContainsSequence(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } @Test public void should_pass_if_actual_contains_both_partial_and_complete_sequence() { actual = newArrayList("Yoda", "Luke", "Yoda", "Obi-Wan"); iterables.assertContainsSequence(someInfo(), actual, array("Yoda", "Obi-Wan")); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_but_not_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Luke", "Leia", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsSequence(someInfo(), actual, array("LUKe", "leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContainsSequence(someInfo(), actual, array("YODA", "luke", "lEIA", "Obi-wan")); } } Iterables_assertContains_Test.java000066400000000000000000000131421243020563200350430ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertContains(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertContains_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_contains_given_values() { iterables.assertContains(someInfo(), actual, array("Luke")); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { iterables.assertContains(someInfo(), actual, array("Leia", "Yoda")); } @Test public void should_pass_if_actual_contains_all_given_values() { iterables.assertContains(someInfo(), actual, array("Luke", "Yoda")); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual.addAll(newArrayList("Luke", "Luke")); iterables.assertContains(someInfo(), actual, array("Luke")); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { iterables.assertContains(someInfo(), actual, array("Luke", "Luke")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertContains(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); Object[] expected = { "Han", "Luke" }; try { iterables.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet("Han"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, array("LUKE")); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, array("LEIA", "yODa")); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, array("luke", "YODA")); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual.addAll(newArrayList("Luke", "Luke")); iterablesWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, array("LUke")); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, array("LUke", "LuKe")); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "Han", "Luke" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet("Han"), comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoNotHaveAtLeast_Test.java000066400000000000000000000055521243020563200364000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertDoNotHaveAtLeast(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertDoNotHaveAtLeast_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_at_least_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_all_not_satisfies_condition_() { actual = newArrayList("Leia", "Chewbacca", "Solo"); iterables.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertDoNotHaveAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveAtLeast(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoNotHaveAtMost_Test.java000066400000000000000000000055331243020563200362510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotHaveAtMost.elementsShouldNotHaveAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertDoNotHaveAtMost(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertDoNotHaveAtMost_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_at_most_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_never_satisfies_condition_() { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertDoNotHaveAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Solo", "Leia", "Chewbacca"); iterables.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveAtMost(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoNotHaveExactly_Test.java000066400000000000000000000062051243020563200364500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotHaveExactly.elementsShouldNotHaveExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertDoNotHaveExactly(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertDoNotHaveExactly_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_not_satisfies_exactly_times_condition() { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertDoNotHaveExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Chewbacca", "Solo", "Leia"); iterables.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoNotHave_Test.java000066400000000000000000000050161243020563200351150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertDoNotHave(AssertionInfo, Iterable, org.fest.assertions.core.Condition)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertDoNotHave_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_each_element_not_satisfies_condition() { actual = newArrayList("Solo", "Leia"); iterables.assertDoNotHave(someInfo(), actual, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Solo", "Leia"); iterables.assertDoNotHave(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Solo", "Leia", "Yoda"); iterables.assertDoNotHave(someInfo(), actual, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHave(actual, newArrayList("Yoda"), jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoesNotContainNull_Test.java000066400000000000000000000071401243020563200370100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldNotContainNull.shouldNotContainNull; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertDoesNotContainNull(AssertionInfo, Collection)}. * * @author Joel Costigliola */ public class Iterables_assertDoesNotContainNull_Test extends IterablesBaseTest { private List actual = newArrayList("Luke", "Yoda"); @Test public void should_pass_if_actual_does_not_contain_null() { iterables.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { actual = newArrayList(); iterables.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertDoesNotContainNull(someInfo(), null); } @Test public void should_fail_if_actual_contains_null() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda", null); try { iterables.assertDoesNotContainNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { actual = newArrayList(); iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContainNull(someInfo(), null); } @Test public void should_fail_if_actual_contains_null_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda", null); try { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContainNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoesNotContain_Test.java000066400000000000000000000111751243020563200361600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Oct 12, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertDoesNotContain(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertDoesNotContain_Test extends IterablesBaseTest { private static List actual = newArrayList("Luke", "Yoda", "Leia");; @Test public void should_pass_if_actual_does_not_contain_given_values() { iterables.assertDoesNotContain(someInfo(), actual, array("Han")); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { iterables.assertDoesNotContain(someInfo(), actual, array("Han", "Han", "Anakin")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertDoesNotContain(someInfo(), emptyList(), null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertDoesNotContain(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { iterables.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet("Luke", "Yoda"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(someInfo(), actual, array("Han")); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(someInfo(), actual, array("Han", "Han", "Anakin")); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "LuKe", "YODA", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet("LuKe", "YODA"), comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000073331243020563200374670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Oct 12, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertDoesNotHaveDuplicates(AssertionInfo, Collection)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertDoesNotHaveDuplicates_Test extends IterablesBaseTest { private final List actual = newArrayList("Luke", "Yoda", "Leia"); @Test public void should_pass_if_actual_does_not_have_duplicates() { iterables.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { iterables.assertDoesNotHaveDuplicates(someInfo(), emptyList()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); Collection duplicates = newLinkedHashSet("Luke", "Yoda"); actual.addAll(duplicates); try { iterables.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, duplicates)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Collection duplicates = newLinkedHashSet("LUKE", "yoda"); actual.addAll(duplicates); try { iterablesWithCaseInsensitiveComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, duplicates, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertEmpty_Test.java000066400000000000000000000060751243020563200343720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertEmpty(AssertionInfo, Collection)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertEmpty_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_is_empty() { iterables.assertEmpty(someInfo(), emptyList()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_has_elements() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterables.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertEmpty(someInfo(), emptyList()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_has_elements_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertEndsWith_Test.java000066400000000000000000000142501243020563200350130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertEndsWith(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertEndsWith_Test extends IterablesBaseTest { private static Collection actual = newArrayList("Yoda", "Luke", "Leia", "Obi-Wan"); @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertEndsWith(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { iterables.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterables.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_but_not_whole_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { iterables.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_sequence_is_smaller_than_end_of_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Luke", "Leia" }; try { iterables.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, Object[] sequence) { verify(failures).failure(info, shouldEndWith(actual, sequence)); } @Test public void should_pass_if_actual_ends_with_sequence() { iterables.assertEndsWith(someInfo(), actual, array("Luke", "Leia", "Obi-Wan")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { iterables.assertEndsWith(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), actual, array("luke", "LEIA", "Obi-Wan")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), actual, array("YOda", "LUke", "Leia", "OBI-Wan")); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_but_not_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000077501243020563200401260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Apr 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2015 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertHasSameSizeAs(AssertionInfo, Iterable, Object[])}. * * @author Nicolas François */ public class Iterables_assertHasSameSizeAs_with_Array_Test extends IterablesBaseTest { @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), array("Solo", "Leia")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_other_is_null() { thrown.expectNullPointerException("The iterable to look for should not be null"); Iterable other = null; iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); String[] other = array("Solo", "Luke", "Leia"); try { iterables.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_has_same_size_as_other_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(someInfo(), newArrayList("Luke", "Yoda"), array("Solo", "Leia")); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_other_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("The iterable to look for should not be null"); Iterable other = null; iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); String[] other = array("Solo", "Luke", "Leia"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000101361243020563200405670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Apr 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2015 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; import org.junit.Test; /** * Tests for {@link Iterables#assertHasSameSizeAs(AssertionInfo, Iterable, Iterable)}. * * @author Nicolas François */ public class Iterables_assertHasSameSizeAs_with_Iterable_Test extends IterablesBaseTest { @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), newArrayList("Solo", "Leia")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_other_is_null() { thrown.expectNullPointerException("The iterable to look for should not be null"); Iterable other = null; iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); Collection other = newArrayList("Solo", "Luke", "Leia"); try { iterables.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_has_same_size_as_other_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(someInfo(), newArrayList("Luke", "Yoda"), newArrayList("Solo", "Leia")); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_other_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("The iterable to look for should not be null"); Iterable other = null; iterables.assertHasSameSizeAs(someInfo(), newArrayList("Yoda", "Luke"), other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); Collection other = newArrayList("Solo", "Luke", "Leia"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHasSize_Test.java000066400000000000000000000063401243020563200346350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertHasSize(AssertionInfo, Collection, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertHasSize_Test extends IterablesBaseTest { @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { iterables.assertHasSize(someInfo(), newArrayList("Luke", "Yoda"), 2); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertHasSize(someInfo(), null, 8); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterables.assertHasSize(info, actual, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.size(), 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSize(someInfo(), newArrayList("Luke", "Yoda"), 2); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertHasSize(someInfo(), null, 8); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSize(info, actual, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.size(), 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHaveAtLeast_Test.java000066400000000000000000000054661243020563200354400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertHaveAtLeast(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertHaveAtLeast_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_all_satisfies_condition_() { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertHaveAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertHaveAtLeast(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveAtLeast(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHaveAtMost_Test.java000066400000000000000000000054621243020563200353060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldHaveAtMost.elementsShouldHaveAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertHaveAtMost(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertHaveAtMost_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_at_most_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_never_satisfies_condition_() { actual = newArrayList("Chewbacca", "Leia", "Obiwan"); iterables.assertHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertHaveAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertHaveAtMost(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveAtMost(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHaveExactly_Test.java000066400000000000000000000061161243020563200355050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldHaveExactly.elementsShouldHaveExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertHaveExactly(AssertionInfo, Iterable, Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertHaveExactly_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_satisfies_exactly_times_condition() { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertHaveExactly(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertHaveExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Solo", "Leia"); iterables.assertHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Obiwan"); iterables.assertHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertHave_Test.java000066400000000000000000000047611243020563200341570ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ElementsShouldHave.elementsShouldHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesWithConditionsBaseTest; /** * Tests for {@link Iterables#assertHave(AssertionInfo, Iterable, org.fest.assertions.core.Condition)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class Iterables_assertHave_Test extends IterablesWithConditionsBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = newArrayList("Yoda", "Luke"); iterables.assertHave(someInfo(), actual, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = newArrayList("Yoda", "Luke"); iterables.assertHave(someInfo(), actual, null); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_fail_if_condition_is_not_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = newArrayList("Yoda", "Luke", "Leia"); iterables.assertHave(someInfo(), actual, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHave(actual, newArrayList("Leia"), jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertIsSubsetOf_Test.java000066400000000000000000000132241243020563200353140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Nov 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldBeSubsetOf.shouldBeSubsetOf; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.iterableToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertIsSubsetOf(AssertionInfo, Collection, Object[])}. * * @author Maciej Jaskowski */ public class Iterables_assertIsSubsetOf_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_is_subset_of_set() { actual = newArrayList("Yoda", "Luke"); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Luke", "Yoda", "Obi-Wan")); } @Test public void should_pass_if_actual_has_the_same_elements_as_set() { actual = newArrayList("Yoda", "Luke"); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Luke", "Yoda")); } @Test public void should_pass_if_actual_is_empty() { actual = newArrayList(); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Luke", "Yoda")); } @Test public void should_pass_if_actual_and_set_are_both_empty() { actual = newArrayList(); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList()); } @Test public void should_pass_if_actual_has_duplicates_but_all_elements_are_in_values() { actual = newArrayList("Yoda", "Yoda"); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Yoda")); } @Test public void should_pass_if_values_has_duplicates_but_all_elements_are_in_values() { actual = newArrayList("Yoda", "C-3PO"); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Yoda", "Yoda", "C-3PO")); } @Test public void should_pass_if_both_actual_and_values_have_duplicates_but_all_elements_are_in_values() { actual = newArrayList("Yoda", "Yoda", "Yoda", "C-3PO", "Obi-Wan"); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList("Yoda", "Yoda", "C-3PO", "C-3PO", "Obi-Wan")); } @Test public void should_throw_error_if_set_is_null() { actual = newArrayList("Yoda", "Luke"); thrown.expectNullPointerException(iterableToLookForIsNull()); iterables.assertIsSubsetOf(someInfo(), actual, null); } @Test public void should_throw_error_if_actual_is_null() { actual = null; thrown.expectAssertionError(actualIsNull()); iterables.assertIsSubsetOf(someInfo(), actual, newArrayList()); } @Test public void should_fail_if_actual_is_not_subset_of_values() { AssertionInfo info = someInfo(); actual = newArrayList("Yoda"); List values = newArrayList("C-3PO", "Leila"); List extra = newArrayList("Yoda"); try { iterables.assertIsSubsetOf(info, actual, values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSubsetOf(actual, values, extra)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_subset_of_values_according_to_custom_comparison_strategy() { actual = newArrayList("Yoda", "Luke"); iterablesWithCaseInsensitiveComparisonStrategy.assertIsSubsetOf(someInfo(), actual, newArrayList("yoda", "lUKE")); } @Test public void should_pass_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { actual = newArrayList("Luke", "Luke"); iterablesWithCaseInsensitiveComparisonStrategy.assertIsSubsetOf(someInfo(), actual, newArrayList("LUke", "yoda")); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { actual = newArrayList("Yoda", "Luke"); iterablesWithCaseInsensitiveComparisonStrategy.assertIsSubsetOf(someInfo(), actual, newArrayList("LUke", "LuKe", "yoda")); } @Test public void should_fail_if_actual_is_not_subset_of_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = newArrayList("Yoda", "Luke"); List values = newArrayList("yoda", "C-3PO"); List extra = newArrayList("Luke"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertIsSubsetOf(info, actual, values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSubsetOf(actual, values, extra, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertNotEmpty_Test.java000066400000000000000000000060031243020563200350420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertNotEmpty(AssertionInfo, Collection)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertNotEmpty_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_is_not_empty() { iterables.assertNotEmpty(someInfo(), newArrayList("Luke")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { iterables.assertNotEmpty(info, emptyList()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertNotEmpty(someInfo(), newArrayList("Luke")); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); iterablesWithCaseInsensitiveComparisonStrategy.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { iterablesWithCaseInsensitiveComparisonStrategy.assertNotEmpty(info, emptyList()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertNullOrEmpty_Test.java000066400000000000000000000056121243020563200355220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Sep 18, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertNullOrEmpty(AssertionInfo, Collection)}. * * @author Alex Ruiz * @author Yvonne Wang */ public class Iterables_assertNullOrEmpty_Test extends IterablesBaseTest { @Test public void should_pass_if_actual_is_null() { iterables.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_actual_is_empty() { iterables.assertNullOrEmpty(someInfo(), emptyList()); } @Test public void should_fail_if_actual_has_elements() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterables.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { iterablesWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(someInfo(), emptyList()); } @Test public void should_fail_if_actual_has_elements_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Collection actual = newArrayList("Yoda"); try { iterablesWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Iterables_assertStartsWith_Test.java000066400000000000000000000134251243020563200354050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/iterables/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.iterables; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Collection; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Iterables; import org.fest.assertions.internal.IterablesBaseTest; /** * Tests for {@link Iterables#assertStartsWith(AssertionInfo, Collection, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Iterables_assertStartsWith_Test extends IterablesBaseTest { private static Collection actual = newArrayList("Yoda", "Luke", "Leia", "Obi-Wan"); @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); iterables.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); iterables.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); iterables.assertStartsWith(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { iterables.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterables.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { iterables.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, Object[] sequence) { verify(failures).failure(info, shouldStartWith(actual, sequence)); } @Test public void should_pass_if_actual_starts_with_sequence() { iterables.assertStartsWith(someInfo(), actual, array("Yoda", "Luke", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { iterables.assertStartsWith(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { iterablesWithCaseInsensitiveComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), actual, array("YODA", "luke", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { iterablesWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), actual, array("Yoda", "LUke", "LeIA", "oBi-WaN")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/000077500000000000000000000000001243020563200254515ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/List_assertIs_Test.java000066400000000000000000000057441243020563200321150ustar00rootroot00000000000000package org.fest.assertions.internal.lists; import static java.util.Collections.emptyList; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldBeAtIndex.shouldBeAtIndex; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.fest.util.FailureMessages.actualIsEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.TestCondition; import org.fest.assertions.data.Index; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertIs(AssertionInfo, List, org.fest.assertions.core.Condition, Index)} . * * @author Bo Gotthardt */ public class List_assertIs_Test extends ListsBaseTest { private static TestCondition condition; private static List actual = newArrayList("Yoda", "Luke", "Leia"); @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertIs(someInfo(), null, condition, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); List empty = emptyList(); lists.assertIs(someInfo(), empty, condition, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); lists.assertIs(someInfo(), actual, condition, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); lists.assertIs(someInfo(), actual, condition, atIndex(6)); } @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); lists.assertIs(someInfo(), actual, null, someIndex()); } @Test public void should_fail_if_actual_does_not_satisfy_condition_at_index() { condition.shouldMatch(false); AssertionInfo info = someInfo(); Index index = atIndex(1); try { lists.assertIs(info, actual, condition, index); } catch (AssertionError e) { verify(failures).failure(info, shouldBeAtIndex(actual, condition, index, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_satisfies_condition_at_index() { condition.shouldMatch(true); lists.assertIs(someInfo(), actual, condition, someIndex()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/Lists_assertContains_Test.java000066400000000000000000000076051243020563200335010ustar00rootroot00000000000000/* * Created on Nov 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.lists; import static java.util.Collections.emptyList; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertContains(AssertionInfo, List, Object, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Lists_assertContains_Test extends ListsBaseTest { private static List actual = newArrayList("Yoda", "Luke", "Leia"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertContains(someInfo(), null, "Yoda", someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); lists.assertContains(someInfo(), emptyList(), "Yoda", someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); lists.assertContains(someInfo(), actual, "Yoda", null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); lists.assertContains(someInfo(), actual, "Yoda", atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { lists.assertContains(info, actual, "Han", index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, "Han", index, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { lists.assertContains(someInfo(), actual, "Luke", atIndex(1)); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { listsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, "Luke", atIndex(1)); listsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, "luke", atIndex(1)); listsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), actual, "LUKE", atIndex(1)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { listsWithCaseInsensitiveComparisonStrategy.assertContains(info, actual, "Han", index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, "Han", index, "Luke", comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Lists_assertDoesNotContain_Test.java000066400000000000000000000071271243020563200345320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.lists; import static java.util.Collections.emptyList; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertDoesNotContain(AssertionInfo, List, Object, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Lists_assertDoesNotContain_Test extends ListsBaseTest { private static List actual = newArrayList("Yoda", "Luke", "Leia"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertDoesNotContain(someInfo(), null, "Yoda", someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_index() { lists.assertDoesNotContain(someInfo(), actual, "Yoda", atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { lists.assertDoesNotContain(someInfo(), emptyList(), "Yoda", someIndex()); } @Test public void should_throw_error_if_index_is_null() { thrown.expectNullPointerException("Index should not be null"); lists.assertDoesNotContain(someInfo(), actual, "Yoda", null); } @Test public void should_pass_if_index_is_out_of_bounds() { lists.assertDoesNotContain(someInfo(), actual, "Yoda", atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { lists.assertDoesNotContain(info, actual, "Yoda", index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, "Yoda", index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { listsWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(someInfo(), actual, "Yoda", atIndex(1)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { listsWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(info, actual, "YODA", index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, "YODA", index, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/Lists_assertHas_Test.java000066400000000000000000000060061243020563200324300ustar00rootroot00000000000000package org.fest.assertions.internal.lists; import static java.util.Collections.emptyList; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldHaveAtIndex.shouldHaveAtIndex; import static org.fest.util.FailureMessages.actualIsEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.core.TestCondition; import org.fest.assertions.data.Index; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertHas(AssertionInfo, List, Condition, Index)}. * * @author Bo Gotthardt */ public class Lists_assertHas_Test extends ListsBaseTest { private static TestCondition condition; private static List actual = newArrayList("Yoda", "Luke", "Leia"); @BeforeClass public static void setUpOnce() { condition = new TestCondition(); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertHas(someInfo(), null, condition, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); List empty = emptyList(); lists.assertHas(someInfo(), empty, condition, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); lists.assertHas(someInfo(), actual, condition, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); lists.assertHas(someInfo(), actual, condition, atIndex(6)); } @Test public void should_throw_error_if_Condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); lists.assertHas(someInfo(), actual, null, someIndex()); } @Test public void should_fail_if_actual_does_not_satisfy_condition_at_index() { condition.shouldMatch(false); AssertionInfo info = someInfo(); Index index = atIndex(1); try { lists.assertHas(info, actual, condition, index); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveAtIndex(actual, condition, index, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_satisfies_condition_at_index() { condition.shouldMatch(true); lists.assertHas(someInfo(), actual, condition, someIndex()); } } Lists_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000121011243020563200375300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.lists; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.Comparator; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertIsSortedAccordingToComparator(AssertionInfo, List, Comparator)}. * * @author Joel Costigliola */ public class Lists_assertIsSortedAccordingToComparator_Test extends ListsBaseTest { private static Comparator stringDescendingOrderComparator = new Comparator() { public int compare(String s1, String s2) { return -s1.compareTo(s2); } }; private static Comparator comparator = new Comparator() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } }; @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { lists.assertIsSortedAccordingToComparator(someInfo(), newArrayList("Yoda", "Vador", "Luke", "Leia", "Leia"), stringDescendingOrderComparator); } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator_whatever_custom_comparison_strategy_is() { listsWithCaseInsensitiveComparisonStrategy.assertIsSortedAccordingToComparator(someInfo(), newArrayList("Yoda", "Vador", "Luke", "Leia", "Leia"), stringDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { lists.assertIsSortedAccordingToComparator(someInfo(), newArrayList(), stringDescendingOrderComparator); lists.assertIsSortedAccordingToComparator(someInfo(), newArrayList(), comparator); } @Test public void should_pass_if_actual_contains_only_one_comparable_element() { lists.assertIsSortedAccordingToComparator(someInfo(), newArrayList("Obiwan"), comparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertIsSortedAccordingToComparator(someInfo(), null, comparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); lists.assertIsSortedAccordingToComparator(someInfo(), newArrayList(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); List actual = newArrayList("Yoda", "Vador", "Leia", "Leia", "Luke"); try { lists.assertIsSortedAccordingToComparator(info, actual, stringDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(3, actual, stringDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_not_mutually_comparable_elements_according_to_given_comparator() { AssertionInfo info = someInfo(); List actual = newArrayList(); actual.add("bar"); actual.add(new Integer(5)); actual.add("foo"); try { lists.assertIsSortedAccordingToComparator(info, actual, stringDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, stringDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_one_element_only_not_comparable_according_to_given_comparator() { AssertionInfo info = someInfo(); List actual = newArrayList(new Object()); try { lists.assertIsSortedAccordingToComparator(info, actual, stringDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, stringDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/lists/Lists_assertIsSorted_Test.java000066400000000000000000000112101243020563200334420ustar00rootroot00000000000000/* * Created on Sep 30, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.lists; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Lists; import org.fest.assertions.internal.ListsBaseTest; /** * Tests for {@link Lists#assertIsSorted(AssertionInfo, List)}. * * @author Joel Costigliola */ public class Lists_assertIsSorted_Test extends ListsBaseTest { private List actual = newArrayList("Leia", "Luke", "Luke", "Vador", "Yoda"); @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { lists.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = newArrayList("leia", "LUKE", "luke", "Vador", "Yoda"); listsWithCaseInsensitiveComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { lists.assertIsSorted(someInfo(), newArrayList()); } @Test public void should_pass_if_actual_contains_only_one_comparable_element() { lists.assertIsSorted(someInfo(), newArrayList("Obiwan")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); lists.assertIsSorted(someInfo(), null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda", "Leia"); try { lists.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = newArrayList("Luke", "Yoda", "Leia"); try { listsWithCaseInsensitiveComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparisonStrategy.getComparator())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_only_one_non_comparable_element() { AssertionInfo info = someInfo(); List actual = newArrayList(new Object()); try { lists.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_non_comparable_elements() { AssertionInfo info = someInfo(); List actual = newArrayList("bar", new Object(), "foo"); try { lists.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_not_mutually_comparable_elements() { AssertionInfo info = someInfo(); List actual = newArrayList(); actual.add("bar"); actual.add(new Integer(5)); actual.add("foo"); try { lists.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/000077500000000000000000000000001243020563200264745ustar00rootroot00000000000000LongArrays_assertContainsOnly_Test.java000066400000000000000000000134031243020563200362630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertContainsOnly(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertContainsOnly_Test extends LongArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6L, 8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10L, 8L, 6L)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6L, 8L, 10L, 8L, 8L, 8L); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6L, 8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6L, 8L, 10L, 6L, 8L, 10L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(8L)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); long[] expected = { 6L, 8L, 20L }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20L), newLinkedHashSet(10L))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6L, -8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10L, -8L, 6L)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6L, -8L, 10L, -8L, -8L, -8L); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6L, -8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6L, -8L, 10L, 6L, -8L, 10L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(-8L)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] expected = { 6L, -8L, 20L }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet(20L), newLinkedHashSet(10L), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertContainsSequence_Test.java000066400000000000000000000150351243020563200371150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertContainsSequence(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertContainsSequence_Test extends LongArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6L, 8L, 10L, 12L); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8L)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 8L, 10L, 12L, 20L, 22L }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L, 22L }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, long[] sequence) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6L, 8L)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6L, 8L, 10L, 12L)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8L)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, -8L, 10L, 12L, 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6L, -8L)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6L, -8L, 10L, 12L)); } } LongArrays_assertContains_Test.java000066400000000000000000000135271243020563200354300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertContains(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertContains_Test extends LongArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6L)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8L, 10L)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6L, 8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6L, 8L, 10L, 10L, 8L); arrays.assertContains(someInfo(), actual, arrayOf(8L)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6L, 6L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8L)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); long[] expected = { 6L, 8L, 9L }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9L))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6L)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8L, 10L)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6L, -8L, 10L)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6L, -8L, 10L, 10L, -8L); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8L)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6L, 6L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(-8L)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] expected = { 6L, -8L, 9L }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(9L), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertContains_at_Index_Test.java000066400000000000000000000114151243020563200372350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.actualIsEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertContains(AssertionInfo, long[], long, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertContains_at_Index_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, 8L, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), 8L, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, 8L, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, 8L, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); long value = 6; Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, 8L, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, -8L, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), -8L, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8L, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8L, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long value = 6; Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, value, index, 8L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, -8L, atIndex(1)); } } LongArrays_assertDoesNotContain_Test.java000066400000000000000000000114231243020563200365320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertDoesNotContain(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertDoesNotContain_Test extends LongArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12L)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12L, 12L, 20L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8L)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); long[] expected = { 6L, 8L, 20L }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6L, 8L))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12L)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12L, 12L, 20L)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8L)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] expected = { 6L, -8L, 20L }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(6L, -8L), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000106531243020563200403510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.fest.assertions.test.TestData.someIndex; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertDoesNotContain(AssertionInfo, long[], long, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertDoesNotContain_at_Index_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, 8L, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, 6L, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), 8L, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, 8L, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, 8L, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, 6L, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6L, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, -8L, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, 6L, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), -8L, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8L, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, -8L, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, 6L, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, 6L, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072401243020563200400420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertDoesNotHaveDuplicates(AssertionInfo, long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertDoesNotHaveDuplicates_Test extends LongArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6L, 8L); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6L, 8L, 6L, 8L); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6L, 8L))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6L, -8L, 6L, -8L); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet(6L, -8L), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertEmpty_Test.java000066400000000000000000000040351243020563200347420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertEmpty(AssertionInfo, long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertEmpty_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); long[] actual = { 6L, 8L }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } LongArrays_assertEndsWith_Test.java000066400000000000000000000143371243020563200353770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertEndsWith(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertEndsWith_Test extends LongArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6L, 8L, 10L, 12L); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8L)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 8L, 10L, 12L, 20L, 22L }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); long[] sequence = { 20L, 22L }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L, 22L }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8L, 10L, 12L)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6L, 8L, 10L, 12L)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8L)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, -8L, 10L, 12L, 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8L, 10L, 12L)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6L, -8L, 10L, 12L)); } } LongArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044071243020563200405000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class LongArrays_assertHasSameSizeAs_with_Array_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Luke")); } } LongArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000045271243020563200411540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class LongArrays_assertHasSameSizeAs_with_Iterable_Test extends LongArraysBaseTest { private final List other = newArrayList("Solo", "Leia", "Luke"); @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda", "Luke"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } LongArrays_assertHasSize_Test.java000066400000000000000000000040301243020563200352050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertHasSize(AssertionInfo, long[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertHasSize_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 2); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } LongArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000071141243020563200415460ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertIsSortedAccordingToComparator(AssertionInfo, long[], Comparator)} * * @author Joel Costigliola */ public class LongArrays_assertIsSortedAccordingToComparator_Test extends LongArraysBaseTest { private Comparator longDescendingOrderComparator; private Comparator longSquareComparator; @Override @Before public void setUp() { super.setUp(); actual = new long[] { 4L, 3L, 2L, 2L, 1L }; longDescendingOrderComparator = new Comparator() { public int compare(Long long1, Long long2) { return -long1.compareTo(long2); } }; longSquareComparator = new Comparator() { public int compare(Long long1, Long long2) { return new Long(long1 * long1).compareTo(new Long(long2 * long2)); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, longDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), longDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), longSquareComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, longDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new long[] { 3L, 2L, 1L, 9L }; try { arrays.assertIsSortedAccordingToComparator(info, actual, longDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, longDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertIsSorted_Test.java000066400000000000000000000076731243020563200354130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSorted; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class LongArrays_assertIsSorted_Test extends LongArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(1L, 2L, 3L, 4L, 4L); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1L)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (long[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1L, 3L, 2L); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1L, -2L, 3L, -4L, 4L)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1L)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (long[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1L, 3L, 2L); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } LongArrays_assertNotEmpty_Test.java000066400000000000000000000040131243020563200354170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertNotEmpty(AssertionInfo, long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertNotEmpty_Test extends LongArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8L)); } } LongArrays_assertNullOrEmpty_Test.java000066400000000000000000000037571243020563200361100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.LongArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertNullOrEmpty(AssertionInfo, long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertNullOrEmpty_Test extends LongArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); long[] actual = { 6L, 8L }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } LongArrays_assertStartsWith_Test.java000066400000000000000000000144221243020563200357610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longarrays/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.LongArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.LongArrays; import org.fest.assertions.internal.LongArraysBaseTest; /** * Tests for {@link LongArrays#assertStartsWith(AssertionInfo, long[], long[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class LongArrays_assertStartsWith_Test extends LongArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6L, 8L, 10L, 12L); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(8L)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 8L, 10L, 12L, 20L, 22L }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); long[] sequence = { 8L, 10L }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6L, 8L, 10L)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6L, 8L, 10L, 12L)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(-8L)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, -8L, 10L, 12L, 20L, 22L }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { -8L, 10L }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); long[] sequence = { 6L, 20L }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6L, -8L, 10L)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6L, -8L, 10L, 12L)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/000077500000000000000000000000001243020563200254355ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertEqual_Test.java000066400000000000000000000053211243020563200327330ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertEqual(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertEqual_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertEqual(someInfo(), null, 8L); } @Test public void should_pass_if_longs_are_equal() { longs.assertEqual(someInfo(), 8L, 8L); } @Test public void should_fail_if_longs_are_not_equal() { AssertionInfo info = someInfo(); try { longs.assertEqual(info, 6L, 8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6L, 8L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); longsWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, 8L); } @Test public void should_pass_if_longs_are_equal_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertEqual(someInfo(), 8L, -8L); } @Test public void should_fail_if_longs_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertEqual(info, 6L, 8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(6L, 8L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Longs_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000063361243020563200356140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertGreaterThanOrEqualTo(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertGreaterThanOrEqualTo_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertGreaterThanOrEqualTo(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_greater_than_other() { longs.assertGreaterThanOrEqualTo(someInfo(), 8L, 6L); } @Test public void should_pass_if_actual_is_equal_to_other() { longs.assertGreaterThanOrEqualTo(someInfo(), 6L, 6L); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { longs.assertGreaterThanOrEqualTo(info, 6L, 8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6L, 8L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); longsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -8L, 6L); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), -6L, 6L); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, 6L, -8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual(6L, -8L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Longs_assertGreaterThan_Test.java000066400000000000000000000071461243020563200340200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertGreaterThan(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertGreaterThan_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertGreaterThan(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_greater_than_other() { longs.assertGreaterThan(someInfo(), 8L, 6L); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { longs.assertGreaterThan(info, 6L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6L, 6L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { longs.assertGreaterThan(info, 6L, 8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6L, 8L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), 8L, 6L); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertGreaterThan(info, -6L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(-6L, 6L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertGreaterThan(info, 6L, -8L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater(6L, -8L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertIsNegative_Test.java000066400000000000000000000037041243020563200337250ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsNegative(AssertionInfo, Long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertIsNegative_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_negative() { longs.assertIsNegative(someInfo(), -6l); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6L> to be less than:<0L>"); longs.assertIsNegative(someInfo(), 6l); } @Test public void should_fail_since_actual_can_not_be_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1L> to be less than:<0L> according to 'AbsValueComparator' comparator"); longsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), -1L); } @Test public void should_fail_since_actual_is_not_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1L> to be less than:<0L>"); longsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), 1L); } } Longs_assertIsNotNegative_Test.java000066400000000000000000000035041243020563200343250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsNotNegative(AssertionInfo, Longs))}. * * @author Nicolas François */ public class Longs_assertIsNotNegative_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { longs.assertIsNotNegative(someInfo(), 6L); } @Test public void should_succeed_since_actual_is_zero() { longs.assertIsNotNegative(someInfo(), 0L); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6L> to be greater than or equal to:<0L>"); longs.assertIsNotNegative(someInfo(), -6L); } @Test public void should_succeed_since_actual_negative_is_not_negative_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), -1L); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), 1L); } } Longs_assertIsNotPositive_Test.java000066400000000000000000000040441243020563200343650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsNotPositive(AssertionInfo, Long))}. * * @author Nicolas François */ public class Longs_assertIsNotPositive_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { longs.assertIsNotPositive(someInfo(), -6L); } @Test public void should_succeed_since_actual_is_zero() { longs.assertIsNotPositive(someInfo(), 0L); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6L> to be less than or equal to:<0L>"); longs.assertIsNotPositive(someInfo(), 6L); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1L> to be less than or equal to:<0L> according to 'AbsValueComparator' comparator"); longsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), -1L); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1L> to be less than or equal to:<0L> according to 'AbsValueComparator' comparator"); longsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), 1L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertIsNotZero_Test.java000066400000000000000000000036211243020563200335610ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsNegative(AssertionInfo, Long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertIsNotZero_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { longs.assertIsNotZero(someInfo(), 2l); } @Test public void should_fail_since_actual_is_zero() { thrown.expectAssertionError("<0L> should not be equal to:<0L>"); longs.assertIsNotZero(someInfo(), 0l); } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { longsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 1L); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { longsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0L); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0L> should not be equal to:<0L>"); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertIsPositive_Test.java000066400000000000000000000035761243020563200337740ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsPositive(AssertionInfo, Long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertIsPositive_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_positive() { longs.assertIsPositive(someInfo(), 6l); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6L> to be greater than:<0L>"); longs.assertIsPositive(someInfo(), -6l); } @Test public void should_succeed_since_actual_is_positive_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), -1L); } @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<0L> to be greater than:<0L> according to 'AbsValueComparator' comparator"); longsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), 0L); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertIsZero_Test.java000066400000000000000000000036741243020563200331100ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertIsNegative(AssertionInfo, Long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertIsZero_Test extends LongsBaseTest { @Test public void should_succeed_since_actual_is_zero() { longs.assertIsZero(someInfo(), 0l); } @Test public void should_fail_since_actual_is_not_zero() { try { longs.assertIsZero(someInfo(), 2l); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]L> but was:<[2]L>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { longsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 1L); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { longsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), 0L); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0L> should not be equal to:<0L>"); } } } Longs_assertLessThanOrEqualTo_Test.java000066400000000000000000000062641243020563200351310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertLessThanOrEqualTo(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertLessThanOrEqualTo_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertLessThanOrEqualTo(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_less_than_other() { longs.assertLessThanOrEqualTo(someInfo(), 6L, 8L); } @Test public void should_pass_if_actual_is_equal_to_other() { longs.assertLessThanOrEqualTo(someInfo(), 6L, 6L); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { longs.assertLessThanOrEqualTo(info, 8L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(8L, 6L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); longsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6L, -8L); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), 6L, -6L); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, -8L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual(-8L, 6L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertLessThan_Test.java000066400000000000000000000067751243020563200334230ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertLessThan(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertLessThan_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertLessThan(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_less_than_other() { longs.assertLessThan(someInfo(), 6L, 8L); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { longs.assertLessThan(info, 6L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6L, 6L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { longs.assertLessThan(info, 8L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(8L, 6L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); longsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, 8L); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), 6L, -8L); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertLessThan(info, 6L, -6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(6L, -6L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertLessThan(info, -8L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess(-8L, 6L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/longs/Longs_assertNotEqual_Test.java000066400000000000000000000053661243020563200334250ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.longs; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Longs; import org.fest.assertions.internal.LongsBaseTest; /** * Tests for {@link Longs#assertNotEqual(AssertionInfo, Long, long)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Longs_assertNotEqual_Test extends LongsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); longs.assertNotEqual(someInfo(), null, 8L); } @Test public void should_pass_if_longs_are_not_equal() { longs.assertNotEqual(someInfo(), 8L, 6L); } @Test public void should_fail_if_longs_are_equal() { AssertionInfo info = someInfo(); try { longs.assertNotEqual(info, 6L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(6L, 6L)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); longsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, 8L); } @Test public void should_pass_if_longs_are_not_equal_according_to_custom_comparison_strategy() { longsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), 8L, 6L); } @Test public void should_fail_if_longs_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { longsWithAbsValueComparisonStrategy.assertNotEqual(info, -6L, 6L); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual(-6L, 6L, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/000077500000000000000000000000001243020563200252535ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertContainsKey_Test.java000066400000000000000000000050701243020563200335500ustar00rootroot00000000000000/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldContainKey.shouldContainKey; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertContainsKey(AssertionInfo, Map, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Maps_assertContainsKey_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("color", "green"), entry(null, null)); } @Test public void should_pass_if_actual_contains_given_key() { maps.assertContainsKey(someInfo(), actual, "name"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertContainsKey(someInfo(), null, "name"); } @Test public void should_success_if_key_is_null() { maps.assertContainsKey(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_key() { AssertionInfo info = someInfo(); String key = "power"; try { maps.assertContainsKey(info, actual, key); } catch (AssertionError e) { verify(failures).failure(info, shouldContainKey(actual, key)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Maps_assertContainsValue_Test.java000066400000000000000000000051301243020563200340120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldContainValue.shouldContainValue; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertContainsValue(AssertionInfo, Map, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Maps_assertContainsValue_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("color", "green"), entry(null, null)); } @Test public void should_pass_if_actual_contains_given_value() { maps.assertContainsValue(someInfo(), actual, "Yoda"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertContainsValue(someInfo(), null, "Yoda"); } @Test public void should_success_if_value_is_null() { maps.assertContainsValue(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_value() { AssertionInfo info = someInfo(); String value = "veryOld"; try { maps.assertContainsValue(info, actual, value); } catch (AssertionError e) { verify(failures).failure(info, shouldContainValue(actual, value)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertContains_Test.java000066400000000000000000000067611243020563200331070ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.MapEntry; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertContains(AssertionInfo, Map, MapEntry[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertContains_Test extends MapsBaseTest { @Test public void should_pass_if_actual_contains_given_entries() { maps.assertContains(someInfo(), actual, array(entry("name", "Yoda"))); } @Test public void should_pass_if_actual_contains_given_entries_in_different_order() { maps.assertContains(someInfo(), actual, array(entry("color", "green"), entry("name", "Yoda"))); } @Test public void should_pass_if_actual_contains_all_given_entries() { maps.assertContains(someInfo(), actual, array(entry("name", "Yoda"), entry("color", "green"))); } @Test public void should_throw_error_if_array_of_entries_to_look_for_is_empty() { thrown.expectIllegalArgumentException(entriesToLookForIsEmpty()); maps.assertContains(someInfo(), actual, new MapEntry[0]); } @Test public void should_throw_error_if_array_of_entries_to_look_for_is_null() { thrown.expectNullPointerException(entriesToLookForIsNull()); maps.assertContains(someInfo(), actual, null); } @Test public void should_throw_error_if_entry_is_null() { MapEntry[] entries = { null }; thrown.expectNullPointerException(entryToLookForIsNull()); maps.assertContains(someInfo(), actual, entries); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertContains(someInfo(), null, array(entry("name", "Yoda"))); } @Test public void should_fail_if_actual_does_not_contain_entries() { AssertionInfo info = someInfo(); MapEntry[] expected = { entry("name", "Yoda"), entry("job", "Jedi") }; try { maps.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(entry("job", "Jedi")))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Maps_assertDoesNotContainKey_Test.java000066400000000000000000000051231243020563200346010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotContainKey.shouldNotContainKey; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertDoesNotContainKey(AssertionInfo, Map, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Maps_assertDoesNotContainKey_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("color", "green")); } @Test public void should_pass_if_actual_contains_given_key() { maps.assertDoesNotContainKey(someInfo(), actual, "power"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertDoesNotContainKey(someInfo(), null, "power"); } @Test public void should_success_if_key_is_null() { maps.assertDoesNotContainKey(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_key() { AssertionInfo info = someInfo(); String key = "name"; try { maps.assertDoesNotContainKey(info, actual, key); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainKey(actual, key)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Maps_assertDoesNotContainValue_Test.java000066400000000000000000000051651243020563200351330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotContainValue.shouldNotContainValue; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.FailureMessages.actualIsNull; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertDoesNotContainValue(AssertionInfo, Map, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Maps_assertDoesNotContainValue_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("color", "green")); } @Test public void should_pass_if_actual_contains_given_value() { maps.assertDoesNotContainValue(someInfo(), actual, "veryOld"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertDoesNotContainValue(someInfo(), null, "veryOld"); } @Test public void should_success_if_value_is_null() { maps.assertDoesNotContainValue(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_value() { AssertionInfo info = someInfo(); String value = "Yoda"; try { maps.assertDoesNotContainValue(info, actual, value); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainValue(actual, value)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Maps_assertDoesNotContain_Test.java000066400000000000000000000057021243020563200341330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.MapEntry; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertDoesNotContain(AssertionInfo, Map, MapEntry[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertDoesNotContain_Test extends MapsBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { maps.assertDoesNotContain(someInfo(), actual, array(entry("job", "Jedi"))); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(entriesToLookForIsEmpty()); maps.assertDoesNotContain(someInfo(), actual, new MapEntry[0]); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(entriesToLookForIsNull()); maps.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertDoesNotContain(someInfo(), null, array(entry("job", "Jedi"))); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); MapEntry[] expected = { entry("name", "Yoda"), entry("job", "Jedi") }; try { maps.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(entry("name", "Yoda")))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertEmpty_Test.java000066400000000000000000000042701243020563200324200ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static java.util.Collections.emptyMap; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertEmpty(AssertionInfo, Map)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertEmpty_Test extends MapsBaseTest { @Test public void should_pass_if_actual_is_empty() { maps.assertEmpty(someInfo(), emptyMap()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_has_elements() { AssertionInfo info = someInfo(); Map actual = mapOf(entry("name", "Yoda")); try { maps.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Maps_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000050211243020563200360670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François */ public class Maps_assertHasSameSizeAs_with_Array_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("job", "Yedi Master")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda"); try { maps.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { maps.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia")); } } Maps_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000051121243020563200365410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François */ public class Maps_assertHasSameSizeAs_with_Iterable_Test extends MapsBaseTest { @SuppressWarnings("unchecked") @Override @Before public void setUp() { super.setUp(); actual = (Map) mapOf(entry("name", "Yoda"), entry("job", "Yedi Master")); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda"); try { maps.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.size(), other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { maps.assertHasSameSizeAs(someInfo(), actual, newArrayList("Solo", "Leia")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertHasSize_Test.java000066400000000000000000000045221243020563200326700ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertHasSize(AssertionInfo, Map, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertHasSize_Test extends MapsBaseTest { @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { Map actual = mapOf(entry("name", "Yoda"), entry("job", "Yedi Master")); maps.assertHasSize(someInfo(), actual, 2); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertHasSize(someInfo(), null, 8); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); Map actual = mapOf(entry("name", "Yoda"), entry("job", "Yedi Master")); try { maps.assertHasSize(info, actual, 8); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.size(), 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertNotEmpty_Test.java000066400000000000000000000043141243020563200331000ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static java.util.Collections.emptyMap; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertNotEmpty(AssertionInfo, Map)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertNotEmpty_Test extends MapsBaseTest { @Test public void should_pass_if_actual_is_not_empty() { Map actual = mapOf(entry("name", "Yoda")); maps.assertNotEmpty(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); maps.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { maps.assertNotEmpty(info, emptyMap()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/maps/Maps_assertNullOrEmpty_Test.java000066400000000000000000000042101243020563200335460ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.maps; import static java.util.Collections.emptyMap; import static org.fest.assertions.data.MapEntry.entry; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.Maps.mapOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Map; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Maps; import org.fest.assertions.internal.MapsBaseTest; /** * Tests for {@link Maps#assertNullOrEmpty(AssertionInfo, Map)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Maps_assertNullOrEmpty_Test extends MapsBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); Map actual = mapOf(entry("name", "Yoda")); try { maps.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { maps.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { maps.assertNullOrEmpty(someInfo(), emptyMap()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/000077500000000000000000000000001243020563200270035ustar00rootroot00000000000000ObjectArrays_assertAreAtLeast_Test.java000066400000000000000000000053511243020563200364510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldBeAtLeast.elementsShouldBeAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertAreAtLeast(AssertionInfo, Object[], int, Condition)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreAtLeast_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertAreAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_all_satisfies_condition_() { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Solo", "Leia"); arrays.assertAreAtLeast(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeAtLeast(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreAtMost_Test.java000066400000000000000000000053471243020563200363300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldBeAtMost.elementsShouldBeAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertAreAtMost(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreAtMost_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertAreAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_all_satisfies_condition_() { actual = array("Chewbacca", "Leia", "Obiwan"); arrays.assertAreAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreAtMost(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeAtMost(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreExactly_Test.java000066400000000000000000000057721243020563200365340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldBeExactly.elementsShouldBeExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertAreExactly(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreExactly_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_exactly_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertAreExactly(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Solo", "Leia"); arrays.assertAreExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreNotAtLeast_Test.java000066400000000000000000000053631243020563200371350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotBeAtLeast.elementsShouldNotBeAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertAreNotAtLeast(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrays_assertAreNotAtLeast_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_not_satisfies_at_least_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertAreNotAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_never_satisfies_condition_() { actual = array("Leia", "Chewbacca", "Solo"); arrays.assertAreNotAtLeast(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreNotAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreNotAtLeast(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeAtLeast(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreNotAtMost_Test.java000066400000000000000000000054071243020563200370060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotBeAtMost.elementsShouldNotBeAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertAreNotAtMost(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreNotAtMost_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if__not_satisfies_at_least_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertAreNotAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_pass_if_never_satisfies_condition_() { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreNotAtMost(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreNotAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Solo", "Leia", "Chewbacca"); arrays.assertAreNotAtMost(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeAtMost(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreNotExactly_Test.java000066400000000000000000000060451243020563200372070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotBeExactly.elementsShouldNotBeExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertNotAreExactly(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreNotExactly_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_not_satisfies_exactly_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertAreNotExactly(someInfo(), actual, 2, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertAreNotExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Chewbacca", "Solo", "Leia"); arrays.assertAreNotExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertAreNotExactly(someInfo(), actual, 2, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBeExactly(actual, 2, jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAreNot_Test.java000066400000000000000000000047551243020563200356630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotBe.elementsShouldNotBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for * {@link ObjectArrays#areNot(org.fest.assertions.core.AssertionInfo, Object[], org.fest.assertions.core.Condition)} * . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAreNot_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = array("Solo", "Leia"); arrays.assertAreNot(someInfo(), actual, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); arrays.assertAreNot(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Solo", "Leia", "Yoda"); arrays.assertAreNot(someInfo(), actual, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldNotBe(actual, newArrayList("Yoda"), jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertAre_Test.java000066400000000000000000000047371243020563200352020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldBe.elementsShouldBe; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for * {@link ObjectArrays#assertAre(org.fest.assertions.core.AssertionInfo, Object[], org.fest.assertions.core.Condition)} * . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertAre_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = array("Yoda", "Luke"); arrays.assertAre(someInfo(), actual, jedi); verify(conditions).assertIsNotNull(jedi); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); arrays.assertAre(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_Condition_is_not_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Leia"); arrays.assertAre(someInfo(), actual, jedi); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jedi); verify(failures).failure(info, elementsShouldBe(actual, newArrayList("Leia"), jedi)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertContainsAll_Test.java000066400000000000000000000135011243020563200366670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.assertions.test.ErrorMessages.iterableToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; import org.junit.Test; /** * Tests for {@link ObjectArrays#assertContainsAll(AssertionInfo, Object[], Iterable)}. * * @author Joel Costigliola */ public class ObjectArrays_assertContainsAll_Test extends ObjectArraysBaseTest { @Test public void should_pass_if_actual_contains_all_iterable_values() { arrays.assertContainsAll(someInfo(), actual, newArrayList("Luke", "Yoda", "Leia")); arrays.assertContainsAll(someInfo(), actual, newArrayList("Luke", "Yoda")); // order is not important arrays.assertContainsAll(someInfo(), actual, newArrayList("Yoda", "Luke")); } @Test public void should_pass_if_actual_contains_all_iterable_values_more_than_once() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arrays.assertContainsAll(someInfo(), actual, newArrayList("Luke")); } @Test public void should_pass_if_iterable_is_empty() { arrays.assertContainsAll(someInfo(), actual, newArrayList()); } @Test public void should_throw_error_if_iterable_to_look_for_is_null() { thrown.expectNullPointerException(iterableToLookForIsNull()); arrays.assertContainsAll(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsAll(someInfo(), null, newArrayList("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_all_iterable_values() { AssertionInfo info = someInfo(); List expected = newArrayList("Han", "Luke"); try { arrays.assertContainsAll(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected.toArray(), newLinkedHashSet("Han"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_contains_all_iterable_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUKE")); } @Test public void should_pass_if_actual_contains_all_iterable_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LEIa", "YodA")); } @Test public void should_pass_if_actual_contains_all_all_iterable_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LukE", "YodA", "LeiA")); } @Test public void should_pass_if_actual_contains_all_iterable_values_more_than_once_according_to_custom_comparison_strategy() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUKE")); } @Test public void should_pass_if_actual_contains_all_iterable_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList("LUKE", "LUKE")); } @Test public void should_pass_if_iterable_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, newArrayList()); } @Test public void should_throw_error_if_iterable_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(iterableToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsAll(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); List expected = newArrayList("Han", "LUKE"); try { arraysWithCustomComparisonStrategy.assertContainsAll(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected.toArray(), newLinkedHashSet("Han"), caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertContainsNull_Test.java000066400000000000000000000076571243020563200371100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldContainNull.shouldContainNull; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertContainsNull(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class ObjectArrays_assertContainsNull_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Luke", "Yoda", null); } @Test public void should_pass_if_actual_contains_null() { arrays.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_only_null_values() { actual = array((String) null, (String) null); arrays.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_null_more_than_once() { actual = array("Luke", null, null); arrays.assertContainsNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsNull(someInfo(), null); } @Test public void should_fail_if_actual_does_not_contain_null() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda"); try { arrays.assertContainsNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_null_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_only_null_values_according_to_custom_comparison_strategy() { actual = array((String) null, (String) null); arraysWithCustomComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_pass_if_actual_contains_null_more_than_once_according_to_custom_comparison_strategy() { actual = array("Luke", null, null); arraysWithCustomComparisonStrategy.assertContainsNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsNull(someInfo(), null); } @Test public void should_fail_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda"); try { arraysWithCustomComparisonStrategy.assertContainsNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertContainsOnly_Test.java000066400000000000000000000141301243020563200370770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertContainsOnly(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertContainsOnly_Test extends ObjectArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { actual = array("Luke", null, "Yoda", null, "Leia"); arrays.assertContainsOnly(someInfo(), actual, array("Luke", "Yoda", "Leia", null)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, array("Leia", "Yoda", "Luke")); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arrays.assertContainsOnly(someInfo(), actual, array("Luke", "Yoda", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, array("Luke", "Luke", "Luke", "Yoda", "Leia")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LUKE", "YOda", "LeiA")); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LeiA", "YOda", "LUKE")); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LUKE", "YOda", "LeiA")); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { actual = array("Luke", "Yoda", "Leia", "LUke"); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, array("LUKE", "LUKE", "LuKE", "YOda", "LeiA")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, array("YOda")); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "LUKE", "YOda", "Han" }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Leia"), caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertContainsSequence_Test.java000066400000000000000000000154721243020563200377400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertContainsSequence(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertContainsSequence_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Yoda", "Luke", "Leia", "Obi-Wan"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, array("Yoda")); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, Object[] sequence) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, array("Luke", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, array("YOda")); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "LUKE", "LeiA", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "LeiA", "Obi-Wan", "Han" }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, array("LUKE", "LeiA")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, array("YOda", "LUKE", "LeiA", "Obi-WAn")); } } ObjectArrays_assertContains_Test.java000066400000000000000000000134241243020563200362420ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertContains(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertContains_Test extends ObjectArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, array("Luke")); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, array("Leia", "Yoda")); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, array("Luke", "Yoda", "Leia")); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arrays.assertContains(someInfo(), actual, array("Luke")); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, array("Luke", "Luke")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); Object[] expected = { "Han", "Luke" }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet("Han"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, array("LUKE")); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, array("LEIa", "YodA")); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, array("LukE", "YodA", "LeiA")); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = array("Luke", "Yoda", "Leia", "Luke", "Luke"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, array("LUKE")); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, array("LUKE", "LUKE")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "Han", "LUKE" }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet("Han"), caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertContains_at_Index_Test.java000066400000000000000000000105031243020563200400500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertContains(AssertionInfo, Object[], Object, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertContains_at_Index_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Yoda", "Luke", "Leia"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, "Yoda", someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), "Yoda", someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, "Yoda", null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, "Yoda", atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arrays.assertContains(info, actual, "Han", index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, "Han", index, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, "Luke", atIndex(1)); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, "YODa", null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, "YodA", atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, "Han", index); } catch (AssertionError e) { verify(failures).failure(info, shouldContainAtIndex(actual, "Han", index, "Luke", caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, "LUKe", atIndex(1)); } } ObjectArrays_assertDoNotHaveAtLeast_Test.java000066400000000000000000000055121243020563200375700ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotHaveAtLeast.elementsShouldNotHaveAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertDoNotHaveAtLeast(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertDoNotHaveAtLeast_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_not_satisfies_at_least_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_never_satisfies_condition_() { actual = array("Leia", "Chewbacca", "Solo"); arrays.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertDoNotHaveAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertDoNotHaveAtLeast(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveAtLeast(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoNotHaveAtMost_Test.java000066400000000000000000000055021243020563200374410ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotHaveAtMost.elementsShouldNotHaveAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertDoNotHaveAtMost(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertDoNotHaveAtMost_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if__not_satisfies_at_least_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_never_satisfies_condition_() { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertDoNotHaveAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Solo", "Leia", "Chewbacca"); arrays.assertDoNotHaveAtMost(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveAtMost(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoNotHaveExactly_Test.java000066400000000000000000000061471243020563200376510ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotHaveExactly.elementsShouldNotHaveExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertDoNotHaveExactly(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertDoNotHaveExactly_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_not_satisfies_exactly_times_condition() { actual = array("Yoda", "Solo", "Leia"); arrays.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertDoNotHaveExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Chewbacca", "Solo", "Leia"); arrays.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_not_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertDoNotHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoNotHave_Test.java000066400000000000000000000050231243020563200363070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for * {@link ObjectArrays#assertDoNotHave(org.fest.assertions.core.AssertionInfo, Object[], org.fest.assertions.core.Condition)} * . * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrays_assertDoNotHave_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = array("Darth Vader", "Leia"); arrays.assertDoNotHave(someInfo(), actual, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); arrays.assertDoNotHave(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Darth Vader", "Leia", "Yoda"); arrays.assertDoNotHave(someInfo(), actual, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldNotHave(actual, newArrayList("Yoda"), jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoesNotContainNull_Test.java000066400000000000000000000071231243020563200402050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldNotContainNull.shouldNotContainNull; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; import org.fest.util.Arrays; /** * Tests for {@link ObjectArrays#assertDoesNotContainNull(AssertionInfo, Object[])}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrays_assertDoesNotContainNull_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Luke", "Yoda"); } @Test public void should_pass_if_actual_does_not_contain_null() { arrays.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { actual = Arrays. array(); arrays.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContainNull(someInfo(), null); } @Test public void should_fail_if_actual_contains_null() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda", null); try { arrays.assertDoesNotContainNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { actual = Arrays. array(); arraysWithCustomComparisonStrategy.assertDoesNotContainNull(someInfo(), actual); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContainNull(someInfo(), null); } @Test public void should_fail_if_actual_contains_null_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda", null); try { arraysWithCustomComparisonStrategy.assertDoesNotContainNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainNull(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoesNotContain_Test.java000066400000000000000000000106041243020563200373500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertDoesNotContain(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertDoesNotContain_Test extends ObjectArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, array("Han")); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, array("Han", "Han", "Anakin")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); Object[] expected = { "Luke", "Yoda", "Han" }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet("Luke", "Yoda"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, array("Han")); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, array("Han", "HAn", "Anakin")); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] expected = { "LUKE", "Yoda", "Han" }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet("LUKE", "Yoda"), caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000105161243020563200411650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertDoesNotContain(AssertionInfo, Object[], Object, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertDoesNotContain_at_Index_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Yoda", "Luke", "Leia"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, "Yoda", someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, "Yoda", atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), "Yoda", someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, "Yoda", null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, "Yoda", atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, "Yoda", index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, "Yoda", index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, "YOda", atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), "YOda", someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, "YOda", null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, "YOda", atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, "YOda", index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, "YOda", index, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000074161243020563200406650ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertDoesNotHaveDuplicates(AssertionInfo, Object[])}. * * @author Alex Ruiz */ public class ObjectArrays_assertDoesNotHaveDuplicates_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Luke", "Yoda"); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda", "Luke", "Yoda"); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet("Luke", "Yoda"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = array("LUKE", "Yoda", "Luke", "Yoda"); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet("Luke", "Yoda"), caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertEmpty_Test.java000066400000000000000000000040641243020563200355620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertEmpty(AssertionInfo, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertEmpty_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); Character[] actual = { 'a', 'b' }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } ObjectArrays_assertEndsWith_Test.java000066400000000000000000000142701243020563200362110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertEndsWith(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertEndsWith_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Yoda", "Luke", "Leia", "Obi-Wan"); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, Object[] sequence) { verify(failures).failure(info, shouldEndWith(actual, sequence)); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, array("Luke", "Leia", "Obi-Wan")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "LUKE", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, array("LUKE", "Leia", "Obi-Wan")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, array("Yoda", "LUKE", "Leia", "Obi-Wan")); } } ObjectArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000050721243020563200413150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertHasSameSizeAs(AssertionInfo, Object[], Object[])}. * * @author Nicolas François * @author Joel Costigliola */ public class ObjectArrays_assertHasSameSizeAs_with_Array_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_other_is_null() { thrown.expectNullPointerException("The array of values to look for should not be null"); String[] actual = array("Solo", "Leia"); String[] other = null; arrays.assertHasSameSizeAs(someInfo(), actual, other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size() { AssertionInfo info = someInfo(); String[] actual = array("Yoda"); String[] other = array("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_has_same_size_as_other() { arrays.assertHasSameSizeAs(someInfo(), array("Solo", "Leia"), array("Solo", "Leia")); } } ObjectArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000052321243020563200417640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Apr 27, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertHasSameSizeAs(AssertionInfo, Object[], Iterable)}. * * @author Nicolas François * @author Joel Costigliola */ public class ObjectArrays_assertHasSameSizeAs_with_Iterable_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_other_is_null() { thrown.expectNullPointerException("The iterable to look for should not be null"); String[] actual = array("Solo", "Leia"); Iterable other = null; arrays.assertHasSameSizeAs(someInfo(), actual, other); } @Test public void should_fail_if_actual_size_is_not_equal_to_other_size() { AssertionInfo info = someInfo(); String[] actual = array("Yoda"); List other = newArrayList("Solo", "Leia"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_has_same_size_as_other() { arrays.assertHasSameSizeAs(someInfo(), array("Solo", "Leia"), newArrayList("Solo", "Leia")); } } ObjectArrays_assertHasSize_Test.java000066400000000000000000000041621243020563200360310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertHasSize(AssertionInfo, Object[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertHasSize_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 6); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); Character[] actual = new Character[2]; try { arrays.assertHasSize(info, actual, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { Byte[] actual = new Byte[2]; arrays.assertHasSize(someInfo(), actual, 2); } } ObjectArrays_assertHaveAtLeast_Test.java000066400000000000000000000053741243020563200366320ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldHaveAtLeast.elementsShouldHaveAtLeast; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertHaveAtLeast(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky */ public class ObjectArrays_assertHaveAtLeast_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_all_satisfies_condition_() { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertHaveAtLeast(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertHaveAtLeast(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Solo", "Leia"); arrays.assertHaveAtLeast(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveAtLeast(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertHaveAtMost_Test.java000066400000000000000000000054261243020563200365020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldHaveAtMost.elementsShouldHaveAtMost; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertHaveAtMost(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertHaveAtMost_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_at_least_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_pass_if_all_satisfies_condition_() { actual = array("Chewbacca", "Leia", "Obiwan"); arrays.assertHaveAtMost(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertHaveAtMost(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertHaveAtMost(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveAtMost(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertHaveExactly_Test.java000066400000000000000000000060601243020563200366770ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 17, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldHaveExactly.elementsShouldHaveExactly; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.core.Condition; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for {@link ObjectArrays#assertHaveExactly(AssertionInfo, Object[], Condition, int)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertHaveExactly_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_satisfies_exactly_times_condition() { actual = array("Yoda", "Luke", "Leia"); arrays.assertHaveExactly(someInfo(), actual, 2, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); actual = array("Yoda", "Luke"); arrays.assertHaveExactly(someInfo(), actual, 2, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_condition_is_not_met_enought() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Solo", "Leia"); arrays.assertHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_condition_is_met_much() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Obiwan"); arrays.assertHaveExactly(someInfo(), actual, 2, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHaveExactly(actual, 2, jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertHaveNot_Test.java000066400000000000000000000046011243020563200360250ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldNotHave.elementsShouldNotHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for * {@link ObjectArrays#haveNot(org.fest.assertions.core.AssertionInfo, Object[], org.fest.assertions.core.Condition)} * . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertHaveNot_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = array("Solo", "Leia"); arrays.assertDoNotHave(someInfo(), actual, jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); arrays.assertDoNotHave(someInfo(), actual, null); } @Test public void should_fail_if_condition_is_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Solo", "Leia", "Yoda"); arrays.assertDoNotHave(someInfo(), actual, jediPower); } catch (AssertionError e) { verify(failures).failure(info, elementsShouldNotHave(actual, newArrayList("Yoda"), jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertHave_Test.java000066400000000000000000000051351243020563200353470ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Mar 5, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ElementsShouldHave.elementsShouldHave; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysWithConditionBaseTest; /** * Tests for * {@link ObjectArrays#have(org.fest.assertions.core.AssertionInfo, Object[], org.fest.assertions.core.Condition)} . * * @author Nicolas François * @author Mikhail Mazursky * @author Joel Costigliola */ public class ObjectArrays_assertHave_Test extends ObjectArraysWithConditionBaseTest { @Test public void should_pass_if_each_element_satisfies_condition() { actual = array("Yoda", "Luke"); arrays.assertHave(someInfo(), actual, jediPower); verify(conditions).assertIsNotNull(jediPower); } @Test public void should_throw_error_if_condition_is_null() { thrown.expectNullPointerException("The condition to evaluate should not be null"); arrays.assertHave(someInfo(), actual, null); verify(conditions).assertIsNotNull(null); } @Test public void should_fail_if_Condition_is_not_met() { testCondition.shouldMatch(false); AssertionInfo info = someInfo(); try { actual = array("Yoda", "Luke", "Leia"); arrays.assertHave(someInfo(), actual, jediPower); } catch (AssertionError e) { verify(conditions).assertIsNotNull(jediPower); verify(failures).failure(info, elementsShouldHave(actual, newArrayList("Leia"), jediPower)); verify(failures).failure(info, elementsShouldHave(actual, newArrayList("Leia"), jediPower)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000070411243020563200423630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrays_assertIsSortedAccordingToComparator_Test extends ObjectArraysBaseTest { private Comparator stringDescendingOrderComparator; private Comparator comparator; @Override @Before public void setUp() { super.setUp(); actual = array("Yoda", "Vador", "Luke", "Luke", "Leia"); stringDescendingOrderComparator = new Comparator() { public int compare(String s1, String s2) { return -s1.compareTo(s2); } }; comparator = new Comparator() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, stringDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), new String[0], stringDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), new String[0], comparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, comparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), array(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = array("Yoda", "Vador", "Leia", "Leia", "Luke"); try { arrays.assertIsSortedAccordingToComparator(info, actual, stringDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(3, actual, stringDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertIsSorted_Test.java000066400000000000000000000166641243020563200362310ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola * @author Mikhail Mazursky */ public class ObjectArrays_assertIsSorted_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Leia", "Luke", "Luke", "Vador", "Yoda"); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_with_comparable_component_type() { arrays.assertIsSorted(someInfo(), new String[0]); } @Test public void should_pass_if_actual_is_empty_with_non_comparable_component_type() { arrays.assertIsSorted(someInfo(), array()); } @Test public void should_pass_if_actual_contains_only_one_comparable_element() { actual = array("Obiwan"); arrays.assertIsSorted(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = array("Luke", "Yoda", "Leia"); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_only_one_element_with_non_comparable_component_type() { AssertionInfo info = someInfo(); Object[] actual = array(new Object()); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_elements_with_non_comparable_component_type() { AssertionInfo info = someInfo(); Object[] actual = array("bar", new Object(), "foo"); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_not_mutually_comparable_elements() { AssertionInfo info = someInfo(); Object[] actual = new Object[] { "bar", new Integer(5), "foo" }; try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveMutuallyComparableElements(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = array("leia", "Luke", "luke", "Vador", "Yoda"); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_with_comparable_component_type_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), new String[0]); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), array()); } @Test public void should_pass_if_actual_contains_only_one_comparable_element_according_to_custom_comparison_strategy() { actual = array("Obiwan"); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = array("LUKE", "Yoda", "Leia"); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_only_one_element_with_non_comparable_component_type_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] actual = array(new Object()); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_elements_with_non_comparable_component_type_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] actual = array("bar", new Object(), "foo"); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_has_some_not_mutually_comparable_elements_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] actual = new Object[] { "bar", new Integer(5), "foo" }; try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveComparableElementsAccordingToGivenComparator(actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ObjectArrays_assertNotEmpty_Test.java000066400000000000000000000041201243020563200362340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 25, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertNotEmpty(AssertionInfo, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertNotEmpty_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), array("Yoda")); } } ObjectArrays_assertNullOrEmpty_Test.java000066400000000000000000000040161243020563200367130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Nov 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertNullOrEmpty(AssertionInfo, Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertNullOrEmpty_Test extends ObjectArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); Integer[] actual = new Integer[] { 5, 8 }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } ObjectArrays_assertStartsWith_Test.java000066400000000000000000000145341243020563200366030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objectarrays/* * Created on Dec 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objectarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectArrays; import org.fest.assertions.internal.ObjectArraysBaseTest; /** * Tests for {@link ObjectArrays#assertStartsWith(AssertionInfo, Object[], Object[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ObjectArrays_assertStartsWith_Test extends ObjectArraysBaseTest { @Override protected void initActualArray() { actual = array("Yoda", "Luke", "Leia", "Obi-Wan"); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, array("Yoda")); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "Luke", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); Object[] sequence = { "Leia", "Obi-Wan", "Han" }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, array("Yoda", "Luke", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, array("Yoda", "Luke", "Leia", "Obi-Wan")); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Yoda", "LUKE", "Leia", "Obi-Wan", "Han", "C-3PO", "R2-D2", "Anakin" }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "Han", "C-3PO" }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); Object[] sequence = { "LEia", "Obi-Wan", "Han" }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, caseInsensitiveStringComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, array("Yoda", "LUKE", "Leia")); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, array("Yoda", "LUKE", "Leia", "Obi-Wan")); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/000077500000000000000000000000001243020563200257445ustar00rootroot00000000000000Objects_assertDoesNotHaveNotSameClassAs_Test.java000066400000000000000000000050201243020563200373370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotHaveSameClass.shouldNotHaveSameClass; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertDoesNotHaveSameClassAs(AssertionInfo, Object, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertDoesNotHaveNotSameClassAs_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_does_not_have_not_same_class_as_other() { objects.assertDoesNotHaveSameClassAs(someInfo(), actual, "Luke"); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given object should not be null"); objects.assertDoesNotHaveSameClassAs(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertDoesNotHaveSameClassAs(someInfo(), null, Object.class); } @Test public void should_fail_if_actual_has_same_type_as_other() { AssertionInfo info = someInfo(); try { objects.assertDoesNotHaveSameClassAs(info, actual, new Person("Luke")); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldNotHaveSameClass(actual, new Person("Luke"))); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/Objects_assertEqual_Test.java000066400000000000000000000045441243020563200335570ustar00rootroot00000000000000/* * Created on Sep 9, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertEqual(AssertionInfo, Object, Object)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertEqual_Test extends ObjectsBaseTest { @Test public void should_pass_if_objects_are_equal() { objects.assertEqual(someInfo(), "Yoda", "Yoda"); } @Test public void should_fail_if_objects_are_not_equal() { AssertionInfo info = someInfo(); try { objects.assertEqual(info, "Luke", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_objects_are_equal_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertEqual(someInfo(), "Yoda", "YODA"); } @Test public void should_fail_if_objects_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertEqual(info, "Luke", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertHasSameClassAs_Test.java000066400000000000000000000047031243020563200352210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldHaveSameClass.shouldHaveSameClass; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertHasSameClassAs(AssertionInfo, Object, Object)}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertHasSameClassAs_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_has_same_type_as_other() { objects.assertHasSameClassAs(someInfo(), actual, new Person("Luke")); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given object should not be null"); objects.assertHasSameClassAs(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertHasSameClassAs(someInfo(), null, new Person("Luke")); } @Test public void should_pass_if_actual_not_has_same_type_as_other() { AssertionInfo info = someInfo(); try { objects.assertHasSameClassAs(info, actual, "Yoda"); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldHaveSameClass(actual, "Yoda")); } } } Objects_assertIsExactlyInstanceOf_Test.java000066400000000000000000000045011243020563200363010ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeExactlyInstanceOf.shouldBeExactlyInstance; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.junit.Test; /** * Tests for {@link Objects#assertIsExactlyInstanceOf(AssertionInfo, Object, Class)}. * * @author Joel Costigliola * @author Nicolas François */ public class Objects_assertIsExactlyInstanceOf_Test extends ObjectsBaseTest { @Test public void should_pass_if_actual_is_exactly_instance_of_type() { objects.assertIsExactlyInstanceOf(someInfo(), "Yoda", String.class); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given type should not be null"); objects.assertIsExactlyInstanceOf(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsExactlyInstanceOf(someInfo(), null, String.class); } @Test public void should_fail_if_actual_is_not_exactly_instance_of_type() { AssertionInfo info = someInfo(); try { objects.assertIsExactlyInstanceOf(info, "Yoda", Object.class); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldBeExactlyInstance("Yoda", Object.class)); } } } Objects_assertIsIn_with_Iterable_Test.java000066400000000000000000000066611243020563200361370ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jan 3, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldBeIn.shouldBeIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.iterableIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.assertions.test.ErrorMessages; import org.junit.BeforeClass; import org.junit.Test; /** * Tests for {@link Objects#assertIsIn(AssertionInfo, Object, Iterable)}. * * @author Joel Costigliola * @author Alex Ruiz * @author Yvonne Wang * @author Nicolas François * @author Mikhail Mazursky */ public class Objects_assertIsIn_with_Iterable_Test extends ObjectsBaseTest { private static Iterable values; @BeforeClass public static void setUpOnce() { values = newArrayList("Yoda", "Leia"); } @Test public void should_throw_error_if_Iterable_is_null() { thrown.expectNullPointerException(iterableIsNull()); Iterable c = null; objects.assertIsIn(someInfo(), "Yoda", c); } @Test public void should_throw_error_if_Iterable_is_empty() { thrown.expectIllegalArgumentException(ErrorMessages.iterableIsEmpty()); objects.assertIsIn(someInfo(), "Yoda", emptyList()); } @Test public void should_pass_if_actual_is_in_Iterable() { objects.assertIsIn(someInfo(), "Yoda", values); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsIn(someInfo(), null, values); } @Test public void should_fail_if_actual_is_not_in_Iterable() { AssertionInfo info = someInfo(); try { objects.assertIsIn(info, "Luke", values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeIn("Luke", values)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_in_Iterable_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertIsIn(someInfo(), "YODA", values); } @Test public void should_fail_if_actual_is_not_in_Iterable_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertIsIn(info, "Luke", values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeIn("Luke", values, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsIn_with_array_Test.java000066400000000000000000000064221243020563200355210ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jan 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeIn.shouldBeIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertIsIn(AssertionInfo, Object, Object[])}. * * @author Joel Costigliola * @author Alex Ruiz * @author Yvonne Wang */ public class Objects_assertIsIn_with_array_Test extends ObjectsBaseTest { private static String[] values; @BeforeClass public static void setUpOnce() { values = array("Yoda", "Leia"); } @Test public void should_throw_error_if_array_is_null() { thrown.expectNullPointerException(arrayIsNull()); Object[] array = null; objects.assertIsIn(someInfo(), "Yoda", array); } @Test public void should_throw_error_if_array_is_empty() { thrown.expectIllegalArgumentException(arrayIsEmpty()); objects.assertIsIn(someInfo(), "Yoda", emptyArray()); } @Test public void should_pass_if_actual_is_in_array() { objects.assertIsIn(someInfo(), "Yoda", values); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsIn(someInfo(), null, values); } @Test public void should_fail_if_actual_is_not_in_array() { AssertionInfo info = someInfo(); try { objects.assertIsIn(info, "Luke", values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeIn("Luke", values)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_in_array_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertIsIn(someInfo(), "YODA", values); } @Test public void should_fail_if_actual_is_not_in_array_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertIsIn(info, "Luke", values); } catch (AssertionError e) { verify(failures).failure(info, shouldBeIn("Luke", values, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsInstanceOfAny_Test.java000066400000000000000000000060671243020563200354300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Dec 27, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeInstanceOfAny.shouldBeInstanceOfAny; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import java.io.File; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsInstanceOfAny(AssertionInfo, Object, Class[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertIsInstanceOfAny_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_instance_of_any_type() { Class[] types = { String.class, Person.class }; objects.assertIsInstanceOfAny(someInfo(), actual, types); } @Test public void should_throw_error_if_array_of_types_is_null() { thrown.expectNullPointerException("The given array of types should not be null"); objects.assertIsInstanceOfAny(someInfo(), actual, null); } @Test public void should_throw_error_if_array_of_types_is_empty() { thrown.expectIllegalArgumentException("The given array of types should not be empty"); objects.assertIsInstanceOfAny(someInfo(), actual, new Class[0]); } @Test public void should_throw_error_if_array_of_types_has_null_elements() { Class[] types = { null, String.class }; thrown.expectNullPointerException("The given array of types:<[null, java.lang.String]> should not have null elements"); objects.assertIsInstanceOfAny(someInfo(), actual, types); } @Test public void should_fail_if_actual_is_null() { Class[] types = { Object.class }; thrown.expectAssertionError(actualIsNull()); objects.assertIsInstanceOfAny(someInfo(), null, types); } @Test public void should_fail_if_actual_is_not_instance_of_any_type() { AssertionInfo info = someInfo(); Class[] types = { String.class, File.class }; try { objects.assertIsInstanceOfAny(info, actual, types); fail(); } catch (AssertionError err) {} verify(failures).failure(info, shouldBeInstanceOfAny(actual, types)); } } Objects_assertIsInstanceOf_Test.java000066400000000000000000000046511243020563200347550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsInstanceOf(AssertionInfo, Object, Class)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertIsInstanceOf_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_instance_of_type() { objects.assertIsInstanceOf(someInfo(), actual, Person.class); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given type should not be null"); objects.assertIsInstanceOf(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsInstanceOf(someInfo(), null, Object.class); } @Test public void should_fail_if_actual_is_not_instance_of_type() { AssertionInfo info = someInfo(); try { objects.assertIsInstanceOf(info, actual, String.class); } catch (AssertionError err) { verify(failures).failure(info, shouldBeInstance(actual, String.class)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsLenientEqualsToByAcceptingFields_Test.java000066400000000000000000000122211243020563200412300ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Apr 8, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static junit.framework.Assert.assertEquals; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.assertions.error.ShouldBeLenientEqualByAccepting.shouldBeLenientEqualByAccepting; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Employee; import org.fest.test.Jedi; import org.fest.util.IntrospectionError; /** * Tests for {@link Objects#assertIsLenientEqualsToByAcceptingFields(AssertionInfo, Object, Object, String...). * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsLenientEqualsToByAcceptingFields_Test extends ObjectsBaseTest { @Test public void should_pass_when_selected_fields_are_equal() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByAcceptingFields(someInfo(), actual, other, "name", "lightSaberColor"); } @Test public void should_pass_even_if_non_accepted_fields_differ() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Blue"); objects.assertIsLenientEqualsToByAcceptingFields(someInfo(), actual, other, "name"); } @Test public void should_pass_when_field_value_is_null() { Jedi actual = new Jedi("Yoda", null); Jedi other = new Jedi("Yoda", null); objects.assertIsLenientEqualsToByAcceptingFields(someInfo(), actual, other, "name", "lightSaberColor"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByAcceptingFields(someInfo(), null, other, "name", "lightSaberColor"); } @Test public void should_fail_when_some_selected_field_values_differ() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Blue"); try { objects.assertIsLenientEqualsToByAcceptingFields(info, actual, other, "name", "lightSaberColor"); } catch (AssertionError err) { List expected = newArrayList((Object) "Blue"); verify(failures).failure( info, shouldBeLenientEqualByAccepting(actual, newArrayList("lightSaberColor"), expected, newArrayList("name", "lightSaberColor"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_some_inherited_field_values_differ() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Luke", "Green"); try { objects.assertIsLenientEqualsToByAcceptingFields(info, actual, other, "name", "lightSaberColor"); } catch (AssertionError err) { List expected = newArrayList((Object) "Luke"); verify(failures).failure( info, shouldBeLenientEqualByAccepting(actual, newArrayList("name"), expected, newArrayList("name", "lightSaberColor"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_objects_to_compare_are_of_different_types() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Employee other = new Employee(); try { objects.assertIsLenientEqualsToByAcceptingFields(info, actual, other, "name"); } catch (AssertionError err) { verify(failures).failure(info, shouldBeInstance(other, actual.getClass())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_selected_field_does_not_exist() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Blue"); try { objects.assertIsLenientEqualsToByAcceptingFields(info, actual, other, "age"); } catch (IntrospectionError expected) { String msg = String.format("No getter for property '%s' in %s", "age", actual.getClass().getName()); assertEquals(msg, expected.getMessage()); return; } fail("expecting an IntrospectionError to be thrown"); } } Objects_assertIsLenientEqualsToByIgnoringFields_Test.java000066400000000000000000000121671243020563200411200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Apr 8, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.assertions.error.ShouldBeLenientEqualByIgnoring.shouldBeLenientEqualByIgnoring; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Employee; import org.fest.test.Jedi; /** * Tests for {@link Objects#assertIsLenientEqualsToByIgnoringFields(AssertionInfo, Object, Object, String...). * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsLenientEqualsToByIgnoringFields_Test extends ObjectsBaseTest { @Test public void should_pass_when_fields_are_equal() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByIgnoringFields(someInfo(), actual, other); } @Test public void should_pass_when_not_ignored_fields_are_equal() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Blue"); objects.assertIsLenientEqualsToByIgnoringFields(someInfo(), actual, other, "lightSaberColor"); } @Test public void should_pass_when_not_ignored_inherited_fields_are_equal() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Luke", "Green"); objects.assertIsLenientEqualsToByIgnoringFields(someInfo(), actual, other, "name"); } @Test public void should_pass_when_field_values_are_null() { Jedi actual = new Jedi("Yoda", null); Jedi other = new Jedi("Yoda", null); objects.assertIsLenientEqualsToByIgnoringFields(someInfo(), actual, other, "name"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByIgnoringFields(someInfo(), null, other, "name"); } @Test public void should_fail_when_some_field_values_differ() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Blue"); try { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other, "name"); } catch (AssertionError err) { verify(failures).failure( info, shouldBeLenientEqualByIgnoring(actual, newArrayList("lightSaberColor"), newArrayList((Object) "Blue"), newArrayList("name"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_some_inherited_field_values_differ() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Luke", "Green"); try { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other, "lightSaberColor"); } catch (AssertionError err) { verify(failures).failure( info, shouldBeLenientEqualByIgnoring(actual, newArrayList("name"), newArrayList((Object) "Luke"), newArrayList("lightSaberColor"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_objects_to_compare_are_of_different_types() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Employee other = new Employee(); try { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other, "name"); } catch (AssertionError err) { verify(failures).failure(info, shouldBeInstance(other, actual.getClass())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_some_field_value_is_null_on_one_object_only() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", null); Jedi other = new Jedi("Yoda", "Green"); try { objects.assertIsLenientEqualsToByIgnoringFields(info, actual, other, "name"); } catch (AssertionError err) { List expected = newArrayList((Object) "Green"); verify(failures).failure(info, shouldBeLenientEqualByIgnoring(actual, newArrayList("lightSaberColor"), expected, newArrayList("name"))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsLenientEqualsToByIgnoringNullFields_Test.java000066400000000000000000000077451243020563200417610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Apr 8, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeInstance.shouldBeInstance; import static org.fest.assertions.error.ShouldBeLenientEqualByIgnoring.shouldBeLenientEqualByIgnoring; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Employee; import org.fest.test.Jedi; /** * Tests for {@link Objects#assertIsLenientEqualsToByIgnoringNull(AssertionInfo, Object, Object). * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsLenientEqualsToByIgnoringNullFields_Test extends ObjectsBaseTest { @Test public void should_pass_when_fields_are_equal() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByIgnoringNullFields(someInfo(), actual, other); } @Test public void should_pass_when_some_other_field_is_null_but_not_actual() { Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Yoda", null); objects.assertIsLenientEqualsToByIgnoringNullFields(someInfo(), actual, other); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); Jedi other = new Jedi("Yoda", "Green"); objects.assertIsLenientEqualsToByIgnoringNullFields(someInfo(), null, other); } @Test public void should_fail_when_some_actual_field_is_null_but_not_other() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", null); Jedi other = new Jedi("Yoda", "Green"); try { objects.assertIsLenientEqualsToByIgnoringNullFields(info, actual, other); } catch (AssertionError err) { List emptyList = newArrayList(); verify(failures).failure(info, shouldBeLenientEqualByIgnoring(actual, newArrayList("lightSaberColor"), newArrayList((Object) "Green"), emptyList)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_a_field_differ() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Jedi other = new Jedi("Soda", "Green"); try { objects.assertIsLenientEqualsToByIgnoringNullFields(info, actual, other); } catch (AssertionError err) { List emptyList = newArrayList(); verify(failures).failure(info, shouldBeLenientEqualByIgnoring(actual, newArrayList("name"), newArrayList((Object) "Soda"), emptyList)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_when_objects_to_compare_are_of_different_types() { AssertionInfo info = someInfo(); Jedi actual = new Jedi("Yoda", "Green"); Employee other = new Employee(); try { objects.assertIsLenientEqualsToByIgnoringNullFields(info, actual, other); } catch (AssertionError err) { verify(failures).failure(info, shouldBeInstance(other, actual.getClass())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsNotExactlyInstanceOf_Test.java000066400000000000000000000045001243020563200367610ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 11, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeExactlyInstanceOf.shouldNotBeExactlyInstance; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.junit.Test; /** * Tests for {@link Objects#assertIsNotExactlyInstanceOf(AssertionInfo, Object, Class)}. * * @author Nicolas François */ public class Objects_assertIsNotExactlyInstanceOf_Test extends ObjectsBaseTest { @Test public void should_pass_if_actual_is_not_exactly_instance_of_type() { objects.assertIsNotExactlyInstanceOf(someInfo(), "Yoda", Object.class); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given type should not be null"); objects.assertIsNotExactlyInstanceOf(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsNotExactlyInstanceOf(someInfo(), null, String.class); } @Test public void should_fail_if_actual_is_exactly_instance_of_type() { AssertionInfo info = someInfo(); try { objects.assertIsNotExactlyInstanceOf(info, "Yoda", String.class); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldNotBeExactlyInstance("Yoda", String.class)); } } } Objects_assertIsNotIn_with_Iterable_Test.java000066400000000000000000000065641243020563200366220ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jan 5, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static java.util.Collections.emptyList; import static org.fest.assertions.error.ShouldNotBeIn.shouldNotBeIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.junit.BeforeClass; import org.junit.Test; /** * Tests for {@link Objects#assertIsNotIn(AssertionInfo, Object, Iterable)}. * * @author Joel Costigliola * @author Alex Ruiz * @author Yvonne Wang * @author Nicolas François */ public class Objects_assertIsNotIn_with_Iterable_Test extends ObjectsBaseTest { private static Iterable values; @BeforeClass public static void setUpOnce() { values = newArrayList("Yoda", "Leia"); } @Test public void should_throw_error_if_Iterable_is_null() { thrown.expectNullPointerException(iterableIsNull()); Iterable c = null; objects.assertIsNotIn(someInfo(), "Luke", c); } @Test public void should_throw_error_if_Iterable_is_empty() { thrown.expectIllegalArgumentException(iterableIsEmpty()); objects.assertIsNotIn(someInfo(), "Luke", emptyList()); } @Test public void should_pass_if_actual_is_not_in_Iterable() { objects.assertIsNotIn(someInfo(), "Luke", values); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsNotIn(someInfo(), null, values); } @Test public void should_fail_if_actual_is_in_Iterable() { AssertionInfo info = someInfo(); try { objects.assertIsNotIn(info, "Yoda", values); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeIn("Yoda", values)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_in_Iterable_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertIsNotIn(someInfo(), "Luke", values); } @Test public void should_fail_if_actual_is_in_Iterable_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertIsNotIn(info, "YODA", values); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeIn("YODA", values, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsNotIn_with_array_Test.java000066400000000000000000000065011243020563200362000ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jan 2, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeIn.shouldNotBeIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ObjectArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertIsNotIn(AssertionInfo, Object, Object[])}. * * @author Joel Costigliola * @author Alex Ruiz * @author Yvonne Wang */ public class Objects_assertIsNotIn_with_array_Test extends ObjectsBaseTest { private static String[] values; @BeforeClass public static void setUpOnce() { values = array("Yoda", "Leia"); } @Test public void should_throw_error_if_array_is_null() { thrown.expectNullPointerException(arrayIsNull()); Object[] array = null; objects.assertIsNotIn(someInfo(), "Yoda", array); } @Test public void should_throw_error_if_array_is_empty() { thrown.expectIllegalArgumentException(arrayIsEmpty()); objects.assertIsNotIn(someInfo(), "Yoda", emptyArray()); } @Test public void should_pass_if_actual_is_in_not_array() { objects.assertIsNotIn(someInfo(), "Luke", values); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsNotIn(someInfo(), null, values); } @Test public void should_fail_if_actual_is_not_in_array() { AssertionInfo info = someInfo(); try { objects.assertIsNotIn(info, "Yoda", values); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeIn("Yoda", values)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_in_not_array_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertIsNotIn(someInfo(), "Luke", values); } @Test public void should_fail_if_actual_is_not_in_array_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertIsNotIn(info, "YODA", values); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeIn("YODA", values, customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertIsNotInstanceOfAny_Test.java000066400000000000000000000061371243020563200361070ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeInstanceOfAny.shouldNotBeInstanceOfAny; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import java.io.File; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsNotInstanceOfAny(AssertionInfo, Object, Class[])}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsNotInstanceOfAny_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_not_instance_of_any_type() { Class[] types = { String.class, File.class }; objects.assertIsNotInstanceOfAny(someInfo(), actual, types); } @Test public void should_throw_error_if_array_of_types_is_null() { thrown.expectNullPointerException("The given array of types should not be null"); objects.assertIsNotInstanceOfAny(someInfo(), actual, null); } @Test public void should_throw_error_if_array_of_types_is_empty() { thrown.expectIllegalArgumentException("The given array of types should not be empty"); objects.assertIsNotInstanceOfAny(someInfo(), actual, new Class[0]); } @Test public void should_throw_error_if_array_of_types_has_null_elements() { Class[] types = { null, String.class }; thrown.expectNullPointerException("The given array of types:<[null, java.lang.String]> should not have null elements"); objects.assertIsNotInstanceOfAny(someInfo(), actual, types); } @Test public void should_fail_if_actual_is_null() { Class[] types = { Object.class }; thrown.expectAssertionError(actualIsNull()); objects.assertIsNotInstanceOfAny(someInfo(), null, types); } @Test public void should_fail_if_actual_is_instance_of_any_type() { AssertionInfo info = someInfo(); Class[] types = { String.class, Person.class }; try { objects.assertIsNotInstanceOfAny(info, actual, types); fail(); } catch (AssertionError err) {} verify(failures).failure(info, shouldNotBeInstanceOfAny(actual, types)); } } Objects_assertIsNotInstanceOf_Test.java000066400000000000000000000045341243020563200354360ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 3, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeInstance.shouldNotBeInstance; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsNotInstanceOf(AssertionInfo, Object, Class)}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsNotInstanceOf_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_not_instance_of_type() { objects.assertIsNotInstanceOf(someInfo(), actual, String.class); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given type should not be null"); objects.assertIsNotInstanceOf(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); objects.assertIsNotInstanceOf(someInfo(), null, Object.class); } @Test public void should_fail_if_actual_is_instance_of_type() { AssertionInfo info = someInfo(); try { objects.assertIsNotInstanceOf(info, actual, Person.class); fail(); } catch (AssertionError err) {} verify(failures).failure(info, shouldNotBeInstance(actual, Person.class)); } } Objects_assertIsNotOfClassIn_Test.java000066400000000000000000000055431243020563200352270ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeOfClassIn.shouldNotBeOfClassIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.io.File; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsNotOfAnyClassIn(AssertionInfo, Object, Class[])}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsNotOfClassIn_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_not_of_class_in_types() { Class[] types = new Class[] { File.class, String.class }; objects.assertIsNotOfAnyClassIn(someInfo(), actual, types); } @Test public void should_pass_if_actual_is__of_class_in_empty_types() { Class[] types = new Class[] {}; objects.assertIsNotOfAnyClassIn(someInfo(), actual, types); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given types should not be null"); objects.assertIsNotOfAnyClassIn(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { Class[] types = new Class[] { File.class, Person.class, String.class }; thrown.expectAssertionError(actualIsNull()); objects.assertIsNotOfAnyClassIn(someInfo(), null, types); } @Test public void should_fail_if_actual_is_of_class_in_types() { AssertionInfo info = someInfo(); Class[] types = new Class[] { File.class, Person.class, String.class }; try { objects.assertIsNotOfAnyClassIn(info, actual, types); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldNotBeOfClassIn(actual, types)); } } } Objects_assertIsOfClassIn_Test.java000066400000000000000000000060321243020563200345400ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Jun 12, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeOfClassIn.shouldBeOfClassIn; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.io.File; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertIsOfAnyClassIn(AssertionInfo, Object, Class[])}. * * @author Nicolas François * @author Joel Costigliola */ public class Objects_assertIsOfClassIn_Test extends ObjectsBaseTest { private static Person actual; @BeforeClass public static void setUpOnce() { actual = new Person("Yoda"); } @Test public void should_pass_if_actual_is_of_class_in_types() { Class[] types = new Class[] { File.class, Person.class, String.class }; objects.assertIsOfAnyClassIn(someInfo(), actual, types); } @Test public void should_throw_error_if_type_is_null() { thrown.expectNullPointerException("The given types should not be null"); objects.assertIsOfAnyClassIn(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { Class[] types = new Class[] { File.class, Person.class, String.class }; thrown.expectAssertionError(actualIsNull()); objects.assertIsOfAnyClassIn(someInfo(), null, types); } @Test public void should_fail_if_actual_is_not_of_class_in_types() { AssertionInfo info = someInfo(); Class[] types = new Class[] { File.class, String.class }; try { objects.assertIsOfAnyClassIn(info, actual, types); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldBeOfClassIn(actual, types)); } } @Test public void should_fail_if_actual_is_not_of_class_in_empty_types() { AssertionInfo info = someInfo(); Class[] types = new Class[] {}; try { objects.assertIsOfAnyClassIn(info, actual, types); failBecauseExpectedAssertionErrorWasNotThrown(); } catch (AssertionError err) { verify(failures).failure(info, shouldBeOfClassIn(actual, types)); } } } Objects_assertNotEqual_Test.java000066400000000000000000000045471243020563200341640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Sep 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertNotEqual(AssertionInfo, Object, Object)}. * * @author Alex Ruiz */ public class Objects_assertNotEqual_Test extends ObjectsBaseTest { @Test public void should_pass_if_objects_are_not_equal() { objects.assertNotEqual(someInfo(), "Yoda", "Luke"); } @Test public void should_fail_if_objects_are_equal() { AssertionInfo info = someInfo(); try { objects.assertNotEqual(info, "Yoda", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual("Yoda", "Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_objects_are_not_equal_according_to_custom_comparison_strategy() { objectsWithCustomComparisonStrategy.assertNotEqual(someInfo(), "Yoda", "Luke"); } @Test public void should_fail_if_objects_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { objectsWithCustomComparisonStrategy.assertNotEqual(info, "YoDA", "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual("YoDA", "Yoda", customComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertNotNull_Test.java000066400000000000000000000033331243020563200340170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Sep 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeNull.shouldNotBeNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertNotNull(AssertionInfo, Object)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertNotNull_Test extends ObjectsBaseTest { @Test public void should_pass_if_object_is_not_null() { objects.assertNotNull(someInfo(), "Luke"); } @Test public void should_fail_if_object_is_null() { AssertionInfo info = someInfo(); try { objects.assertNotNull(info, null); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeNull()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Objects_assertNotSame_Test.java000066400000000000000000000035041243020563200337720ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldNotBeSame.shouldNotBeSame; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertNotSame(AssertionInfo, Object, Object)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertNotSame_Test extends ObjectsBaseTest { @Test public void should_pass_if_objects_are_not_same() { objects.assertNotSame(someInfo(), "Yoda", "Luke"); } @Test public void should_fail_if_objects_are_same() { AssertionInfo info = someInfo(); Object actual = new Person("Yoda"); try { objects.assertNotSame(info, actual, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeSame(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/Objects_assertNull_Test.java000066400000000000000000000033671243020563200334240ustar00rootroot00000000000000/* * Created on Sep 16, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; /** * Tests for {@link Objects#assertNull(AssertionInfo, Object)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertNull_Test extends ObjectsBaseTest { @Test public void should_pass_if_object_is_null() { objects.assertNull(someInfo(), null); } @Test public void should_fail_if_object_is_not_null() { AssertionInfo info = someInfo(); Object actual = new Object(); try { objects.assertNull(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual(actual, null)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/objects/Objects_assertSame_Test.java000066400000000000000000000033661243020563200333760ustar00rootroot00000000000000/* * Created on Sep 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.objects; import static org.fest.assertions.error.ShouldBeSame.shouldBeSame; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Objects; import org.fest.assertions.internal.ObjectsBaseTest; import org.fest.test.Person; /** * Tests for {@link Objects#assertSame(AssertionInfo, Object, Object)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Objects_assertSame_Test extends ObjectsBaseTest { @Test public void should_pass_if_objects_are_same() { Object actual = new Object(); objects.assertSame(someInfo(), actual, actual); } @Test public void should_fail_if_objects_are_not_same() { AssertionInfo info = someInfo(); Object a = new Person("Yoda"); Object e = new Person("Yoda"); try { objects.assertSame(info, a, e); fail(); } catch (AssertionError err) {} verify(failures).failure(info, shouldBeSame(a, e)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/000077500000000000000000000000001243020563200266745ustar00rootroot00000000000000ShortArrays_assertContainsOnly_Test.java000066400000000000000000000134021243020563200366620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldContainOnly.shouldContainOnly; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertContainsOnly(AssertionInfo, short[], short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertContainsOnly_Test extends ShortArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values_only() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(10, 8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once() { actual = arrayOf(6, 8, 10, 8, 8, 8); arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated() { arrays.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10, 6, 8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsOnly(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only() { AssertionInfo info = someInfo(); short[] expected = { 6, 8, 20 }; try { arrays.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet((short) 20), newLinkedHashSet((short) 10))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_only_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_only_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(10, -8, 6)); } @Test public void should_pass_if_actual_contains_given_values_only_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, -8, 10, -8, 10, -8); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, -10)); } @Test public void should_pass_if_actual_contains_given_values_only_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, arrayOf(6, 8, 10, 6, -8, 10)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsOnly(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsOnly(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnly(actual, expected, newLinkedHashSet((short) 20), newLinkedHashSet((short) 10), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertContainsSequence_Test.java000066400000000000000000000150051243020563200375120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldContainSequence.shouldContainSequence; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertContainsSequence(AssertionInfo, short[], short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertContainsSequence_Test extends ShortArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContainsSequence(someInfo(), null, arrayOf(8)); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); short[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20, 22 }; try { arrays.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verifyFailureThrownWhenSequenceNotFound(info, sequence); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenSequenceNotFound(AssertionInfo info, short[] sequence) { verify(failures).failure(info, shouldContainSequence(actual, sequence)); } @Test public void should_pass_if_actual_contains_sequence() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertContainsSequence(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), null, arrayOf(-8)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_whole_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_first_elements_of_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertContainsSequence(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldContainSequence(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContainsSequence(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } ShortArrays_assertContains_Test.java000066400000000000000000000135161243020563200360260ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldContain.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertContains(AssertionInfo, short[], short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertContains_Test extends ShortArraysBaseTest { @Test public void should_pass_if_actual_contains_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order() { arrays.assertContains(someInfo(), actual, arrayOf(8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values() { arrays.assertContains(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once() { actual = arrayOf(6, 8, 10, 10, 8); arrays.assertContains(someInfo(), actual, arrayOf(8)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated() { arrays.assertContains(someInfo(), actual, arrayOf(6, 6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_values() { AssertionInfo info = someInfo(); short[] expected = { 6, 8, 9 }; try { arrays.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet((short) 9))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-6)); } @Test public void should_pass_if_actual_contains_given_values_in_different_order_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(-8, 10)); } @Test public void should_pass_if_actual_contains_all_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_contains_given_values_more_than_once_according_to_custom_comparison_strategy() { actual = arrayOf(6, 8, 10, -10, 8); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(10)); } @Test public void should_pass_if_actual_contains_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, arrayOf(6, 6, -6)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_does_not_contain_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] expected = { 6, 8, 9 }; try { arraysWithCustomComparisonStrategy.assertContains(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet((short) 9), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertContains_at_Index_Test.java000066400000000000000000000114061243020563200376350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.fest.util.FailureMessages.*; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertContains(AssertionInfo, short[], short, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertContains_at_Index_Test extends ShortArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertContains(someInfo(), null, (short) 8, someIndex()); } @Test public void should_fail_if_actual_is_empty() { thrown.expectAssertionError(actualIsEmpty()); arrays.assertContains(someInfo(), emptyArray(), (short) 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertContains(someInfo(), actual, (short) 8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arrays.assertContains(someInfo(), actual, (short) 8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index() { AssertionInfo info = someInfo(); short value = 6; Index index = atIndex(1); try { arrays.assertContains(info, actual, value, index); } catch (AssertionError e) { short found = 8; verify(failures).failure(info, shouldContainAtIndex(actual, value, index, found)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index() { arrays.assertContains(someInfo(), actual, (short) 8, atIndex(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), null, (short) 8, someIndex()); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsEmpty()); arraysWithCustomComparisonStrategy.assertContains(someInfo(), emptyArray(), (short) 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (short) 8, null); } @Test public void should_throw_error_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { thrown.expectIndexOutOfBoundsException("Index should be between <0> and <2> (inclusive,) but was <6>"); arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (short) 8, atIndex(6)); } @Test public void should_fail_if_actual_does_not_contain_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short value = 6; Index index = atIndex(1); try { arraysWithCustomComparisonStrategy.assertContains(info, actual, value, index); } catch (AssertionError e) { short found = 8; verify(failures).failure(info, shouldContainAtIndex(actual, value, index, found, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertContains(someInfo(), actual, (short) -8, atIndex(1)); } } ShortArrays_assertDoesNotContain_Test.java000066400000000000000000000114521243020563200371340ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldNotContain.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertDoesNotContain(AssertionInfo, short[], short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertDoesNotContain_Test extends ShortArraysBaseTest { @Test public void should_pass_if_actual_does_not_contain_given_values() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() { arrays.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_actual_contains_given_values() { AssertionInfo info = someInfo(); short[] expected = { 6, 8, 20 }; try { arrays.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet((short) 6, (short) 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_contain_given_values_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12)); } @Test public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, arrayOf(12, 12, 20)); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, emptyArray()); } @Test public void should_throw_error_if_array_of_values_to_look_for_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_actual_contains_given_values_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] expected = { 6, -8, 20 }; try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, expected); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet((short) 6, (short) -8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertDoesNotContain_at_Index_Test.java000066400000000000000000000107561243020563200407550ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.data.Index.atIndex; import static org.fest.assertions.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.data.Index; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertDoesNotContain(AssertionInfo, short[], short, Index)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertDoesNotContain_at_Index_Test extends ShortArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotContain(someInfo(), null, (short) 8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index() { arrays.assertDoesNotContain(someInfo(), actual, (short) 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotContain(someInfo(), emptyArray(), (short) 8, someIndex()); } @Test public void should_throw_error_if_Index_is_null() { thrown.expectNullPointerException("Index should not be null"); arrays.assertDoesNotContain(someInfo(), actual, (short) 8, null); } @Test public void should_pass_if_Index_is_out_of_bounds() { arrays.assertDoesNotContain(someInfo(), actual, (short) 8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index() { AssertionInfo info = someInfo(); short value = 6; Index index = atIndex(0); try { arrays.assertDoesNotContain(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, value, index)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), null, (short) -8, someIndex()); } @Test public void should_pass_if_actual_does_not_contain_value_at_Index_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (short) 6, atIndex(1)); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), emptyArray(), (short) -8, someIndex()); } @Test public void should_throw_error_if_Index_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException("Index should not be null"); arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (short) -8, null); } @Test public void should_pass_if_Index_is_out_of_bounds_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotContain(someInfo(), actual, (short) -8, atIndex(6)); } @Test public void should_fail_if_actual_contains_value_at_index_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short value = 6; Index index = atIndex(0); try { arraysWithCustomComparisonStrategy.assertDoesNotContain(info, actual, value, index); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContainAtIndex(actual, value, index, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertDoesNotHaveDuplicates_Test.java000066400000000000000000000072701243020563200404450ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Sets.newLinkedHashSet; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertDoesNotHaveDuplicates(AssertionInfo, short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertDoesNotHaveDuplicates_Test extends ShortArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8); } @Test public void should_pass_if_actual_does_not_have_duplicates() { arrays.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates() { AssertionInfo info = someInfo(); actual = arrayOf(6, 8, 6, 8); try { arrays.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet((short) 6, (short) 8))); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_does_not_have_duplicates_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(someInfo(), null); } @Test public void should_fail_if_actual_contains_duplicates_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(6, -8, 6, 8); try { arraysWithCustomComparisonStrategy.assertDoesNotHaveDuplicates(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldNotHaveDuplicates(actual, newLinkedHashSet((short) 6, (short) 8), absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertEmpty_Test.java000066400000000000000000000040101243020563200353330ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertEmpty(AssertionInfo, short[])}. * * @author Alex Ruiz */ public class ShortArrays_assertEmpty_Test extends ShortArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); short[] actual = { 6, 8 }; try { arrays.assertEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { arrays.assertEmpty(someInfo(), emptyArray()); } } ShortArrays_assertEndsWith_Test.java000066400000000000000000000142501243020563200357710ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertEndsWith(AssertionInfo, short[], short[])}. * * @author Alex Ruiz */ public class ShortArrays_assertEndsWith_Test extends ShortArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertEndsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); short[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence() { AssertionInfo info = someInfo(); short[] sequence = { 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20, 22 }; try { arrays.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence() { arrays.assertEndsWith(someInfo(), actual, arrayOf(8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertEndsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_end_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_ends_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertEndsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_ends_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(-8, 10, 12)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertEndsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } ShortArrays_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000047331243020563200411020ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.fest.util.FailureMessages.actualIsNull; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.*; import org.junit.*; /** * Tests for {@link ShortArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François */ public class ShortArrays_assertHasSameSizeAs_with_Array_Test extends ShortArraysBaseTest { private static short[] actual; @BeforeClass public static void setUpOnce() { // don't use a static import here, it leads to a compilation error with oracle jdk 1.7.0_05 compiler due to the // other array static import. actual = arrayOf(6, 8); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia", "Yoda"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia")); } } ShortArrays_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000047771243020563200415630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.arrayOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.junit.BeforeClass; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François */ public class ShortArrays_assertHasSameSizeAs_with_Iterable_Test extends ShortArraysBaseTest { private static short[] actual; private final List other = newArrayList("Solo", "Leia"); @BeforeClass public static void setUpOnce() { actual = arrayOf(6, 8); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSameSizeAs(someInfo(), null, other); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia", "Yoda"); try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length, other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSameSizeAs(someInfo(), actual, other); } } ShortArrays_assertHasSize_Test.java000066400000000000000000000040371243020563200356140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertHasSize(AssertionInfo, short[], int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertHasSize_Test extends ShortArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); try { arrays.assertHasSize(info, actual, 2); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length, 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { arrays.assertHasSize(someInfo(), actual, 3); } } ShortArrays_assertIsSortedAccordingToComparator_Test.java000066400000000000000000000071341243020563200421500ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldBeSorted.shouldBeSortedAccordingToGivenComparator; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.Comparator; import org.junit.Before; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertIsSortedAccordingToComparator(AssertionInfo, short[], Comparator)} * * @author Joel Costigliola */ public class ShortArrays_assertIsSortedAccordingToComparator_Test extends ShortArraysBaseTest { private Comparator shortDescendingOrderComparator; private Comparator shortAscendingOrderComparator; @Override @Before public void setUp() { super.setUp(); actual = new short[] { 4, 3, 2, 2, 1 }; shortDescendingOrderComparator = new Comparator() { public int compare(Short short1, Short short2) { return -short1.compareTo(short2); } }; shortAscendingOrderComparator = new Comparator() { public int compare(Short short1, Short short2) { return -short1.compareTo(short2); } }; } @Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, shortDescendingOrderComparator); } @Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), shortDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), shortAscendingOrderComparator); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, shortDescendingOrderComparator); } @Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); } @Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new short[] { 3, 2, 1, 9 }; try { arrays.assertIsSortedAccordingToComparator(info, actual, shortDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual, shortDescendingOrderComparator)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertIsSorted_Test.java000066400000000000000000000075461243020563200360120ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Nov 29, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldBeSorted.*; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertIsSorted(AssertionInfo, Object[])}. * * @author Joel Costigliola */ public class ShortArrays_assertIsSorted_Test extends ShortArraysBaseTest { @Override protected void initActualArray() { actual = new short[] { 1, 2, 3, 4, 4 }; } @Test public void should_pass_if_actual_is_sorted_in_ascending_order() { arrays.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty() { arrays.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element() { arrays.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSorted(someInfo(), (short[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arrays.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSorted(1, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_sorted_in_ascending_order_according_to_custom_comparison_strategy() { actual = new short[] { 1, -2, 3, -4, 4 }; arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), actual); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), emptyArray()); } @Test public void should_pass_if_actual_contains_only_one_element_whatever_custom_comparison_strategy_is() { arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), arrayOf(1)); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertIsSorted(someInfo(), (short[]) null); } @Test public void should_fail_if_actual_is_not_sorted_in_ascending_order_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); actual = arrayOf(1, 3, 2); try { arraysWithCustomComparisonStrategy.assertIsSorted(info, actual); } catch (AssertionError e) { verify(failures) .failure(info, shouldBeSortedAccordingToGivenComparator(1, actual, comparatorForCustomComparisonStrategy())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } ShortArrays_assertNotEmpty_Test.java000066400000000000000000000040221243020563200360170ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertNotEmpty(AssertionInfo, short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertNotEmpty_Test extends ShortArraysBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { arrays.assertNotEmpty(info, emptyArray()); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { arrays.assertNotEmpty(someInfo(), arrayOf(8)); } } ShortArrays_assertNullOrEmpty_Test.java000066400000000000000000000037661243020563200365100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.ShortArrays.emptyArray; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertNullOrEmpty(AssertionInfo, short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertNullOrEmpty_Test extends ShortArraysBaseTest { @Test public void should_fail_if_array_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); short[] actual = { 6, 8 }; try { arrays.assertNullOrEmpty(info, actual); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty(actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_array_is_null() { arrays.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_array_is_empty() { arrays.assertNullOrEmpty(someInfo(), emptyArray()); } } ShortArrays_assertStartsWith_Test.java000066400000000000000000000143711243020563200363640ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shortarrays/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shortarrays; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.*; import static org.fest.assertions.test.ShortArrays.*; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.ShortArrays; import org.fest.assertions.internal.ShortArraysBaseTest; /** * Tests for {@link ShortArrays#assertStartsWith(AssertionInfo, short[], short[])}. * * @author Alex Ruiz * @author Joel Costigliola */ public class ShortArrays_assertStartsWith_Test extends ShortArraysBaseTest { @Override protected void initActualArray() { actual = arrayOf(6, 8, 10, 12); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, arrayOf(8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual() { AssertionInfo info = someInfo(); short[] sequence = { 6, 8, 10, 12, 20, 22 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence() { AssertionInfo info = someInfo(); short[] sequence = { 8, 10 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20 }; try { arrays.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, arrayOf(6, 8, 10, 12)); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(valuesToLookForIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, null); } @Test public void should_throw_error_if_sequence_is_empty_whatever_custom_comparison_strategy_is() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, emptyArray()); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), null, arrayOf(-8)); } @Test public void should_fail_if_sequence_is_bigger_than_actual_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, -8, 10, 12, 20, 22 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_start_with_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { -8, 10 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_starts_with_first_elements_of_sequence_only_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); short[] sequence = { 6, 20 }; try { arraysWithCustomComparisonStrategy.assertStartsWith(info, actual, sequence); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith(actual, sequence, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_starts_with_sequence_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10)); } @Test public void should_pass_if_actual_and_sequence_are_equal_according_to_custom_comparison_strategy() { arraysWithCustomComparisonStrategy.assertStartsWith(someInfo(), actual, arrayOf(6, -8, 10, 12)); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/000077500000000000000000000000001243020563200256355ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/Shorts_assertEqual_Test.java000066400000000000000000000055051243020563200333370ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldBeEqual.shouldBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertEqual(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertEqual_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertEqual(someInfo(), null, (short) 8); } @Test public void should_pass_if_shorts_are_equal() { shorts.assertEqual(someInfo(), (short) 8, (short) 8); } @Test public void should_fail_if_shorts_are_not_equal() { AssertionInfo info = someInfo(); try { shorts.assertEqual(info, (short) 6, (short) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); shortsWithAbsValueComparisonStrategy.assertEqual(someInfo(), null, (short) 8); } @Test public void should_pass_if_shorts_are_equal_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertEqual(someInfo(), (short) 8, (short) -8); } @Test public void should_fail_if_shorts_are_not_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertEqual(info, (short) 6, (short) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Shorts_assertGreaterThanOrEqualTo_Test.java000066400000000000000000000065541243020563200362160ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldBeGreaterOrEqual.shouldBeGreaterOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertGreaterThanOrEqualTo(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertGreaterThanOrEqualTo_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertGreaterThanOrEqualTo(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_greater_than_other() { shorts.assertGreaterThanOrEqualTo(someInfo(), (short) 8, (short) 6); } @Test public void should_pass_if_actual_is_equal_to_other() { shorts.assertGreaterThanOrEqualTo(someInfo(), (short) 6, (short) 6); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { shorts.assertGreaterThanOrEqualTo(info, (short) 6, (short) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual((short) 6, (short) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); shortsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), (short) -8, (short) 6); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(someInfo(), (short) 6, (short) -6); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertGreaterThanOrEqualTo(info, (short) 6, (short) -8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreaterOrEqual((short) 6, (short) -8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Shorts_assertGreaterThan_Test.java000066400000000000000000000074111243020563200344130ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldBeGreater.shouldBeGreater; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertGreaterThan(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertGreaterThan_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertGreaterThan(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_greater_than_other() { shorts.assertGreaterThan(someInfo(), (short) 8, (short) 6); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { shorts.assertGreaterThan(info, (short) 6, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((short) 6, (short) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other() { AssertionInfo info = someInfo(); try { shorts.assertGreaterThan(info, (short) 6, (short) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((short) 6, (short) 8)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } // ------------------------------------------------------------------------------------------------------------------ // tests using a custom comparison strategy // ------------------------------------------------------------------------------------------------------------------ @Test public void should_pass_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertGreaterThan(someInfo(), (short) -8, (short) 6); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertGreaterThan(info, (short) -6, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((short) -6, (short) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertGreaterThan(info, (short) -6, (short) 8); } catch (AssertionError e) { verify(failures).failure(info, shouldBeGreater((short) -6, (short) 8, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Shorts_assertIsNegative_Test.java000066400000000000000000000037451243020563200342530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsNegative(AssertionInfo, Short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertIsNegative_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_negative() { shorts.assertIsNegative(someInfo(), (short) -6); } @Test public void should_fail_since_actual_is_not_negative() { thrown.expectAssertionError("expected:<6> to be less than:<0>"); shorts.assertIsNegative(someInfo(), (short) 6); } @Test public void should_fail_since_actual_can_not_be_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than:<0> according to 'AbsValueComparator' comparator"); shortsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (short) -1); } @Test public void should_fail_since_actual_is_not_negative_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than:<0>"); shortsWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (short) 1); } } Shorts_assertIsNotNegative_Test.java000066400000000000000000000037001243020563200347230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsNotPositive(AssertionInfo, Short)}. * * @author Nicolas François */ public class Shorts_assertIsNotNegative_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_not_negative() { shorts.assertIsNotNegative(someInfo(), (short) 6); } @Test public void should_succeed_since_actual_is_zero() { shorts.assertIsNotNegative(someInfo(), (short) 0); } @Test public void should_fail_since_actual_is_negative() { thrown.expectAssertionError("expected:<-6> to be greater than or equal to:<0>"); shorts.assertIsNotNegative(someInfo(), (short) -6); } @Test public void should_succeed_since_actual_is_not_negative_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), (short) -1); } @Test public void should_succeed_since_actual_positive_is_not_negative_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertIsNotNegative(someInfo(), (short) 1); } } Shorts_assertIsNotPositive_Test.java000066400000000000000000000041141243020563200347630ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on May 28, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsNotPositive(AssertionInfo, Short))}. * * @author Nicolas François */ public class Shorts_assertIsNotPositive_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_not_positive() { shorts.assertIsNotPositive(someInfo(), (short) -6); } @Test public void should_succeed_since_actual_is_zero() { shorts.assertIsNotPositive(someInfo(), (short) 0); } @Test public void should_fail_since_actual_is_positive() { thrown.expectAssertionError("expected:<6> to be less than or equal to:<0>"); shorts.assertIsNotPositive(someInfo(), (short) 6); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<-1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); shortsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (short) -1); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<1> to be less than or equal to:<0> according to 'AbsValueComparator' comparator"); shortsWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (short) 1); } } Shorts_assertIsNotZero_Test.java000066400000000000000000000036641243020563200341110ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsNegative(AssertionInfo, Short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertIsNotZero_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_not_zero() { shorts.assertIsNotZero(someInfo(), (short) 2); } @Test public void should_fail_since_actual_is_zero() { thrown.expectAssertionError("<0> should not be equal to:<0>"); shorts.assertIsNotZero(someInfo(), (short) 0); } @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { shortsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (short) 1); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { shortsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (short) 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } Shorts_assertIsPositive_Test.java000066400000000000000000000036401243020563200343050ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsPositive(AssertionInfo, Short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertIsPositive_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_positive() { shorts.assertIsPositive(someInfo(), (short) 6); } @Test public void should_fail_since_actual_is_not_positive() { thrown.expectAssertionError("expected:<-6> to be greater than:<0>"); shorts.assertIsPositive(someInfo(), (short) -6); } @Test public void should_succeed_since_actual_is_positive_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (short) -1); } @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { thrown.expectAssertionError("expected:<0> to be greater than:<0> according to 'AbsValueComparator' comparator"); shortsWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (short) 0); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/Shorts_assertIsZero_Test.java000066400000000000000000000037371243020563200335100ustar00rootroot00000000000000/* * Created on Oct 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.assertEquals; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertIsNegative(AssertionInfo, Short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertIsZero_Test extends ShortsBaseTest { @Test public void should_succeed_since_actual_is_zero() { shorts.assertIsZero(someInfo(), (short) 0); } @Test public void should_fail_since_actual_is_not_zero() { try { shorts.assertIsZero(someInfo(), (short) 2); } catch (AssertionError e) { assertEquals(e.getMessage(), "expected:<[0]> but was:<[2]>"); } } @Test public void should_succeed_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { shortsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (short) 1); } @Test public void should_fail_since_actual_is_zero_whatever_custom_comparison_strategy_is() { try { shortsWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (short) 0); } catch (AssertionError e) { assertEquals(e.getMessage(), "<0> should not be equal to:<0>"); } } } Shorts_assertLessThanOrEqualTo_Test.java000066400000000000000000000065021243020563200355240ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldBeLessOrEqual.shouldBeLessOrEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertLessThanOrEqualTo(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertLessThanOrEqualTo_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertLessThanOrEqualTo(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_less_than_other() { shorts.assertLessThanOrEqualTo(someInfo(), (short) 6, (short) 8); } @Test public void should_pass_if_actual_is_equal_to_other() { shorts.assertLessThanOrEqualTo(someInfo(), (short) 6, (short) 6); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { shorts.assertLessThanOrEqualTo(info, (short) 8, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual((short) 8, (short) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); shortsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), (short) 6, (short) -8); } @Test public void should_pass_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(someInfo(), (short) 6, (short) -6); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertLessThanOrEqualTo(info, (short) -8, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLessOrEqual((short) -8, (short) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/Shorts_assertLessThan_Test.java000066400000000000000000000072471243020563200340160ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldBeLess.shouldBeLess; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertLessThan(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertLessThan_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertLessThan(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_less_than_other() { shorts.assertLessThan(someInfo(), (short) 6, (short) 8); } @Test public void should_fail_if_actual_is_equal_to_other() { AssertionInfo info = someInfo(); try { shorts.assertLessThan(info, (short) 6, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((short) 6, (short) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other() { AssertionInfo info = someInfo(); try { shorts.assertLessThan(info, (short) 8, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((short) 8, (short) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); shortsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), null, (short) 8); } @Test public void should_pass_if_actual_is_less_than_other_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertLessThan(someInfo(), (short) 6, (short) -8); } @Test public void should_fail_if_actual_is_equal_to_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertLessThan(info, (short) 6, (short) -6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((short) 6, (short) -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_greater_than_other_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertLessThan(info, (short) -8, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldBeLess((short) -8, (short) 6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/shorts/Shorts_assertNotEqual_Test.java000066400000000000000000000055521243020563200340220ustar00rootroot00000000000000/* * Created on Oct 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.shorts; import static org.fest.assertions.error.ShouldNotBeEqual.shouldNotBeEqual; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Shorts; import org.fest.assertions.internal.ShortsBaseTest; /** * Tests for {@link Shorts#assertNotEqual(AssertionInfo, Short, short)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Shorts_assertNotEqual_Test extends ShortsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); shorts.assertNotEqual(someInfo(), null, (short) 8); } @Test public void should_pass_if_shorts_are_not_equal() { shorts.assertNotEqual(someInfo(), (short) 8, (short) 6); } @Test public void should_fail_if_shorts_are_equal() { AssertionInfo info = someInfo(); try { shorts.assertNotEqual(info, (short) 6, (short) 6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual((short) 6, (short) 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); shortsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), null, (short) 8); } @Test public void should_pass_if_shorts_are_not_equal_according_to_custom_comparison_strategy() { shortsWithAbsValueComparisonStrategy.assertNotEqual(someInfo(), (short) 8, (short) 6); } @Test public void should_fail_if_shorts_are_equal_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { shortsWithAbsValueComparisonStrategy.assertNotEqual(info, (short) 6, (short) -6); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEqual((short) 6, (short) -6, absValueComparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/000077500000000000000000000000001243020563200260045ustar00rootroot00000000000000Strings_assertContainsIgnoringCase_Test.java000066400000000000000000000076251243020563200366030ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldContainString.shouldContainIgnoringCase; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.sequenceToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertContainsIgnoringCase(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertContainsIgnoringCase_Test extends StringsBaseTest { @Test public void should_fail_if_actual_does_not_contain_sequence() { AssertionInfo info = someInfo(); try { strings.assertContainsIgnoringCase(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainIgnoringCase("Yoda", "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(sequenceToLookForIsNull()); strings.assertContainsIgnoringCase(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertContainsIgnoringCase(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_contains_sequence() { strings.assertContainsIgnoringCase(someInfo(), "Yoda", "Yo"); } @Test public void should_pass_if_actual_contains_sequence_in_different_case() { strings.assertContainsIgnoringCase(someInfo(), "Yoda", "yo"); } @Test public void should_fail_if_actual_does_not_contain_sequence_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainIgnoringCase("Yoda", "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_sequence_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(sequenceToLookForIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_contains_sequence_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", "Yo"); } @Test public void should_pass_if_actual_contains_sequence_in_different_case_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertContainsIgnoringCase(someInfo(), "Yoda", "yo"); } } Strings_assertContainsOnlyOnce_Test.java000066400000000000000000000072041243020563200357520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/stringspackage org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldContainStringOnlyOnce.shouldContainOnlyOnce; import static org.fest.assertions.test.ErrorMessages.sequenceToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.FailureMessages.actualIsNull; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; public class Strings_assertContainsOnlyOnce_Test extends StringsBaseTest { @Test public void should_pass_if_actual_is_contains_given_string_only_once() { strings.assertContainsOnlyOnce(someInfo(), "Yoda", "Yo"); } @Test public void should_fail_if_actual_contains_given_string_more_than_once() { AssertionInfo info = someInfo(); try { strings.assertContainsOnlyOnce(info, "Yodayoda", "oda"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnlyOnce("Yodayoda", "oda", 2)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_sequence_only_once_but_in_different_case() { AssertionInfo info = someInfo(); try { strings.assertContainsOnlyOnce(info, "Yoda", "yo"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnlyOnce("Yoda", "yo", 0)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_does_not_contain_given_string() { AssertionInfo info = someInfo(); try { strings.assertContainsOnlyOnce(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnlyOnce("Yoda", "Luke", 0)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(sequenceToLookForIsNull()); strings.assertContainsOnlyOnce(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertContainsOnlyOnce(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_contains_sequence_only_once_according_to_custom_comparison_strategy() { stringsWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(someInfo(), "Yoda", "Yo"); stringsWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(someInfo(), "Yoda", "yo"); stringsWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(someInfo(), "Yoda", "YO"); } @Test public void should_fail_if_actual_does_not_contain_sequence_only_once_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnlyOnce("Yoda", "Luke", 0, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_sequence_several_times_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContainOnlyOnce("Yoda", "Luke", 0, comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Strings_assertContains_Test.java000066400000000000000000000066651243020563200343150ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldContainString.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.sequenceToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertContains(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertContains_Test extends StringsBaseTest { @Test public void should_fail_if_actual_does_not_contain_sequence() { AssertionInfo info = someInfo(); try { strings.assertContains(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContain("Yoda", "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_actual_contains_sequence_but_in_different_case() { AssertionInfo info = someInfo(); try { strings.assertContains(info, "Yoda", "yo"); } catch (AssertionError e) { verify(failures).failure(info, shouldContain("Yoda", "yo")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(sequenceToLookForIsNull()); strings.assertContains(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertContains(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_contains_sequence() { strings.assertContains(someInfo(), "Yoda", "Yo"); } @Test public void should_pass_if_actual_contains_sequence_according_to_custom_comparison_strategy() { stringsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), "Yoda", "Yo"); stringsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), "Yoda", "yo"); stringsWithCaseInsensitiveComparisonStrategy.assertContains(someInfo(), "Yoda", "YO"); } @Test public void should_fail_if_actual_does_not_contain_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertContains(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldContain("Yoda", "Luke", comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Strings_assertDoesNotContain_Test.java000066400000000000000000000056721243020563200354230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldNotContainString.shouldNotContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.sequenceToLookForIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertDoesNotContain(AssertionInfo, String, String)}. * * @author Alex Ruiz */ public class Strings_assertDoesNotContain_Test extends StringsBaseTest { @Test public void should_fail_if_actual_contains_sequence() { AssertionInfo info = someInfo(); try { strings.assertDoesNotContain(info, "Yoda", "oda"); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain("Yoda", "oda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(sequenceToLookForIsNull()); strings.assertDoesNotContain(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertDoesNotContain(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_does_not_contain_sequence() { strings.assertDoesNotContain(someInfo(), "Yoda", "Lu"); } @Test public void should_pass_if_actual_does_not_contain_sequence_according_to_custom_comparison_strategy() { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(someInfo(), "Yoda", "Lu"); } @Test public void should_fail_if_actual_does_not_contain_sequence_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotContain(info, "Yoda", "yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldNotContain("Yoda", "yoda", comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Strings_assertDoesNotMatch_Pattern_Test.java000066400000000000000000000070171243020563200365540ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldNotMatchPattern.shouldNotMatch; import static org.fest.assertions.test.ErrorMessages.regexPatternIsNull; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.regex.Pattern; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertDoesNotMatch(AssertionInfo, String, Pattern)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertDoesNotMatch_Pattern_Test extends StringsBaseTest { private String actual = "Yoda"; @Test public void should_throw_error_if_Pattern_is_null() { thrown.expectNullPointerException(regexPatternIsNull()); Pattern pattern = null; strings.assertDoesNotMatch(someInfo(), actual, pattern); } @Test public void should_fail_if_actual_matches_Pattern() { AssertionInfo info = someInfo(); Pattern pattern = matchAnything(); try { strings.assertDoesNotMatch(info, actual, pattern); } catch (AssertionError e) { verify(failures).failure(info, shouldNotMatch(actual, pattern.pattern())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null() { strings.assertDoesNotMatch(someInfo(), null, matchAnything()); } @Test public void should_pass_if_actual_does_not_match_Pattern() { strings.assertDoesNotMatch(someInfo(), actual, Pattern.compile("Luke")); } @Test public void should_throw_error_if_Pattern_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(regexPatternIsNull()); Pattern pattern = null; stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), actual, pattern); } @Test public void should_fail_if_actual_matches_Pattern_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); Pattern pattern = matchAnything(); try { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(info, actual, pattern); } catch (AssertionError e) { verify(failures).failure(info, shouldNotMatch(actual, pattern.pattern())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), null, matchAnything()); } @Test public void should_pass_if_actual_does_not_match_Pattern_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), actual, Pattern.compile("Luke")); } } Strings_assertDoesNotMatch_String_Test.java000066400000000000000000000100041243020563200363730ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldNotMatchPattern.shouldNotMatch; import static org.fest.assertions.test.ErrorMessages.regexPatternIsNull; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.regex.PatternSyntaxException; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertDoesNotMatch(AssertionInfo, String, String)}. * * @author Alex Ruiz */ public class Strings_assertDoesNotMatch_String_Test extends StringsBaseTest { private String actual = "Yoda"; @Test public void should_throw_error_if_regular_expression_is_null() { thrown.expectNullPointerException(regexPatternIsNull()); String pattern = null; strings.assertDoesNotMatch(someInfo(), actual, pattern); } @Test public void should_throw_error_if_syntax_of_regular_expression_is_invalid() { thrown.expect(PatternSyntaxException.class); strings.assertDoesNotMatch(someInfo(), actual, "*..."); } @Test public void should_fail_if_actual_matches_regular_expression() { AssertionInfo info = someInfo(); String regex = matchAnything().pattern(); try { strings.assertDoesNotMatch(info, actual, regex); } catch (AssertionError e) { verify(failures).failure(info, shouldNotMatch(actual, regex)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null() { strings.assertDoesNotMatch(someInfo(), null, matchAnything().pattern()); } @Test public void should_pass_if_actual_does_not_match_regular_expression() { strings.assertDoesNotMatch(someInfo(), actual, "Luke"); } @Test public void should_throw_error_if_regular_expression_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(regexPatternIsNull()); String pattern = null; stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), actual, pattern); } @Test public void should_throw_error_if_syntax_of_regular_expression_is_invalid_whatever_custom_comparison_strategy_is() { thrown.expect(PatternSyntaxException.class); stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), actual, "*..."); } @Test public void should_fail_if_actual_matches_regular_expression_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); String regex = matchAnything().pattern(); try { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(info, actual, regex); } catch (AssertionError e) { verify(failures).failure(info, shouldNotMatch(actual, regex)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), null, matchAnything().pattern()); } @Test public void should_pass_if_actual_does_not_match_regular_expression_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertDoesNotMatch(someInfo(), actual, "Luke"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/Strings_assertEmpty_Test.java000066400000000000000000000053131243020563200337010ustar00rootroot00000000000000/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldBeEmpty.shouldBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertEmpty(AssertionInfo, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertEmpty_Test extends StringsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty() { AssertionInfo info = someInfo(); try { strings.assertEmpty(info, "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty("Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty() { strings.assertEmpty(someInfo(), ""); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_not_empty_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertEmpty(info, "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeEmpty("Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertEmpty(someInfo(), ""); } } Strings_assertEndsWith_Test.java000066400000000000000000000062651243020563200342600ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertEndsWith(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertEndsWith_Test extends StringsBaseTest { @Test public void should_fail_if_actual_does_not_end_with_suffix() { AssertionInfo info = someInfo(); try { strings.assertEndsWith(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith("Yoda", "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_suffix_is_null() { thrown.expectNullPointerException("The given suffix should not be null"); strings.assertEndsWith(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertEndsWith(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_ends_with_suffix() { strings.assertEndsWith(someInfo(), "Yoda", "oda"); } @Test public void should_pass_if_actual_ends_with_suffix_according_to_custom_comparison_strategy() { stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), "Yoda", "oda"); stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), "Yoda", "da"); stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), "Yoda", "a"); stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), "Yoda", "Oda"); stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(someInfo(), "Yoda", "ODA"); } @Test public void should_fail_if_actual_does_not_end_with_suffix_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertEndsWith(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldEndWith("Yoda", "Luke", comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } Strings_assertEqualsIgnoringCase_Test.java000066400000000000000000000112561243020563200362520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldBeEqualIgnoringCase.shouldBeEqual; import static org.fest.assertions.test.CharArrays.arrayOf; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertEqualsIgnoringCase(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertEqualsIgnoringCase_Test extends StringsBaseTest { @Test public void should_fail_if_actual_is_null_and_expected_is_not() { AssertionInfo info = someInfo(); try { strings.assertEqualsIgnoringCase(info, null, "Luke"); } catch (AssertionError e) { verifyFailureThrownWhenStringsAreNotEqual(info, null, "Luke"); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_both_Strings_are_not_equal_regardless_of_case() { AssertionInfo info = someInfo(); try { strings.assertEqualsIgnoringCase(info, "Yoda", "Luke"); } catch (AssertionError e) { verifyFailureThrownWhenStringsAreNotEqual(info, "Yoda", "Luke"); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } private void verifyFailureThrownWhenStringsAreNotEqual(AssertionInfo info, String actual, String expected) { verify(failures).failure(info, shouldBeEqual(actual, expected)); } @Test public void should_pass_if_both_Strings_are_null() { strings.assertEqualsIgnoringCase(someInfo(), null, null); } @Test public void should_pass_if_both_Strings_are_the_same() { String s = "Yoda"; strings.assertEqualsIgnoringCase(someInfo(), s, s); } @Test public void should_pass_if_both_Strings_are_equal_but_not_same() { strings.assertEqualsIgnoringCase(someInfo(), "Yoda", new String(arrayOf('Y', 'o', 'd', 'a'))); } @Test public void should_pass_if_both_Strings_are_equal_ignoring_case() { strings.assertEqualsIgnoringCase(someInfo(), "Yoda", "YODA"); } @Test public void should_fail_if_actual_is_null_and_expected_is_not_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(info, null, "Luke"); } catch (AssertionError e) { verifyFailureThrownWhenStringsAreNotEqual(info, null, "Luke"); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_fail_if_both_Strings_are_not_equal_regardless_of_case_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(info, "Yoda", "Luke"); } catch (AssertionError e) { verifyFailureThrownWhenStringsAreNotEqual(info, "Yoda", "Luke"); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_both_Strings_are_null_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(someInfo(), null, null); } @Test public void should_pass_if_both_Strings_are_the_same_whatever_custom_comparison_strategy_is() { String s = "Yoda"; stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(someInfo(), s, s); } @Test public void should_pass_if_both_Strings_are_equal_but_not_same_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(someInfo(), "Yoda", new String( arrayOf('Y', 'o', 'd', 'a'))); } @Test public void should_pass_if_both_Strings_are_equal_ignoring_case_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertEqualsIgnoringCase(someInfo(), "Yoda", "YODA"); } } Strings_assertHasSameSizeAs_with_Array_Test.java000066400000000000000000000044021243020563200373530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Arrays.array; import static org.mockito.Mockito.verify; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.BooleanArrays; import org.junit.Test; /** * Tests for {@link BooleanArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Object[])}. * * @author Nicolas François */ public class Strings_assertHasSameSizeAs_with_Array_Test extends StringsBaseTest { private static String actual = "Han"; @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertHasSameSizeAs(someInfo(), null, array("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String[] other = array("Solo", "Leia"); try { strings.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length(), other.length)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { strings.assertHasSameSizeAs(someInfo(), actual, array("Solo", "Leia", "Yoda")); } } Strings_assertHasSameSizeAs_with_Iterable_Test.java000066400000000000000000000044741243020563200400350ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Jun 4, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.fest.util.Lists.newArrayList; import static org.mockito.Mockito.verify; import java.util.List; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.BooleanArrays; import org.junit.Test; /** * Tests for {@link BooleanArrays#assertHasSameSizeAs(AssertionInfo, boolean[], Iterable)}. * * @author Nicolas François */ public class Strings_assertHasSameSizeAs_with_Iterable_Test extends StringsBaseTest { private static String actual = "Han"; @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertHasSameSizeAs(someInfo(), null, newArrayList("Solo", "Leia")); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); List other = newArrayList("Solo", "Leia"); try { strings.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSameSizeAs(actual, actual.length(), other.size())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { strings.assertHasSameSizeAs(someInfo(), actual, newArrayList("Solo", "Leia", "Yoda")); } } Strings_assertHasSize_Test.java000066400000000000000000000056761243020563200341060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 14, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldHaveSize.shouldHaveSize; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertHasSize(AssertionInfo, String, int)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertHasSize_Test extends StringsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { AssertionInfo info = someInfo(); String actual = "Han"; try { strings.assertHasSize(info, actual, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length(), 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size() { strings.assertHasSize(someInfo(), "Han", 3); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertHasSize(someInfo(), null, 3); } @Test public void should_fail_if_size_of_actual_is_not_equal_to_expected_size_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); String actual = "Han"; try { stringsWithCaseInsensitiveComparisonStrategy.assertHasSize(info, actual, 6); } catch (AssertionError e) { verify(failures).failure(info, shouldHaveSize(actual, actual.length(), 6)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_size_of_actual_is_equal_to_expected_size_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertHasSize(someInfo(), "Han", 3); } } Strings_assertMatches_Pattern_Test.java000066400000000000000000000070531243020563200356100ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldMatchPattern.shouldMatch; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.regexPatternIsNull; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.regex.Pattern; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertMatches(AssertionInfo, String, Pattern)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertMatches_Pattern_Test extends StringsBaseTest { private String actual = "Yoda"; @Test public void should_throw_error_if_Pattern_is_null() { thrown.expectNullPointerException(regexPatternIsNull()); Pattern pattern = null; strings.assertMatches(someInfo(), actual, pattern); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertMatches(someInfo(), null, matchAnything()); } @Test public void should_fail_if_actual_does_not_match_Pattern() { AssertionInfo info = someInfo(); try { strings.assertMatches(info, actual, Pattern.compile("Luke")); } catch (AssertionError e) { verify(failures).failure(info, shouldMatch(actual, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_matches_Pattern() { strings.assertMatches(someInfo(), actual, Pattern.compile("Yod.*")); } @Test public void should_throw_error_if_Pattern_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(regexPatternIsNull()); Pattern pattern = null; stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), actual, pattern); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), null, matchAnything()); } @Test public void should_fail_if_actual_does_not_match_Pattern_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertMatches(info, actual, Pattern.compile("Luke")); } catch (AssertionError e) { verify(failures).failure(info, shouldMatch(actual, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_matches_Pattern_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), actual, Pattern.compile("Yod.*")); } } Strings_assertMatches_String_Test.java000066400000000000000000000100001243020563200354230ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldMatchPattern.shouldMatch; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.ErrorMessages.regexPatternIsNull; import static org.fest.assertions.test.TestData.*; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import java.util.regex.PatternSyntaxException; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertMatches(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertMatches_String_Test extends StringsBaseTest { private String actual = "Yoda"; @Test public void should_throw_error_if_regular_expression_is_null() { thrown.expectNullPointerException(regexPatternIsNull()); String regex = null; strings.assertMatches(someInfo(), actual, regex); } @Test public void should_throw_error_if_syntax_of_regular_expression_is_invalid() { thrown.expect(PatternSyntaxException.class); strings.assertMatches(someInfo(), actual, "*..."); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertMatches(someInfo(), null, matchAnything().pattern()); } @Test public void should_fail_if_actual_does_not_match_regular_expression() { AssertionInfo info = someInfo(); try { strings.assertMatches(info, actual, "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldMatch(actual, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_matches_Pattern() { strings.assertMatches(someInfo(), actual, "Yod.*"); } @Test public void should_throw_error_if_regular_expression_is_null_whatever_custom_comparison_strategy_is() { thrown.expectNullPointerException(regexPatternIsNull()); String regex = null; stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), actual, regex); } @Test public void should_throw_error_if_syntax_of_regular_expression_is_invalid_whatever_custom_comparison_strategy_is() { thrown.expect(PatternSyntaxException.class); stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), actual, "*..."); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), null, matchAnything().pattern()); } @Test public void should_fail_if_actual_does_not_match_regular_expression_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertMatches(info, actual, "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldMatch(actual, "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_matches_Pattern_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertMatches(someInfo(), actual, "Yod.*"); } } Strings_assertNotEmpty_Test.java000066400000000000000000000053431243020563200343060ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertNotEmpty(AssertionInfo, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertNotEmpty_Test extends StringsBaseTest { @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty() { AssertionInfo info = someInfo(); try { strings.assertNotEmpty(info, ""); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty() { strings.assertNotEmpty(someInfo(), "Yoda"); } @Test public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() { thrown.expectAssertionError(actualIsNull()); stringsWithCaseInsensitiveComparisonStrategy.assertNotEmpty(someInfo(), null); } @Test public void should_fail_if_actual_is_empty_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertNotEmpty(info, ""); } catch (AssertionError e) { verify(failures).failure(info, shouldNotBeEmpty()); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_not_empty_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertNotEmpty(someInfo(), "Yoda"); } } Strings_assertNullOrEmpty_Test.java000066400000000000000000000052271243020563200347620ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertNullOrEmpty(AssertionInfo, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertNullOrEmpty_Test extends StringsBaseTest { @Test public void should_fail_if_actual_is_not_null_and_is_not_empty() { AssertionInfo info = someInfo(); try { strings.assertNullOrEmpty(info, "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty("Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null() { strings.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_actual_is_empty() { strings.assertNullOrEmpty(someInfo(), ""); } @Test public void should_fail_if_actual_is_not_null_and_is_not_empty_whatever_custom_comparison_strategy_is() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(info, "Yoda"); } catch (AssertionError e) { verify(failures).failure(info, shouldBeNullOrEmpty("Yoda")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_pass_if_actual_is_null_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(someInfo(), null); } @Test public void should_pass_if_actual_is_empty_whatever_custom_comparison_strategy_is() { stringsWithCaseInsensitiveComparisonStrategy.assertNullOrEmpty(someInfo(), ""); } } Strings_assertStartsWith_Test.java000066400000000000000000000064751243020563200346520ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/strings/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.strings; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.fest.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.StringsBaseTest; import org.fest.assertions.internal.Strings; /** * Tests for {@link Strings#assertStartsWith(AssertionInfo, String, String)}. * * @author Alex Ruiz * @author Joel Costigliola */ public class Strings_assertStartsWith_Test extends StringsBaseTest { @Test public void should_fail_if_actual_does_not_start_with_prefix() { AssertionInfo info = someInfo(); try { strings.assertStartsWith(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith("Yoda", "Luke")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } @Test public void should_throw_error_if_prefix_is_null() { thrown.expectNullPointerException("The given prefix should not be null"); strings.assertStartsWith(someInfo(), "Yoda", null); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); strings.assertStartsWith(someInfo(), null, "Yoda"); } @Test public void should_pass_if_actual_starts_with_prefix() { strings.assertStartsWith(someInfo(), "Yoda", "Yo"); } @Test public void should_pass_if_actual_starts_with_prefix_according_to_custom_comparison_strategy() { stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "Y"); stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "Yo"); stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "Yod"); stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "Yoda"); stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "yoda"); stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(someInfo(), "Yoda", "YODA"); } @Test public void should_fail_if_actual_does_not_start_with_prefix_according_to_custom_comparison_strategy() { AssertionInfo info = someInfo(); try { stringsWithCaseInsensitiveComparisonStrategy.assertStartsWith(info, "Yoda", "Luke"); } catch (AssertionError e) { verify(failures).failure(info, shouldStartWith("Yoda", "Luke", comparisonStrategy)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/000077500000000000000000000000001243020563200264655ustar00rootroot00000000000000Throwables_assertHasMessageContaining_Test.java000066400000000000000000000041031243020563200377140ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.throwables; import static org.fest.assertions.error.ShouldEndWith.shouldEndWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Throwables; import org.fest.assertions.internal.ThrowablesBaseTest; /** * Tests for {@link Throwables#assertHasMessageEndingWith(AssertionInfo, Throwable, String)}. * * @author Joel Costigliola */ public class Throwables_assertHasMessageContaining_Test extends ThrowablesBaseTest { @Test public void should_pass_if_actual_has_message_ending_with_expected_description() { throwables.assertHasMessageEndingWith(someInfo(), actual, "sage"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); throwables.assertHasMessageEndingWith(someInfo(), null, "Throwable"); } @Test public void should_fail_if_actual_has_message_not_ending_with_expected_description() { AssertionInfo info = someInfo(); try { throwables.assertHasMessageEndingWith(info, actual, "expected end"); fail("AssertionError expected"); } catch (AssertionError err) { verify(failures).failure(info, shouldEndWith(actual.getMessage(), "expected end")); } } } Throwables_assertHasMessageEndingWith_Test.java000066400000000000000000000041611243020563200376670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.throwables; import static org.fest.assertions.error.ShouldContainString.shouldContain; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Throwables; import org.fest.assertions.internal.ThrowablesBaseTest; /** * Tests for {@link Throwables#assertHasMessageContaining(AssertionInfo, Throwable, String)}. * * @author Joel Costigliola */ public class Throwables_assertHasMessageEndingWith_Test extends ThrowablesBaseTest { @Test public void should_pass_if_actual_has_message_containinging_with_expected_description() { throwables.assertHasMessageContaining(someInfo(), actual, "able"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); throwables.assertHasMessageContaining(someInfo(), null, "Throwable"); } @Test public void should_fail_if_actual_has_message_not_containinging_with_expected_description() { AssertionInfo info = someInfo(); try { throwables.assertHasMessageContaining(info, actual, "expected descirption part"); fail("AssertionError expected"); } catch (AssertionError err) { verify(failures).failure(info, shouldContain(actual.getMessage(), "expected descirption part")); } } } Throwables_assertHasMessageStartingWith_Test.java000066400000000000000000000041401243020563200402530ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.throwables; import static org.fest.assertions.error.ShouldStartWith.shouldStartWith; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Throwables; import org.fest.assertions.internal.ThrowablesBaseTest; /** * Tests for {@link Throwables#assertHasMessageStartingWith(AssertionInfo, Throwable, String)}. * * @author Joel Costigliola */ public class Throwables_assertHasMessageStartingWith_Test extends ThrowablesBaseTest { @Test public void should_pass_if_actual_has_message_starting_with_expected_description() { throwables.assertHasMessageStartingWith(someInfo(), actual, "Throwable"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); throwables.assertHasMessageStartingWith(someInfo(), null, "Throwable"); } @Test public void should_fail_if_actual_has_message_not_starting_with_expected_description() { AssertionInfo info = someInfo(); try { throwables.assertHasMessageStartingWith(info, actual, "expected start"); fail("AssertionError expected"); } catch (AssertionError err) { verify(failures).failure(info, shouldStartWith(actual.getMessage(), "expected start")); } } } Throwables_assertHasMessage_Test.java000066400000000000000000000037751243020563200357200ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.throwables; import static org.fest.assertions.error.ShouldHaveMessage.shouldHaveMessage; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Throwables; import org.fest.assertions.internal.ThrowablesBaseTest; /** * Tests for {@link Throwables#assertHasMessage(AssertionInfo, Throwable, String)}. * * @author Joel Costigliola */ public class Throwables_assertHasMessage_Test extends ThrowablesBaseTest { @Test public void should_pass_if_actual_has_expected_message() { throwables.assertHasMessage(someInfo(), actual, "Throwable message"); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); throwables.assertHasMessage(someInfo(), null, "Throwable message"); } @Test public void should_fail_if_actual_has_not_expected_message() { AssertionInfo info = someInfo(); try { throwables.assertHasMessage(info, actual, "expected message"); fail("AssertionError expected"); } catch (AssertionError err) { verify(failures).failure(info, shouldHaveMessage(actual, "expected message")); } } } Throwables_assertHasNoCause_Test.java000066400000000000000000000037731243020563200356670ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/internal/throwables/* * Created on Dec 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.internal.throwables; import static org.fest.assertions.error.ShouldHaveNoCause.shouldHaveNoCause; import static org.fest.util.FailureMessages.actualIsNull; import static org.fest.assertions.test.TestData.someInfo; import static org.junit.Assert.fail; import static org.mockito.Mockito.verify; import org.junit.Test; import org.fest.assertions.core.AssertionInfo; import org.fest.assertions.internal.Throwables; import org.fest.assertions.internal.ThrowablesBaseTest; /** * Tests for {@link Throwables#assertHasNoCause(AssertionInfo, Throwable, Class)}. * * @author Joel Costigliola */ public class Throwables_assertHasNoCause_Test extends ThrowablesBaseTest { @Test public void should_pass_if_actual_has_no_cause() { throwables.assertHasNoCause(someInfo(), actual); } @Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); throwables.assertHasNoCause(someInfo(), null); } @Test public void should_fail_if_actual_has_a_cause() { AssertionInfo info = someInfo(); Throwable throwableWithCause = new Throwable(new NullPointerException()); try { throwables.assertHasNoCause(info, throwableWithCause); fail("AssertionError expected"); } catch (AssertionError err) { verify(failures).failure(info, shouldHaveNoCause(throwableWithCause)); } } } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/000077500000000000000000000000001243020563200234565ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/test/BooleanArrays.java000066400000000000000000000016751243020563200270730ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class BooleanArrays { private static final boolean[] EMPTY = {}; public static boolean[] arrayOf(boolean... values) { return values; } public static boolean[] emptyArray() { return EMPTY; } private BooleanArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/ByteArrays.java000066400000000000000000000020701243020563200264050ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class ByteArrays { private static final byte[] EMPTY = {}; public static byte[] arrayOf(int... values) { int size = values.length; byte[] array = new byte[size]; for (int i = 0; i < size; i++) { array[i] = (byte) values[i]; } return array; } public static byte[] emptyArray() { return EMPTY; } private ByteArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/CharArrays.java000066400000000000000000000016531243020563200263650ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class CharArrays { private static final char[] EMPTY = {}; public static char[] arrayOf(char... values) { return values; } public static char[] emptyArray() { return EMPTY; } private CharArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/DoubleArrays.java000066400000000000000000000016671243020563200267270ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class DoubleArrays { private static final double[] EMPTY = {}; public static double[] arrayOf(double... values) { return values; } public static double[] emptyArray() { return EMPTY; } private DoubleArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/ErrorMessages.java000066400000000000000000000057031243020563200271070ustar00rootroot00000000000000/* * Created on Dec 22, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz * @author Yvonne Wang * @author Nicolas François */ public final class ErrorMessages { public static String arrayIsNull() { return "The given array should not be null"; } public static String arrayIsEmpty() { return "The given array should not be empty"; } public static String iterableIsNull() { return "The given iterable should not be null"; } public static String iterableIsEmpty() { return "The given iterable should not be empty"; } public static String descriptionIsNull() { return "The description to set should not be null"; } public static String entriesToLookForIsEmpty() { return "The array of entries to look for should not be empty"; } public static String entriesToLookForIsNull() { return "The array of entries to look for should not be null"; } public static String entryToLookForIsNull() { return "Entries to look for should not be null"; } public static String isNotArray(Object o) { return String.format("The object <%s> should be an array", o); } public static String iterableToLookForIsNull() { return "The iterable to look for should not be null"; } public static String offsetIsNull() { return "The given offset should not be null"; } public static String offsetValueIsNotPositive() { return "The value of the offset should be greater than zero"; } public static String regexPatternIsNull() { return "The regular expression pattern to match should not be null"; } public static String sequenceToLookForIsNull() { return "The sequence to look for should not be null"; } public static String valuesToLookForIsEmpty() { return "The array of values to look for should not be empty"; } public static String valuesToLookForIsNull() { return "The array of values to look for should not be null"; } public static String dateToCompareActualWithIsNull() { return "The date to compare actual with should not be null"; } public static String startDateToCompareActualWithIsNull() { return "The start date of period to compare actual with should not be null"; } public static String endDateToCompareActualWithIsNull() { return "The end date of period to compare actual with should not be null"; } private ErrorMessages() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/ExpectedException.java000066400000000000000000000043751243020563200277520ustar00rootroot00000000000000/* * Created on Sep 7, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; /** * Allows in-test specification of expected exception types and messages. * * @author Alex Ruiz */ public class ExpectedException implements TestRule { private final org.junit.rules.ExpectedException delegate = org.junit.rules.ExpectedException.none(); public static ExpectedException none() { return new ExpectedException(); } private ExpectedException() {} @Override public Statement apply(Statement base, Description description) { return delegate.apply(base, description); } public void expectAssertionError(String message) { expect(AssertionError.class, message); } public void expectNullPointerException(String message) { expect(NullPointerException.class, message); } public void expectIllegalArgumentException(String message) { expect(IllegalArgumentException.class, message); } public void expectIndexOutOfBoundsException(String message) { expect(IndexOutOfBoundsException.class, message); } public void expectUnsupportedOperationException(String message) { expect(UnsupportedOperationException.class, message); } private void expect(Class type, String message) { expect(type); expectMessage(message); } public void expect(Throwable error) { expect(error.getClass()); expectMessage(error.getMessage()); } public void expect(Class type) { delegate.expect(type); } public void expectMessage(String message) { delegate.expectMessage(message); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/FloatArrays.java000066400000000000000000000016611243020563200265540ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class FloatArrays { private static final float[] EMPTY = {}; public static float[] arrayOf(float... values) { return values; } public static float[] emptyArray() { return EMPTY; } private FloatArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/IntArrays.java000066400000000000000000000016451243020563200262430ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class IntArrays { private static final int[] EMPTY = {}; public static int[] arrayOf(int... values) { return values; } public static int[] emptyArray() { return EMPTY; } private IntArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/LongArrays.java000066400000000000000000000016531243020563200264070ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class LongArrays { private static final long[] EMPTY = {}; public static long[] arrayOf(long... values) { return values; } public static long[] emptyArray() { return EMPTY; } private LongArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/Maps.java000066400000000000000000000020551243020563200252230ustar00rootroot00000000000000/* * Created on Dec 21, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; import java.util.LinkedHashMap; import java.util.Map; import org.fest.assertions.data.MapEntry; /** * @author Alex Ruiz */ public final class Maps { public static Map mapOf(MapEntry... entries) { Map map = new LinkedHashMap(); for (MapEntry entry : entries) map.put(entry.key, entry.value); return map; } private Maps() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/ObjectArrays.java000066400000000000000000000016671243020563200267230ustar00rootroot00000000000000/* * Created on Dec 24, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class ObjectArrays { private static final Object[] EMPTY = {}; public static Object[] arrayOf(Object... values) { return values; } public static Object[] emptyArray() { return EMPTY; } private ObjectArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/ShortArrays.java000066400000000000000000000021001243020563200265730ustar00rootroot00000000000000/* * Created on Dec 20, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.test; /** * @author Alex Ruiz */ public final class ShortArrays { private static final short[] EMPTY = {}; public static short[] arrayOf(int... values) { int size = values.length; short[] array = new short[size]; for (int i = 0; i < size; i++) { array[i] = (short) values[i]; } return array; } public static short[] emptyArray() { return EMPTY; } private ShortArrays() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/test/TestData.java000066400000000000000000000032661243020563200260410ustar00rootroot00000000000000/* * Created on Oct 17, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.test; import static org.fest.assertions.data.Index.atIndex; import java.util.regex.Pattern; import org.fest.assertions.core.*; import org.fest.assertions.data.*; import org.fest.assertions.description.*; /** * @author Alex Ruiz * @author Yvonne Wang */ public final class TestData { private static final AssertionInfo ASSERTION_INFO = new WritableAssertionInfo(); private static final TextDescription DESCRIPTION = new TextDescription( "who's the more foolish: the fool, or the fool who follows him?"); private static final Index INDEX = atIndex(0); private static final Pattern MATCH_ANYTHING = Pattern.compile(".*"); public static Pattern matchAnything() { return MATCH_ANYTHING; } public static Index someIndex() { return INDEX; } public static AssertionInfo someInfo() { return ASSERTION_INFO; } public static Description someDescription() { return DESCRIPTION; } public static String someTextDescription() { return "there's always a bigger fish"; } private TestData() {} } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/000077500000000000000000000000001243020563200234545ustar00rootroot00000000000000fest-assert-2.0M10/src/test/java/org/fest/assertions/util/AbsValueComparator.java000066400000000000000000000005571243020563200300600ustar00rootroot00000000000000package org.fest.assertions.util; import static java.lang.Math.abs; import java.util.Comparator; public class AbsValueComparator implements Comparator { public int compare(NUMBER i1, NUMBER i2) { double diff = abs(i1.doubleValue()) - abs(i2.doubleValue()); if (diff == 0.0) return 0; return diff < 0.0 ? -1 : 1; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/ArrayWrapperList_get_Test.java000066400000000000000000000035131243020563200314320ustar00rootroot00000000000000/* * Created on Jan 15, 2011 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2011 the original author or authors. */ package org.fest.assertions.util; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.assertEquals; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link ArrayWrapperList#get(int)}. * * @author Yvonne Wang */ public class ArrayWrapperList_get_Test { @Rule public ExpectedException thrown = none(); private ArrayWrapperList list; @Before public void setUp() { int[] array = { 6, 8 }; list = ArrayWrapperList.wrap(array); } @Test public void should_return_value_at_index() { assertEquals(8, list.get(1)); } @Test public void should_throw_error_if_index_is_negative() { thrown.expectIndexOutOfBoundsException("Index should be between 0 and 1 (inclusive,) but was -1"); list.get(-1); } @Test public void should_throw_error_if_index_is_equal_to_size() { thrown.expectIndexOutOfBoundsException("Index should be between 0 and 1 (inclusive,) but was 2"); list.get(2); } @Test public void should_throw_error_if_index_is_greater_than_size() { thrown.expectIndexOutOfBoundsException("Index should be between 0 and 1 (inclusive,) but was 6"); list.get(6); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/ArrayWrapperList_size_Test.java000066400000000000000000000031201243020563200316170ustar00rootroot00000000000000/* * Created on Nov 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2010-2011 the original author or authors. */ package org.fest.assertions.util; import static org.fest.assertions.test.IntArrays.emptyArray; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.*; import org.junit.runners.Parameterized.Parameters; /** * Tests for {@link ArrayWrapperList#size()}. * * @author Alex Ruiz */ @RunWith(Parameterized.class) public class ArrayWrapperList_size_Test { @Parameters public static Collection parameters() { return newArrayList(new Object[][] { { new int[] { 0, 1, 2 } }, { new int[] { 0 } }, { emptyArray() } }); } private final int[] array; public ArrayWrapperList_size_Test(int[] array) { this.array = array; } @Test public void should_return_size_of_array() { ArrayWrapperList list = new ArrayWrapperList(array); assertEquals(array.length, list.size()); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/ArrayWrapperList_wrap_Test.java000066400000000000000000000030441243020563200316230ustar00rootroot00000000000000/* * Created on Nov 26, 2010 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright @2010-2012 the original author or authors. */ package org.fest.assertions.util; import static org.fest.assertions.test.ExpectedException.none; import static org.junit.Assert.*; import org.fest.assertions.test.ExpectedException; import org.junit.*; /** * Tests for {@link ArrayWrapperList#wrap(Object)}. * * @author Alex Ruiz */ public class ArrayWrapperList_wrap_Test { @Rule public ExpectedException thrown = none(); @Test public void should_create_ArrayWrapperList_if_array_is_not_null() { int[] array = { 6, 8 }; ArrayWrapperList list = ArrayWrapperList.wrap(array); assertNotNull(list); assertSame(array, list.array); } @Test public void should_return_null_if_array_is_null() { assertNull(ArrayWrapperList.wrap(null)); } @Test public void should_throw_error_if_parameter_is_not_array() { thrown.expectIllegalArgumentException("The object to wrap should be an array"); ArrayWrapperList.wrap("Yoda"); } } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/CaseInsensitiveCharacterComparator.java000066400000000000000000000006131243020563200332600ustar00rootroot00000000000000package org.fest.assertions.util; import java.util.Comparator; public class CaseInsensitiveCharacterComparator implements Comparator { public final static CaseInsensitiveCharacterComparator instance = new CaseInsensitiveCharacterComparator(); public int compare(Character c1, Character c2) { return c1.toString().toLowerCase().compareTo(c2.toString().toLowerCase()); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/util/CaseInsensitiveStringComparator.java000066400000000000000000000005441243020563200326350ustar00rootroot00000000000000package org.fest.assertions.util; import java.util.Comparator; public class CaseInsensitiveStringComparator implements Comparator { public final static CaseInsensitiveStringComparator instance = new CaseInsensitiveStringComparator(); public int compare(String s1, String s2) { return s1.toLowerCase().compareTo(s2.toLowerCase()); } }fest-assert-2.0M10/src/test/java/org/fest/assertions/util/StackTraceUtils.java000066400000000000000000000013061243020563200273640ustar00rootroot00000000000000package org.fest.assertions.util; public class StackTraceUtils { /** * Returns true if given {@link Throwable} stack trace contains Fest related elements, false otherwise. * @param throwable the {@link Throwable} we want to check stack trace for Fest related elements. * @return true if given {@link Throwable} stack trace contains Fest related elements, false otherwise. */ public static boolean hasStackTraceElementRelatedToFest(Throwable throwable) { StackTraceElement[] stackTrace = throwable.getStackTrace(); for (StackTraceElement stackTraceElement : stackTrace) { if (stackTraceElement.getClassName().contains("org.fest")) { return true; } } return false; } } fest-assert-2.0M10/src/test/java/org/fest/assertions/util/YearAndMonthComparator.java000066400000000000000000000011551243020563200307020ustar00rootroot00000000000000package org.fest.assertions.util; import static org.fest.util.Dates.*; import java.util.Comparator; import java.util.Date; /** * * Compares two date by looking at their year and month only, thus 2011-01-01 and 2011-01-31 are considered equal. * * @author Joel Costigliola * */ public class YearAndMonthComparator implements Comparator { public final static YearAndMonthComparator instance = new YearAndMonthComparator(); public int compare(Date date1, Date date2) { if (yearOf(date1) != yearOf(date2)) { return yearOf(date1) - yearOf(date2); } return monthOf(date1) - monthOf(date2); } }fest-assert-2.0M10/src/test/resources/000077500000000000000000000000001243020563200176465ustar00rootroot00000000000000fest-assert-2.0M10/src/test/resources/actual_file.txt000066400000000000000000000000071243020563200226540ustar00rootroot00000000000000actual fest-assert-2.0M10/src/test/resources/expected_file.txt000066400000000000000000000000001243020563200231750ustar00rootroot00000000000000fest-assert-2.0M10/src/test/resources/red.png000066400000000000000000000002751243020563200211320ustar00rootroot00000000000000PNG  IHDRHsRGBgAMA a cHRMz&u0`:pQ<tEXtSoftwarePaint.NET v3.08erIDATWcDXH)@=Ĩ8@IENDB`