Skip to content

Commit

Permalink
fix: set stringValue in DoubleValue.setValue (#2009)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qnzvna authored May 19, 2024
1 parent 7d4cc2f commit e07f8d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public double getValue() {

public void setValue(Double d) {
value = d;
stringValue = String.valueOf(value);
}

@Override
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/net/sf/jsqlparser/expression/DoubleValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class DoubleValueTest {
Expand All @@ -28,4 +29,14 @@ public void testEmptyValue() {
new DoubleValue("");
});
}

@Test
public void shouldSetStringValue() {
final DoubleValue doubleValue = new DoubleValue("42");

doubleValue.setValue(43D);

assertEquals(43D, doubleValue.getValue());
assertEquals("43.0", doubleValue.toString());
}
}

0 comments on commit e07f8d0

Please sign in to comment.