From 6a64f6dc31b3038187ce9246bdf438be9cc94bae Mon Sep 17 00:00:00 2001 From: Jeremy Faller Date: Tue, 24 Nov 2020 12:58:21 -0500 Subject: cmd/go: encode backslash and newline in response files Fixes #42295 Change-Id: Ie324bc99a74c1d864c6c2da2e7b929b338c2e033 Reviewed-on: https://go-review.googlesource.com/c/go/+/272870 Trust: Jeremy Faller Run-TryBot: Jeremy Faller TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Bryan C. Mills --- src/cmd/internal/objabi/flag_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/cmd/internal/objabi/flag_test.go (limited to 'src/cmd/internal/objabi/flag_test.go') diff --git a/src/cmd/internal/objabi/flag_test.go b/src/cmd/internal/objabi/flag_test.go new file mode 100644 index 0000000000..935b9c2193 --- /dev/null +++ b/src/cmd/internal/objabi/flag_test.go @@ -0,0 +1,26 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package objabi + +import "testing" + +func TestDecodeArg(t *testing.T) { + t.Parallel() + tests := []struct { + arg, want string + }{ + {"", ""}, + {"hello", "hello"}, + {"hello\\n", "hello\n"}, + {"hello\\nthere", "hello\nthere"}, + {"hello\\\\there", "hello\\there"}, + {"\\\\\\n", "\\\n"}, + } + for _, test := range tests { + if got := DecodeArg(test.arg); got != test.want { + t.Errorf("decodoeArg(%q) = %q, want %q", test.arg, got, test.want) + } + } +} -- cgit v1.3