From b9087bc625757648dc54320558f162c7a4a63f52 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Tue, 29 Mar 2022 11:12:18 +0900 Subject: [PATCH] Add commissioner test case for start Change-Id: I61604323de139881a9024a6d06307a45cfad7c8b Signed-off-by: hyunuk.tak --- tests/unittest/thread-unittest-commissioner.cpp | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/unittest/thread-unittest-commissioner.cpp diff --git a/tests/unittest/thread-unittest-commissioner.cpp b/tests/unittest/thread-unittest-commissioner.cpp new file mode 100644 index 0000000..62a8ff1 --- /dev/null +++ b/tests/unittest/thread-unittest-commissioner.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "thread.h" + +class ThreadCommissionerTest : public ::testing::Test +{ +public: + thread_instance_h instance; + +protected: + void SetUp() override + { + thread_initialize(); + instance = nullptr; + } + + void TearDown() override + { + if (instance) + thread_disable(instance); + thread_deinitialize(); + } +}; + +TEST_F(ThreadCommissionerTest, CommissionerStartNotInitialized) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize()); + EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED, thread_commissioner_start(instance)); +} + +TEST_F(ThreadCommissionerTest, CommissionerStartInvalidParameter) +{ + EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER, thread_commissioner_start(instance)); +} + +TEST_F(ThreadCommissionerTest, CommissionerStartErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, thread_commissioner_start(instance)); +} \ No newline at end of file -- 2.7.4