test_version_information.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // Copyright 2022 FZI Forschungszentrum Informatik
5 // Created on behalf of Universal Robots A/S
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // -- END LICENSE BLOCK ------------------------------------------------
19 
20 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 
29 #include <gtest/gtest.h>
30 
33 
34 using namespace urcl;
35 
36 TEST(version_information, test_split)
37 {
38  const std::string version_string1 = "5.12.0.1101319";
39  std::vector<std::string> expected = { "5", "12", "0", "1101319" };
40 
41  EXPECT_EQ(expected, splitString(version_string1));
42 }
43 
44 TEST(version_information, string_parsing)
45 {
46  const std::string version_string_full = "5.12.1.1234";
47  const std::string version_3 = "5.12.1";
48  const std::string version_2 = "5.12";
49  auto expected = VersionInformation();
50  expected.major = 5;
51  expected.minor = 12;
52  expected.bugfix = 1;
53  expected.build = 1234;
54 
55  EXPECT_EQ(expected, VersionInformation::fromString(version_string_full));
56  expected.build = 0;
57  EXPECT_EQ(expected, VersionInformation::fromString(version_3));
58  expected.bugfix = 0;
59  EXPECT_EQ(expected, VersionInformation::fromString(version_2));
60 
61  const std::string illegal_string("asdy");
62  EXPECT_THROW(VersionInformation::fromString(illegal_string), UrException);
63  const std::string illegal_string_2("1");
64  EXPECT_THROW(VersionInformation::fromString(illegal_string_2), UrException);
65 }
66 
67 TEST(version_information, test_relations)
68 {
69  auto v1 = VersionInformation::fromString("5.5.0.1101319");
70  auto v2 = VersionInformation::fromString("5.5.0.1101318");
71  auto v3 = VersionInformation::fromString("5.5.1");
72  auto v4 = VersionInformation::fromString("3.12.0.1234");
73 
74  EXPECT_EQ(v1, v1);
75  EXPECT_LT(v2, v1);
76  EXPECT_LE(v2, v1);
77  EXPECT_LE(v1, v1);
78  EXPECT_GT(v1, v2);
79  EXPECT_GE(v1, v1);
80  EXPECT_LT(v1, v3);
81  EXPECT_LT(v4, v1);
82  EXPECT_TRUE(v1 != v2);
83 }
84 
85 int main(int argc, char* argv[])
86 {
87  ::testing::InitGoogleTest(&argc, argv);
88 
89  return RUN_ALL_TESTS();
90 }
TEST(version_information, test_split)
Struct containing a robot&#39;s version information.
std::vector< std::string > splitString(std::string input, const std::string &delimiter=".")
int main(int argc, char *argv[])
Our base class for exceptions. Specialized exceptions should inherit from those.
Definition: exceptions.h:41
static VersionInformation fromString(const std::string &str)
Parses a version string into a VersionInformation object.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47