Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
test_meta_utils.cc
Go to the documentation of this file.
1#include <cassert>
2#include <string>
3#include <unordered_map>
4
5#include "TFile.h"
6
8
10{
11 std::string jpp_version_in = "14.1.0";
12 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> md;
13 std::string app_name = "JSirene";
14 std::string git_key = "GIT";
15 md[app_name][git_key] = jpp_version_in;
16
17 auto jpp_version = get_jpp_version_from_meta(md);
18 assert(jpp_version == jpp_version_in);
19
20 auto jpp_major = get_jpp_major_version(jpp_version);
21 assert(jpp_major == 14);
22
23 assert(get_jpp_major_version("v14.1.0") == 14);
24 assert(get_jpp_major_version("14") == 14);
25 assert(get_jpp_major_version("14abc") == -1);
26 assert(get_jpp_major_version("a") == -1);
27 assert(get_jpp_major_version("v21.0.0-rc.3-51-g750e696c2") == 21);
28
29 return 0;
30}
31
33{
34 std::string dirname = "../km3net_testdata/km3net_testdata/data/";
35 // Test old file
36 std::string filename = dirname + "offline/KM3NeT_00000049_00011291.mc.gsg_neutrinos.km3sim_sirene_merged.jterbr.jppmuon_jppshower_static.offline.v9.2.sample.root";
37 auto jpp_version = get_jpp_version_from_file(filename.c_str());
38 auto jpp_major = get_jpp_major_version(jpp_version);
39 assert(jpp_major == 20);
40
41 return 0;
42}
43
44int main()
45{
47 test_file();
48
49 return 0;
50}
std::string get_jpp_version_from_meta(const std::unordered_map< std::string, std::unordered_map< std::string, std::string > > &meta)
Retrieve the JPP version from the metadata (mainly used for testing purposes)
Definition meta_utils.cc:38
std::string get_jpp_version_from_file(const char *filename)
Reads the jpp version from file.
Definition meta_utils.cc:57
int get_jpp_major_version(const std::string &version_str)
Get the jpp major version.
Definition meta_utils.cc:63
int test_file()
int test_standalone()
int main()