+# String option tests.
+proc_with_prefix test-string {variant} {
+ global all_options
+
+ set cmd [make_cmd $variant]
+
+ res_test_gdb_complete_none \
+ "1 [expect_none ""]" \
+ "$cmd -string "
+
+ # Check that "-" where a value is expected does not show the
+ # command's options. I.e., a string's value is not optional.
+ # Check both completion and running the command.
+ res_test_gdb_complete_none \
+ "1 [expect_none ""]" \
+ "$cmd -string -"
+ gdb_test "$cmd -string --"\
+ "-string requires an argument"
+ if {$variant == "require-delimiter"} {
+ gdb_test "$cmd -string" [expect_none "-string"]
+ } else {
+ gdb_test "$cmd -string"\
+ "-string requires an argument"
+ }
+
+ res_test_gdb_complete_none \
+ "1 [expect_none ""]" \
+ "$cmd -string STR"
+ gdb_test "$cmd -string STR --" [expect_string "STR" ""]
+
+ # Completing at "-" after parsing STR should list all options.
+ res_test_gdb_complete_multiple \
+ "1 [expect_string "STR" "-"]" \
+ "$cmd -string STR " "-" "" $all_options
+
+ # Check that only FOO is considered part of the string's value.
+ # I.e., that we stop parsing the string at the first whitespace.
+ if {$variant == "require-delimiter"} {
+ res_test_gdb_complete_none \
+ "1 [expect_string "FOO" "BAR"]" \
+ "$cmd -string FOO BAR"
+ } else {
+ res_test_gdb_complete_none "0 BAR" "$cmd -string FOO BAR"
+ }
+ gdb_test "$cmd -string FOO BAR --" "Unrecognized option at: BAR --"
+}
+