Skip to content

Commit

Permalink
for example specification 1,000 MB to 1000 MB , No comma separated he…
Browse files Browse the repository at this point in the history
…re (linkedin#396)

* for specification 1,000 MB to 1000 MB

java.lang.IllegalArgumentException: The formatted string [1,000 MB] does not match with the regex

* add the unit test case to test ignore thousand-separator(1,000 MB to 1000 MB) in MemoryFormatUtilsTest
  • Loading branch information
Seandity authored and pralabhkumar committed Sep 16, 2019
1 parent 2c79e8c commit 721c82a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/com/linkedin/drelephant/util/MemoryFormatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static long stringToBytes(String formattedString) {
return 0L;
}

Matcher matcher = REGEX_MATCHER.matcher(formattedString);
Matcher matcher = REGEX_MATCHER.matcher(formattedString.replace(",",""));
if (!matcher.matches()) {
throw new IllegalArgumentException(
"The formatted string [" + formattedString + "] does not match with the regex /" + REGEX_MATCHER.toString()
Expand Down
2 changes: 2 additions & 0 deletions test/com/linkedin/drelephant/util/MemoryFormatUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public void testScientificStringNumberToBytes() {
assertEquals(expectedBytes, MemoryFormatUtils.stringToBytes("0.879e1 MB"));
assertEquals(expectedBytes, MemoryFormatUtils.stringToBytes("+0.879e+1 MB"));
assertEquals(expectedBytes, MemoryFormatUtils.stringToBytes("87.9e-1 MB"));
assertEquals(expectedBytes, MemoryFormatUtils.stringToBytes("8,790e-3 MB"));
assertEquals(expectedBytes, MemoryFormatUtils.stringToBytes("8,790,000e-6 MB"));
}

public void testStringToBytes() {
Expand Down

0 comments on commit 721c82a

Please sign in to comment.