22 #include "gtest/gtest.h"
28 class SDDSParserTest :
public ::testing::Test {
36 virtual ~SDDSParserTest() {
44 virtual void SetUp() {
50 virtual void TearDown() {
59 TEST_F(SDDSParserTest, ReadEnergy) {
62 std::string s =
"energy";
65 double expected = 2.220252349855340e-01;
66 ASSERT_DOUBLE_EQ(expected, energy);
69 TEST_F(SDDSParserTest, ReadLastPosition) {
71 double position = 0.0;
73 sddsr->getValue(-1, s, position);
75 double expected = 4.247573354842603e-03;
76 ASSERT_DOUBLE_EQ(expected, position);
79 TEST_F(SDDSParserTest, InterpolateRms_x) {
81 double spos = 4.0e-03;
82 double rmsx_interp = 0.0;
85 sddsr->getInterpolatedValue(spos,
"rms_x", rmsx_interp);
88 double spos_before = 3.786226707177705e-03;
89 double spos_after = 4.015012129060398e-03;
90 double rmsx_before = 3.147090549966750e-04;
91 double rmsx_after = 3.166390884805550e-04;
93 double expected = rmsx_before + (spos - spos_before) * (rmsx_after - rmsx_before) / (spos_after - spos_before);
95 ASSERT_DOUBLE_EQ(expected, rmsx_interp);
100 int main(
int argc,
char **argv) {
101 ::testing::InitGoogleTest(&argc, argv);
102 return RUN_ALL_TESTS();
int main(int argc, char **argv)
void getValue(int t, std::string column_name, T &nval)