Skip to content

Commit 3457125

Browse files
committed
test(value): cover ContentPart audio paths to restore PIT 100% (pre-existing bernardladenthin#267)
The PIT mutation gate (100% on value.*) was failing at 98% — 4 NO_COVERAGE mutations, all in ContentPart's audio methods from the merged audio-input feature (bernardladenthin#267): inputAudio was never exercised with "mp3" (only "wav"), and audioFile(Path) had no tests at all. Pre-existing on main; this branch inherits it via the rebase. Add four ContentPartTest cases — inputAudio("mp3"), audioFile .wav/.mp3 detection, and audioFile unknown-extension rejection — mirroring the existing imageFile tests. Local PIT now reports 243/243 killed (100%); ContentPartTest 17 -> 21, all green.
1 parent fe467cd commit 3457125

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,44 @@ public void imageFileRejectsUnknownExtension() throws IOException {
147147
assertThat(expected.getMessage(), is(notNullValue()));
148148
}
149149
}
150+
151+
@Test
152+
public void inputAudioAcceptsMp3Format() {
153+
byte[] bytes = new byte[] {9, 8, 7};
154+
ContentPart p = ContentPart.inputAudio(bytes, "MP3");
155+
assertThat(p.getAudioFormat(), is("mp3"));
156+
assertThat(p.getAudioData(), is(Base64.getEncoder().encodeToString(bytes)));
157+
}
158+
159+
@Test
160+
public void audioFileDetectsWavFromExtension() throws IOException {
161+
Path file = tmp.resolve("clip.WAV");
162+
byte[] bytes = new byte[] {1, 2, 3, 4};
163+
Files.write(file, bytes);
164+
ContentPart p = ContentPart.audioFile(file);
165+
assertThat(p.getAudioFormat(), is("wav"));
166+
assertThat(p.getAudioData(), is(Base64.getEncoder().encodeToString(bytes)));
167+
}
168+
169+
@Test
170+
public void audioFileDetectsMp3FromExtension() throws IOException {
171+
Path file = tmp.resolve("clip.mp3");
172+
byte[] bytes = new byte[] {5, 6, 7, 8};
173+
Files.write(file, bytes);
174+
ContentPart p = ContentPart.audioFile(file);
175+
assertThat(p.getAudioFormat(), is("mp3"));
176+
assertThat(p.getAudioData(), is(Base64.getEncoder().encodeToString(bytes)));
177+
}
178+
179+
@Test
180+
public void audioFileRejectsUnknownExtension() throws IOException {
181+
Path file = tmp.resolve("clip.ogg");
182+
Files.write(file, new byte[] {0});
183+
try {
184+
ContentPart.audioFile(file);
185+
fail("expected IllegalArgumentException for unknown audio extension");
186+
} catch (IllegalArgumentException expected) {
187+
assertThat(expected.getMessage(), is(notNullValue()));
188+
}
189+
}
150190
}

0 commit comments

Comments
 (0)