Imported Upstream version 1.18.0
[platform/core/ml/nnfw.git] / compiler / circle-opselector / src / TestHelper.h
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 #ifndef __CIRCLE_OPSELECTOR_TEST_HELPER_H__
18 #define __CIRCLE_OPSELECTOR_TEST_HELPER_H__
19
20 #include <cassert>
21 #include <string.h>
22
23 template <size_t N> class Argv
24 {
25 public:
26   typedef char *pchar_t;
27
28 public:
29   ~Argv()
30   {
31     for (size_t n = 0; n < _ptr; ++n)
32       delete _argv[n];
33   }
34
35   void add(const char *in)
36   {
37     assert(_ptr < N);
38     _argv[_ptr] = new char[strlen(in) + 1];
39     strncpy(_argv[_ptr], in, strlen(in) + 1);
40     _ptr++;
41   }
42
43   pchar_t *argv(void) { return _argv; }
44
45 private:
46   pchar_t _argv[N] = {
47     nullptr,
48   };
49   size_t _ptr = 0;
50 };
51
52 #endif // __CIRCLE_OPSELECTOR_TEST_HELPER_H__