Imported Upstream version 1.18.0
[platform/core/ml/nnfw.git] / compiler / circle-opselector / src / Driver.test.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "Driver.test.h"
18 #include "TestHelper.h"
19
20 #include <gtest/gtest.h>
21
22 TEST(DriverTest, NoArg_NEG)
23 {
24   Argv<1> argv;
25   argv.add("circle-opselector");
26
27   ::testing::internal::CaptureStderr();
28   ::testing::internal::CaptureStdout();
29   int result = entry(1, argv.argv());
30   ::testing::internal::GetCapturedStdout();
31   ASSERT_EQ(EXIT_FAILURE, result);
32 }
33
34 TEST(DriverTest, Wrong_ID_NEG)
35 {
36   std::string str1 = "1";
37   std::string empty = "";
38   std::string no_integer = "1531538X5";
39
40   ASSERT_EQ(true, is_number(str1));
41   ASSERT_EQ(false, is_number(empty));
42   ASSERT_EQ(false, is_number(no_integer));
43 }
44
45 TEST(DriverTest, Split)
46 {
47   std::vector<uint32_t> vec1;
48   std::vector<uint32_t> vec2;
49
50   std::string hyphen = "1-3,8-10";
51   std::string comma = "1,2,3";
52
53   vec1.push_back(1);
54   vec1.push_back(2);
55   vec1.push_back(3);
56   vec1.push_back(8);
57   vec1.push_back(9);
58   vec1.push_back(10);
59
60   vec2.push_back(1);
61   vec2.push_back(2);
62   vec2.push_back(3);
63
64   ASSERT_EQ(vec1, split_id_input(hyphen));
65   ASSERT_EQ(vec2, split_id_input(comma));
66 }