Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests;
  • Loading branch information
mylog00 committed Jul 24, 2022
commit ff83ac678865ae04d4d1015fda7d4294500dcfb1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testToString() throws Exception {
}

@Test
public void testToHexOctString() throws Exception {
public void testToHexOctBinString() throws Exception {
Value i = this.getLocalValue("i");

Map<String, Object> options = formatter.getDefaultOptions();
Expand All @@ -113,7 +113,11 @@ public void testToHexOctString() throws Exception {

options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.OCT);
assertEquals("NumericFormatter should be able to format an oct integer.",
"0" +Integer.toOctalString(111), formatter.toString(i, options));
"0" + Integer.toOctalString(111), formatter.toString(i, options));

options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.BIN);
assertEquals("NumericFormatter should be able to format an bin integer.",
"0b" + Integer.toBinaryString(111), formatter.toString(i, options));
}

@Test
Expand All @@ -127,7 +131,6 @@ public void testValueOf() throws Exception {
assertEquals("Should create an integer with right value.", "111", newValue.toString());

options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.HEX);

newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
Expand All @@ -139,6 +142,12 @@ public void testValueOf() throws Exception {
assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
assertEquals("Should create an integer with right value.", "111", newValue.toString());

options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.BIN);
newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
assertEquals("Should create an integer with right value.", "111", newValue.toString());


newValue = formatter.valueOf("-12121212", i.type(), options);
assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
Expand Down