MCPcopy
hub / github.com/klauspost/compress / TestNameDecoderDefault

Function TestNameDecoderDefault

zip/reader_test.go:1979–2008  ·  view source on GitHub ↗

TestNameDecoderDefault verifies that NewReader preserves the existing behavior when no decoder is supplied.

(t *testing.T)

Source from the content-addressed store, hash-verified

1977// TestNameDecoderDefault verifies that NewReader preserves the existing
1978// behavior when no decoder is supplied.
1979func TestNameDecoderDefault(t *testing.T) {
1980 rawName := "\x93\xfa\x96{\x8c\xea.txt"
1981
1982 var buf bytes.Buffer
1983 zw := NewWriter(&buf)
1984 if _, err := zw.CreateHeader(&FileHeader{
1985 Name: rawName,
1986 NonUTF8: true,
1987 Method: Store,
1988 }); err != nil {
1989 t.Fatal(err)
1990 }
1991 if err := zw.Close(); err != nil {
1992 t.Fatal(err)
1993 }
1994
1995 zr, err := NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
1996 if err != nil {
1997 t.Fatal(err)
1998 }
1999 if len(zr.File) != 1 {
2000 t.Fatalf("File count = %d, want 1", len(zr.File))
2001 }
2002 if zr.File[0].Name != rawName {
2003 t.Errorf("Name = %q, want raw %q", zr.File[0].Name, rawName)
2004 }
2005 if !zr.File[0].NonUTF8 {
2006 t.Errorf("NonUTF8 = false, want true for non-UTF-8 raw name")
2007 }
2008}
2009
2010// TestNameDecoderError verifies that an error returned by the decoder is
2011// propagated from NewReaderWithOptions.

Callers

nothing calls this directly

Calls 7

CreateHeaderMethod · 0.95
CloseMethod · 0.95
FatalMethod · 0.80
LenMethod · 0.80
NewWriterFunction · 0.70
NewReaderFunction · 0.70
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…