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:
Aakil Iqbal
2023-10-25 09:30:18 +05:30
committed by GitHub
parent 9dae389faa
commit a4711d61d8
2 changed files with 62 additions and 0 deletions

View 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);
}
}