normalize_statement_t.cc
Go to the documentation of this file.
1 // Test the normalize_statement functionality, which is used for comparing
2 // schemas.
3 
6 
7 #include <iostream>
8 #include <string>
9 
10 using namespace cet::sqlite;
11 using namespace std;
12 
13 namespace {
14  void
15  normalize_then_compare(std::string test, std::string const& ref)
16  {
18  if (test != ref) {
19  throw Exception{errors::OtherError} << "Statements do not match:\n"
20  << " Test statement: " << test << '\n'
21  << " Ref. statement: " << ref << '\n';
22  }
23  }
24 }
25 
26 int
27 main() try {
28  // Test spaces around parentheses and commas
29  {
30  std::string const test{"CREATE TABLE TimeEvent ( Run integer, SubRun "
31  "integer,Event integer , Time numeric) "};
32  std::string const ref{"CREATE TABLE TimeEvent(Run integer,SubRun "
33  "integer,Event integer,Time numeric)"};
34  normalize_then_compare(test, ref);
35  }
36 }
37 catch (std::exception const& e) {
38  std::cerr << e.what() << '\n';
39  return 1;
40 }
41 catch (...) {
42  std::cerr << "Caught unknown exception.\n";
43  return 2;
44 }
std::string string
Definition: nybbler.cc:12
void normalize_statement(std::string &to_replace)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:27
STL namespace.
const double e
int main()
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33