preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VersioningTests.cpp
Go to the documentation of this file.
1#include <algorithm>
2#include <boost/test/tools/old/interface.hpp>
3#include <ostream>
4#include <string>
5#include <type_traits>
6
7#include "precice/Tooling.hpp"
8#include "precice/Version.h"
9#include "testing/Testing.hpp"
10#include "utils/assertion.hpp"
11
12BOOST_AUTO_TEST_SUITE(PreciceTests)
13BOOST_AUTO_TEST_SUITE(Versioning)
14
16BOOST_AUTO_TEST_CASE(VersionInformation)
17{
20 BOOST_TEST_CONTEXT("Info is \"" << info << "\"")
21 {
22 BOOST_TEST(!info.empty(), "The info contains at least the version.");
23
24 auto semis = std::count(info.begin(), info.end(), ';');
25 BOOST_TEST(semis >= 2, "The info contains " << semis << " of at least 3 sections ");
26
27 auto firstSemi = info.find(';');
28 auto version = info.substr(0, firstSemi);
29 BOOST_TEST_INFO("Section: " << version);
30 BOOST_TEST(!version.empty(), "The info contains the version section");
31
32 auto secondSemi = info.find(';', firstSemi + 1);
33 auto revision = info.substr(firstSemi + 1, secondSemi - firstSemi - 1);
34 BOOST_TEST_INFO("Section: " << revision);
35 BOOST_TEST(!revision.empty(), "The info contains the revision section");
36 }
37}
38
41{
43
44 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_MAJOR)>::value);
45 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_MINOR)>::value);
46 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_PATCH)>::value);
47
48 BOOST_TEST(PRECICE_VERSION_MAJOR > 0);
49 BOOST_TEST(PRECICE_VERSION_MINOR >= 0);
50 BOOST_TEST(PRECICE_VERSION_PATCH >= 0);
51
52 BOOST_REQUIRE_NO_THROW(std::string{PRECICE_VERSION});
53
54 const std::string version{PRECICE_VERSION};
55 // Minimal length of the version string is 5 chars X.Y.Z
56 BOOST_REQUIRE(version.length() >= 5);
57 // The version string contains 2 dots
58 BOOST_REQUIRE(std::count(version.begin(), version.end(), '.') == 2);
59}
60
62BOOST_AUTO_TEST_CASE(VersionMacroGreaterEqual)
63{
65
66 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(0, 0, 0));
67 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(1, 0, 0));
68 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(1, 1, 1));
69
70 // Equality
71 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(
72 PRECICE_VERSION_MAJOR,
73 PRECICE_VERSION_MINOR,
74 PRECICE_VERSION_PATCH));
75
76 // Wild guess
77 BOOST_REQUIRE(!PRECICE_VERSION_GREATER_EQUAL(99, 9, 99));
78}
79
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST()
Definition Testing.hpp:39
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
Definition Testing.hpp:29
BOOST_AUTO_TEST_CASE(VersionInformation)
T count(T... args)
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition Tooling.cpp:70