CMDAPIVarArgsSorting #43

Zusammengeführt
YoyoNow hat 3 Commits von CMDAPIVarArgsSorting nach master 2023-02-04 11:54:25 +01:00 zusammengeführt
4 geänderte Dateien mit 29 neuen und 1 gelöschten Zeilen
Nur Änderungen aus Commit 45e9698634 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -140,7 +140,6 @@ public abstract class AbstractSWCommand<T> {
}
Collections.sort(commandList);
System.out.println(commandList.stream().map(o -> o.method).collect(Collectors.toList()));
initialized = true;
}

Datei anzeigen

@ -82,6 +82,8 @@ public class SubCommand<T> implements Comparable<SubCommand<T>> {
if (tVarArgs) tLength *= -1;
if (oVarArgs) oLength *= -1;
if (tVarArgs && oVarArgs) return Integer.compare(tLength, oLength);
return -Integer.compare(tLength, oLength);
}

Datei anzeigen

@ -38,6 +38,11 @@ public class SubCMDSortingCommand extends TestSWCommand {
throw new ExecutionIdentifier("Command with 1 parameter");
}
@Register
public void test(String s, String i1, String i2, String i3, String... args) {
throw new ExecutionIdentifier("Command with 3+n parameters");
}
@Register
public void test(String s, String... args) {
throw new ExecutionIdentifier("Command with n parameters");

Datei anzeigen

@ -58,4 +58,26 @@ public class SubCMDSortingCommandTest {
assertCMDFramework(e, ExecutionIdentifier.class, "Command with n parameters");
}
}
@Test
public void testThreeArgsVarArg() {
SubCMDSortingCommand cmd = new SubCMDSortingCommand();
try {
cmd.execute("", "", new String[]{"Hello", "World", "YoyoNow", "Hugo"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "Command with 3+n parameters");
}
}
@Test
public void testThreeArgsVarArg2() {
SubCMDSortingCommand cmd = new SubCMDSortingCommand();
try {
cmd.execute("", "", new String[]{"Hello", "World", "YoyoNow"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "Command with 3+n parameters");
}
}
}