mirror of https://github.com/golang/go.git
all: move examples into package *_test.
Fixes #5677. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/11992043
This commit is contained in:
parent
d26d5e6403
commit
b7c3d06a1f
|
|
@ -1504,24 +1504,6 @@ func TestSubstitutionTableKnownAnswerDecrypt(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func ExampleNewTripleDESCipher() {
|
||||
// NewTripleDESCipher can also be used when EDE2 is required by
|
||||
// duplicating the first 8 bytes of the 16-byte key.
|
||||
ede2Key := []byte("example key 1234")
|
||||
|
||||
var tripleDESKey []byte
|
||||
tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
|
||||
tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
|
||||
|
||||
_, err := NewTripleDESCipher(tripleDESKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// See crypto/cipher for how to use a cipher.Block for encryption and
|
||||
// decryption.
|
||||
}
|
||||
|
||||
func BenchmarkEncrypt(b *testing.B) {
|
||||
tt := encryptDESTests[0]
|
||||
c, err := NewCipher(tt.key)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package des_test
|
||||
|
||||
import "crypto/des"
|
||||
|
||||
func ExampleNewTripleDESCipher() {
|
||||
// NewTripleDESCipher can also be used when EDE2 is required by
|
||||
// duplicating the first 8 bytes of the 16-byte key.
|
||||
ede2Key := []byte("example key 1234")
|
||||
|
||||
var tripleDESKey []byte
|
||||
tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
|
||||
tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
|
||||
|
||||
_, err := des.NewTripleDESCipher(tripleDESKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// See crypto/cipher for how to use a cipher.Block for encryption and
|
||||
// decryption.
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package md5_test
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ExampleNew() {
|
||||
h := md5.New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
// Output: e2c569be17396eca2a2e3c11578123ed
|
||||
}
|
||||
|
|
@ -105,14 +105,6 @@ func TestLarge(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func ExampleNew() {
|
||||
h := New()
|
||||
io.WriteString(h, "The fog is getting thicker!")
|
||||
io.WriteString(h, "And Leon's getting laaarger!")
|
||||
fmt.Printf("%x", h.Sum(nil))
|
||||
// Output: e2c569be17396eca2a2e3c11578123ed
|
||||
}
|
||||
|
||||
var bench = New()
|
||||
var buf = make([]byte, 8192+1)
|
||||
var sum = make([]byte, bench.Size())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sha1_test
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ExampleNew() {
|
||||
h := sha1.New()
|
||||
io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.")
|
||||
fmt.Printf("% x", h.Sum(nil))
|
||||
// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
|
||||
}
|
||||
|
|
@ -76,13 +76,6 @@ func TestGolden(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func ExampleNew() {
|
||||
h := New()
|
||||
io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.")
|
||||
fmt.Printf("% x", h.Sum(nil))
|
||||
// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
|
||||
}
|
||||
|
||||
var bench = New()
|
||||
var buf = make([]byte, 8192)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue