mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 15:32:25 +00:00
stdcxx: std::istream::ignore support
This commit is contained in:
parent
4b165190ee
commit
f2b9a6238c
@ -152,6 +152,8 @@ _ZNKSt9type_info10__do_catchEPKS_PPvj T
|
||||
_ZNKSt9type_info11__do_upcastEPKN10__cxxabiv117__class_type_infoEPPv T
|
||||
_ZNKSt9type_info14__is_pointer_pEv T
|
||||
_ZNKSt9type_info15__is_function_pEv T
|
||||
_ZNSi6ignoreEl T
|
||||
_ZNSi6ignoreEli T
|
||||
_ZNSt10__num_base11_S_atoms_inE D 8
|
||||
_ZNSt10__num_base12_S_atoms_outE D 8
|
||||
_ZNSt10__num_base15_S_format_floatERKSt8ios_basePcc T
|
||||
|
@ -45,5 +45,7 @@ compare_output_to {
|
||||
[init -> test-stdcxx] 456
|
||||
[init -> test-stdcxx] 7.8
|
||||
[init -> test-stdcxx] caught std::invalid_argument
|
||||
[init -> test-stdcxx] 1
|
||||
[init -> test-stdcxx] 2
|
||||
[init -> test-stdcxx] ° °° °°° test-stdcxx finished °°° °° °
|
||||
}
|
||||
|
@ -84,6 +84,31 @@ static void test_lock_guard()
|
||||
}
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <limits>
|
||||
|
||||
static void test_ignore()
|
||||
{
|
||||
std::istringstream input("1\n"
|
||||
"some non-numeric input\n"
|
||||
"2\n");
|
||||
for (;;) {
|
||||
int n;
|
||||
input >> n;
|
||||
|
||||
if (input.eof() || input.bad()) {
|
||||
break;
|
||||
} else if (input.fail()) {
|
||||
input.clear(); /* unset failbit */
|
||||
input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); /* skip bad input */
|
||||
} else {
|
||||
std::cout << n << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::cout << "° °° °°° test-stdcxx started °°° °° °" << std::endl;
|
||||
@ -92,6 +117,7 @@ int main(int argc, char **argv)
|
||||
test_cstdlib();
|
||||
test_stdexcept();
|
||||
test_lock_guard();
|
||||
test_ignore();
|
||||
|
||||
std::cout << "° °° °°° test-stdcxx finished °°° °° °" << std::endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user