Skip to content

Commit d45e352

Browse files
committed
test: drop Enum.ordinal() dependence (Error Prone EnumOrdinal) in two tests
Both tests depended on Enum.ordinal(), which Error Prone flags (EnumOrdinal): ordinal is an implementation detail and tying assertions to it is fragile. - value/LogLevelTest: testOrdinalOrder asserted pairwise ordinal inequalities. Replaced with testDeclarationOrder, which assertArrayEquals against LogLevel.values() (declaration order) — pins the full least-to-most-severe order without ordinal(), and is strictly stronger. - parameters/ModelParametersExtendedTest: testSetMirostatAllValues compared the emitted --mirostat value to String.valueOf(m.ordinal()), a coincidence that ordinal 0/1/2 matches MiroStat's CLI arg values. Now asserts against m.getArgValue() — the contract setMirostat actually writes (via putEnum) — mirroring the sibling rope-scaling test. Verified: full `mvn test-compile` reports 0 EnumOrdinal warnings; LogLevelTest 7/7 and ModelParametersExtendedTest 140/140 pass; spotless:check clean.
1 parent ed5a82a commit d45e352

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/test/java/net/ladenthin/llama/parameters/ModelParametersExtendedTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,9 @@ public void testSetRopeScalingAllValues() {
10311031
public void testSetMirostatAllValues() {
10321032
for (MiroStat m : MiroStat.values()) {
10331033
ModelParameters p = new ModelParameters().setMirostat(m);
1034-
assertThat(p.parameters.get("--mirostat"), is(String.valueOf(m.ordinal())));
1034+
// Assert against the enum's CLI arg-value contract (what setMirostat
1035+
// actually writes), not Enum.ordinal() (Error Prone EnumOrdinal).
1036+
assertThat(p.parameters.get("--mirostat"), is(m.getArgValue()));
10351037
}
10361038
}
10371039

src/test/java/net/ladenthin/llama/value/LogLevelTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public void testError() {
4141
}
4242

4343
@Test
44-
public void testOrdinalOrder() {
45-
// Log levels must be ordered from least to most severe
46-
assertTrue(LogLevel.DEBUG.ordinal() < LogLevel.INFO.ordinal());
47-
assertTrue(LogLevel.INFO.ordinal() < LogLevel.WARN.ordinal());
48-
assertTrue(LogLevel.WARN.ordinal() < LogLevel.ERROR.ordinal());
44+
public void testDeclarationOrder() {
45+
// Declared from least to most severe; the order is part of the contract
46+
// (mirrors llama.cpp's native log-level severity). values() returns the
47+
// constants in declaration order, so this pins the full order without
48+
// depending on Enum.ordinal() (Error Prone EnumOrdinal).
49+
assertArrayEquals(
50+
new LogLevel[] {LogLevel.DEBUG, LogLevel.INFO, LogLevel.WARN, LogLevel.ERROR}, LogLevel.values());
4951
}
5052

5153
@Test

0 commit comments

Comments
 (0)