mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Add attribute conversion tests
This commit is contained in:
@@ -19,7 +19,7 @@ public class AttributeConfigConverter implements CommandLine.ITypeConverter<Attr
|
|||||||
* @throws CommandLine.TypeConversionException if the input string is invalid or contains invalid language codes
|
* @throws CommandLine.TypeConversionException if the input string is invalid or contains invalid language codes
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AttributeConfig convert(String s) throws Exception {
|
public AttributeConfig convert(String s) {
|
||||||
validateInput(s);
|
validateInput(s);
|
||||||
|
|
||||||
String[] split = s.split(SEPARATOR);
|
String[] split = s.split(SEPARATOR);
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger.config;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.AttributeConfig;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import picocli.CommandLine;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class AttributeConfigConverterTest {
|
||||||
|
|
||||||
|
private static Stream<Arguments> validData() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of("jpn:ger", new AttributeConfig("jpn", "ger")),
|
||||||
|
Arguments.of("eng:eng", new AttributeConfig("eng", "eng")),
|
||||||
|
Arguments.of("OFF:OFF", new AttributeConfig("OFF", "OFF"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("validData")
|
||||||
|
void convert(String input, AttributeConfig expected) {
|
||||||
|
AttributeConfigConverter underTest = new AttributeConfigConverter();
|
||||||
|
AttributeConfig actual = underTest.convert(input);
|
||||||
|
assertEquals(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stream<Arguments> invalidData() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of("ars:eng"),
|
||||||
|
Arguments.of("ars:OFF"),
|
||||||
|
Arguments.of("OFF:ars"),
|
||||||
|
Arguments.of("ars:ars"),
|
||||||
|
Arguments.of("arss:ars"),
|
||||||
|
Arguments.of("ars:arsr")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("invalidData")
|
||||||
|
void convertInvalid(String input) {
|
||||||
|
AttributeConfigConverter underTest = new AttributeConfigConverter();
|
||||||
|
assertThrows(CommandLine.TypeConversionException.class, () -> underTest.convert(input));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user