# Copyright 1992-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see . */
# Test case for CLLbs15503
# This file was written by Sue Kimura (sue_kimura@hp.com)
# Rewritten by Michael Chastain (mec.gnu@mindspring.com)
require allow_stl_tests
standard_testfile .cc
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
if {![runto_main]} {
return
}
# Set breakpoint on template function
gdb_test "break StringTest::testFunction" \
"Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal."
gdb_test "continue" \
".*Breakpoint $decimal, StringTest::testFunction \\(this=$hex\\).*" \
"continue to StringTest"
# Run to some random point in the middle of the function.
gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"]
gdb_continue_to_breakpoint "find position where blank needs to be inserted"
# Call some string methods.
gdb_test "print s.length()" "\\$\[0-9\]+ = 42"
gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'"
gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'"
gdb_test "print (const char *) s" \
"\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\""