Commit 644638bc by Benjamin Kosnik

[multiple changes]


2000-06-13  Brent Verner <brent@rcfile.org>

	* bits/string.tcc (string::rfind): Fix.
	* testsuite/21_strings/rfind.cc: New file.

2000-06-26  Anthony Williams  <anthony@anthonyw.cjb.net>

	* testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error.

2000-06-26  Branko Cibej  <branko.cibej@hermes.si>

        * testsuite/27_io/filebuf_members.cc (test_01): Fixed typos.

        * mkcheck.in: Make the *.txt and *.tst files writable after
	  copying them to $TEST_DIR.

        * testsuite/27_io/ostream_inserter_arith.cc: Renamed
          __TEST_NUMPUT_VERBOSE to TEST_NUMPUT_VERBOSE.
        Define TEST_NUMPUT_VERBOSE only if DEBUG_ASSERT.

From-SVN: r34719
parent 913c27bf
2000-06-13 Brent Verner <brent@rcfile.org>
* bits/string.tcc (string::rfind): Fix.
* testsuite/21_strings/rfind.cc: New file.
2000-06-26 Anthony Williams <anthony@anthonyw.cjb.net>
* testsuite/21_strings/ctor_copy_dtor.cc: Fixed logic error.
2000-06-26 Branko Cibej <branko.cibej@hermes.si> 2000-06-26 Branko Cibej <branko.cibej@hermes.si>
* mkcheck.in: Make the *.txt and *.tst files writable * testsuite/27_io/filebuf_members.cc (test_01): Fixed typos.
after copying them to $TEST_DIR.
* mkcheck.in: Make the *.txt and *.tst files writable after
copying them to $TEST_DIR.
* testsuite/27_io/ostream_inserter_arith.cc: Renamed
__TEST_NUMPUT_VERBOSE to TEST_NUMPUT_VERBOSE.
Define TEST_NUMPUT_VERBOSE only if DEBUG_ASSERT.
2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com> 2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. * bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it.
......
...@@ -634,14 +634,14 @@ namespace std ...@@ -634,14 +634,14 @@ namespace std
size_type __size = this->size(); size_type __size = this->size();
if (__n <= __size) if (__n <= __size)
{ {
size_t __xpos = __size - __n; __pos = std::min(__size - __n ,__pos);
if (__xpos > __pos) const _CharT* __data = _M_data();
__xpos = __pos; do
{
for (++__xpos; __xpos-- > 0; ) if (traits_type::compare(__data + __pos, __s, __n) == 0)
if (traits_type::eq(_M_data()[__xpos], *__s) return __pos;
&& traits_type::compare(_M_data() + __xpos, __s, __n) == 0) }
return __xpos; while (__pos-- > 0);
} }
return npos; return npos;
} }
......
// 1999-06-04 bkoz // 1999-06-04 bkoz
// Copyright (C) 1999 Free Software Foundation, Inc. // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -79,8 +79,9 @@ int test01(void) ...@@ -79,8 +79,9 @@ int test01(void)
// NB: As strlen(str_lit01) != csz01, this test is undefined. It // NB: As strlen(str_lit01) != csz01, this test is undefined. It
// should not crash, but what gets constructed is a bit arbitrary. // should not crash, but what gets constructed is a bit arbitrary.
// The "maverick's" of all string objects.
try { try {
std::string str04(str_lit01, npos); // the "maverick's" of all string objects. std::string str04(str_lit01, npos);
test &= true; test &= true;
} }
catch(std::length_error& fail) { catch(std::length_error& fail) {
...@@ -90,9 +91,10 @@ int test01(void) ...@@ -90,9 +91,10 @@ int test01(void)
test &= false; test &= false;
} }
// Build a maxsize-1 lengthed string consisting of all A's
try { try {
std::string str03(str_lit01, csz01 - 1); std::string str03(csz01 - 1, 'A');
test &= str03.size() != 0; test &= str03.size() == csz01 - 1;
test &= str03.size() <= str03.capacity(); test &= str03.size() <= str03.capacity();
} }
// NB: bad_alloc is regrettable but entirely kosher for // NB: bad_alloc is regrettable but entirely kosher for
......
...@@ -47,7 +47,7 @@ test_01() ...@@ -47,7 +47,7 @@ test_01()
int close_num; int close_num;
// read (ext) // read (ext)
int fd = open(name01, O_RDONLY); int fd = open(name_01, O_RDONLY);
test &= fd >= 0; test &= fd >= 0;
{ {
...@@ -59,11 +59,11 @@ test_01() ...@@ -59,11 +59,11 @@ test_01()
// read (standard) // read (standard)
FILE* f = fopen(name01, "r"); FILE* f = fopen(name_01, "r");
test &= !f; test &= !f;
{ {
std::ifstream ifstream1(name02); std::ifstream ifstream1(name_01);
test &= ifstream1.is_open(); test &= ifstream1.is_open();
std::ios_base::iostate st01 = ifstream1.rdstate(); std::ios_base::iostate st01 = ifstream1.rdstate();
test &= st01 == std::ios_base::goodbit; test &= st01 == std::ios_base::goodbit;
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
using namespace std; using namespace std;
#define __TEST_NUMPUT_VERBOSE 1 #ifndef DEBUG_ASSERT
# define TEST_NUMPUT_VERBOSE 1
#endif
struct _TestCase struct _TestCase
{ {
...@@ -190,7 +192,7 @@ void test01() ...@@ -190,7 +192,7 @@ void test01()
for (int j=0; j<sizeof(testcases)/sizeof(testcases[0]); j++) for (int j=0; j<sizeof(testcases)/sizeof(testcases[0]); j++)
{ {
_TestCase & tc = testcases[j]; _TestCase & tc = testcases[j];
#ifdef __TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << tc.result << endl; cout << "expect: " << tc.result << endl;
#endif #endif
// test double with char type // test double with char type
...@@ -201,7 +203,7 @@ void test01() ...@@ -201,7 +203,7 @@ void test01()
os.imbue(__loc); os.imbue(__loc);
apply_formatting(tc, os); apply_formatting(tc, os);
os << tc.val; os << tc.val;
#ifdef __TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl; cout << "result: " << os.str() << endl;
#endif #endif
assert(os && os.str() == tc.result); assert(os && os.str() == tc.result);
...@@ -214,7 +216,7 @@ void test01() ...@@ -214,7 +216,7 @@ void test01()
os.imbue(__loc); os.imbue(__loc);
apply_formatting(tc, os); apply_formatting(tc, os);
os << (long double)tc.val; os << (long double)tc.val;
#ifdef __TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "result: " << os.str() << endl; cout << "result: " << os.str() << endl;
#endif #endif
assert(os && os.str() == tc.result); assert(os && os.str() == tc.result);
...@@ -257,7 +259,7 @@ void test02() ...@@ -257,7 +259,7 @@ void test02()
char largebuf[512]; char largebuf[512];
sprintf(largebuf, "%.*Le", prec, val); sprintf(largebuf, "%.*Le", prec, val);
#ifdef __TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "expect: " << largebuf << endl; cout << "expect: " << largebuf << endl;
cout << "result: " << os.str() << endl; cout << "result: " << os.str() << endl;
#endif #endif
...@@ -298,7 +300,7 @@ int main() ...@@ -298,7 +300,7 @@ int main()
{ {
test01(); test01();
test02(); test02();
#ifdef __TEST_NUMPUT_VERBOSE #ifdef TEST_NUMPUT_VERBOSE
cout << "Test passed!" << endl; cout << "Test passed!" << endl;
#endif #endif
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment