diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-25 16:09:36 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-25 16:09:36 +1000 |
| commit | 525ed2ae1bc710e2a80de0fc10300da83d594ccb (patch) | |
| tree | 49af557432f7e6fc86ae6025f7616137baaa91ad /src/drivers/test | |
| parent | 8db57d6dc5cf5c83cffd393a37ca37bc1a67f1af (diff) | |
| download | tangara-fw-525ed2ae1bc710e2a80de0fc10300da83d594ccb.tar.gz | |
Add a basic overview of writing and running tests
Diffstat (limited to 'src/drivers/test')
| -rw-r--r-- | src/drivers/test/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/drivers/test/test_adc.cpp | 2 | ||||
| -rw-r--r-- | src/drivers/test/test_samd.cpp | 32 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/drivers/test/CMakeLists.txt b/src/drivers/test/CMakeLists.txt index ff1dab0b..f18dc357 100644 --- a/src/drivers/test/CMakeLists.txt +++ b/src/drivers/test/CMakeLists.txt @@ -3,5 +3,5 @@ # SPDX-License-Identifier: GPL-3.0-only idf_component_register( - SRCS "test_adc.cpp" "test_storage.cpp" "test_dac.cpp" + SRCS "test_adc.cpp" "test_storage.cpp" "test_dac.cpp" "test_samd.cpp" INCLUDE_DIRS "." REQUIRES catch2 cmock drivers fixtures) diff --git a/src/drivers/test/test_adc.cpp b/src/drivers/test/test_adc.cpp index df103af3..a8dad4bd 100644 --- a/src/drivers/test/test_adc.cpp +++ b/src/drivers/test/test_adc.cpp @@ -12,7 +12,7 @@ namespace drivers { -TEST_CASE("battery measurement", "[integration]") { +TEST_CASE("battery adc", "[integration]") { AdcBattery battery; SECTION("voltage is within range") { diff --git a/src/drivers/test/test_samd.cpp b/src/drivers/test/test_samd.cpp new file mode 100644 index 00000000..c466d88e --- /dev/null +++ b/src/drivers/test/test_samd.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "drivers/samd.hpp" + +#include <cstdint> + +#include "catch2/catch.hpp" + +#include "i2c_fixture.hpp" + +namespace drivers { + +TEST_CASE("samd21 interface", "[integration]") { + I2CFixture i2c; + auto samd = std::make_unique<Samd>(); + + REQUIRE(samd); + + SECTION("usb reports connection") { + samd->UpdateUsbStatus(); + + auto status = samd->GetUsbStatus(); + + REQUIRE(status == Samd::UsbStatus::kAttachedIdle); + } +} + +} // namespace drivers |
