-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Team334/SwerveBase-CTRE
- Loading branch information
Showing
5 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package frc.lib; | ||
|
||
import static frc.lib.UnitTestingUtil.reset; | ||
import static frc.lib.UnitTestingUtil.setupTests; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.ctre.phoenix6.StatusCode; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import frc.lib.FaultsTable.Fault; | ||
import frc.lib.FaultsTable.FaultType; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CTREUtilTest { | ||
private TalonFX _motor; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
setupTests(); | ||
|
||
_motor = new TalonFX(1); | ||
} | ||
|
||
@AfterEach | ||
public void close() throws Exception { | ||
reset(); | ||
|
||
_motor.close(); | ||
} | ||
|
||
@Test | ||
public void motorName() { | ||
var name = CTREUtil.getName(_motor); | ||
|
||
assertEquals(name, "TalonFX (1)"); | ||
} | ||
|
||
@Test | ||
public void motorAttempt() { | ||
var name = CTREUtil.getName(_motor); | ||
|
||
var failed = CTREUtil.attempt(() -> StatusCode.ConfigFailed, _motor); | ||
|
||
assert failed; | ||
|
||
FaultLogger.update(); | ||
|
||
assert FaultLogger.totalFaults() | ||
.contains( | ||
new Fault( | ||
name + ": Config Apply Failed - " + StatusCode.ConfigFailed.getDescription(), | ||
FaultType.ERROR)); | ||
} | ||
} |