1
+ package problems .impl ;
2
+
3
+ import org .junit .Assert ;
4
+ import org .junit .Test ;
5
+ import problems .exceptions .NoFirstMissingPositiveIntegerException ;
6
+ import problems .interfaces .FirstMissingPositiveIntegerIdentifier ;
7
+
8
+ import java .util .Arrays ;
9
+
10
+ public class FirstMissingPositiveIntegerIdentifierImplTest {
11
+ private final FirstMissingPositiveIntegerIdentifier firstMissingPositiveIntegerIdentifier = new FirstMissingPositiveIntegerIdentifierImpl ();
12
+
13
+ @ Test
14
+ public void itShouldReturnSeenValues () {
15
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{}), new boolean []{}));
16
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{-1 }), new boolean []{false }));
17
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{0 }), new boolean []{false }));
18
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{1 }), new boolean []{true }));
19
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{2 }), new boolean []{false }));
20
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{2 , 3 }), new boolean []{false , true }));
21
+ Assert .assertTrue (Arrays .equals (firstMissingPositiveIntegerIdentifier .identifyIfFirstIntegersHaveBeenSeen (new int []{1 , 3 , 3 , 1 }), new boolean []{true , false , true , false }));
22
+ }
23
+
24
+ @ Test
25
+ public void itShouldIdentifyFirstMissingPositiveInteger () {
26
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{}), 1 );
27
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{-1 }), 1 );
28
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{0 }), 1 );
29
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{1 }), 2 );
30
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{2 }), 1 );
31
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{2 , 3 }), 1 );
32
+ Assert .assertEquals (firstMissingPositiveIntegerIdentifier .identifyFirstMissingPositiveInteger (new int []{1 , 3 , 3 , 1 }), 2 );
33
+ }
34
+
35
+ }
0 commit comments