|
| 1 | +/* mbed Microcontroller Library |
| 2 | + * Copyright (c) 2019 ARM Limited |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#include "utest/utest.h" |
| 19 | +#include "unity/unity.h" |
| 20 | +#include "greentea-client/test_env.h" |
| 21 | + |
| 22 | +using namespace utest::v1; |
| 23 | + |
| 24 | +#include "PinNames.h" |
| 25 | +#include "gpio_api.h" |
| 26 | + |
| 27 | +static void gpio_nc_test() |
| 28 | +{ |
| 29 | + gpio_t nc_obj; |
| 30 | + gpio_init(&nc_obj, NC); |
| 31 | + TEST_ASSERT_FALSE(gpio_is_connected(&nc_obj)); |
| 32 | + |
| 33 | + gpio_t led_obj; |
| 34 | + gpio_init(&led_obj, LED1); |
| 35 | + if (LED1 == NC) { |
| 36 | + TEST_ASSERT_FALSE(gpio_is_connected(&led_obj)); |
| 37 | + } else { |
| 38 | + TEST_ASSERT_TRUE(gpio_is_connected(&led_obj)); |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +Case cases[] = { |
| 43 | + Case("gpio NC test", gpio_nc_test) |
| 44 | +}; |
| 45 | + |
| 46 | +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) |
| 47 | +{ |
| 48 | + GREENTEA_SETUP(20, "default_auto"); |
| 49 | + return greentea_test_setup_handler(number_of_cases); |
| 50 | +} |
| 51 | + |
| 52 | +Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); |
| 53 | + |
| 54 | +int main() |
| 55 | +{ |
| 56 | + Harness::run(specification); |
| 57 | +} |
0 commit comments