2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <cker/operation/Range.h>
19 #include <gtest/gtest.h>
22 TEST(CKer_Operation, Range)
28 std::vector<int> actual(10);
29 nnfw::cker::Range<int>(&start, &limit, &delta, actual.data());
31 for (int i = 0; i < actual.size(); i++)
32 ASSERT_EQ(actual[i], i);
39 std::vector<int> expected = {3, 6, 9, 12, 15};
40 std::vector<int> actual(expected.size());
41 nnfw::cker::Range<int>(&start, &limit, &delta, actual.data());
43 for (int i = 0; i < actual.size(); i++)
44 ASSERT_EQ(actual[i], expected[i]);
48 const float start = 3;
49 const float limit = 1;
50 const float delta = -0.5;
51 std::vector<float> expected = {3, 2.5, 2, 1.5};
52 std::vector<float> actual(expected.size());
53 nnfw::cker::Range<float>(&start, &limit, &delta, actual.data());
55 for (int i = 0; i < actual.size(); i++)
56 ASSERT_FLOAT_EQ(actual[i], expected[i]);
60 TEST(CKer_Operation, neg_Range)
63 const int start = 212;
66 std::vector<int> actual(10);
68 EXPECT_ANY_THROW(nnfw::cker::Range<int>(&start, &limit, &delta, actual.data()));