preCICE v3.1.2
Loading...
Searching...
No Matches
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
15BOOST_AUTO_TEST_CASE(VersionInformation)
16{
17 PRECICE_TEST(1_rank);
19 BOOST_TEST_CONTEXT("Info is \"" << info << "\"")
20 {
21 BOOST_TEST(!info.empty(), "The info contains at least the version.");
22
23 auto semis = std::count(info.begin(), info.end(), ';');
24 BOOST_TEST(semis >= 2, "The info contains " << semis << " of at least 3 sections ");
25
26 auto firstSemi = info.find(';');
27 auto version = info.substr(0, firstSemi);
28 BOOST_TEST_INFO("Section: " << version);
29 BOOST_TEST(!version.empty(), "The info contains the version section");
30
31 auto secondSemi = info.find(';', firstSemi + 1);
32 auto revision = info.substr(firstSemi + 1, secondSemi - firstSemi - 1);
33 BOOST_TEST_INFO("Section: " << revision);
34 BOOST_TEST(!revision.empty(), "The info contains the revision section");
35 }
36}
37
39{
40 PRECICE_TEST(1_rank);
41
42 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_MAJOR)>::value);
43 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_MINOR)>::value);
44 BOOST_REQUIRE(std::is_integral<decltype(PRECICE_VERSION_PATCH)>::value);
45
46 BOOST_TEST(PRECICE_VERSION_MAJOR > 0);
47 BOOST_TEST(PRECICE_VERSION_MINOR >= 0);
48 BOOST_TEST(PRECICE_VERSION_PATCH >= 0);
49
50 BOOST_REQUIRE_NO_THROW(std::string{PRECICE_VERSION});
51
52 const std::string version{PRECICE_VERSION};
53 // Minimal length of the version string is 5 chars X.Y.Z
54 BOOST_REQUIRE(version.length() >= 5);
55 // The version string contains 2 dots
56 BOOST_REQUIRE(std::count(version.begin(), version.end(), '.') == 2);
57}
58
59BOOST_AUTO_TEST_CASE(VersionMacroGreaterEqual)
60{
61 PRECICE_TEST(1_rank);
62
63 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(0, 0, 0));
64 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(1, 0, 0));
65 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(1, 1, 1));
66
67 // Equality
68 BOOST_REQUIRE(PRECICE_VERSION_GREATER_EQUAL(
69 PRECICE_VERSION_MAJOR,
70 PRECICE_VERSION_MINOR,
71 PRECICE_VERSION_PATCH));
72
73 // Wild guess
74 BOOST_REQUIRE(!PRECICE_VERSION_GREATER_EQUAL(99, 9, 99));
75}
76
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Definition Testing.hpp:27
BOOST_AUTO_TEST_CASE(VersionInformation)
T count(T... args)
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition Tooling.cpp:70