Fix JavaRandomUnitTest

This commit is contained in:
pivovarit 2017-02-05 08:55:35 +01:00
parent 6d0dcd52fa
commit 14bee159bd
1 changed files with 4 additions and 4 deletions

View File

@ -1,12 +1,12 @@
package org.baeldung.java;
import java.nio.charset.Charset;
import java.util.Random;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.junit.Test;
import java.nio.charset.Charset;
import java.util.Random;
public class JavaRandomUnitTest {
// tests - random long
@ -164,7 +164,7 @@ public class JavaRandomUnitTest {
final int targetStringLength = 10;
final StringBuilder buffer = new StringBuilder(targetStringLength);
for (int i = 0; i < targetStringLength; i++) {
final int randomLimitedInt = leftLimit + (int) (new Random().nextFloat() * (rightLimit - leftLimit));
final int randomLimitedInt = leftLimit + (int) (new Random().nextFloat() * (rightLimit - leftLimit + 1));
buffer.append((char) randomLimitedInt);
}
final String generatedString = buffer.toString();