xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.cp/bs15503.exp (revision 70f7362772ba52b749c976fb5e86e39a8b2c9afc)
1# Copyright 1992-2023 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
16# Test case for CLLbs15503
17# This file was written by Sue Kimura (sue_kimura@hp.com)
18# Rewritten by Michael Chastain (mec.gnu@mindspring.com)
19
20if { [skip_stl_tests] } { return }
21
22standard_testfile .cc
23
24if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
25    return -1
26}
27
28if {![runto_main]} {
29    return
30}
31
32# Set breakpoint on template function
33
34gdb_test "break StringTest<wchar_t>::testFunction" \
35    "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal."
36
37gdb_test "continue" \
38    ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \
39    "continue to StringTest<wchar_t>"
40
41# Run to some random point in the middle of the function.
42
43gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"]
44gdb_continue_to_breakpoint "find position where blank needs to be inserted"
45
46# Call some string methods.
47
48gdb_test "print s.length()"		"\\$\[0-9\]+ = 42"
49gdb_test "print s\[0\]"			"\\$\[0-9\]+ =.* 'I'"
50gdb_test "print s\[s.length()-1\]"	"\\$\[0-9\]+ =.* 'g'"
51gdb_test "print (const char *) s" \
52    "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\""
53
54# TODO: tests that do not work with gcc 2.95.3
55# -- chastain 2004-01-07
56#
57# gdb_test "print s.compare(s)"		"\\$\[0-9\]+ = 0"
58# gdb_test "print s.compare(\"AAA\")"     "\\$\[0-9\]+ = 1"
59# gdb_test "print s.compare(\"ZZZ\")"     "\\$\[0-9\]+ = -1"
60
61# TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2.
62# cannot call overloaded non-member operator.  -- chastain 2004-01-07
63#
64# gdb_test "print s == s"			"\\$\[0-9\]+ = true"
65# gdb_test "print s > "AAA"			"\\$\[0-9\]+ = true"
66# gdb_test "print s < "ZZZ"			"\\$\[0-9\]+ = true"
67
68# TODO: GDB doesn't know to convert the string to a const char *, and
69# instead tries to use the string as a structure initializer.
70#
71# gdb_test "print s == \"I am a short stringand now a longer string\"" \
72#     "\\$\[0-9\]+ = true"
73
74gdb_test "print (const char *) s.substr(0,4)"	"\\$\[0-9\]+ = $hex \"I am\""
75gdb_test "print (const char *) (s=s.substr(0,4))" \
76    "\\$\[0-9\]+ = $hex \"I am\""
77
78# TODO: cannot call overloaded non-member operator again.
79# -- chastain 2004-01-07
80#
81# gdb_test "print (const char *) (s + s)" \
82#    "\\$\[0-9\]+ = $hex \"I amI am\""
83# gdb_test "print (const char *) (s + \" \" + s)" \
84#    "\\$\[0-9\]+ = $hex \"I am I am\""
85