PRISMS-PF  v2.1
test_parse_line.h
Go to the documentation of this file.
1 // Unit test(s) for the method "parse_line"
2 
3 template <int dim,typename T>
5  bool pass = false;
6  bool pass_subtest1 = false;
7  bool pass_subtest2 = false;
8  bool pass_subtest3 = false;
9  bool pass_subtest4 = false;
10  bool pass_subtest5 = false;
11 
12  bool found_entry;
13  char buffer[100];
14 
15  std::cout << "\nTesting 'parse_line'... " << std::endl;
16 
17  //create test problem class object
18  //userInputParameters userInputs;
19  //userInputs.loadUserInput();
20 
21  dealii::ParameterHandler parameter_handler;
22  variableAttributeLoader variable_attributes;
23  inputFileReader input_file_reader("parameters_test.in",variable_attributes);
24 
25  // Subtest 1
26  std::string line = "set Test entry = 3";
27  std::string keyword = "set";
28  std::string entry_name = "Test entry";
29  std::string out_string;
30  found_entry = input_file_reader.parse_line(line,keyword,entry_name,out_string,true);
31 
32  std::cout << out_string << " " << found_entry << std::endl;
33 
34  if (found_entry == true && boost::iequals(out_string,"3")){
35  pass_subtest1 = true;
36  }
37  sprintf (buffer, "Subtest 1 result for 'parse_line': %u\n", pass_subtest1);
38  std::cout << buffer;
39 
40  // Subtest 2
41  line = "set Test entry = 3";
42  keyword = "bork";
43  entry_name = "Test entry";
44  found_entry = input_file_reader.parse_line(line,keyword,entry_name,out_string,true);
45 
46  if (found_entry == false){
47  pass_subtest2 = true;
48  }
49  sprintf (buffer, "Subtest 2 result for 'parse_line': %u\n", pass_subtest2);
50  std::cout << buffer;
51 
52  // Subtest 3
53  line = "set Test entry = 3";
54  keyword = "set";
55  entry_name = "Test entry wrong";
56  found_entry = input_file_reader.parse_line(line,keyword,entry_name,out_string,true);
57 
58  if (found_entry == false){
59  pass_subtest3 = true;
60  }
61  sprintf (buffer, "Subtest 3 result for 'parse_line': %u\n", pass_subtest3);
62  std::cout << buffer;
63 
64  // Subtest 4
65  line = "set Test entry = 3";
66  keyword = "bork";
67  entry_name = "Test entry wrong";
68  found_entry = input_file_reader.parse_line(line,keyword,entry_name,out_string,true);
69 
70  if (found_entry == false){
71  pass_subtest4 = true;
72  }
73  sprintf (buffer, "Subtest 4 result for 'parse_line': %u\n", pass_subtest4);
74  std::cout << buffer;
75 
76  // Subtest 5
77  line = "\tset Test entry = 3";
78  keyword = "set";
79  entry_name = "Test entry";
80  found_entry = input_file_reader.parse_line(line,keyword,entry_name,out_string,true);
81 
82  if (found_entry == true && boost::iequals(out_string,"3")){
83  pass_subtest5 = true;
84  }
85  sprintf (buffer, "Subtest 5 result for 'parse_line': %u\n", pass_subtest5);
86  std::cout << buffer;
87 
88  // Check if all subtests passed
89  if (pass_subtest4&&pass_subtest3&&pass_subtest2&&pass_subtest1) {pass=true;}
90 
91  sprintf (buffer, "Test result for 'parse_line': %u\n", pass);
92  std::cout << buffer;
93 
94  return pass;
95 }
bool test_parse_line()
bool parse_line(std::string line, const std::string keyword, const std::string entry_name, std::string &out_string, bool expect_equals_sign) const