narrow_stream_objects.cc [plain text]
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <testsuite_hooks.h>
#include <iostream>
int
test01()
{
bool test = true;
char array1[20];
typedef std::ios::traits_type ctraits_type;
ctraits_type::int_type i = 15;
ctraits_type::copy(array1, "testing istream", i);
array1[i] = '\0';
std::cout << "testing cout" << std::endl;
std::cerr << "testing cerr" << std::endl;
VERIFY( std::cerr.flags() & std::ios_base::unitbuf );
std::clog << "testing clog" << std::endl;
VERIFY( std::cin.tie() == &std::cout );
return 0;
}
void test02()
{
using namespace std;
int i;
cin >> i;
cout << "i == " << i << endl;
}
void test03()
{
using namespace std;
ios_base::sync_with_stdio(false);
int i;
cin >> i;
cout << "i == " << i << endl;
}
void test04()
{
using namespace std;
cout << "hello ";
cout.flush();
cerr << "fine ";
cerr.flush();
cout << "world" << endl;
cout.flush();
}
void test05()
{
std::cout << "hello" << ' ' << "world" << std::endl;
std::cout << "Enter your name: ";
std::string s;
std::cin >> s;
std::cout << "hello " << s << std::endl;
}
void test06()
{
using namespace std;
int i;
cin >> i;
if (!cin.good())
{
cerr << endl;
cerr << "i == " << i << endl;
cerr << "cin.rdstate() == " << cin.rdstate() << endl;
cerr << "cin.bad() == " << cin.bad() << endl;
cerr << "cin.fail() == " << cin.fail() << endl;
cerr << "cin.eof() == " << cin.eof() << endl;
}
else
cerr << "i == " << i << endl;
}
void test07()
{
bool test = true;
std::cout << "Enter 'test':";
std::string s;
std::getline(std::cin, s, '\n');
VERIFY( s == "test" );
}
void test08()
{
bool test = true;
char buff[2048];
std::cout << "Enter name: ";
std::cin.getline(buff, 2048);
}
void test09()
{
bool test = true;
std::cout << "Enter favorite beach: ";
std::cin.ignore(2048, '\n');
}
void
test10()
{
using namespace std;
cout << "Press ENTER once\n";
cin.ignore(1);
cout << "_M_gcount: "<< cin.gcount() << endl;
}
int
main()
{
test01();
return 0;
}