@@ -15,14 +15,14 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.8.1.3 filebuf member functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.8.1.3 filebuf member functions
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
// { dg-require-fileio "" }
+// { dg-additional-files "filebuf_members-1.tst filebuf_members-1.txt" }
+// { dg-final { file-io-diff "filebuf_members-1" } }
#include <fstream>
#include <testsuite_hooks.h>
@@ -17,11 +17,14 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.2.3 basic_istream::operator>>
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.2.3 basic_istream::operator>>
// { dg-require-fileio "" }
+// { dg-additional-files "istream_extractor_other-1.tst" }
+// { dg-additional-files "istream_extractor_other-1.txt" }
+// { dg-additional-files "istream_extractor_other-2.tst" }
+// { dg-final { file-io-diff "istream_extractor_other-1" } }
+// { dg-final { file-io-diff "istream_extractor_other-2" } }
#include <istream>
#include <fstream>
@@ -15,11 +15,14 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.2.3 basic_istream::operator>>
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.2.3 basic_istream::operator>>
// { dg-require-fileio "" }
+// { dg-additional-files "wistream_extractor_other-1.tst" }
+// { dg-additional-files "wistream_extractor_other-1.txt" }
+// { dg-additional-files "wistream_extractor_other-2.tst" }
+// { dg-final { file-io-diff "wistream_extractor_other-1" } }
+// { dg-final { file-io-diff "wistream_extractor_other-2" } }
#include <istream>
#include <fstream>
@@ -17,11 +17,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
// { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
#include <istream>
#include <sstream>
@@ -15,11 +15,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
// { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
#include <istream>
#include <sstream>
@@ -17,11 +17,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
// { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
#include <istream>
#include <fstream>
@@ -15,11 +15,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
// { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
#include <istream>
#include <fstream>
@@ -17,10 +17,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_seeks-1" } }
#include <istream>
#include <fstream>
@@ -15,10 +15,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "wistream_seeks-1" } }
#include <istream>
#include <fstream>
@@ -17,12 +17,16 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
// { dg-require-fileio "" }
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// { dg-additional-files "istream_seeks-2.tst" }
+// Do not create istream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "istream_seeks-1" } }
+// { dg-final { file-io-diff "istream_seeks-2" } }
#include <istream>
#include <sstream>
@@ -16,11 +16,15 @@
// <http://www.gnu.org/licenses/>.
// { dg-require-fileio "" }
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// { dg-additional-files "wistream_seeks-2.tst" }
+// Do not create wistream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "wistream_seeks-1" } }
+// { dg-final { file-io-diff "wistream_seeks-2" } }
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
#include <istream>
#include <sstream>
@@ -17,12 +17,16 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
// { dg-require-fileio "" }
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// { dg-additional-files "istream_seeks-2.tst" }
+// Do not create istream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "istream_seeks-1" } }
+// { dg-final { file-io-diff "istream_seeks-2" } }
#include <istream>
#include <sstream>
@@ -16,11 +16,15 @@
// <http://www.gnu.org/licenses/>.
// { dg-require-fileio "" }
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// { dg-additional-files "wistream_seeks-2.tst" }
+// Do not create wistream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "wistream_seeks-1" } }
+// { dg-final { file-io-diff "wistream_seeks-2" } }
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
#include <istream>
#include <sstream>
@@ -17,10 +17,9 @@
// C++98 27.8.1.10 ofstream member functions
-// { dg-additional-files "ofstream_members-1.tst" }
-// @diff@ %-*.tst %-*.txt
-
// { dg-require-fileio "" }
+// { dg-additional-files "ofstream_members-1.tst" }
+// { dg-final { file-io-diff "ofstream_members-1" } }
#include <ostream>
#include <fstream>
@@ -18,11 +18,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
// { dg-require-fileio "" }
+// { dg-additional-files "ostream_inserter_other-1.tst" }
+// { dg-additional-files "ostream_inserter_other-2.tst" }
+// { dg-final { file-io-diff "ostream_inserter_other-1" } }
+// { dg-final { file-io-diff "ostream_inserter_other-2" } }
#include <ostream>
#include <sstream>
@@ -18,9 +18,9 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
+
+// { dg-final { file-io-diff "ostream_inserter_other_in" "ostream_inserter_other_out" } }
#include <ostream>
#include <fstream>
@@ -56,6 +56,7 @@ test03(void)
out.seekp(0, ios_base::end);
i_read = in.tellg() - rs;
i_wrote = out.tellp() - ws;
+ VERIFY( i_read == i_wrote );
in.close();
out.close();
}
@@ -15,11 +15,13 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
// { dg-require-fileio "" }
+// { dg-additional-files "wostream_inserter_other-1.tst" }
+// { dg-additional-files "wostream_inserter_other-2.tst" }
+// { dg-final { file-io-diff "wostream_inserter_other-1" } }
+// { dg-final { file-io-diff "wostream_inserter_other-2" } }
#include <ostream>
#include <sstream>
@@ -15,9 +15,9 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
+
+// { dg-final { file-io-diff "wostream_inserter_other_in.txt" "wostream_inserter_other_out.txt" } }
#include <ostream>
#include <fstream>
@@ -53,6 +53,7 @@ test03(void)
out.seekp(0, ios_base::end);
i_read = in.tellg() - rs;
i_wrote = out.tellp() - ws;
+ VERIFY( i_read == i_wrote );
in.close();
out.close();
}
@@ -20,8 +20,9 @@
// <http://www.gnu.org/licenses/>.
// 27.4.2.4 ios_base static members
-// @require@ %-*.tst
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "ios_base_members_static-1.tst" }
+// { dg-final { file-io-diff "ios_base_members_static-1" } }
#include <cstdio>
#include <sstream>
@@ -1674,3 +1674,35 @@ if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
}
}
+
+# Compare output file written by test to expected result.
+# With two arguments the comparison is done via 'diff arg1 arg2'.
+# With one argument the comparison is done via 'diff arg1.tst arg1.txt'.
+proc file-io-diff { args } {
+ set nargs [llength $args]
+ if { $nargs < 1 } {
+ error "too few arguments to file-io-diff"
+ }
+ if { $nargs > 2 } {
+ error "too many arguments to file-io-diff"
+ }
+ if { $nargs == 1 } {
+ set file1 [lindex $args 0]
+ set file2 "${file1}.txt"
+ append file1 ".tst"
+ } else {
+ set file1 [lindex $args 0]
+ set file2 [lindex $args 1]
+ }
+
+ spawn -noecho diff -u $file1 $file2
+ expect {
+ -re ".+" {
+ set msg "files differ\n"
+ append msg $expect_out(0,string)
+ fail $msg
+ exp_continue
+ }
+ }
+ return
+}