blob: 20ab52b20abdd48083994516c66243ae527bd97c [file] [log] [blame]
Lei YU093b5912019-10-22 15:28:51 +08001/**
2 * Copyright © 2019 IBM Corporation
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#include "../version.hpp"
17
18#include <gtest/gtest.h>
19
20TEST(Version, GetLatest)
21{
22 // Input 2 different version where primary versions are different
23 std::vector<std::string> input = {"00000110", "01100110"};
24 EXPECT_EQ("01100110", version::getLatest(input));
25
26 // Input 3 different version where secondary versions are different
27 input = {"11223366", "11223355", "11223344"};
28 EXPECT_EQ("11223366", version::getLatest(input));
29
30 // Input 3 different version where communication versions are different
31 input = {"111133336666", "111133338888", "111133332222"};
32 EXPECT_EQ("111133338888", version::getLatest(input));
33
34 // Input has 3 same versions
35 input = {"11112222", "11112222", "11112222"};
36 EXPECT_EQ("11112222", version::getLatest(input));
37
38 // Input has one version
39 input = {"11112222"};
40 EXPECT_EQ("11112222", version::getLatest(input));
41
42 // Input empty
43 input = {};
44 EXPECT_EQ("", version::getLatest(input));
45}