Author: sebor
Date: Mon Apr 21 18:07:03 2008
New Revision: 650338
URL: http://svn.apache.org/viewvc?rev=650338&view=rev
Log:
2008-04-21 Martin Sebor <[EMAIL PROTECTED]>
* tests/regress/27.istream.getline.stdcxx-67.cpp: Added a regression
test for STDCXX-67.
Added:
stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp (with props)
Added: stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp?rev=650338&view=auto
==============================================================================
--- stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp (added)
+++ stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp Mon Apr 21
18:07:03 2008
@@ -0,0 +1,82 @@
+/************************************************************************
+ *
+ * 27.istream.getline.stdcxx-67.cpp - regression test for STDCXX-67
+ *
+ * http://issues.apache.org/jira/browse/STDCXX-67
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ **************************************************************************/
+
+#include <cassert>
+#include <sstream>
+
+int main ()
+{
+ std::istringstream strm ("\n\n");
+
+ char s [3] = { 'x', 'y', 'z' };
+
+ strm.getline (s, 0);
+
+ // 27.6.1.3, p17, bullet 2:
+ // Characters are extracted and stored until c == delim for the next
+ // available input character c.
+
+ assert (strm.goodbit == strm.rdstate ());
+ assert (1 == strm.gcount ());
+ assert ('x' == s [0]);
+ assert ('y' == s [1]);
+ assert ('z' == s [2]);
+
+ strm.getline (s, 1);
+
+ // 27.6.1.3, p17, bullet 3:
+ // Characters are extracted and stored until (n - 1) characters
+ // are stored (in which case the function calls setstate(failbit)).
+ // p20:
+ // In any case, it then stores a null character (using charT()) into
+ // the next successive location of the array.
+
+ assert (strm.goodbit == strm.rdstate ());
+ assert (1 == strm.gcount ());
+ assert ('\0' == s [0]);
+ assert ('y' == s [1]);
+ assert ('z' == s [2]);
+
+ strm.clear ();
+ strm.getline (s, 2);
+
+ // 27.6.1.3, p17, bullet 1:
+ // Characters are extracted and stored until end-of-file occurs on
+ // the input sequence (in which case the function calls setstate(eofbit))
+ // p20:
+ // In any case, it then stores a null character (using charT()) into
+ // the next successive location of the array.
+
+ assert ((strm.eofbit | strm.failbit) == strm.rdstate ());
+ assert (0 == strm.gcount ());
+ assert ('\0' == s [0]);
+ assert ('y' == s [1]);
+ assert ('z' == s [2]);
+
+ return 0;
+}
Propchange: stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: stdcxx/trunk/tests/regress/27.istream.getline.stdcxx-67.cpp
------------------------------------------------------------------------------
svn:keywords = Id