blob: 1b3f5d8afe77fad1c20d598c7f47f9593fed674f [file] [log] [blame]
Yuxuan 'fishy' Wang270696c2025-05-28 10:54:04 -07001/*
2* Licensed to the Apache Software Foundation (ASF) under one
3* or more contributor license agreements. See the NOTICE file
4* distributed with this work for additional information
5* regarding copyright ownership. The ASF licenses this file
6* to you under the Apache License, Version 2.0 (the
7* "License"); you may not use this file except in compliance
8* with the License. You may obtain a copy of the License at
9*
10* http://www.apache.org/licenses/LICENSE-2.0
11*
12* Unless required by applicable law or agreed to in writing,
13* software distributed under the License is distributed on an
14* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15* KIND, either express or implied. See the License for the
16* specific language governing permissions and limitations
17* under the License.
18 */
19
20package thrift
21
22import (
23 "compress/zlib"
24 "fmt"
25 "maps"
26 "slices"
27 "testing"
28)
29
30func TestZlibWriterPools(t *testing.T) {
31 // make sure we have the writer pools created at the given levels
32 for _, level := range []int{
33 zlib.HuffmanOnly,
34 zlib.DefaultCompression,
35 zlib.NoCompression,
36 zlib.BestSpeed,
37 zlib.BestCompression,
38 } {
39 t.Run(fmt.Sprintf("%d", level), func(t *testing.T) {
40 _, ok := zlibWriterPools[level]
41 if !ok {
42 t.Errorf("level %d does not exist in the writer pools", level)
43 }
44 })
45 }
46 if t.Failed() {
47 levels := slices.Collect(maps.Keys(zlibWriterPools))
48 slices.Sort(levels)
49 t.Log("zlib writer pools:", levels)
50 }
51}