github.com/pion/dtls/v2@v2.2.12/pkg/crypto/hash/hash_test.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package hash 5 6 import ( 7 "testing" 8 9 "github.com/pion/dtls/v2/pkg/crypto/fingerprint" 10 ) 11 12 func TestHashAlgorithm_StringRoundtrip(t *testing.T) { 13 for algo := range Algorithms() { 14 if algo == Ed25519 || algo == None { 15 continue 16 } 17 18 str := algo.String() 19 hash1 := algo.CryptoHash() 20 hash2, err := fingerprint.HashFromString(str) 21 if err != nil { 22 t.Fatalf("fingerprint.HashFromString failed: %v", err) 23 } 24 if hash1 != hash2 { 25 t.Errorf("Hash algorithm mismatch, input: %d, after roundtrip: %d", int(hash1), int(hash2)) 26 } 27 } 28 }