Skip to content

Commit

Permalink
Add compose/schedule lock testing to composition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Aug 28, 2023
1 parent c8b82c0 commit 2465d7f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 59 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package edu.wpi.first.wpilibj2.command;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -29,4 +31,33 @@ void runWhenDisabled(boolean runsWhenDisabled) {
composeSingle(new WaitUntilCommand(() -> false).ignoringDisable(runsWhenDisabled));
assertEquals(runsWhenDisabled, command.runsWhenDisabled());
}

@Test
void commandInOtherCompositionTest() {
var command = new InstantCommand();
var composition = new WrapperCommand(command) {};
assertThrows(IllegalArgumentException.class, () -> composeSingle(command));
}

@Test
void commandInMultipleCompositionsTest() {
var command = new InstantCommand();
var composition = composeSingle(command);
assertThrows(IllegalArgumentException.class, () -> composeSingle(command));
}

@Test
void composeThenScheduleTest() {
var command = new InstantCommand();
var composition = composeSingle(command);
assertThrows(
IllegalArgumentException.class, () -> CommandScheduler.getInstance().schedule(command));
}

@Test
void scheduleThenComposeTest() {
var command = new RunCommand(() -> {});
CommandScheduler.getInstance().schedule(command);
assertThrows(IllegalArgumentException.class, () -> composeSingle(command));
}
}

0 comments on commit 2465d7f

Please sign in to comment.