From f1292f603542414fb4380b8d2d5ecfbefed1598c Mon Sep 17 00:00:00 2001 From: V2Ray Date: Wed, 9 Sep 2015 15:26:11 +0200 Subject: [PATCH] format code --- io/socks/socks_test.go | 4 ++-- io/vmess/decryptionreader_test.go | 24 ++++++++++++------------ testing/unit/assertions.go | 4 ++-- testing/unit/errorsubject.go | 8 ++++---- vid_test.go | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/io/socks/socks_test.go b/io/socks/socks_test.go index 8fa63eed..ec132f68 100644 --- a/io/socks/socks_test.go +++ b/io/socks/socks_test.go @@ -16,7 +16,7 @@ func TestAuthenticationRequestRead(t *testing.T) { 0x02, // methods } request, err := ReadAuthentication(bytes.NewReader(rawRequest)) - assert.Error(err).IsNil() + assert.Error(err).IsNil() assert.Byte(request.version).Named("Version").Equals(0x05) assert.Byte(request.nMethods).Named("#Methods").Equals(0x01) assert.Byte(request.authMethods[0]).Named("Auth Method").Equals(0x02) @@ -46,7 +46,7 @@ func TestRequestRead(t *testing.T) { 0x00, 0x35, // port 53 } request, err := ReadRequest(bytes.NewReader(rawRequest)) - assert.Error(err).IsNil() + assert.Error(err).IsNil() assert.Byte(request.Version).Named("Version").Equals(0x05) assert.Byte(request.Command).Named("Command").Equals(0x01) assert.Byte(request.AddrType).Named("Address Type").Equals(0x01) diff --git a/io/vmess/decryptionreader_test.go b/io/vmess/decryptionreader_test.go index 2f783628..0f33dd32 100644 --- a/io/vmess/decryptionreader_test.go +++ b/io/vmess/decryptionreader_test.go @@ -7,21 +7,21 @@ import ( "crypto/rand" mrand "math/rand" "testing" - - "github.com/v2ray/v2ray-core/testing/unit" + + "github.com/v2ray/v2ray-core/testing/unit" ) func randomBytes(p []byte, t *testing.T) { - assert := unit.Assert(t) - + assert := unit.Assert(t) + nBytes, err := rand.Read(p) - assert.Error(err).IsNil() - assert.Int(nBytes).Named("# bytes of random buffer").Equals(len(p)) + assert.Error(err).IsNil() + assert.Int(nBytes).Named("# bytes of random buffer").Equals(len(p)) } func TestNormalReading(t *testing.T) { - assert := unit.Assert(t) - + assert := unit.Assert(t) + testSize := 256 plaintext := make([]byte, testSize) randomBytes(plaintext, t) @@ -33,8 +33,8 @@ func TestNormalReading(t *testing.T) { randomBytes(iv, t) aesBlock, err := aes.NewCipher(key) - assert.Error(err).IsNil() - + assert.Error(err).IsNil() + aesMode := cipher.NewCBCEncrypter(aesBlock, iv) ciphertext := make([]byte, testSize) @@ -55,8 +55,8 @@ func TestNormalReading(t *testing.T) { } bytesRead, err := reader.Read(readtext[readSize : readSize+nBytes]) assert.Error(err).IsNil() - assert.Int(bytesRead).Equals(nBytes) + assert.Int(bytesRead).Equals(nBytes) readSize += nBytes } - assert.Bytes(readtext).Named("Plaintext").Equals(plaintext) + assert.Bytes(readtext).Named("Plaintext").Equals(plaintext) } diff --git a/testing/unit/assertions.go b/testing/unit/assertions.go index 17c7426b..92cccd54 100644 --- a/testing/unit/assertions.go +++ b/testing/unit/assertions.go @@ -33,9 +33,9 @@ func (a *Assertion) Bytes(value []byte) *BytesSubject { } func (a *Assertion) String(value string) *StringSubject { - return NewStringSubject(NewSubject(a), value) + return NewStringSubject(NewSubject(a), value) } func (a *Assertion) Error(value error) *ErrorSubject { - return NewErrorSubject(NewSubject(a), value) + return NewErrorSubject(NewSubject(a), value) } diff --git a/testing/unit/errorsubject.go b/testing/unit/errorsubject.go index 9ef4210b..18608319 100644 --- a/testing/unit/errorsubject.go +++ b/testing/unit/errorsubject.go @@ -32,7 +32,7 @@ func (subject *ErrorSubject) Equals(expectation error) { } func (subject *ErrorSubject) IsNil() { - if subject.value != nil { - subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.") - } -} \ No newline at end of file + if subject.value != nil { + subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.") + } +} diff --git a/vid_test.go b/vid_test.go index b2e3df84..aeda48de 100644 --- a/vid_test.go +++ b/vid_test.go @@ -2,16 +2,16 @@ package core import ( "testing" - - "github.com/v2ray/v2ray-core/testing/unit" + + "github.com/v2ray/v2ray-core/testing/unit" ) func TestUUIDToVID(t *testing.T) { - assert := unit.Assert(t) - + assert := unit.Assert(t) + uuid := "2418d087-648d-4990-86e8-19dca1d006d3" expectedBytes := []byte{0x24, 0x18, 0xd0, 0x87, 0x64, 0x8d, 0x49, 0x90, 0x86, 0xe8, 0x19, 0xdc, 0xa1, 0xd0, 0x06, 0xd3} actualBytes, _ := UUIDToVID(uuid) - assert.Bytes(actualBytes[:]).Named("UUID").Equals(expectedBytes) + assert.Bytes(actualBytes[:]).Named("UUID").Equals(expectedBytes) }