forked from kherud/java-llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAbstractCliArgEnumTest.java
More file actions
54 lines (44 loc) · 1.6 KB
/
Copy pathAbstractCliArgEnumTest.java
File metadata and controls
54 lines (44 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
// SPDX-FileCopyrightText: 2023-2025 Konstantin Herud
//
// SPDX-License-Identifier: MIT
package net.ladenthin.llama.args;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Shared parameterized assertions for enums implementing {@link CliArg}.
*
* <p>Subclasses declare {@code @RunWith(Parameterized.class)} and provide a
* {@code @Parameterized.Parameters} data method returning
* {@code (enumConstant, expectedArgValue, expectedEnumCount)} rows.
*/
public abstract class AbstractCliArgEnumTest<E extends Enum<E> & CliArg> {
private final E value;
private final String expectedArgValue;
private final int expectedEnumCount;
protected AbstractCliArgEnumTest(E value, String expectedArgValue, int expectedEnumCount) {
this.value = value;
this.expectedArgValue = expectedArgValue;
this.expectedEnumCount = expectedEnumCount;
}
@Test
public void testGetArgValue() {
assertEquals(expectedArgValue, value.getArgValue());
}
@Test
public void testEnumCount() {
assertEquals(expectedEnumCount, value.getDeclaringClass().getEnumConstants().length);
}
@Test
public void testImplementsCliArg() {
assertTrue(value instanceof CliArg);
}
@Test
public void testArgValueNonEmpty() {
assertNotNull(value.getArgValue());
assertFalse(value.getArgValue().isEmpty());
}
}