Compare commits

...

6 Commits

Author SHA256 Message Date
b79e701b7a NoIssue: Upgrade build to gradle-9.3.1 2026-02-07 10:41:58 +01:00
1228165347 NoIssue: Upgrade build to Java 25 2026-02-07 10:30:10 +01:00
be07738fc4 NoIssue: Dependency bump 2026-02-07 10:28:01 +01:00
Minimons
c8d8829f83 NoIssue: Add two tests for random Strings 2025-12-03 10:39:51 +01:00
Minimons
2f25bc7dc4 NoIssue: Fix name 2025-12-03 09:53:09 +01:00
Minimons
254a55d955 NoIssue: Fix description 2025-12-03 09:52:50 +01:00
5 changed files with 63 additions and 10 deletions

View File

@@ -28,10 +28,9 @@ repositories {
}
dependencies {
// The test classes are compiled with these:
compileOnly("org.jetbrains:annotations:26.0.2-1")
implementation("com.r35157.libs:random-api:0.1-dev")
implementation("com.r35157.libs:random-impl-ref:0.1-dev")
implementation("org.jetbrains:annotations:26.0.1")
// The JUnit platform will not be included in the JAR file but are needed for running the tests:
testImplementation(platform("org.junit:junit-bom:5.11.4"))
@@ -40,11 +39,11 @@ dependencies {
}
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(24)) }
toolchain { languageVersion.set(JavaLanguageVersion.of(25)) }
}
tasks.withType<JavaCompile> {
options.release.set(24)
tasks.withType<JavaCompile>().configureEach {
options.release.set(25)
}
tasks.test {

View File

@@ -1,5 +1,5 @@
org.gradle.java.installations.auto-detect=true
org.gradle.java.installations.fromEnv=JAVA_HOME
org.gradle.java.installations.paths=/usr/local/software/java/jfx-24
org.gradle.java.installations.paths=/usr/local/software/java/jfx-25
org.gradle.java.installations.auto-download=false
org.gradle.configuration-cache=true

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -9,11 +9,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@DisplayName("Sad Random Ints Tests")
public class IncorrectRandomIntsTests {
public class IncorrectRandomIntTests {
@DisplayName("RandomInts.getSomeInts()")
@DisplayName("Do incorrect range bounds throw?")
@Test
void testThatMinBoundIsGreaterThanMaxBoundThrows() {
void testThatItThrowsWhenMinBoundIsGreaterThanMaxBound() {
// Arrange
int minBound = 10;
int maxBound = 5;

View File

@@ -0,0 +1,54 @@
package com.r35157.libs.random.tests.sad;
import com.r35157.libs.random.RandomValueGeneratorInt;
import com.r35157.libs.random.RandomValueGeneratorString;
import com.r35157.libs.random.impl.ref.RandomValueGeneratorIntImpl;
import com.r35157.libs.random.impl.ref.RandomValueGeneratorStringImpl;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@DisplayName("Sad Random Strings Tests")
public class IncorrectRandomStringTests {
@DisplayName("Do initializing with <null> throw NPE?")
@Test
void testThatInitializingWithNullIntGeneratorThrows() {
// Arrange
String expectedErrorMsg = "Cannot initialize with <null> RandomValueGeneratorInt!";
RandomValueGeneratorInt rvgi = null;
// Act + Assert
NullPointerException thrown = assertThrows(
NullPointerException.class,
() -> new RandomValueGeneratorStringImpl(rvgi)
);
// Assert
String actualErrorMsg = thrown.getMessage();
assertEquals(expectedErrorMsg, actualErrorMsg);
}
@DisplayName("Do generating negative length Strings throw IAE?")
@Test
void testThatGeneratingStringsOfNegativeLengthThrowsIAE() {
// Arrange
int length = -1;
String expectedErrorMsg = "Cannot generate random Strings of size " + length + "!";
RandomValueGeneratorString sut = new RandomValueGeneratorStringImpl(rvgi);
// Act + Assert
IllegalArgumentException thrown = assertThrows(
IllegalArgumentException.class,
() -> sut.getSomeStringAlphaNumericOnly(length)
);
// Assert
String actualErrorMsg = thrown.getMessage();
assertEquals(expectedErrorMsg, actualErrorMsg);
}
private static final RandomValueGeneratorInt rvgi = new RandomValueGeneratorIntImpl();
}