//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // XFAIL: with_system_lib=x86_64-apple-darwin11 // // 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()); } }