mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sim] Add support for disabling SimDevices (#2568)
This allows disabling/enabling SimDevices via prefix matching. This can be used to force devices that normally use SimDevice in simulation mode to instead talk directly to the hardware as in normal operation.
This commit is contained in:
25
hal/src/test/native/cpp/mockdata/SimDeviceDataTests.cpp
Normal file
25
hal/src/test/native/cpp/mockdata/SimDeviceDataTests.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "hal/SimDevice.h"
|
||||
#include "hal/simulation/SimDeviceData.h"
|
||||
|
||||
namespace hal {
|
||||
|
||||
TEST(SimDeviceSimTests, TestEnabled) {
|
||||
ASSERT_TRUE(HALSIM_IsSimDeviceEnabled("foo"));
|
||||
HALSIM_SetSimDeviceEnabled("f", false);
|
||||
HALSIM_SetSimDeviceEnabled("foob", true);
|
||||
ASSERT_FALSE(HALSIM_IsSimDeviceEnabled("foo"));
|
||||
ASSERT_TRUE(HALSIM_IsSimDeviceEnabled("foobar"));
|
||||
ASSERT_TRUE(HALSIM_IsSimDeviceEnabled("bar"));
|
||||
|
||||
ASSERT_EQ(HAL_CreateSimDevice("foo"), 0);
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
Reference in New Issue
Block a user