From 4e4fda78a2126ac78c6c0fb88040e687bfc7950e Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 21 Feb 2019 08:35:02 +0700 Subject: memfs: add method to dump files as Go generated source If you familiar with go-bindata [1], this method is similar with that. [1] github.com/shuLhan/go-bindata --- lib/bytes/bytes_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/bytes/bytes_test.go') diff --git a/lib/bytes/bytes_test.go b/lib/bytes/bytes_test.go index 2e1b3a24..5885eeb2 100644 --- a/lib/bytes/bytes_test.go +++ b/lib/bytes/bytes_test.go @@ -312,6 +312,22 @@ func TestTokenFind(t *testing.T) { testTokenFind(t, line, token, 0, exp) } +func TestInReplace(t *testing.T) { + cases := []struct { + in string + exp string + }{{ + in: "/a/path/to/file.ext", + exp: "_a_path_to_file_ext", + }} + + for _, c := range cases { + got := InReplace([]byte(c.in), []byte(ASCIILettersNumber), '_') + + test.Assert(t, "InReplace", c.exp, string(got), true) + } +} + func BenchmarkToLowerStd(b *testing.B) { randomInput256 := Random([]byte(HexaLetters), 256) -- cgit v1.3-6-g1900