Skip to content

Commit

Permalink
Corrected bug where set config values were reset during mvn testing
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Apr 30, 2023
1 parent eb2e759 commit 902c5b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.fross</groupId>
<artifactId>rpncalc</artifactId>
<version>4.7.6</version>
<version>4.7.7</version>
<packaging>jar</packaging>

<name>rpncalc</name>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rpncalc
version: '4.7.6'
version: '4.7.7'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fross/rpncalc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static void main(String[] args) {

// Display the initial program header information
Output.printColorln(Ansi.Color.CYAN, "+" + "-".repeat(configProgramWidth - 2) + "+");
Output.printColorln(Ansi.Color.CYAN, Format.CenterText(configProgramWidth, "RPN Calculator v" + VERSION, "|", "|"));
Output.printColorln(Ansi.Color.CYAN, Format.CenterText(configProgramWidth, "RPN Calculator v" + VERSION, "|", "|"));
Output.printColorln(Ansi.Color.CYAN, Format.CenterText(configProgramWidth, COPYRIGHT, "|", "|"));
Output.printColorln(Ansi.Color.CYAN, Format.CenterText(configProgramWidth, "Enter command 'h' for help details", "|", "|"));
Output.printColorln(Ansi.Color.CYAN, Format.CenterText(configProgramWidth, "", "|", "|"));
Expand Down
25 changes: 21 additions & 4 deletions src/test/java/org/fross/rpncalc/ConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ConfigurationTest {
int memSlots = prefConfig.getInt("memoryslots", Main.CONFIG_DEFAULT_MEMORY_SLOTS);

@Test
void testCmdSetMemSlots() {
void testSetMemSlots() {
// Test MemSlots
Configuration.cmdSet("memslots 1123");
assertEquals(1123, StackMemory.memorySlots.length);
Expand All @@ -53,12 +53,25 @@ void testCmdSetMemSlots() {

Configuration.cmdSet("memslots 71");
assertEquals(71, StackMemory.memorySlots.length);


// Rest configuration to original user value
prefConfig.putInt("memoryslots", memSlots);
}

@Test
void testSetWidth() {
// Test Width
Configuration.cmdSet("width 100");
assertEquals(100, Main.configProgramWidth);
assertEquals("100", prefConfig.get("programwidth", ""));


// Rest configuration to original user value
prefConfig.putInt("programwidth", width);
}


@Test
void testSetAlignment() {
// Test Align
Configuration.cmdSet("alignment d");
assertEquals("d", Main.configAlignment);
Expand All @@ -83,6 +96,10 @@ void testCmdSetMemSlots() {
Configuration.cmdSet("align L");
assertEquals("l", Main.configAlignment);
assertEquals("l", prefConfig.get("alignment", ""));

// Rest configuration to original user value
prefConfig.put("alignment", align);

}

@Test
Expand All @@ -98,7 +115,7 @@ void testResetCommand() {
assertEquals(Main.CONFIG_DEFAULT_MEMORY_SLOTS, Main.configMemorySlots);
assertEquals(Main.CONFIG_DEFAULT_MEMORY_SLOTS, Integer.parseInt(prefConfig.get("memoryslots", "")));

// Restore original configurations
// Rest configuration to original user value
prefConfig.putInt("programwidth", width);
prefConfig.put("alignment", align);
prefConfig.putInt("memoryslots", memSlots);
Expand Down

0 comments on commit 902c5b6

Please sign in to comment.