-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1015 from jonathansamuel-bnym/issues/989-add-test…
…-coverage-for-bag-add-occurrences-procedure Add test cases for BagAddOccurrencesProcedure
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...est/java/org/eclipse/collections/impl/block/procedure/BagAddOccurrencesProcedureTest.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,49 @@ | ||
/* | ||
* Copyright (c) 2020 The Bank of New York Mellon and others. | ||
* 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.bag.MutableBag; | ||
import org.eclipse.collections.api.factory.Bags; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class BagAddOccurrencesProcedureTest | ||
{ | ||
@Test | ||
public void basicCase() | ||
{ | ||
MutableBag<String> targetCollection = Bags.mutable.empty(); | ||
BagAddOccurrencesProcedure<String> procedure = new BagAddOccurrencesProcedure<>(targetCollection); | ||
|
||
procedure.value("fred", 1); | ||
procedure.value("fred", 1); | ||
procedure.value("mary", 3); | ||
|
||
Assert.assertEquals(2, procedure.getResult().occurrencesOf("fred")); | ||
Assert.assertEquals(3, procedure.getResult().occurrencesOf("mary")); | ||
Assert.assertEquals(0, procedure.getResult().occurrencesOf("other")); | ||
} | ||
|
||
@Test | ||
public void basicCaseUsingFactoryMethod() | ||
{ | ||
MutableBag<String> targetCollection = Bags.mutable.empty(); | ||
BagAddOccurrencesProcedure<String> procedure = BagAddOccurrencesProcedure.on(targetCollection); | ||
|
||
procedure.value("fred", 1); | ||
procedure.value("fred", 1); | ||
procedure.value("mary", 3); | ||
|
||
Assert.assertEquals(2, procedure.getResult().occurrencesOf("fred")); | ||
Assert.assertEquals(3, procedure.getResult().occurrencesOf("mary")); | ||
Assert.assertEquals(0, procedure.getResult().occurrencesOf("other")); | ||
} | ||
} |