Test our predefined tables are correct. We don't predefine them, since this also tests our transformations. Reference from here: https://github.com/facebook/zstd/blob/ededcfca57366461021c922720878c81a5854a0a/lib/decompress/zstd_decompress_block.c#L234
(t *testing.T)
| 1936 | // We don't predefine them, since this also tests our transformations. |
| 1937 | // Reference from here: https://github.com/facebook/zstd/blob/ededcfca57366461021c922720878c81a5854a0a/lib/decompress/zstd_decompress_block.c#L234 |
| 1938 | func TestPredefTables(t *testing.T) { |
| 1939 | initPredefined() |
| 1940 | x := func(nextState uint16, nbAddBits, nbBits uint8, baseVal uint32) decSymbol { |
| 1941 | return newDecSymbol(nbBits, nbAddBits, nextState, baseVal) |
| 1942 | } |
| 1943 | for i := range fsePredef[:] { |
| 1944 | var want []decSymbol |
| 1945 | switch tableIndex(i) { |
| 1946 | case tableLiteralLengths: |
| 1947 | want = []decSymbol{ |
| 1948 | /* nextState, nbAddBits, nbBits, baseVal */ |
| 1949 | x(0, 0, 4, 0), x(16, 0, 4, 0), |
| 1950 | x(32, 0, 5, 1), x(0, 0, 5, 3), |
| 1951 | x(0, 0, 5, 4), x(0, 0, 5, 6), |
| 1952 | x(0, 0, 5, 7), x(0, 0, 5, 9), |
| 1953 | x(0, 0, 5, 10), x(0, 0, 5, 12), |
| 1954 | x(0, 0, 6, 14), x(0, 1, 5, 16), |
| 1955 | x(0, 1, 5, 20), x(0, 1, 5, 22), |
| 1956 | x(0, 2, 5, 28), x(0, 3, 5, 32), |
| 1957 | x(0, 4, 5, 48), x(32, 6, 5, 64), |
| 1958 | x(0, 7, 5, 128), x(0, 8, 6, 256), |
| 1959 | x(0, 10, 6, 1024), x(0, 12, 6, 4096), |
| 1960 | x(32, 0, 4, 0), x(0, 0, 4, 1), |
| 1961 | x(0, 0, 5, 2), x(32, 0, 5, 4), |
| 1962 | x(0, 0, 5, 5), x(32, 0, 5, 7), |
| 1963 | x(0, 0, 5, 8), x(32, 0, 5, 10), |
| 1964 | x(0, 0, 5, 11), x(0, 0, 6, 13), |
| 1965 | x(32, 1, 5, 16), x(0, 1, 5, 18), |
| 1966 | x(32, 1, 5, 22), x(0, 2, 5, 24), |
| 1967 | x(32, 3, 5, 32), x(0, 3, 5, 40), |
| 1968 | x(0, 6, 4, 64), x(16, 6, 4, 64), |
| 1969 | x(32, 7, 5, 128), x(0, 9, 6, 512), |
| 1970 | x(0, 11, 6, 2048), x(48, 0, 4, 0), |
| 1971 | x(16, 0, 4, 1), x(32, 0, 5, 2), |
| 1972 | x(32, 0, 5, 3), x(32, 0, 5, 5), |
| 1973 | x(32, 0, 5, 6), x(32, 0, 5, 8), |
| 1974 | x(32, 0, 5, 9), x(32, 0, 5, 11), |
| 1975 | x(32, 0, 5, 12), x(0, 0, 6, 15), |
| 1976 | x(32, 1, 5, 18), x(32, 1, 5, 20), |
| 1977 | x(32, 2, 5, 24), x(32, 2, 5, 28), |
| 1978 | x(32, 3, 5, 40), x(32, 4, 5, 48), |
| 1979 | x(0, 16, 6, 65536), x(0, 15, 6, 32768), |
| 1980 | x(0, 14, 6, 16384), x(0, 13, 6, 8192), |
| 1981 | } |
| 1982 | case tableOffsets: |
| 1983 | want = []decSymbol{ |
| 1984 | /* nextState, nbAddBits, nbBits, baseVal */ |
| 1985 | x(0, 0, 5, 0), x(0, 6, 4, 61), |
| 1986 | x(0, 9, 5, 509), x(0, 15, 5, 32765), |
| 1987 | x(0, 21, 5, 2097149), x(0, 3, 5, 5), |
| 1988 | x(0, 7, 4, 125), x(0, 12, 5, 4093), |
| 1989 | x(0, 18, 5, 262141), x(0, 23, 5, 8388605), |
| 1990 | x(0, 5, 5, 29), x(0, 8, 4, 253), |
| 1991 | x(0, 14, 5, 16381), x(0, 20, 5, 1048573), |
| 1992 | x(0, 2, 5, 1), x(16, 7, 4, 125), |
| 1993 | x(0, 11, 5, 2045), x(0, 17, 5, 131069), |
| 1994 | x(0, 22, 5, 4194301), x(0, 4, 5, 13), |
| 1995 | x(16, 8, 4, 253), x(0, 13, 5, 8189), |
nothing calls this directly
no test coverage detected
searching dependent graphs…