// Copyright (c) 2015 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
+// accompanying file LICENSE or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/nowide/iostream.hpp>
-#include <boost/nowide/detail/utf.hpp>
+#include <boost/nowide/utf/utf.hpp>
+#include <limits>
#include <string>
#include "test.hpp"
bool isValidUTF8(const std::string& s)
{
- using namespace boost::nowide::detail::utf;
+ using namespace boost::nowide::utf;
for(std::string::const_iterator it = s.begin(); it != s.end();)
{
code_point c = utf_traits<char>::decode(it, s.end());
TEST(boost::nowide::cerr);
if(argc == 2 && argv[1] == std::string("-i"))
{
+ boost::nowide::cout << "Input 2 strings" << std::endl;
std::string v1, v2;
boost::nowide::cin >> v1 >> v2;
TEST(boost::nowide::cin);
boost::nowide::cout << "First: " << v1 << std::endl;
boost::nowide::cout << "Second: " << v2 << std::endl;
TEST(boost::nowide::cout);
+
+ // Check sync
+ boost::nowide::cout << "Input 2 strings\n";
+ boost::nowide::cout.flush();
+ TEST(boost::nowide::cin >> v1);
+ boost::nowide::cin.sync();
+ boost::nowide::cout << "First: " << v1 << std::endl;
+ boost::nowide::cout << "2nd string should be ignored. Input 1 more + [ENTER]" << std::endl;
+ // And check getline not getting the CR
+ TEST(std::getline(boost::nowide::cin, v1));
+ TEST(!v1.empty() && v1[v1.size() - 1u] != '\r');
+ boost::nowide::cout << "Value: " << v1 << std::endl;
+
+ boost::nowide::cout << "Press ENTER to exit";
+ boost::nowide::cin.clear();
+ boost::nowide::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
+ boost::nowide::cin.get();
}
}