Skip to content

Commit

Permalink
close #120 : changed assert check to use compareTo() in BinaryOperati…
Browse files Browse the repository at this point in the history
…on constructor
  • Loading branch information
gonzalezsieira committed Feb 26, 2015
1 parent d5ab21d commit ed92c8a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Pablo Rodríguez Mier <<a href="mailto:[email protected]">[email protected]</a>>
* @author Adrián González Sieira <<a href="[email protected]">[email protected]</a>>
*/
public class BinaryOperation<E> implements BinaryFunction<E> {
public class BinaryOperation<E extends Comparable<E>> implements BinaryFunction<E> {

private E maxElem;
private E identityElem;
Expand All @@ -45,9 +45,9 @@ public class BinaryOperation<E> implements BinaryFunction<E> {
*/
public BinaryOperation(BinaryFunction<E> operation, E identityElem, E maxElem) {
// Check properties
assert operation.apply(identityElem, maxElem).equals(maxElem);
assert operation.apply(maxElem, identityElem).equals(maxElem);
assert operation.apply(identityElem, identityElem).equals(identityElem);
assert operation.apply(identityElem, maxElem).compareTo(maxElem) == 0;
assert operation.apply(maxElem, identityElem).compareTo(maxElem) == 0;
assert operation.apply(identityElem, identityElem).compareTo(identityElem) == 0;
//Preconditions.checkArgument(operation.apply(identityElem, maxElem).equals(maxElem), "Property error: I x A != A");
//Preconditions.checkArgument(operation.apply(maxElem, identityElem).equals(maxElem), "Property error: A x I != A");
//Preconditions.checkArgument(operation.apply(identityElem, identityElem).equals(identityElem), "Property error: I x I != I");
Expand Down

0 comments on commit ed92c8a

Please sign in to comment.