mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 06:55:02 +08:00
Added MapReduce Algorithm in Misc Folder. (#4828)
* Added MapReduce Algorithm in Misc Folder. * Did formatting correctly * Removed main function and added MapReduceTest * format the code
This commit is contained in:
23
src/test/java/com/thealgorithms/misc/MapReduceTest.java
Normal file
23
src/test/java/com/thealgorithms/misc/MapReduceTest.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.thealgorithms.misc;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MapReduceTest {
|
||||
@Test
|
||||
public void testMapReduceWithSingleWordSentence() {
|
||||
String oneWordSentence = "Hactober";
|
||||
String result = MapReduce.mapreduce(oneWordSentence);
|
||||
|
||||
assertEquals("Hactober: 1", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapReduceWithMultipleWordSentence() {
|
||||
String multipleWordSentence = "I Love Love HactoberFest";
|
||||
String result = MapReduce.mapreduce(multipleWordSentence);
|
||||
|
||||
assertEquals("I: 1,Love: 2,HactoberFest: 1", result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user