github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/md5sum/md5sum_test.go (about) 1 // Copyright 2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "testing" 9 10 "github.com/u-root/u-root/pkg/testutil" 11 ) 12 13 func TestCksum(t *testing.T) { 14 var testMatrix = []struct { 15 data []byte 16 cksum string 17 }{ 18 {[]byte("abcdef\n"), "5ab557c937e38f15291c04b7e99544ad"}, 19 {[]byte("pqra\n"), "721d6b135656aa83baca6ebdbd2f6c86"}, 20 } 21 22 for _, testData := range testMatrix { 23 if testData.cksum != calculateMd5Sum("", testData.data) { 24 t.Errorf("md5sum verification failed. (Expected: %s, Received: %s)", testData.cksum, calculateMd5Sum("", testData.data)) 25 } 26 } 27 28 } 29 30 func TestMain(m *testing.M) { 31 testutil.Run(m, main) 32 }