forked from kherud/java-llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSessionTest.java
More file actions
31 lines (26 loc) · 1.32 KB
/
Copy pathSessionTest.java
File metadata and controls
31 lines (26 loc) · 1.32 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
// SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
//
// SPDX-License-Identifier: MIT
package net.ladenthin.llama;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
/**
* Model-free unit tests for {@link Session} construction invariants. A session is pinned to one
* concrete slot for both inference and {@link Session#save(String)} / {@link Session#restore(String)} /
* {@link Session#close()}, so a negative slot id is rejected at construction rather than surfacing
* deep inside the first {@code send()} call (where {@code InferenceParameters.withSlotId} would throw).
*/
public class SessionTest {
@Test
public void negativeSlotIdRejectedAtConstruction() {
// The slot-id guard runs before the model is dereferenced, so a null model still exercises it.
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> new Session(null, -1, null));
assertThat(ex.getMessage(), containsString("slotId must be non-negative"));
}
@Test
public void negativeSlotIdRejectedOnCustomizerConstructor() {
assertThrows(IllegalArgumentException.class, () -> new Session(null, -7, null, p -> p));
}
}