Skip to content

Commit

Permalink
feat: Replace Camel case uppercase with Pascal case
Browse files Browse the repository at this point in the history
The main modification is in `NamingConvention.java` replacing the enumeration `CAMEL_CASE_UPPERCASE` with `PASCAL_CASE`. This change can help to improve the readability of the code by reducing the verbosity of names and ensure convention consistency. Also, a new test file `NamingConventionTest.java` has been introduced to ensure correctness and stability of the code against these modifications.
  • Loading branch information
JPilson committed Apr 21, 2024
1 parent 340ab13 commit 4583404
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public enum NamingConvention {
CAMEL_CASE("Camel Case"),
CAMEL_CASE_UPPERCASE("Camel Case (Uppercase)"),
PASCAL_CASE("Pascal Case"),
SNAKE_CASE("Snake Case"),
SNAKE_CASE_UPPERCASE("Snake Case (Uppercase)");

Expand Down Expand Up @@ -76,7 +76,7 @@ static public String convertKeyToConvention(String key, NamingConvention convent
yield formatToSnakeCase(newKey, true);
case CAMEL_CASE:
yield formatToCamelCase(newKey, false);
case CAMEL_CASE_UPPERCASE:
case PASCAL_CASE:
yield formatToCamelCase(newKey, true);

};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.marhali.easyi18n.settings;

import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import de.marhali.easyi18n.settings.presets.NamingConvention;

import java.io.IOException;

public class NamingConventionTest extends BasePlatformTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}

public void testConvertToNamingConvention() throws IOException {
assertEquals("helloWorld", NamingConvention.convertKeyToConvention("Hello World", NamingConvention.CAMEL_CASE));
assertEquals("hello_world", NamingConvention.convertKeyToConvention("Hello World", NamingConvention.SNAKE_CASE));
assertEquals("HelloWorld", NamingConvention.convertKeyToConvention("Hello World", NamingConvention.PASCAL_CASE));
assertEquals("HELLO_WORLD", NamingConvention.convertKeyToConvention("Hello World", NamingConvention.SNAKE_CASE_UPPERCASE));
}

public void testGetEnumNames() throws Exception {
String[] expected = {"Camel Case", "Pascal Case", "Snake Case", "Snake Case (Uppercase)"};
String[] actual = NamingConvention.getEnumNames();
assertEquals(expected.length, actual.length);
}


public void testFromString() {
assertEquals(NamingConvention.CAMEL_CASE, NamingConvention.fromString("Camel Case"));
assertEquals(NamingConvention.PASCAL_CASE, NamingConvention.fromString("Pascal Case"));
assertEquals(NamingConvention.SNAKE_CASE, NamingConvention.fromString("Snake Case"));
assertEquals(NamingConvention.SNAKE_CASE_UPPERCASE, NamingConvention.fromString("Snake Case (Uppercase)"));
assertEquals(NamingConvention.CAMEL_CASE, NamingConvention.fromString("Invalid Input"));
}
}

0 comments on commit 4583404

Please sign in to comment.