From 95c345e6fb2a40c7fa5a0476396c1adfdd84acc9 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Wed, 24 May 2023 18:08:36 +0200 Subject: [PATCH] AP_JSButton: add unittest --- libraries/AP_JSButton/tests/test_jsbutton.cpp | 16 ++++++++++++++++ libraries/AP_JSButton/tests/wscript | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 libraries/AP_JSButton/tests/test_jsbutton.cpp create mode 100644 libraries/AP_JSButton/tests/wscript diff --git a/libraries/AP_JSButton/tests/test_jsbutton.cpp b/libraries/AP_JSButton/tests/test_jsbutton.cpp new file mode 100644 index 0000000000..109db3a04a --- /dev/null +++ b/libraries/AP_JSButton/tests/test_jsbutton.cpp @@ -0,0 +1,16 @@ +#include +#include + +const AP_HAL::HAL& hal = AP_HAL::get_HAL(); + +TEST(JSButtonTest, Test) +{ + JSButton jsbutton; + EXPECT_EQ(jsbutton.function(), JSButton::k_none); + EXPECT_EQ(jsbutton.function(true), JSButton::k_none); + jsbutton.set_default(JSButton::k_shift, JSButton::k_arm_toggle); + EXPECT_EQ(jsbutton.function(), JSButton::k_shift); + EXPECT_EQ(jsbutton.function(true), JSButton::k_arm_toggle); +} + +AP_GTEST_MAIN() diff --git a/libraries/AP_JSButton/tests/wscript b/libraries/AP_JSButton/tests/wscript new file mode 100644 index 0000000000..cd3e5e3ce7 --- /dev/null +++ b/libraries/AP_JSButton/tests/wscript @@ -0,0 +1,7 @@ +#!/usr/bin/env python +# encoding: utf-8 + +def build(bld): + bld.ap_find_tests( + use='ap', + )