3939import org .junit .Test ;
4040import org .junit .runner .RunWith ;
4141
42+ import java .util .ArrayList ;
43+ import java .util .List ;
44+
4245import static junit .framework .TestCase .assertEquals ;
4346
4447@ RunWith (AndroidJUnit4 .class )
@@ -59,4 +62,25 @@ public void testSettersAndGetters() {
5962 assertEquals (voiceCommand .getVoiceCommandSelectionListener (), voiceCommandSelectionListener );
6063 }
6164
65+ @ Test
66+ public void testDuplicateStrings () {
67+ List <String > voiceCommandsList = new ArrayList <>();
68+ voiceCommandsList .add ("Test1" );
69+ voiceCommandsList .add ("Test1" );
70+ voiceCommandsList .add ("Test1" );
71+ VoiceCommand voiceCommand = new VoiceCommand (voiceCommandsList , voiceCommandSelectionListener );
72+
73+ assertEquals (1 , voiceCommand .getVoiceCommands ().size ());
74+ assertEquals ("Test1" , voiceCommand .getVoiceCommands ().get (0 ));
75+
76+ voiceCommandsList = new ArrayList <>();
77+ voiceCommandsList .add ("Test1" );
78+ voiceCommandsList .add ("Test2" );
79+ voiceCommandsList .add ("Test1" );
80+ VoiceCommand voiceCommand2 = new VoiceCommand (voiceCommandsList , voiceCommandSelectionListener );
81+
82+ assertEquals (2 , voiceCommand2 .getVoiceCommands ().size ());
83+ assertEquals ("Test1" , voiceCommand2 .getVoiceCommands ().get (0 ));
84+ assertEquals ("Test2" , voiceCommand2 .getVoiceCommands ().get (1 ));
85+ }
6286}
0 commit comments