1*e47783fdSXin Li// Copyright 2019 Google LLC 2*e47783fdSXin Li// 3*e47783fdSXin Li// Licensed under the Apache License, Version 2.0 (the "License"); 4*e47783fdSXin Li// you may not use this file except in compliance with the License. 5*e47783fdSXin Li// You may obtain a copy of the License at 6*e47783fdSXin Li// 7*e47783fdSXin Li// https://www.apache.org/licenses/LICENSE-2.0 8*e47783fdSXin Li// 9*e47783fdSXin Li// Unless required by applicable law or agreed to in writing, software 10*e47783fdSXin Li// distributed under the License is distributed on an "AS IS" BASIS, 11*e47783fdSXin Li// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*e47783fdSXin Li// See the License for the specific language governing permissions and 13*e47783fdSXin Li// limitations under the License. 14*e47783fdSXin Lipackage zopflipng 15*e47783fdSXin Li 16*e47783fdSXin Liimport ( 17*e47783fdSXin Li "io/ioutil" 18*e47783fdSXin Li "testing" 19*e47783fdSXin Li) 20*e47783fdSXin Li 21*e47783fdSXin Li// TestCompress verifies that ZopfliPng compresses PNGs correctly. 22*e47783fdSXin Lifunc TestCompress(t *testing.T) { 23*e47783fdSXin Li path := "testdata/zoidberg.png" 24*e47783fdSXin Li contents, err := ioutil.ReadFile(path) 25*e47783fdSXin Li if err != nil { 26*e47783fdSXin Li t.Errorf("Failed to load testdata: %s", path) 27*e47783fdSXin Li } 28*e47783fdSXin Li compressed, err := Compress(contents) 29*e47783fdSXin Li if err != nil { 30*e47783fdSXin Li t.Error("ZopfliPNG failed: ", err) 31*e47783fdSXin Li } 32*e47783fdSXin Li if len(compressed) >= len(contents) { 33*e47783fdSXin Li t.Error("ZopfliPNG did not compress png") 34*e47783fdSXin Li } 35*e47783fdSXin Li} 36