diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-13 14:02:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-13 14:02:04 +0200 |
commit | 29c8ce737f513766673fd3e57e30233d9fcce159 (patch) | |
tree | 5438af51e0befd3dbc831f8258d4b2a964f1a957 /tests/compiler/cxx-indenter/driver.cxx | |
parent | 9767fa0eb684560d3ed9a5abc026e658b5ba735a (diff) |
Add C++ source code indenter
Diffstat (limited to 'tests/compiler/cxx-indenter/driver.cxx')
-rw-r--r-- | tests/compiler/cxx-indenter/driver.cxx | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/compiler/cxx-indenter/driver.cxx b/tests/compiler/cxx-indenter/driver.cxx new file mode 100644 index 0000000..0f9a3c5 --- /dev/null +++ b/tests/compiler/cxx-indenter/driver.cxx @@ -0,0 +1,104 @@ +// file : tests/compiler/cxx-indenter/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <fstream> +#include <iostream> + +#include <cutl/compiler/code-stream.hxx> +#include <cutl/compiler/cxx-indenter.hxx> + +using namespace std; +using namespace cutl::compiler; + +int +main () +{ + //std::wostream& os (wcout); + //ostream_filter<cxx_indenter, wchar_t> filt (os); + + std::ostream& os (cout); + ostream_filter<cxx_indenter, char> filt (os); + + os << "if (true)" + << "{" + << "// Hello there" << endl + << "//" << endl + << "a ();" + << "}" + << "else" + << "{" + << "b ();" + << "}"; + + os << "if (false)" + << "{" + << "if (true)" + << "{" + << "// test" << endl + << "}" + << "else" + << "{" + << "// test" << endl + << "b ();" + << "}" + << "}"; + + os << "namespace a" + << "{" + << "void f ();" + << "}" + << "#if defined(__HP_aCC) && __HP_aCC <= 39999" << endl + << "#include <foo.h>" << endl + << "#endif" << endl + << endl + << "namespace b" + << "{" + << "void f ();" + << "}"; + + // Test do-while handling. + // + os << "do" << endl + << "f ();" + << "while (false);" + << endl; + + os << "do" + << "{" + << "f ();" + << "}" + << "while (false);" + << endl; + + os << "do" + << "{" + << "if (f ())" + << "{" + << "g ();" + << "}" + << "}" + << "while (false);" + << endl; + + os << "do" + << "{" + << "do" << endl + << "f ();" + << "while (false);" + << "}" + << "while (false);" + << endl; + + os << "do" + << "{" + << "do" + << "{" + << "f ();" + << "}" + << "while (false);" + << "}" + << "while (false);" + << endl; +} |