ARTS 2.5.11 (git: 6827797f)
compile_time_tests.cc
Go to the documentation of this file.
1#include "isotopologues.h"
2#include "quantum_numbers.h"
3
4namespace CompileTimeTests {
6constexpr bool testIsotopologuesAllValid() noexcept {
7 using namespace Species;
8 for (auto& x: Isotopologues) if (not good_enum(x.spec)) return false;
9 return true;
10}
11
12static_assert(testIsotopologuesAllValid(), "Error!\n\n"
13 "Cannot have invalid species in the isotopologues list.\n"
14 "One of your newly added or modified species cannot be understood\n");
15
17constexpr bool testShortNames() noexcept {
18 for (Index i=0; i<Index(Species::Species::FINAL); i++) {
19 auto a = Species::Species(i);
20 auto b = Species::toShortName(a);
21 auto c = Species::fromShortName(b);
22 if (not good_enum(c) or c not_eq a) {
23 return false;
24 }
25 }
26 return true;
27}
28
29static_assert(testShortNames(), "Error!\n\n"
30 "Cannot convert some species from to its short name and back to its enum-value.\n"
31 "All species in Species::Species must be translatable to and from short names in\n"
32 "the two function signatures:\n\n"
33 "\tstd::string_view toShortName(Species x)\n"
34 "\tSpecies fromShortName(const std::string_view x)\n"
35 "\n"
36 "Please ensure that any new Species you've added is available in these functions\n"
37 "and in all functions that makes use of a Species-switch.\n");
38
40constexpr bool testSpeciesIncreasing() noexcept {
41 using namespace Species;
42 static_assert(Isotopologues.size() not_eq 0);
43 for (std::size_t i=0; i<Isotopologues.size()-1; i++) {
44 auto& a = Isotopologues[i];
45 auto& b = Isotopologues[i+1];
46 if (std::size_t(a.spec) > std::size_t(b.spec)) {
48 return false;
49 }
50 }
51 return true;
52}
53
54static_assert(testSpeciesIncreasing(), "Error!\n\n"
55"Species in Isotopologues must be increasing.\n"
56"One of your newly added isotopologues is not in increasing order\n");
57
59constexpr bool testIsotopologuesIncreasing() noexcept {
60 using namespace Species;
61 static_assert(Isotopologues.size() not_eq 0);
62 for (std::size_t i=0; i<Isotopologues.size()-1; i++) {
63 auto& a = Isotopologues[i];
64 auto& b = Isotopologues[i+1];
65 if (a.spec == b.spec) {
66 if (a.isotname.compare(b.isotname) >= 0) {
68 return false;
69 }
70 }
71 }
72 return true;
73}
74
75static_assert(testIsotopologuesIncreasing(), "Error!\n\n"
76 "Isotopologues must be increasing.\n"
77 "One of your newly added isotopologues is not in increasing order\n");
78
79
81 "There's a missing value in the default isotopologue_ratiosInitFromBuiltin()"
82);
83
84constexpr bool check_global_local_types() {
85 using namespace Quantum::Number;
86
87 // Check independence
88 for (auto qn: local_types) for (auto qn2: global_types) if (qn == qn2) return false;
89
90 // Check completeness
91 if (global_types.size() + local_types.size() not_eq size_t(Type::FINAL)) return false;
92
93 // Check that local state has no string types
94 for (auto qn: local_types) if (common_value_type(common_value_type(qn), ValueType::H) not_eq ValueType::H) return false;
95
96 return true;
97}
98
99static_assert(check_global_local_types(), "Missing some quantum numbers from the global/local states");
100} // namespace CompileTimeTests
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
Definition: enums.h:21
constexpr bool testIsotopologuesIncreasing() noexcept
Don't call this manually, it only exists to catch a developer error.
constexpr bool check_global_local_types()
constexpr bool testSpeciesIncreasing() noexcept
Don't call this manually, it only exists to catch a developer error.
constexpr bool testShortNames() noexcept
Don't call this manually, it only exists to catch a developer error.
constexpr bool testIsotopologuesAllValid() noexcept
Don't call this manually, it only exists to catch a developer error.
constexpr IsotopologueRatios isotopologue_ratiosInitFromBuiltin()
constexpr bool all_isotopes_have_a_value() const noexcept
#define a
#define c
#define b