~christopher-hunt08/maus/beam_selection_development

« back to all changes in this revision

Viewing changes to tests/cpp_unit/JsonCppProcessors/CommonProcessorTest.hh

  • Committer: Chris Rogers
  • Date: 2012-10-13 18:43:00 UTC
  • mfrom: (663.6.137 merge)
  • mto: (663.6.204 merge)
  • mto: This revision was merged to the branch mainline in revision 680.
  • Revision ID: chris.rogers@stfc.ac.uk-20121013184300-ry9q81m45dmtgejr
Bring control room branch into line with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#ifndef _TESTS_CPP_UNIT_JSONCPPPROCESSORS_COMMONPROCESSORTEST_HH_
 
18
 
 
19
#include <string>
 
20
 
 
21
namespace MAUS {
 
22
namespace ProcessorTest {
 
23
template <class TYPE>
 
24
void test_value(ProcessorBase<TYPE>* proc, std::string test_string) {
 
25
    Json::Value json_in;
 
26
    ASSERT_NO_THROW(json_in = JsonWrapper::StringToJson(test_string))
 
27
                                                                 << test_string;
 
28
    TYPE* cpp_type = NULL;
 
29
    ASSERT_NO_THROW(cpp_type = proc->JsonToCpp(json_in));
 
30
    Json::Value* json_out = NULL;
 
31
    ASSERT_NO_THROW(json_out = proc->CppToJson(*cpp_type));
 
32
    EXPECT_PRED3(JsonWrapper::AlmostEqual, json_in, *json_out, 1e-9);
 
33
    delete cpp_type;
 
34
    delete json_out;
 
35
}
 
36
}
 
37
}
 
38
 
 
39
#endif
 
40