mirror of
				https://github.com/v2fly/v2ray-core.git
				synced 2025-10-31 01:39:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			498 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			498 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package io_test
 | |
| 
 | |
| import (
 | |
| 	"bytes"
 | |
| 	"crypto/rand"
 | |
| 	"testing"
 | |
| 
 | |
| 	"v2ray.com/core/common/alloc"
 | |
| 	. "v2ray.com/core/common/io"
 | |
| 	"v2ray.com/core/testing/assert"
 | |
| )
 | |
| 
 | |
| func TestAdaptiveWriter(t *testing.T) {
 | |
| 	assert := assert.On(t)
 | |
| 
 | |
| 	lb := alloc.NewLargeBuffer()
 | |
| 	rand.Read(lb.Value)
 | |
| 
 | |
| 	writeBuffer := make([]byte, 0, 1024*1024)
 | |
| 
 | |
| 	writer := NewAdaptiveWriter(NewBufferedWriter(bytes.NewBuffer(writeBuffer)))
 | |
| 	err := writer.Write(lb)
 | |
| 	assert.Error(err).IsNil()
 | |
| 	assert.Bytes(lb.Bytes()).Equals(writeBuffer)
 | |
| }
 | 
