//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // basic_istream& // operator>>(basic_istream& is, complex& x); #include #include #include int main() { { std::istringstream is("5"); std::complex c; is >> c; assert(c == std::complex(5, 0)); assert(is.eof()); } { std::istringstream is(" 5 "); std::complex c; is >> c; assert(c == std::complex(5, 0)); assert(is.good()); } { std::istringstream is(" 5, "); std::complex c; is >> c; assert(c == std::complex(5, 0)); assert(is.good()); } { std::istringstream is(" , 5, "); std::complex c; is >> c; assert(c == std::complex(0, 0)); assert(is.fail()); } { std::istringstream is("5.5 "); std::complex c; is >> c; assert(c == std::complex(5.5, 0)); assert(is.good()); } { std::istringstream is(" ( 5.5 ) "); std::complex c; is >> c; assert(c == std::complex(5.5, 0)); assert(is.good()); } { std::istringstream is(" 5.5)"); std::complex c; is >> c; assert(c == std::complex(5.5, 0)); assert(is.good()); } { std::istringstream is("(5.5 "); std::complex c; is >> c; assert(c == std::complex(0, 0)); assert(is.fail()); } { std::istringstream is("(5.5,"); std::complex c; is >> c; assert(c == std::complex(0, 0)); assert(is.fail()); } { std::istringstream is("( -5.5 , -6.5 )"); std::complex c; is >> c; assert(c == std::complex(-5.5, -6.5)); assert(is.eof()); } { std::istringstream is("(-5.5,-6.5)"); std::complex c; is >> c; assert(c == std::complex(-5.5, -6.5)); assert(is.eof()); } }