mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
**New features** - Created a devicetree DTS and YAML parser in Python - Created new modules: - TactilityKernel (LGPL v3.0 license) - Platforms/PlatformEsp32 (LGPL v3.0 license) - Platforms/PlatformPosix (LGPL v3.0 license) - Tests/TactilityKernelTests Most boards have a placeholder DTS file, while T-Lora Pager has a few devices attached. **Licenses** Clarified licenses and copyrights better. - Add explanation about the intent behind them. - Added explanation about licenses for past and future subprojects - Added more details explanations with regards to the logo usage - Copied licenses to subprojects to make it more explicit
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
#include "doctest.h"
|
|
#include <Tactility/Driver.h>
|
|
|
|
TEST_CASE("driver_construct and driver_destruct should set and unset the correct fields") {
|
|
Driver driver = { 0 };
|
|
|
|
int error = driver_construct(&driver);
|
|
CHECK_EQ(error, 0);
|
|
CHECK_NE(driver.internal.data, nullptr);
|
|
|
|
error = driver_destruct(&driver);
|
|
CHECK_EQ(error, 0);
|
|
CHECK_EQ(driver.internal.data, nullptr);
|
|
}
|
|
|
|
TEST_CASE("driver_is_compatible should return true if a compatible value is found") {
|
|
const char* compatible[] = { "test_compatible", nullptr };
|
|
Driver driver = {
|
|
.name = "test_driver",
|
|
.compatible = compatible,
|
|
.start_device = nullptr,
|
|
.stop_device = nullptr,
|
|
.api = nullptr,
|
|
.device_type = nullptr,
|
|
.internal = { 0 }
|
|
};
|
|
CHECK_EQ(driver_is_compatible(&driver, "test_compatible"), true);
|
|
CHECK_EQ(driver_is_compatible(&driver, "nope"), false);
|
|
CHECK_EQ(driver_is_compatible(&driver, nullptr), false);
|
|
}
|
|
|
|
TEST_CASE("driver_find should only find a compatible driver when the driver was constructed") {
|
|
const char* compatible[] = { "test_compatible", nullptr };
|
|
Driver driver = {
|
|
.name = "test_driver",
|
|
.compatible = compatible,
|
|
.start_device = nullptr,
|
|
.stop_device = nullptr,
|
|
.api = nullptr,
|
|
.device_type = nullptr,
|
|
.internal = { 0 }
|
|
};
|
|
|
|
Driver* found_driver = driver_find_compatible("test_compatible");
|
|
CHECK_EQ(found_driver, nullptr);
|
|
|
|
int error = driver_construct(&driver);
|
|
CHECK_EQ(error, 0);
|
|
|
|
found_driver = driver_find_compatible("test_compatible");
|
|
CHECK_EQ(found_driver, &driver);
|
|
|
|
error = driver_destruct(&driver);
|
|
CHECK_EQ(error, 0);
|
|
|
|
found_driver = driver_find_compatible("test_compatible");
|
|
CHECK_EQ(found_driver, nullptr);
|
|
}
|