re PR libstdc++/23550 (char_traits requirements/1.cc test bad math)

2005-08-24  Lawrence Lim  <llim@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
	    Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/23550
	* testsuite/21_strings/char_traits/requirements/char/1.cc
	(test01): Simplify counting.
	* testsuite/21_strings/char_traits/requirements/wchar_t/1.cc
	(test02): Same.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r103451
This commit is contained in:
Lawrence Lim 2005-08-24 20:29:27 +00:00 committed by Benjamin Kosnik
parent 6f48c21a63
commit a35f1a13b9
3 changed files with 30 additions and 14 deletions

View File

@ -1,3 +1,13 @@
2005-08-24 Lawrence Lim <llim@redhat.com>
Jakub Jelinek <jakub@redhat.com>
Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/23550
* testsuite/21_strings/char_traits/requirements/char/1.cc
(test01): Simplify counting.
* testsuite/21_strings/char_traits/requirements/wchar_t/1.cc
(test02): Same.
2005-08-24 Paolo Carlini <pcarlini@suse.de> 2005-08-24 Paolo Carlini <pcarlini@suse.de>
Chris Jefferson <chris@bubblescope.net> Chris Jefferson <chris@bubblescope.net>

View File

@ -1,6 +1,7 @@
// 1999-06-03 bkoz // 1999-06-03 bkoz
// Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. // Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
// 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
@ -32,12 +33,12 @@ void test01(void)
// 21.1.1 character traits requirements // 21.1.1 character traits requirements
// Key for decoding what function signatures really mean: // Key for decoding what function signatures really mean:
// X == char_traits<_CharT> // X == char_traits<_CharT>
// [c,d] == _CharT // [c,d] == _CharT
// [p,q] == const _CharT* // [p,q] == const _CharT*
// s == _CharT* // s == _CharT*
// [n,i,j] == size_t // [n,i,j] == size_t
// f == X::int_type // f == X::int_type
// pos == X::pos_type // pos == X::pos_type
// state == X::state_type // state == X::state_type
@ -54,9 +55,11 @@ void test01(void)
// correctly even where p is in [s, s + n), and yields s. // correctly even where p is in [s, s + n), and yields s.
char array1[] = {'z', 'u', 'm', 'a', ' ', 'b', 'e', 'a', 'c', 'h', 0}; char array1[] = {'z', 'u', 'm', 'a', ' ', 'b', 'e', 'a', 'c', 'h', 0};
const char str_lit1[] = "montara and ocean beach"; const char str_lit1[] = "montara and ocean beach";
int len = sizeof(str_lit1) + sizeof(array1) - 1; // two terminating chars const char str_lit2[] = "boracay, philippines";
char array2[len]; const int len1 = sizeof(str_lit1)/sizeof(char);
std::char_traits<char>::copy(array2, "boracay, philippines", len); const int len2 = sizeof(str_lit2)/sizeof(char);
char array2[len1 + len2 - 1]; // two terminating chars
std::char_traits<char>::copy(array2, str_lit2, len2);
VERIFY( str_lit1[0] == 'm' ); VERIFY( str_lit1[0] == 'm' );
c1 = array2[0]; c1 = array2[0];

View File

@ -1,6 +1,7 @@
// 1999-06-03 bkoz // 1999-06-03 bkoz
// Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. // Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
// 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
@ -32,12 +33,12 @@ void test02(void)
// 21.1.1 character traits requirements // 21.1.1 character traits requirements
// Key for decoding what function signatures really mean: // Key for decoding what function signatures really mean:
// X == char_traits<_CharT> // X == char_traits<_CharT>
// [c,d] == _CharT // [c,d] == _CharT
// [p,q] == const _CharT* // [p,q] == const _CharT*
// s == _CharT* // s == _CharT*
// [n,i,j] == size_t // [n,i,j] == size_t
// f == X::int_type // f == X::int_type
// pos == X::pos_type // pos == X::pos_type
// state == X::state_type // state == X::state_type
@ -54,9 +55,11 @@ void test02(void)
// correctly even where p is in [s, s + n), and yields s. // correctly even where p is in [s, s + n), and yields s.
wchar_t array1[] = {L'z', L'u', L'm', L'a', L' ', L'b', L'e', L'a', L'c', L'h', 0}; wchar_t array1[] = {L'z', L'u', L'm', L'a', L' ', L'b', L'e', L'a', L'c', L'h', 0};
const wchar_t str_lit1[] = L"montara and ocean beach"; const wchar_t str_lit1[] = L"montara and ocean beach";
int len = sizeof(str_lit1) + sizeof(array1) - 1; // two terminating chars const wchar_t str_lit2[] = L"boracay, philippines";
wchar_t array2[len]; const int len1 = sizeof(str_lit1)/sizeof(wchar_t);
std::char_traits<wchar_t>::copy(array2, L"boracay, philippines", len); const int len2 = sizeof(str_lit2)/sizeof(wchar_t);
wchar_t array2[len1 + len2 - 1]; // two terminating chars
std::char_traits<wchar_t>::copy(array2, str_lit2, len2);
VERIFY( str_lit1[0] == 'm' ); VERIFY( str_lit1[0] == 'm' );
c1 = array2[0]; c1 = array2[0];