I've migrated an older test for integration into the test suite. The original 27_basic_ios.cpp source file is attached for comparision to the new version shown below with some commentary.
file tests/iostream/27.basic.ios.cpp: 1 /*********************************************************************** **** 2 * 3 * 27.basic.ios.cpp - test exercising the class template basic_ios 4 * 5 * $Id: //stdcxx/trunk/tests/iostream/27_basic_ios.cpp#1 $ 6 * 7 ************************************************************************ *** 8 * 9 * Licensed to the Apache Software Foundation (ASF) under one or more 10 * contributor license agreements. See the NOTICE file distributed 11 * with this work for additional information regarding copyright 12 * ownership. The ASF licenses this file to you under the Apache 13 * License, Version 2.0 (the "License"); you may not use this file 14 * except in compliance with the License. You may obtain a copy of 15 * the License at 16 * 17 * http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an "AS IS" BASIS, 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 22 * implied. See the License for the specific language governing 23 * permissions and limitations under the License. 24 * 25 * Copyright 1994-2008 Rogue Wave Software. 26 * 27 ************************************************************************ **/ 28 29 // prevent the inclusion of non-essential public headers; only headers 30 // necessary to compile each header #included here are #included 31 // will produce errors if any templates defined in the header are 32 // instantiated without the names they use having been completely defined 33 #if !defined (_MSC_VER) || _MSC_VER > 1300 34 # define _RWSTD_NO_REDUNDANT_DEFINITIONS 35 #endif 36 37 // prevent out-of-line template definitions in .cc files from being explicitly 38 // #included during the processing of library headers (faster compilation) 39 // assumes that the test doesn't instantiate those templates on types other 40 // than those they were explcitly instantiated on (will have no effect if 41 // explicit instantiation is disabled or unsupported) 42 #define _RWSTD_NO_TEMPLATE_DEFINITIONS 43 44 #include <ios> 45 46 // IMPORTANT: do not #include any other header before the declarations 47 // below in order not to accidentally bring in any missing 48 // definitions from the #included header 49 50 #ifndef _RWSTD_NO_NAMESPACE 51 # define std std 52 #else 53 # define std 54 #endif // _RWSTD_NO_NAMESPACE 55 56 /*********************************************************************** ***/ 57 Nothing spectacular here. Updated the copyright notice. I did deviate slightly from convention of using 2 spaces to indent preprocessing directives only to be consistent with the convention of using 4 spaces to indent regular code. Why be consistent with inconsistent conventions? :) 58 // compilation tests 59 60 // use defs from <iosfwd> to verify that it is #included 61 62 struct S { /* empty */ }; 63 64 typedef std::char_traits<S> Traits; 65 typedef std::char_traits<char> char_Traits; 66 67 #ifndef _RWSTD_NO_WCHAR_T 68 69 typedef std::char_traits<wchar_t> wchar_t_Traits; 70 71 #endif // _RWSTD_NO_WCHAR_T 72 73 typedef std::allocator<S> Alloc; 74 75 #ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 76 77 // make sure that default template arguments are specified 78 79 typedef std::basic_ios<S> S_basic_ios; 80 typedef std::basic_streambuf<S> S_basic_streambuf; 81 typedef std::basic_istream<S> S_basic_istream; 82 typedef std::basic_ostream<S> S_basic_ostream; 83 typedef std::basic_iostream<S> S_basic_iostream; 84 typedef std::basic_stringbuf<S> S_basic_stringbuf; 85 typedef std::basic_istringstream<S> S_basic_istringstream; 86 typedef std::basic_ostringstream<S> S_basic_ostringstream; 87 typedef std::basic_stringstream<S> S_basic_stringstream; 88 89 typedef std::basic_filebuf<S> S_basic_filebuf; 90 typedef std::basic_ifstream<S> S_basic_ifstream; 91 typedef std::basic_ofstream<S> S_basic_ofstream; 92 typedef std::basic_fstream<S> S_basic_fstream; 93 94 typedef std::istreambuf_iterator<S> S_istreambuf_iterator; 95 typedef std::ostreambuf_iterator<S> S_ostreambuf_iterator; 96 97 #else // if defined _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 98 99 // specify default template argument for broken compilers 100 101 typedef std::basic_ios<S, Traits> S_basic_ios; 102 typedef std::basic_streambuf<S, Traits> S_basic_streambuf; 103 typedef std::basic_istream<S, Traits> S_basic_istream; 104 typedef std::basic_ostream<S, Traits> S_basic_ostream; 105 typedef std::basic_iostream<S, Traits> S_basic_iostream; 106 typedef std::basic_stringbuf<S, Traits, Alloc> S_basic_stringbuf; 107 typedef std::basic_istringstream<S, Traits, Alloc> S_basic_istringstream; 108 typedef std::basic_ostringstream<S, Traits, Alloc> S_basic_ostringstream; 109 typedef std::basic_stringstream<S, Traits, Alloc> S_basic_stringstream; 110 111 typedef std::basic_filebuf<S, Traits> S_basic_filebuf; 112 typedef std::basic_ifstream<S, Traits> S_basic_ifstream; 113 typedef std::basic_ofstream<S, Traits> S_basic_ofstream; 114 typedef std::basic_fstream<S, Traits> S_basic_fstream; 115 116 typedef std::istreambuf_iterator<S, Traits> S_istreambuf_iterator; 117 typedef std::ostreambuf_iterator<S, Traits> S_ostreambuf_iterator; 118 119 #endif // _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES 120 121 typedef std::fpos<S> S_fpos; 122 123 // test whether all required typedefs are defined 124 125 typedef std::ios X_ios; 126 typedef std::streambuf X_streambuf; 127 typedef std::istream X_istream; 128 typedef std::ostream X_ostream; 129 typedef std::iostream X_iostream; 130 typedef std::stringbuf X_stringbuf; 131 typedef std::istringstream X_istringstream; 132 typedef std::ostringstream X_ostringstream; 133 typedef std::stringstream X_stringstream; 134 typedef std::filebuf X_filebuf; 135 typedef std::ifstream X_ifstream; 136 typedef std::ofstream X_ofstream; 137 typedef std::fstream X_fstream; 138 139 typedef std::streampos X_streampos; 140 141 #ifndef _RWSTD_NO_WCHAR_T 142 143 typedef std::wios X_wios; 144 typedef std::wstreambuf X_wstreambuf; 145 typedef std::wistream X_wistream; 146 typedef std::wostream X_wostream; 147 typedef std::wiostream X_wiostream; 148 typedef std::wstringbuf X_wstringbuf; 149 typedef std::wistringstream X_wistringstream; 150 typedef std::wostringstream X_wostringstream; 151 typedef std::wstringstream X_wstringstream; 152 typedef std::wfilebuf X_wfilebuf; 153 typedef std::wifstream X_wifstream; 154 typedef std::wofstream X_wofstream; 155 typedef std::wfstream X_wfstream; 156 157 typedef std::wstreampos X_wstreampos; 158 159 #endif // _RWSTD_NO_WCHAR_T 160 Moved these typedefs out of the original function up to file scope in the same fashion as other tests in tests/iostream e.g. 27.forward.cpp. Exactly the same as the original otherwise. Oh, also added little comment to empty structure. I prefer to explicitly comment omitted empty structures, unused parameters, default arguments, empty function blocks, and such as I have seen throught the STDCXX code. 161 /*********************************************************************** ***/ 162 163 // additional compilation tests 164 165 #include <driver.h> 166 167 static void 168 test_synopsis () 169 { 170 rw_info (0, 0, __LINE__, "27.4.4 Class template basic_ios"); 171 172 // exercise types 173 std::streamoff off = 0; 174 _RWSTD_UNUSED (off); 175 176 std::streamsize size = 0; 177 _RWSTD_UNUSED (size); 178 179 std::fpos<int> fpi; 180 _RWSTD_UNUSED (fpi); 181 182 std::ios_base *iob = 0; 183 _RWSTD_UNUSED (iob); 184 185 // exercise a default argument 186 std::basic_ios<char, std::char_traits<char> > *bios_2 = 0; 187 std::basic_ios<char /*, char_traits<char> */> *bios_1 = bios_2; 188 189 _RWSTD_UNUSED (bios_2); 190 _RWSTD_UNUSED (bios_1); 191 192 #ifndef _RWSTD_NO_WCHAR_T 193 194 // exercise a default argument 195 std::basic_ios<wchar_t, std::char_traits<wchar_t> > *wbios_2 = 0; 196 std::basic_ios<wchar_t /*, char_traits<wchar_t> */> *wbios_1 = wbios_2; 197 198 _RWSTD_UNUSED (wbios_2); 199 _RWSTD_UNUSED (wbios_1); 200 201 #endif // _RWSTD_NO_WCHAR_T 202 203 #define TEST_MANIP(name) { \ 204 std::ios_base& (*pf)(std::ios_base&) = &name; \ 205 _RWSTD_UNUSED (pf); \ 206 } 207 208 // 27.4.5, manipulators: 209 TEST_MANIP (std::boolalpha); 210 TEST_MANIP (std::noboolalpha); 211 TEST_MANIP (std::noshowbase); 212 TEST_MANIP (std::showpoint); 213 TEST_MANIP (std::noshowpoint); 214 TEST_MANIP (std::noshowpos); 215 TEST_MANIP (std::skipws); 216 TEST_MANIP (std::noskipws); 217 TEST_MANIP (std::uppercase); 218 TEST_MANIP (std::nouppercase); 219 TEST_MANIP (std::internal); 220 TEST_MANIP (std::left); 221 TEST_MANIP (std::right); 222 TEST_MANIP (std::dec); 223 TEST_MANIP (std::hex); 224 TEST_MANIP (std::oct); 225 TEST_MANIP (std::fixed); 226 TEST_MANIP (std::scientific); 227 } 228 Include rwtest driver header now that its actually needed (and not before). Added an rw_info() call. Otherwise, same as original. 229 /*********************************************************************** ***/ 230 231 // invariant tests 232 233 template <class charT> 234 void test_ctors (charT /* unused */, const char* cname) 235 { 236 rw_info (0, 0, __LINE__, "27.4.4.1 basic_ios<%s> constructors", cname); 237 238 // 27.4.4.1, p1 239 std::basic_ios<charT, std::char_traits<charT> > io0 (0); 240 241 rw_assert (0 == io0.rdbuf (), __FILE__, __LINE__, 242 "basic_ios<%s>::rdbuf () == 0", cname); 243 244 rw_assert (0 == io0.tie (), __FILE__, __LINE__, 245 "basic_ios<%s>::tie () == 0", cname); 246 247 rw_assert (io0.badbit == io0.rdstate (), __FILE__, __LINE__, 248 "basic_ios<%s>::rdstate () == %{If}, got %{If}", 249 cname, io0.badbit, io0.flags ()); 250 251 rw_assert ((io0.skipws | io0.dec) == io0.flags (), 252 __FILE__, __LINE__, 253 "basic_ios<%s>::flags () == %{If}, got %{If}", 254 cname, io0.skipws | io0.dec, io0.flags ()); 255 256 rw_assert (0 == io0.width (), __FILE__, __LINE__, 257 "basic_ios<%s>::width () == 0, got %l", 258 cname, io0.width ()); 259 260 rw_assert (6 == io0.precision (), __FILE__, __LINE__, 261 "basic_ios<%s>::precision () == 6, got %l", 262 cname, io0.precision ()); 263 264 rw_assert (io0.widen (' ') == io0.fill (), __FILE__, __LINE__, 265 "basic_ios<%s>::fill ()", cname); 266 } 267 Pass type name in as function parameter. Updated diagnostic message with rw_info(). Switch RW_ASSERT to rw_assert. Used ${If} format specifier for ios flags. Also, I removed the getloc() test because a.) it was broken i.e. used an undefined locale object, b.) couldn't come up with a reasonable test for getloc(), and c.) its an inherited member function anyways. And last but not least... 268 /*********************************************************************** ***/ 269 270 // command-line options 271 static int rw_opt_no_basic_ios_ctors = 0; 272 273 static int 274 run_test (int /* unused */, char* /* unused */ []) 275 { 276 test_synopsis (); 277 278 if (rw_opt_no_basic_ios_ctors) { 279 rw_note (0, 0, 0, "basic_ios<T> ctors disabled"); 280 } else { 281 test_ctors (char (), "char"); 282 } 283 284 return 0; 285 } 286 287 extern int 288 main (int argc, char* argv []) 289 { 290 return rw_test (argc, argv, __FILE__, 291 "lib.iostream.basic_ios", 292 0, // no comment 293 run_test, 294 "|-no-basic_ios-ctors# ", 295 &rw_opt_no_basic_ios_ctors); 296 } 297 Added command-line option for assertions that were disabled by hard-coding in the original. That's about it. Please review and post any comments. Thanks, Brad.
