diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /libbackend-elements/tests/indentation/cxx/driver.cxx |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'libbackend-elements/tests/indentation/cxx/driver.cxx')
-rw-r--r-- | libbackend-elements/tests/indentation/cxx/driver.cxx | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/libbackend-elements/tests/indentation/cxx/driver.cxx b/libbackend-elements/tests/indentation/cxx/driver.cxx new file mode 100644 index 0000000..adfc2fc --- /dev/null +++ b/libbackend-elements/tests/indentation/cxx/driver.cxx @@ -0,0 +1,105 @@ +// file : tests/indentation/cxx/driver.cxx +// author : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2006-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <iostream> + +#include <cult/types.hxx> + +#include <backend-elements/indentation/cxx.hxx> +#include <backend-elements/indentation/clip.hxx> + +using namespace Cult::Types; +using namespace BackendElements::Indentation; + +using std::cout; +using std::endl; + +Int +main () +{ + std::ostream& os (cout); + Clip<CXX, Char> clip (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; +} |