@@ -49,11 +49,13 @@ public void initIniReader() {
4949 "intKey = 5\n " +
5050 "invalidIntKey = 3.4\n " +
5151 "anotherInvalidIntKey = two\n " +
52+ "blankIntKey = \n " +
5253 "floatKey = 6\n " +
5354 "anotherFloatKey = 7.3f\n " +
5455 "invalidFloatKey = 8,6\n " +
5556 "anotherInvalidFloatKey = hi\n " +
5657 "enumInvalid = 1\n " +
58+ "enumEmpty =\n " +
5759 "enumValid = KEYBOARD\n " +
5860 "UnicodeKey çáč🧝 = unicodevalue áśǵj́ḱĺóí⋄«»⋄⋄ǫő" ;
5961 iniReader = new IniReader (new BufferedReader (new StringReader (iniFileContents )));
@@ -82,6 +84,7 @@ public void testGetInt() {
8284 assertEquals (iniReader .getInt ("intKey" , 0 ), 5 );
8385 assertEquals (iniReader .getInt ("invalidIntKey" , 56 ), 56 );
8486 assertEquals (iniReader .getInt ("anotherInvalidIntKey" , 57 ), 57 );
87+ assertEquals (iniReader .getInt ("blankIntKey" , 58 ), 58 );
8588 }
8689
8790 @ Test
@@ -108,16 +111,16 @@ public void testGetFloat() {
108111 @ Test
109112 public void testEnums () {
110113 // When no value exists in the file, use the defaultValue in getString.
111- assertEquals (Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumDefault" , "MIXED" )).or (GameOptions .ControlType .KEYBOARD ), GameOptions .ControlType .MIXED );
112- assertEquals (Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumDefault" , "MIXED" )).or (GameOptions .ControlType .MIXED ), GameOptions .ControlType .MIXED );
114+ assertEquals (GameOptions .ControlType .MIXED , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumDefault" , "MIXED" )).or (GameOptions .ControlType .KEYBOARD ));
115+ assertEquals (GameOptions .ControlType .MIXED , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumDefault" , "MIXED" )).or (GameOptions .ControlType .MIXED ));
116+ assertEquals (GameOptions .ControlType .KEYBOARD , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumEmpty" , "KEYBOARD" )).or (GameOptions .ControlType .MIXED ));
113117
114118 // When the value in the file isn't a valid enum, use the default value in getIfPresent
115- assertEquals (Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumInvalid" , "KEYBOARD" )).or (GameOptions .ControlType .MIXED ), GameOptions . ControlType . MIXED );
116- assertEquals (Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumInvalid" , "MIXED" )).or (GameOptions .ControlType .MIXED ), GameOptions . ControlType . MIXED );
119+ assertEquals (GameOptions . ControlType . MIXED , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumInvalid" , "KEYBOARD" )).or (GameOptions .ControlType .MIXED ));
120+ assertEquals (GameOptions . ControlType . MIXED , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumInvalid" , "MIXED" )).or (GameOptions .ControlType .MIXED ));
117121
118122 // When the value is in the file, use that value regardless of the default values.
119- assertEquals (Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumValid" , "MIXED" )).or (GameOptions .ControlType .MIXED ), GameOptions . ControlType . KEYBOARD );
123+ assertEquals (GameOptions . ControlType . KEYBOARD , Enums .getIfPresent (GameOptions .ControlType .class , iniReader .getString ("enumValid" , "MIXED" )).or (GameOptions .ControlType .MIXED ));
120124 }
121125
122- //TODO ADD MOAR TESTS
123126}
0 commit comments