X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fterm_test.go;fp=cmd%2Fsafcm%2Fterm_test.go;h=0000000000000000000000000000000000000000;hb=ecbcb0132728cc18016819a214378b642d92278e;hp=479d7e8e197f7ab951331adec562c6e8671e21e2;hpb=b0f49e5d47786984e24731b200d3d3d7d6add263;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/term_test.go b/cmd/safcm/term_test.go deleted file mode 100644 index 479d7e8..0000000 --- a/cmd/safcm/term_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2021 Simon Ruderich -// -// 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 . - -package main - -import ( - "testing" - - "ruderich.org/simon/safcm/testutil" -) - -func TestEscapeControlCharacters(t *testing.T) { - tests := []struct { - name string - isTTY bool - x string - exp string - }{ - { - "UTF-8", - false, - "Hello, 世界", - "Hello, 世界", - }, - { - "UTF-8 (TTY)", - true, - "Hello, 世界", - "Hello, 世界", - }, - - { - "color", - false, - ColorString(true, ColorRed, "red"), - `\x1B[31mred\x1B[0m`, - }, - { - "color (TTY)", - true, - ColorString(true, ColorRed, "red"), - "\x1B[35m\\x1B\x1B[0m[31mred\x1B[35m\\x1B\x1B[0m[0m", - }, - - { - "\\r\\n", - false, - "\r\n", - "\\r\n", - }, - { - "\\r\\n (TTY)", - true, - "\r\n", - "\x1B[35m\\r\x1B[0m\n", - }, - - { - "binary", - false, - "\xD6\x24\xA4\x45\xA2\x68\xD3\x0E\xD4\xC7\xC3\x1F", - "\xD6$\xA4E\xA2h\xD3\\x0E\xD4\xC7\xC3\\x1F", - }, - { - "binary (TTY)", - true, - "\xD6\x24\xA4\x45\xA2\x68\xD3\x0E\xD4\xC7\xC3\x1F", - "\xD6$\xA4E\xA2h\xD3\x1B[35m\\x0E\x1B[0m\xD4\xC7\xc3\x1B[35m\\x1F\x1B[0m", - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - res := EscapeControlCharacters(tc.isTTY, tc.x) - testutil.AssertEqual(t, "res", res, tc.exp) - }) - } -}