Upgrade server dependencies, manage them with govendor
This commit is contained in:
parent
ebee2746d6
commit
971278e7e5
1748 changed files with 196165 additions and 194500 deletions
5
vendor/github.com/dsnet/compress/brotli/brotli_test.go
generated
vendored
5
vendor/github.com/dsnet/compress/brotli/brotli_test.go
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
225
vendor/github.com/dsnet/compress/brotli/common_test.go
generated
vendored
225
vendor/github.com/dsnet/compress/brotli/common_test.go
generated
vendored
|
@ -1,225 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
||||
|
||||
import "hash/crc32"
|
||||
import "bytes"
|
||||
import "encoding/hex"
|
||||
import "testing"
|
||||
|
||||
func TestTableCRC(t *testing.T) {
|
||||
// Convert transformLUT to byte array according to Appendix B of the RFC.
|
||||
var transformBuf bytes.Buffer
|
||||
for _, t := range transformLUT {
|
||||
transformBuf.WriteString(t.prefix + "\x00")
|
||||
transformBuf.WriteByte(byte(t.transform))
|
||||
transformBuf.WriteString(t.suffix + "\x00")
|
||||
}
|
||||
|
||||
var vectors = []struct {
|
||||
crc uint32
|
||||
buf []byte
|
||||
}{
|
||||
{crc: 0x5136cb04, buf: dictLUT[:]},
|
||||
{crc: 0x8e91efb7, buf: contextLUT0[:]},
|
||||
{crc: 0xd01a32f4, buf: contextLUT1[:]},
|
||||
{crc: 0x0dd7a0d6, buf: contextLUT2[:]},
|
||||
{crc: 0x3d965f81, buf: transformBuf.Bytes()},
|
||||
}
|
||||
|
||||
for i, v := range vectors {
|
||||
crc := crc32.ChecksumIEEE(v.buf)
|
||||
if crc != v.crc {
|
||||
t.Errorf("test %d, CRC-32 mismatch: got %08x, want %08x", i, crc, v.crc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMoveToFront(t *testing.T) {
|
||||
var vectors = []struct {
|
||||
input, output string
|
||||
}{{
|
||||
input: "",
|
||||
output: "",
|
||||
}, {
|
||||
input: "ff00ff00ff00ff00",
|
||||
output: "ff01010101010101",
|
||||
}, {
|
||||
input: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000010000000001",
|
||||
output: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000010100000001",
|
||||
}, {
|
||||
input: "0000000000000000000000010101010101010101010101010101010101010101" +
|
||||
"0101010101010101010101010101010101010101000000000000000203030004",
|
||||
output: "0000000000000000000000010000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000010000000000000203000204",
|
||||
}, {
|
||||
input: "00000001",
|
||||
output: "00000001",
|
||||
}, {
|
||||
input: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000100000000",
|
||||
output: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000101000000",
|
||||
}, {
|
||||
input: "0000000000000000010101010101010101010101010101010101010101010101" +
|
||||
"0101010101010101010101010101010101010101010101010101010101010101" +
|
||||
"0101010101010101010200000000000000020203030303030304040505050505" +
|
||||
"0505050505050505050505050505050505050505050505050505050505050505",
|
||||
output: "0000000000000000010000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000202000000000000010003000000000004000500000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "000000010101000202020003030300040404000505050006",
|
||||
output: "000000010000010200000103000001040000010500000106",
|
||||
}, {
|
||||
input: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000001010102020202030202020202" +
|
||||
"0202020202020202020202020202020202020202020202020202020202020202",
|
||||
output: "0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000001000002000000030100000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "0000000000000000000102020202020202020000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000302020202020202010103030303030304040505050505" +
|
||||
"0505050505050505050505050505050505050505050505050505050505050505",
|
||||
output: "0000000000000000000102000000000000000200000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000302000000000000030002000000000004000500000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "0000010000000102020201030303010404020105",
|
||||
output: "0000010100000102000001030000010400030205",
|
||||
}, {
|
||||
input: "0000000000000000010202010101010101010202020202020202020202020202" +
|
||||
"0202020202020202020202020202020202020202020202020202020202020202" +
|
||||
"0202020202020202020201010101010101020202020202020203040000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000201010101010101020205050505050503030606060606" +
|
||||
"0606060606060606060606060606060606060606060606060606060606060606" +
|
||||
"0606060606060606060202020202020202000702020202020202040404040404" +
|
||||
"0404040404040404040404040404040404040404040404040404040404040404",
|
||||
output: "0000000000000000010200010000000000000100000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000001000000000000010000000000000003040400000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000304000000000000010005000000000005000600000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000300000000000000050702000000000000070000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "0000000000000001010100020202000303030004040400050505000606060007" +
|
||||
"070700080808000909090a0a",
|
||||
output: "0000000000000001000001020000010300000104000001050000010600000107" +
|
||||
"000001080000010900000a00",
|
||||
}, {
|
||||
input: "0000010203030303040000050600070507050201070206060804000400020002" +
|
||||
"06000200000006000905020000080805050a0202000808080808080105080808" +
|
||||
"0400050205020505050505050b0205040b0505050505050b0605050505050505" +
|
||||
"0505050505050505050505050505050502050505050505050505050202050505" +
|
||||
"040502020b0b0b0b020b0b0b0b0b0b02020b0b0b0b0b0b02020b0b0b0b0b0b0b" +
|
||||
"0b0b0b0b0b0b0b02020b0b0b0b0b0b0b0b0b0b0b0b0b0b0204020b0b0b050b0a" +
|
||||
"0c0c02010d0d0d0d0d00060b0d0d0d0d020201020d0d0d0d0c0b02020d0d0d07" +
|
||||
"04040404070606020b050402060602000e020202060205040404060606040202" +
|
||||
"040404040404040404040404000000000f0f00090f0f0f0f0f0f0f0b09030d0d" +
|
||||
"0909060909090101010100000909090909090909010101010101010101010101" +
|
||||
"0101010101010101010101010d0d0d0d0d0d0d10090c0909090909100f0f0f0f" +
|
||||
"0f0f07070f0f0f0f0f0f0e0e0f0f0f0f0f0f0f0f0c0c0c0c0c0c0c0c0c0c0c0c" +
|
||||
"0c0c00080d0d0d0d0d0d020b0d0d0d0d030200010d0d0d0d0d0b02040d0d0d07" +
|
||||
"0202020207060b020202020206060b0e0e040006060208080808080806060606" +
|
||||
"00000000000000000000000009090909111111110d0d0d0d1212120900000000" +
|
||||
"000107060a0a0505050500001212121212121212090909090909090909090909" +
|
||||
"050511040d0d0d0d0d02040b0d070d0d0a0200010d0d0d0d050b02020d0d0d0d" +
|
||||
"07020202060b0b0b0402050b02050b07010b00050202020202020c0002020202" +
|
||||
"02020202020202020202020202020202020202020d0d0d0d0d0d0d0d09090909" +
|
||||
"09090f0912121212121212121210101010101010090909090909090909090909" +
|
||||
"0909090909090909090909090909090909090909090909090909090909090909" +
|
||||
"090909090e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e" +
|
||||
"0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e" +
|
||||
"0e0e020211111111111111111111080808080808111111111111111111111111" +
|
||||
"1111111111111111111111111111111111111111111111111111111111111111" +
|
||||
"111111110e0e0e0e0e0e0e0e0e030303030303030e0e0e0e0e0e0e0e0e0e0e0e" +
|
||||
"0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e" +
|
||||
"0e0e0e0e03030303030303030303030303030303030303030303030303030303",
|
||||
output: "0000010203000000040400050602070301010607030205000807070101040101" +
|
||||
"04020201000002010908040300060003000a0400040400000000000905020000" +
|
||||
"0804030501010100000000000b02020403020000000000010902000000000000" +
|
||||
"0000000000000000000000000000000004010000000000000000000100010000" +
|
||||
"0401020004000000010100000000000100010000000000010001000000000000" +
|
||||
"0000000000000001000100000000000000000000000000010301020000030108" +
|
||||
"0c0004090d00000000090907030000000500050102000000060403000300000c" +
|
||||
"0a00000001070004050a0503040001090e020000030105050000030000010300" +
|
||||
"010000000000000000000000050000000f00010e0200000000000008020f0b00" +
|
||||
"0200080100000d00000007000200000000000000020000000000000000000000" +
|
||||
"0000000000000000000000000400000000000010030e01000000000209000000" +
|
||||
"00000e000100000000000e000100000000000000050000000000000000000000" +
|
||||
"000008100800000000000e0d020000000d03050c040000000005040e0300000b" +
|
||||
"03000000010e0503000000000200020c0006080400050a000000000002000000" +
|
||||
"0300000000000000000000000e000000110000000a0000001200000304000000" +
|
||||
"000c0c0712001200000005000700000000000000070000000000000000000000" +
|
||||
"0300090c0a000000000c020e030b01000a050a0c040000000907050003000000" +
|
||||
"070200000c040000090306030202020507020804050000000000100302000000" +
|
||||
"000000000000000000000000000000000000000009000000000000000c000000" +
|
||||
"000011010e000000000000000012000000000000020000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000011000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000060010000000000000000000110000000000010000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000003000000000000000012000000000000010000000000000000000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000001000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "0000000000010101010102020202030303030404040405050505050606060707" +
|
||||
"07070808",
|
||||
output: "0000000000010000000002000000030000000400000005000000000600000700" +
|
||||
"00000800",
|
||||
}, {
|
||||
input: "0000000000000000010001010101010101000000000000000002020303030303" +
|
||||
"0303030303030303030303030303030303030303030303030303030303030303" +
|
||||
"0303030303030303030401010101010101040005050505050502020303030303" +
|
||||
"0303030303030303030303030303030303030303030303030303030303030303",
|
||||
output: "0000000000000000010101000000000000010000000000000002000300000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000" +
|
||||
"0000000000000000000404000000000000010405000000000005000500000000" +
|
||||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
}, {
|
||||
input: "0000010000000102020101030303010404040105050501060606010707010108" +
|
||||
"08010109",
|
||||
output: "0000010100000102000100030000010400000105000001060000010700010008" +
|
||||
"00010009",
|
||||
}}
|
||||
|
||||
var mtf moveToFront
|
||||
for i, v := range vectors {
|
||||
input, _ := hex.DecodeString(v.input)
|
||||
mtf.Encode(input)
|
||||
output := append([]uint8(nil), input...)
|
||||
mtf.Decode(input)
|
||||
|
||||
if input := hex.EncodeToString(input); input != v.input {
|
||||
t.Errorf("test %d, input differs:\ngot %v\nwant %v", i, input, v.input)
|
||||
}
|
||||
if output := hex.EncodeToString(output); output != v.output {
|
||||
t.Errorf("test %d, output differs:\ngot %v\nwant %v", i, output, v.output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This package relies on dynamic generation of LUTs to reduce the static
|
||||
// binary size. This benchmark attempts to measure the startup cost of init.
|
||||
// This benchmark is not thread-safe; so do not run it in parallel with other
|
||||
// tests or benchmarks!
|
||||
func BenchmarkInit(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
initLUTs()
|
||||
}
|
||||
}
|
161
vendor/github.com/dsnet/compress/brotli/dict_decoder_test.go
generated
vendored
161
vendor/github.com/dsnet/compress/brotli/dict_decoder_test.go
generated
vendored
|
@ -1,161 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
||||
|
||||
import "bytes"
|
||||
import "strings"
|
||||
import "testing"
|
||||
|
||||
func TestDictDecoder(t *testing.T) {
|
||||
const abc = "ABC\n"
|
||||
const fox = "The quick brown fox jumped over the lazy dog!\n"
|
||||
const poem = "The Road Not Taken\nRobert Frost\n" +
|
||||
"\n" +
|
||||
"Two roads diverged in a yellow wood,\n" +
|
||||
"And sorry I could not travel both\n" +
|
||||
"And be one traveler, long I stood\n" +
|
||||
"And looked down one as far as I could\n" +
|
||||
"To where it bent in the undergrowth;\n" +
|
||||
"\n" +
|
||||
"Then took the other, as just as fair,\n" +
|
||||
"And having perhaps the better claim,\n" +
|
||||
"Because it was grassy and wanted wear;\n" +
|
||||
"Though as for that the passing there\n" +
|
||||
"Had worn them really about the same,\n" +
|
||||
"\n" +
|
||||
"And both that morning equally lay\n" +
|
||||
"In leaves no step had trodden black.\n" +
|
||||
"Oh, I kept the first for another day!\n" +
|
||||
"Yet knowing how way leads on to way,\n" +
|
||||
"I doubted if I should ever come back.\n" +
|
||||
"\n" +
|
||||
"I shall be telling this with a sigh\n" +
|
||||
"Somewhere ages and ages hence:\n" +
|
||||
"Two roads diverged in a wood, and I-\n" +
|
||||
"I took the one less traveled by,\n" +
|
||||
"And that has made all the difference.\n"
|
||||
var refs = []struct {
|
||||
dist int // Backward distance (0 if this is an insertion)
|
||||
length int // Length of copy or insertion
|
||||
}{
|
||||
{0, 38}, {33, 3}, {0, 48}, {79, 3}, {0, 11}, {34, 5}, {0, 6}, {23, 7},
|
||||
{0, 8}, {50, 3}, {0, 2}, {69, 3}, {34, 5}, {0, 4}, {97, 3}, {0, 4},
|
||||
{43, 5}, {0, 6}, {7, 4}, {88, 7}, {0, 12}, {80, 3}, {0, 2}, {141, 4},
|
||||
{0, 1}, {196, 3}, {0, 3}, {157, 3}, {0, 6}, {181, 3}, {0, 2}, {23, 3},
|
||||
{77, 3}, {28, 5}, {128, 3}, {110, 4}, {70, 3}, {0, 4}, {85, 6}, {0, 2},
|
||||
{182, 6}, {0, 4}, {133, 3}, {0, 7}, {47, 5}, {0, 20}, {112, 5}, {0, 1},
|
||||
{58, 3}, {0, 8}, {59, 3}, {0, 4}, {173, 3}, {0, 5}, {114, 3}, {0, 4},
|
||||
{92, 5}, {0, 2}, {71, 3}, {0, 2}, {76, 5}, {0, 1}, {46, 3}, {96, 4},
|
||||
{130, 4}, {0, 3}, {360, 3}, {0, 3}, {178, 5}, {0, 7}, {75, 3}, {0, 3},
|
||||
{45, 6}, {0, 6}, {299, 6}, {180, 3}, {70, 6}, {0, 1}, {48, 3}, {66, 4},
|
||||
{0, 3}, {47, 5}, {0, 9}, {325, 3}, {0, 1}, {359, 3}, {318, 3}, {0, 2},
|
||||
{199, 3}, {0, 1}, {344, 3}, {0, 3}, {248, 3}, {0, 10}, {310, 3}, {0, 3},
|
||||
{93, 6}, {0, 3}, {252, 3}, {157, 4}, {0, 2}, {273, 5}, {0, 14}, {99, 4},
|
||||
{0, 1}, {464, 4}, {0, 2}, {92, 4}, {495, 3}, {0, 1}, {322, 4}, {16, 4},
|
||||
{0, 3}, {402, 3}, {0, 2}, {237, 4}, {0, 2}, {432, 4}, {0, 1}, {483, 5},
|
||||
{0, 2}, {294, 4}, {0, 2}, {306, 3}, {113, 5}, {0, 1}, {26, 4}, {164, 3},
|
||||
{488, 4}, {0, 1}, {542, 3}, {248, 6}, {0, 5}, {205, 3}, {0, 8}, {48, 3},
|
||||
{449, 6}, {0, 2}, {192, 3}, {328, 4}, {9, 5}, {433, 3}, {0, 3}, {622, 25},
|
||||
{615, 5}, {46, 5}, {0, 2}, {104, 3}, {475, 10}, {549, 3}, {0, 4}, {597, 8},
|
||||
{314, 3}, {0, 1}, {473, 6}, {317, 5}, {0, 1}, {400, 3}, {0, 3}, {109, 3},
|
||||
{151, 3}, {48, 4}, {0, 4}, {125, 3}, {108, 3}, {0, 2},
|
||||
}
|
||||
|
||||
var want string
|
||||
var buf bytes.Buffer
|
||||
var dd dictDecoder
|
||||
dd.Init(1 << 11)
|
||||
|
||||
var checkLastBytes = func(str string) {
|
||||
if len(str) < 2 {
|
||||
str = "\x00\x00" + str
|
||||
}
|
||||
str = str[len(str)-2:]
|
||||
p1, p2 := dd.LastBytes()
|
||||
got := string([]byte{p2, p1})
|
||||
if got != str {
|
||||
t.Errorf("last bytes mismatch: got %q, want %q", got, str)
|
||||
}
|
||||
}
|
||||
var writeCopy = func(dist, length int) {
|
||||
if dist < length {
|
||||
cnt := (dist + length - 1) / dist
|
||||
want += strings.Repeat(want[len(want)-dist:], cnt)[:length]
|
||||
} else {
|
||||
want += want[len(want)-dist:][:length]
|
||||
}
|
||||
|
||||
for length > 0 {
|
||||
length -= dd.WriteCopy(dist, length)
|
||||
if dd.AvailSize() == 0 {
|
||||
buf.Write(dd.ReadFlush())
|
||||
}
|
||||
}
|
||||
|
||||
checkLastBytes(want)
|
||||
}
|
||||
var writeString = func(str string) {
|
||||
want += str
|
||||
|
||||
for len(str) > 0 {
|
||||
cnt := copy(dd.WriteSlice(), str)
|
||||
str = str[cnt:]
|
||||
dd.WriteMark(cnt)
|
||||
if dd.AvailSize() == 0 {
|
||||
buf.Write(dd.ReadFlush())
|
||||
}
|
||||
}
|
||||
|
||||
checkLastBytes(want)
|
||||
}
|
||||
|
||||
writeString("")
|
||||
writeString(".")
|
||||
str := poem
|
||||
for _, ref := range refs {
|
||||
if ref.dist == 0 {
|
||||
writeString(str[:ref.length])
|
||||
} else {
|
||||
writeCopy(ref.dist, ref.length)
|
||||
}
|
||||
str = str[ref.length:]
|
||||
}
|
||||
writeCopy(dd.HistSize(), 33)
|
||||
writeString(abc)
|
||||
writeCopy(len(abc), 59*len(abc))
|
||||
writeString(fox)
|
||||
writeCopy(len(fox), 9*len(fox))
|
||||
writeString(".")
|
||||
writeCopy(1, 9)
|
||||
writeString(strings.ToUpper(poem))
|
||||
writeCopy(len(poem), 7*len(poem))
|
||||
writeCopy(dd.HistSize(), 10)
|
||||
|
||||
buf.Write(dd.ReadFlush())
|
||||
if buf.String() != want {
|
||||
t.Errorf("final string mismatch:\ngot %q\nwant %q", buf.String(), want)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDictDecoderCopy(b *testing.B) {
|
||||
nb := 1 << 24
|
||||
b.SetBytes(int64(nb))
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
var dd dictDecoder
|
||||
dd.Init(1 << 16)
|
||||
|
||||
copy(dd.WriteSlice(), "abc")
|
||||
dd.WriteMark(3)
|
||||
|
||||
dist, length := 3, nb
|
||||
for length > 0 {
|
||||
length -= dd.WriteCopy(dist, length)
|
||||
if dd.AvailSize() == 0 {
|
||||
dd.ReadFlush()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
5
vendor/github.com/dsnet/compress/brotli/dict_encoder_test.go
generated
vendored
5
vendor/github.com/dsnet/compress/brotli/dict_encoder_test.go
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
5
vendor/github.com/dsnet/compress/brotli/prefix_test.go
generated
vendored
5
vendor/github.com/dsnet/compress/brotli/prefix_test.go
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
455
vendor/github.com/dsnet/compress/brotli/reader_test.go
generated
vendored
455
vendor/github.com/dsnet/compress/brotli/reader_test.go
generated
vendored
|
@ -1,455 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
||||
|
||||
import "io"
|
||||
import "io/ioutil"
|
||||
import "bufio"
|
||||
import "bytes"
|
||||
import "strings"
|
||||
import "encoding/hex"
|
||||
import "runtime"
|
||||
import "testing"
|
||||
|
||||
func TestReader(t *testing.T) {
|
||||
var vectors = []struct {
|
||||
desc string // Description of the test
|
||||
input string // Test input string in hex
|
||||
output string // Expected output string in hex
|
||||
inIdx int64 // Expected input offset after reading
|
||||
outIdx int64 // Expected output offset after reading
|
||||
err error // Expected error
|
||||
}{{
|
||||
desc: "empty string (truncated)",
|
||||
err: io.ErrUnexpectedEOF,
|
||||
}, {
|
||||
desc: "empty last block (WBITS: 16)",
|
||||
input: "06",
|
||||
inIdx: 1,
|
||||
}, {
|
||||
desc: "empty last block (WBITS: 12)",
|
||||
input: "c101",
|
||||
inIdx: 2,
|
||||
}, {
|
||||
desc: "empty last block (WBITS: 17)",
|
||||
input: "8101",
|
||||
inIdx: 2,
|
||||
}, {
|
||||
desc: "empty last block (WBITS: 21)",
|
||||
input: "39",
|
||||
inIdx: 1,
|
||||
}, {
|
||||
desc: "empty last block (WBITS: invalid)",
|
||||
input: "9101",
|
||||
inIdx: 1,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "empty last block (trash at the end)",
|
||||
input: "06ff",
|
||||
inIdx: 1,
|
||||
}, {
|
||||
desc: "empty last block (padding is non-zero)",
|
||||
input: "16",
|
||||
inIdx: 1,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "empty meta data block (MLEN: 0)",
|
||||
input: "0c03",
|
||||
inIdx: 2,
|
||||
}, {
|
||||
desc: "meta data block",
|
||||
input: "2c0648656c6c6f2c20776f726c642103",
|
||||
inIdx: 16,
|
||||
}, {
|
||||
desc: "meta data block (truncated)",
|
||||
input: "2c06",
|
||||
inIdx: 2,
|
||||
err: io.ErrUnexpectedEOF,
|
||||
}, {
|
||||
desc: "meta data block (use reserved bit)",
|
||||
input: "3c0648656c6c6f2c20776f726c642103",
|
||||
inIdx: 1,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "meta data block (meta padding is non-zero)",
|
||||
input: "2c8648656c6c6f2c20776f726c642103",
|
||||
inIdx: 2,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "meta data block (non-minimal MLEN)",
|
||||
input: "4c060048656c6c6f2c20776f726c642103",
|
||||
inIdx: 3,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "meta data block (MLEN: 1<<0)",
|
||||
input: "2c00ff03",
|
||||
inIdx: 4,
|
||||
}, {
|
||||
desc: "meta data block (MLEN: 1<<24)",
|
||||
input: "ecffff7f" + strings.Repeat("f0", 1<<24) + "03",
|
||||
inIdx: 5 + 1<<24,
|
||||
}, {
|
||||
desc: "raw data block",
|
||||
input: "c0001048656c6c6f2c20776f726c642103",
|
||||
output: "48656c6c6f2c20776f726c6421",
|
||||
inIdx: 17,
|
||||
outIdx: 13,
|
||||
}, {
|
||||
desc: "raw data block (truncated)",
|
||||
input: "c00010",
|
||||
inIdx: 3,
|
||||
err: io.ErrUnexpectedEOF,
|
||||
}, {
|
||||
desc: "raw data block (raw padding is non-zero)",
|
||||
input: "c000f048656c6c6f2c20776f726c642103",
|
||||
inIdx: 3,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "raw data block (non-minimal MLEN)",
|
||||
input: "c400000148656c6c6f2c20776f726c642103",
|
||||
inIdx: 3,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "raw data block (MLEN: 1<<0)",
|
||||
input: "0000106103",
|
||||
output: "61",
|
||||
inIdx: 4 + 1<<0,
|
||||
outIdx: 1 << 0,
|
||||
}, {
|
||||
desc: "raw data block (MLEN: 1<<24)",
|
||||
input: "f8ffff1f" + strings.Repeat("f0", 1<<24) + "03",
|
||||
output: strings.Repeat("f0", 1<<24),
|
||||
inIdx: 5 + 1<<24,
|
||||
outIdx: 1 << 24,
|
||||
}, {
|
||||
desc: "simple prefix (|L|:1 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "00000000c4682010c0",
|
||||
output: "a3",
|
||||
inIdx: 9,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, out-of-order (|L|:2 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "00000000d4a8682010c001",
|
||||
output: "a3",
|
||||
inIdx: 11,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, non-unique (|L|:2 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "00000000d4e8682010c001",
|
||||
output: "",
|
||||
inIdx: 7,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "simple prefix, out-of-order (|L|:3 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "0000000024e8e96820104003",
|
||||
output: "a3",
|
||||
inIdx: 12,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, out-of-order, no-tree-select (|L|:4 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "0000000034e8e968a840208006",
|
||||
output: "a3",
|
||||
inIdx: 13,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, out-of-order, yes-tree-select (|L|:4 |I|:1 |D|:1 MLEN:1)",
|
||||
input: "0000000034e8e968e94020800d",
|
||||
output: "a3",
|
||||
inIdx: 13,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, max-sym-ok (|L|:1 |I|:2 |D|:1 MLEN:1)",
|
||||
input: "00000000c46821f06b0006",
|
||||
output: "a3",
|
||||
inIdx: 11,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "simple prefix, max-sym-bad (|L|:1 |I|:2 |D|:1 MLEN:1)",
|
||||
input: "00000000c46821006c0006",
|
||||
output: "",
|
||||
inIdx: 9,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, terminate-clens-codes (|L|:1 |I|:2 |D|:1 MLEN:1)",
|
||||
input: "0000000070472010c001",
|
||||
output: "01",
|
||||
inIdx: 10,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, terminate-clens-codes (|L|:1 |I|:2 |D|:1 MLEN:1)",
|
||||
input: "0000000070c01d080470",
|
||||
output: "01",
|
||||
inIdx: 10,
|
||||
outIdx: 1,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, terminate-clens-codes (|L|:1 |I|:2 |D|:1 MLEN:2)",
|
||||
input: "1000000070c01d1004d0",
|
||||
output: "0100",
|
||||
inIdx: 10,
|
||||
outIdx: 2,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, terminate-codes (|L|:1 |I|:4 |D|:1 MLEN:3)",
|
||||
input: "20000000b0c100000056151804700e",
|
||||
output: "030201",
|
||||
inIdx: 15,
|
||||
outIdx: 3,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, under-subscribed (|L|:1 |I|:4 |D|:1 MLEN:3)",
|
||||
input: "20000000b0c1000000ae2a3008e01c",
|
||||
output: "",
|
||||
inIdx: 10,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, over-subscribed (|L|:1 |I|:4 |D|:1 MLEN:3)",
|
||||
input: "20000000b0c1000000ac0a0c023807",
|
||||
output: "",
|
||||
inIdx: 10,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens (|L|:1 |I|:256 |D|:1 MLEN:4)",
|
||||
input: "30000000000000020001420000a5ff5503",
|
||||
output: "00a5ffaa",
|
||||
inIdx: 17,
|
||||
outIdx: 4,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens (|L|:1 |I|:32 |D|:1 MLEN:4)",
|
||||
input: "3000000000c001000004080100faf7",
|
||||
output: "00051f1b",
|
||||
inIdx: 15,
|
||||
outIdx: 4,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens, zero clen (|L|:1 |I|:? |D|:1 MLEN:4)",
|
||||
input: "30000000007000000004080100faf7",
|
||||
output: "",
|
||||
inIdx: 10,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, empty clens (|L|:1 |I|:? |D|:1 MLEN:4)",
|
||||
input: "30000000000000000001420080fe3d",
|
||||
output: "",
|
||||
inIdx: 9,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens, rep-last clen (|L|:1 |I|:256 |D|:1 MLEN:4)",
|
||||
input: "3000000000002000006a014200aa33cc5503",
|
||||
output: "55cc33aa",
|
||||
inIdx: 18,
|
||||
outIdx: 4,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens, rep-last clen, over-subscribed (|L|:1 |I|:257 |D|:1 MLEN:4)",
|
||||
input: "300000000000200000aa014200aa33cc5503",
|
||||
output: "",
|
||||
inIdx: 10,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, single clens, rep-last clen, integer overflow (|L|:1 |I|:1018 |D|:1 MLEN:4)",
|
||||
input: "3000000000002000002a070801a8ce30570d",
|
||||
output: "",
|
||||
inIdx: 11,
|
||||
outIdx: 0,
|
||||
err: ErrCorrupt,
|
||||
}, {
|
||||
desc: "complex prefix, skip-two, single clens, rep-last clen (|L|:1 |I|:256 |D|:1 MLEN:4)",
|
||||
input: "3000000008000f00805a801080ea0c73d5",
|
||||
output: "55cc33aa",
|
||||
inIdx: 17,
|
||||
outIdx: 4,
|
||||
}, {
|
||||
desc: "complex prefix, skip-three, single clens, rep-last clen (|L|:1 |I|:256 |D|:1 MLEN:4)",
|
||||
input: "300000000cc00300a0162004a03ac35c35",
|
||||
output: "55cc33aa",
|
||||
inIdx: 17,
|
||||
outIdx: 4,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, linear clens (|L|:1 |I|:16 |D|:1 MLEN:16)",
|
||||
input: "f000000050555555ffff8bd5169058d43cb2fadcf77f201480dabdeff7f7efbf" +
|
||||
"fffddffffbfffe7fffff01",
|
||||
output: "6162636465666768696a6b6c6d6e6f70",
|
||||
inIdx: 43,
|
||||
outIdx: 16,
|
||||
}, {
|
||||
desc: "complex prefix, skip-zero, mixed clens (|L|:1 |I|:192 |D|:1 MLEN:16)",
|
||||
input: "f000000050555555ffffe37a310f369a4d4b80756cc779b0619a02a1002c29ab" +
|
||||
"ec066084eee99dfd67d8ac18",
|
||||
output: "000240525356575e717a8abcbdbed7d9",
|
||||
inIdx: 44,
|
||||
outIdx: 16,
|
||||
}, {
|
||||
desc: "compressed string: \"Hello, world! Hello, world!\"",
|
||||
input: "1b1a00008c946ed6540dc2825426d942de6a9668ea996c961e00",
|
||||
output: "48656c6c6f2c20776f726c64212048656c6c6f2c20776f726c6421",
|
||||
inIdx: 26,
|
||||
outIdx: 27,
|
||||
}, {
|
||||
desc: "compressed string (padding is non-zero): \"Hello, world! Hello, world!\"",
|
||||
input: "1b1a00008c946ed6540dc2825426d942de6a9668ea996c961e80",
|
||||
output: "48656c6c6f2c20776f726c64212048656c6c6f2c20776f726c6421",
|
||||
inIdx: 26,
|
||||
outIdx: 27,
|
||||
err: ErrCorrupt,
|
||||
}}
|
||||
|
||||
for i, v := range vectors {
|
||||
input, _ := hex.DecodeString(v.input)
|
||||
rd, err := NewReader(bytes.NewReader(input), nil)
|
||||
if err != nil {
|
||||
t.Errorf("test %d, unexpected NewReader error: %v", i, err)
|
||||
}
|
||||
data, err := ioutil.ReadAll(rd)
|
||||
output := hex.EncodeToString(data)
|
||||
|
||||
if err != v.err {
|
||||
t.Errorf("test %d, %s\nerror mismatch: got %v, want %v", i, v.desc, err, v.err)
|
||||
}
|
||||
if output != v.output {
|
||||
t.Errorf("test %d, %s\noutput mismatch:\ngot %v\nwant %v", i, v.desc, output, v.output)
|
||||
}
|
||||
if rd.InputOffset != v.inIdx {
|
||||
t.Errorf("test %d, %s\ninput offset mismatch: got %d, want %d", i, v.desc, rd.InputOffset, v.inIdx)
|
||||
}
|
||||
if rd.OutputOffset != v.outIdx {
|
||||
t.Errorf("test %d, %s\noutput offset mismatch: got %d, want %d", i, v.desc, rd.OutputOffset, v.outIdx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReaderGolden(t *testing.T) {
|
||||
var vectors = []struct {
|
||||
input string // Input filename
|
||||
output string // Output filename
|
||||
}{
|
||||
{"empty.br", "empty"},
|
||||
{"empty.00.br", "empty"},
|
||||
{"empty.01.br", "empty"},
|
||||
{"empty.02.br", "empty"},
|
||||
{"empty.03.br", "empty"},
|
||||
{"empty.04.br", "empty"},
|
||||
{"empty.05.br", "empty"},
|
||||
{"empty.06.br", "empty"},
|
||||
{"empty.07.br", "empty"},
|
||||
{"empty.08.br", "empty"},
|
||||
{"empty.09.br", "empty"},
|
||||
{"empty.10.br", "empty"},
|
||||
{"empty.11.br", "empty"},
|
||||
{"empty.12.br", "empty"},
|
||||
{"empty.13.br", "empty"},
|
||||
{"empty.14.br", "empty"},
|
||||
{"empty.15.br", "empty"},
|
||||
{"empty.16.br", "empty"},
|
||||
{"empty.17.br", "empty"},
|
||||
{"empty.18.br", "empty"},
|
||||
{"zeros.br", "zeros"},
|
||||
{"x.br", "x"},
|
||||
{"x.00.br", "x"},
|
||||
{"x.01.br", "x"},
|
||||
{"x.02.br", "x"},
|
||||
{"x.03.br", "x"},
|
||||
{"xyzzy.br", "xyzzy"},
|
||||
{"10x10y.br", "10x10y"},
|
||||
{"64x.br", "64x"},
|
||||
{"backward65536.br", "backward65536"},
|
||||
{"quickfox.br", "quickfox"},
|
||||
{"quickfox_repeated.br", "quickfox_repeated"},
|
||||
{"ukkonooa.br", "ukkonooa"},
|
||||
{"monkey.br", "monkey"},
|
||||
{"random_org_10k.bin.br", "random_org_10k.bin"},
|
||||
{"asyoulik.txt.br", "asyoulik.txt"},
|
||||
{"compressed_file.br", "compressed_file"},
|
||||
{"compressed_repeated.br", "compressed_repeated"},
|
||||
{"alice29.txt.br", "alice29.txt"},
|
||||
{"lcet10.txt.br", "lcet10.txt"},
|
||||
{"mapsdatazrh.br", "mapsdatazrh"},
|
||||
{"plrabn12.txt.br", "plrabn12.txt"},
|
||||
}
|
||||
|
||||
for i, v := range vectors {
|
||||
input, err := ioutil.ReadFile("testdata/" + v.input)
|
||||
if err != nil {
|
||||
t.Errorf("test %d: %s\n%v", i, v.input, err)
|
||||
continue
|
||||
}
|
||||
output, err := ioutil.ReadFile("testdata/" + v.output)
|
||||
if err != nil {
|
||||
t.Errorf("test %d: %s\n%v", i, v.output, err)
|
||||
continue
|
||||
}
|
||||
|
||||
rd, err := NewReader(bytes.NewReader(input), nil)
|
||||
if err != nil {
|
||||
t.Errorf("test %d, unexpected NewReader error: %v", i, err)
|
||||
}
|
||||
data, err := ioutil.ReadAll(rd)
|
||||
if err != nil {
|
||||
t.Errorf("test %d, %s\nerror mismatch: got %v, want nil", i, v.input, err)
|
||||
}
|
||||
if string(data) != string(output) {
|
||||
t.Errorf("test %d, %s\noutput mismatch:\ngot %q\nwant %q", i, v.input, string(data), string(output))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkDecode(b *testing.B, testfile string) {
|
||||
b.StopTimer()
|
||||
b.ReportAllocs()
|
||||
|
||||
input, err := ioutil.ReadFile("testdata/" + testfile)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
r, err := NewReader(bytes.NewReader(input), nil)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
output, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
nb := int64(len(output))
|
||||
output = nil
|
||||
runtime.GC()
|
||||
|
||||
b.SetBytes(nb)
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
r, err := NewReader(bufio.NewReader(bytes.NewReader(input)), nil)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
cnt, err := io.Copy(ioutil.Discard, r)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if cnt != nb {
|
||||
b.Fatalf("unexpected count: got %d, want %d", cnt, nb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDecodeDigitsSpeed1e4(b *testing.B) { benchmarkDecode(b, "digits-speed-1e4.br") }
|
||||
func BenchmarkDecodeDigitsSpeed1e5(b *testing.B) { benchmarkDecode(b, "digits-speed-1e5.br") }
|
||||
func BenchmarkDecodeDigitsSpeed1e6(b *testing.B) { benchmarkDecode(b, "digits-speed-1e6.br") }
|
||||
func BenchmarkDecodeDigitsDefault1e4(b *testing.B) { benchmarkDecode(b, "digits-default-1e4.br") }
|
||||
func BenchmarkDecodeDigitsDefault1e5(b *testing.B) { benchmarkDecode(b, "digits-default-1e5.br") }
|
||||
func BenchmarkDecodeDigitsDefault1e6(b *testing.B) { benchmarkDecode(b, "digits-default-1e6.br") }
|
||||
func BenchmarkDecodeDigitsCompress1e4(b *testing.B) { benchmarkDecode(b, "digits-best-1e4.br") }
|
||||
func BenchmarkDecodeDigitsCompress1e5(b *testing.B) { benchmarkDecode(b, "digits-best-1e5.br") }
|
||||
func BenchmarkDecodeDigitsCompress1e6(b *testing.B) { benchmarkDecode(b, "digits-best-1e6.br") }
|
||||
func BenchmarkDecodeTwainSpeed1e4(b *testing.B) { benchmarkDecode(b, "twain-speed-1e4.br") }
|
||||
func BenchmarkDecodeTwainSpeed1e5(b *testing.B) { benchmarkDecode(b, "twain-speed-1e5.br") }
|
||||
func BenchmarkDecodeTwainSpeed1e6(b *testing.B) { benchmarkDecode(b, "twain-speed-1e6.br") }
|
||||
func BenchmarkDecodeTwainDefault1e4(b *testing.B) { benchmarkDecode(b, "twain-default-1e4.br") }
|
||||
func BenchmarkDecodeTwainDefault1e5(b *testing.B) { benchmarkDecode(b, "twain-default-1e5.br") }
|
||||
func BenchmarkDecodeTwainDefault1e6(b *testing.B) { benchmarkDecode(b, "twain-default-1e6.br") }
|
||||
func BenchmarkDecodeTwainCompress1e4(b *testing.B) { benchmarkDecode(b, "twain-best-1e4.br") }
|
||||
func BenchmarkDecodeTwainCompress1e5(b *testing.B) { benchmarkDecode(b, "twain-best-1e5.br") }
|
||||
func BenchmarkDecodeTwainCompress1e6(b *testing.B) { benchmarkDecode(b, "twain-best-1e6.br") }
|
61
vendor/github.com/dsnet/compress/brotli/transform_test.go
generated
vendored
61
vendor/github.com/dsnet/compress/brotli/transform_test.go
generated
vendored
|
@ -1,61 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTransform(t *testing.T) {
|
||||
var vectors = []struct {
|
||||
id int
|
||||
input string
|
||||
output string
|
||||
}{
|
||||
{id: 0, input: "Hello, world!", output: "Hello, world!"},
|
||||
{id: 23, input: "groups of", output: "groups"},
|
||||
{id: 42, input: "s for the ", output: "s for "},
|
||||
{id: 48, input: "presentation", output: "prese"},
|
||||
{id: 56, input: "maintenance", output: "maint"},
|
||||
{id: 23, input: "Alexandria", output: "Alexand"},
|
||||
{id: 23, input: "archives", output: "archi"},
|
||||
{id: 49, input: "fighty", output: "fighting "},
|
||||
{id: 49, input: "12", output: "1ing "},
|
||||
{id: 49, input: "1", output: "ing "},
|
||||
{id: 49, input: "", output: "ing "},
|
||||
{id: 64, input: "123456789a", output: "1"},
|
||||
{id: 64, input: "123456789", output: ""},
|
||||
{id: 64, input: "1", output: ""},
|
||||
{id: 64, input: "", output: ""},
|
||||
{id: 3, input: "afloat", output: "float"},
|
||||
{id: 3, input: "12", output: "2"},
|
||||
{id: 3, input: "1", output: ""},
|
||||
{id: 3, input: "", output: ""},
|
||||
{id: 54, input: "123456789a", output: "a"},
|
||||
{id: 54, input: "123456789", output: ""},
|
||||
{id: 54, input: "1", output: ""},
|
||||
{id: 54, input: "", output: ""},
|
||||
{id: 73, input: "", output: " the of the "},
|
||||
{id: 73, input: "dichlorodifluoromethanes", output: " the dichlorodifluoromethanes of the "},
|
||||
{id: 15, input: "", output: " "},
|
||||
{id: 15, input: "meow", output: " Meow "},
|
||||
{id: 15, input: "-scale", output: " -scale "},
|
||||
{id: 15, input: "почти", output: " Почти "},
|
||||
{id: 15, input: "互联网", output: " 亗联网 "},
|
||||
{id: 119, input: "", output: " ='"},
|
||||
{id: 119, input: "meow", output: " MEOW='"},
|
||||
{id: 119, input: "-scale", output: " -SCALE='"},
|
||||
{id: 119, input: "почти", output: " ПОѧѢИ='"},
|
||||
{id: 119, input: "互联网", output: " 亗聑罔='"},
|
||||
}
|
||||
|
||||
var buf [maxWordSize]byte
|
||||
for i, v := range vectors {
|
||||
cnt := transformWord(buf[:], []byte(v.input), v.id)
|
||||
output := string(buf[:cnt])
|
||||
|
||||
if output != v.output {
|
||||
t.Errorf("test %d, output mismatch: got %q, want %q", i, output, v.output)
|
||||
}
|
||||
}
|
||||
}
|
5
vendor/github.com/dsnet/compress/brotli/writer_test.go
generated
vendored
5
vendor/github.com/dsnet/compress/brotli/writer_test.go
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
// Copyright 2015, Joe Tsai. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
package brotli
|
Loading…
Add table
Add a link
Reference in a new issue