feat: Replace Camel case uppercase with Pascal case
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.
This commit is contained in:
parent
340ab134e5
commit
45834046dd
@ -10,7 +10,7 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public enum NamingConvention {
|
public enum NamingConvention {
|
||||||
CAMEL_CASE("Camel Case"),
|
CAMEL_CASE("Camel Case"),
|
||||||
CAMEL_CASE_UPPERCASE("Camel Case (Uppercase)"),
|
PASCAL_CASE("Pascal Case"),
|
||||||
SNAKE_CASE("Snake Case"),
|
SNAKE_CASE("Snake Case"),
|
||||||
SNAKE_CASE_UPPERCASE("Snake Case (Uppercase)");
|
SNAKE_CASE_UPPERCASE("Snake Case (Uppercase)");
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public enum NamingConvention {
|
|||||||
yield formatToSnakeCase(newKey, true);
|
yield formatToSnakeCase(newKey, true);
|
||||||
case CAMEL_CASE:
|
case CAMEL_CASE:
|
||||||
yield formatToCamelCase(newKey, false);
|
yield formatToCamelCase(newKey, false);
|
||||||
case CAMEL_CASE_UPPERCASE:
|
case PASCAL_CASE:
|
||||||
yield formatToCamelCase(newKey, true);
|
yield formatToCamelCase(newKey, true);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user