From 1ef12a515fcf4334725767e09d11583301a5153b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Nov 2016 15:17:53 +0200 Subject: Adjust for literal here-document support in testscript --- tests/compiler/sloc-counter/driver.cxx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'tests/compiler/sloc-counter/driver.cxx') diff --git a/tests/compiler/sloc-counter/driver.cxx b/tests/compiler/sloc-counter/driver.cxx index 9d738b3..d06bfbe 100644 --- a/tests/compiler/sloc-counter/driver.cxx +++ b/tests/compiler/sloc-counter/driver.cxx @@ -3,6 +3,8 @@ // license : MIT; see accompanying LICENSE file #include +#include +#include #include #include @@ -14,23 +16,25 @@ using namespace cutl::compiler; int main (int argc, char* argv[]) { - if (argc != 2) - { - cerr << "usage: " << argv[0] << " " << endl; - return 1; - } + ifstream ifs; + + if (argc > 1) + ifs.open (argv[1]); - ostream_filter filt (cout); + istream& in (ifs.is_open () ? ifs : cin); - ifstream ifs (argv[1]); + ostringstream os1, os2; + ostream_filter filt (os1); - for (istream::int_type c (ifs.get ()); - c != istream::traits_type::eof (); - c = ifs.get ()) + for (istream::int_type i (in.get ()); + i != istream::traits_type::eof (); + i = in.get ()) { - cout.put (istream::traits_type::to_char_type (c)); + char c (istream::traits_type::to_char_type (i)); + os1.put (c); + os2.put (c); } - cout << endl - << filt.stream ().count () << endl; + assert (os1.str () == os2.str ()); + cout << filt.stream ().count () << endl; } -- cgit v1.1