-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1109 Improve Pit Coverage. Add new tests.
- Loading branch information
1 parent
58922e1
commit e728959
Showing
17 changed files
with
649 additions
and
4 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
.../org/eclipse/collections/impl/block/procedure/AdaptObjectIntProcedureToProcedureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2021 The Bank of New York Mellon. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.impl.block.procedure; | ||
|
||
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class AdaptObjectIntProcedureToProcedureTest | ||
{ | ||
@Test | ||
public void value() | ||
{ | ||
MockObjectIntProcedure mockObjectIntProcedure = new MockObjectIntProcedure(); | ||
AdaptObjectIntProcedureToProcedure<Integer> procedure = | ||
new AdaptObjectIntProcedureToProcedure<>(mockObjectIntProcedure); | ||
procedure.value(1); | ||
Assert.assertEquals(1, mockObjectIntProcedure.getEachValue()); | ||
Assert.assertEquals(0, mockObjectIntProcedure.getParameterValue()); | ||
|
||
procedure.value(2); | ||
Assert.assertEquals(2, mockObjectIntProcedure.getEachValue()); | ||
Assert.assertEquals(1, mockObjectIntProcedure.getParameterValue()); | ||
|
||
procedure.value(3); | ||
Assert.assertEquals(3, mockObjectIntProcedure.getEachValue()); | ||
Assert.assertEquals(2, mockObjectIntProcedure.getParameterValue()); | ||
} | ||
|
||
private static class MockObjectIntProcedure | ||
implements ObjectIntProcedure<Integer> | ||
{ | ||
private int eachValue; | ||
private int parameterValue; | ||
|
||
@Override | ||
public void value(Integer each, int parameter) | ||
{ | ||
this.eachValue = each; | ||
this.parameterValue = parameter; | ||
} | ||
|
||
public int getEachValue() | ||
{ | ||
return this.eachValue; | ||
} | ||
|
||
public int getParameterValue() | ||
{ | ||
return this.parameterValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ests/src/test/java/org/eclipse/collections/impl/block/procedure/CollectProcedureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2021 The Bank of New York Mellon. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.impl.block.procedure; | ||
|
||
import org.eclipse.collections.api.factory.Lists; | ||
import org.eclipse.collections.impl.block.factory.Functions; | ||
import org.eclipse.collections.impl.test.Verify; | ||
import org.junit.Test; | ||
|
||
public class CollectProcedureTest | ||
{ | ||
@Test | ||
public void getCollection() | ||
{ | ||
CollectProcedure<Integer, Integer> collectProcedure = | ||
new CollectProcedure<>(Functions.getIntegerPassThru(), Lists.mutable.empty()); | ||
|
||
Verify.assertEmpty(collectProcedure.getCollection()); | ||
collectProcedure.value(1); | ||
Verify.assertContainsAll(collectProcedure.getCollection(), 1); | ||
|
||
collectProcedure.value(2); | ||
Verify.assertContainsAll(collectProcedure.getCollection(), 1, 2); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...rc/test/java/org/eclipse/collections/impl/block/procedure/CollectionAddProcedureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2021 The Bank of New York Mellon. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.impl.block.procedure; | ||
|
||
import org.eclipse.collections.api.factory.Lists; | ||
import org.eclipse.collections.impl.test.Verify; | ||
import org.eclipse.collections.impl.utility.StringIterate; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class CollectionAddProcedureTest | ||
{ | ||
@Test | ||
public void toStringTest() | ||
{ | ||
CollectionAddProcedure<Integer> procedure = new CollectionAddProcedure<>(Lists.mutable.empty()); | ||
String s = procedure.toString(); | ||
Assert.assertNotNull(s); | ||
Assert.assertTrue(StringIterate.notEmptyOrWhitespace(s)); | ||
} | ||
|
||
@Test | ||
public void getResult() | ||
{ | ||
CollectionAddProcedure<Integer> procedure = CollectionAddProcedure.on(Lists.mutable.empty()); | ||
Verify.assertEmpty(procedure.getResult()); | ||
procedure.value(1); | ||
Verify.assertSize(1, procedure.getResult()); | ||
Verify.assertContainsAll(procedure.getResult(), 1); | ||
|
||
procedure.value(2); | ||
Verify.assertSize(2, procedure.getResult()); | ||
Verify.assertContainsAll(procedure.getResult(), 1, 2); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...test/java/org/eclipse/collections/impl/block/procedure/CollectionRemoveProcedureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2021 The Bank of New York Mellon. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.impl.block.procedure; | ||
|
||
import org.eclipse.collections.api.factory.Lists; | ||
import org.eclipse.collections.impl.test.Verify; | ||
import org.eclipse.collections.impl.utility.StringIterate; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class CollectionRemoveProcedureTest | ||
{ | ||
@Test | ||
public void getResult() | ||
{ | ||
CollectionRemoveProcedure<Integer> procedure = CollectionRemoveProcedure.on(Lists.mutable.with(1, 2)); | ||
Verify.assertContainsAll(procedure.getResult(), 1, 2); | ||
procedure.value(5); | ||
Verify.assertContainsAll(procedure.getResult(), 1, 2); | ||
procedure.value(1); | ||
Verify.assertSize(1, procedure.getResult()); | ||
Verify.assertContainsAll(procedure.getResult(), 2); | ||
} | ||
|
||
public void toStringTest() | ||
{ | ||
CollectionRemoveProcedure<Integer> procedure = CollectionRemoveProcedure.on(Lists.mutable.with(1, 2)); | ||
String s = procedure.toString(); | ||
Assert.assertNotNull(s); | ||
Assert.assertTrue(StringIterate.notEmptyOrWhitespace(s)); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...ests/src/test/java/org/eclipse/collections/impl/block/procedure/CounterProcedureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2021 The Bank of New York Mellon. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.impl.block.procedure; | ||
|
||
import org.eclipse.collections.api.block.procedure.Procedure; | ||
import org.eclipse.collections.impl.utility.StringIterate; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class CounterProcedureTest | ||
{ | ||
@Test | ||
public void getCount() | ||
{ | ||
MockProcedure mockProcedure = new MockProcedure(); | ||
CounterProcedure<Integer> procedure = new CounterProcedure<>(mockProcedure); | ||
Assert.assertNull(mockProcedure.getValue()); | ||
Assert.assertEquals(0, procedure.getCount()); | ||
procedure.value(1); | ||
Assert.assertEquals(1, (int) mockProcedure.getValue()); | ||
Assert.assertEquals(1, procedure.getCount()); | ||
|
||
procedure.value(2); | ||
Assert.assertEquals(2, (int) mockProcedure.getValue()); | ||
Assert.assertEquals(2, procedure.getCount()); | ||
} | ||
|
||
@Test | ||
public void toStringTest() | ||
{ | ||
MockProcedure mockProcedure = new MockProcedure(); | ||
CounterProcedure<Integer> procedure = new CounterProcedure<>(mockProcedure); | ||
String s = procedure.toString(); | ||
Assert.assertNotNull(s); | ||
Assert.assertTrue(StringIterate.notEmptyOrWhitespace(s)); | ||
} | ||
|
||
private static class MockProcedure implements Procedure<Integer> | ||
{ | ||
private Integer value; | ||
|
||
@Override | ||
public void value(Integer each) | ||
{ | ||
this.value = each; | ||
} | ||
|
||
public Integer getValue() | ||
{ | ||
return this.value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.