-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for testing framework #129
Changes from 1 commit
a1e680f
f558872
62f5a7a
300f0fb
cd744cb
c7c10f5
4b9abf2
56266fa
18cb64a
a672208
6446b82
d85d550
9701337
e2660bd
ea9dd48
7a9bc58
61876c8
f177abc
3e82b09
3c0d4f3
7de333e
3d33f1c
9d1a9d0
dd44a96
0e8c7ef
4ff2fdf
e663d12
e73f72a
8b8e5eb
572c99b
10e03d0
73534c1
689db50
2b35889
1f25358
a62f47d
af08e3d
2c4a202
846bb01
9b7c217
ab03caf
0d69a31
8ea86f2
182ae78
a3aaa2c
f387dab
edef6d9
17ad3b9
7cfa5d3
848f2da
9555179
45797b7
e58bdf4
4c962f0
8bb3282
15d0f83
dc20190
8902794
ddf1a6d
8acb468
2f3b4b7
b7ca972
b3c32b4
d06a89f
4104604
337138a
b6efb43
bf592d3
6f85645
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<metadata p1="75" p2="12.32" p3="Aloha" /> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
#include <TRestRun.h> | ||
#include <TRestMetadata.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <filesystem> | ||
|
@@ -10,6 +11,7 @@ using namespace std; | |
|
||
#define FILES_PATH fs::path(__FILE__).parent_path().parent_path() / "files" | ||
#define BASIC_TRESTRUN_RML FILES_PATH / "TRestRunBasic.rml" | ||
#define BASIC_TRESTMETADATA_RML FILES_PATH / "metadata.rml" | ||
|
||
TEST(FrameworkCore, TestFiles) { | ||
cout << "FrameworkCore test files path: " << FILES_PATH << endl; | ||
|
@@ -37,3 +39,26 @@ TEST(FrameworkCore, TRestRun) { | |
EXPECT_TRUE(run.GetRunDescription() == "This is a test for TRestRun"); | ||
EXPECT_TRUE(run.GetVerboseLevelString() == "debug"); | ||
} | ||
|
||
TEST(FrameworkCore, TRestMetadata) { | ||
// Check required files exist | ||
EXPECT_TRUE(fs::exists(BASIC_TRESTMETADATA_RML)); | ||
|
||
// Create new TRestMetadata class | ||
class metadataTestClass: public TRestMetadata{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any REST class should be starting by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
but this is not a class, its just a cpp file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, it is a class, as it is stated in front of it name, I agree we could make an exception inside tests, but I thought it was not possible that the XML header and the class name would be different, it is this possible? @nkx? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay now I see what you mean. but this is not a class definition, the same test file could contain many class definitions, it should not begin by This was introduced by @DavidDiezIb and I think its a great idea to test a class such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind the naming convention, we can change it if you prefer. Just I thought it was better not to use REST naming convenctions to avoid confussion with any real REST classes. Related to the name of the metadata section, I can modify it to coincide with name of the class, maybe is easier to read. But There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am not debating that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's right, maybe we should remove the option to select the section by hand in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I didn't know that was possible, we never use it that way, isn't @nkx?
So probably we should remove the second argument of that method, and just define a local variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, I agree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However I am a bit surprised, I thought the second argument was the given name, so that if I got two
So that the constructor would pick up the right definition using:
At least thats how I am using it inside for example I guess it is because either option is posible as from the definition
But why do we need |
||
int fP1; | ||
double fP2; | ||
string fP3; | ||
}; | ||
|
||
metadataTestClass meta; | ||
meta.LoadConfigFromFile(BASIC_TRESTMETADATA_RML, "metadata"); | ||
|
||
meta.PrintMetadata(); | ||
//cout << meta.GetParameter("p1") << endl; | ||
|
||
EXPECT_TRUE(meta.GetParameter("p1") == "75"); | ||
EXPECT_TRUE(meta.GetParameter("p2") == "12.32"); | ||
EXPECT_TRUE(meta.GetParameter("p3") == "Aloha"); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not keep the convention that the xml header is the name of the c++ metadata class, which is
metadataTestClass
.