1# Copyright 1992, 2004 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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17# Test case for CLLbs15503
18# This file was written by Sue Kimura (sue_kimura@hp.com)
19# Rewritten by Michael Chastain (mec.gnu@mindspring.com)
20
21if $tracelevel {
22    strace $tracelevel
23}
24
25set testfile "bs15503"
26set srcfile ${testfile}.cc
27set binfile ${objdir}/${subdir}/${testfile}
28
29if [get_compiler_info ${binfile}] {
30    return -1
31}
32
33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } {
34    perror "Couldn't compile ${srcfile}"
35    return -1
36}
37
38gdb_exit
39gdb_start
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${binfile}
42
43if ![runto_main] then {
44    perror "couldn't run to breakpoint"
45    continue
46}
47
48# Set breakpoint on template function
49
50gdb_test "break StringTest<wchar_t>::testFunction" \
51    "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal."
52
53gdb_test "continue" \
54    ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \
55    "continue to StringTest<wchar_t>"
56
57# Run to some random point in the middle of the function.
58
59gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"]
60gdb_continue_to_breakpoint "find position where blank needs to be inserted"
61
62# Call some string methods.
63
64gdb_test "print s.length()"		"\\$\[0-9\]+ = 42"
65gdb_test "print s\[0\]"			"\\$\[0-9\]+ =.* 'I'"
66gdb_test "print s\[s.length()-1\]"	"\\$\[0-9\]+ =.* 'g'"
67gdb_test "print (const char *) s" \
68    "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\""
69
70# TODO: tests that do not work with gcc 2.95.3
71# -- chastain 2004-01-07
72#
73# gdb_test "print s.compare(s)"		"\\$\[0-9\]+ = 0"
74# gdb_test "print s.compare(\"AAA\")"     "\\$\[0-9\]+ = 1"
75# gdb_test "print s.compare(\"ZZZ\")"     "\\$\[0-9\]+ = -1"
76
77# TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2.
78# cannot call overloaded non-member operator.  -- chastain 2004-01-07
79#
80# gdb_test "print s == s"			"\\$\[0-9\]+ = true"
81# gdb_test "print s > "AAA"			"\\$\[0-9\]+ = true"
82# gdb_test "print s < "ZZZ"			"\\$\[0-9\]+ = true"
83
84# TODO crash gdb!  This is going to be a great test!
85# -- chastain 2004-01-07
86#
87# gdb_test "print s == \"I am a short stringand now a longer string\"" \
88#     "\\$\[0-9\]+ = "true"
89
90gdb_test "print (const char *) s.substr(0,4)"	"\\$\[0-9\]+ = $hex \"I am\""
91gdb_test "print (const char *) (s=s.substr(0,4))" \
92    "\\$\[0-9\]+ = $hex \"I am\""
93
94# TODO: cannot call overloaded non-member operator again.
95# -- chastain 2004-01-07
96#
97# gdb_test "print (const char *) (s + s)" \
98#    "\\$\[0-9\]+ = $hex \"I amI am\""
99# gdb_test "print (const char *) (s + \" \" + s)" \
100#    "\\$\[0-9\]+ = $hex \"I am I am\""
101