Закинул общий репозиторий
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package producers
|
||||
|
||||
type Producer interface {
|
||||
WritePsToChan(psChan chan int)
|
||||
GetCountPorts() int
|
||||
}
|
||||
|
||||
type Generator struct {
|
||||
}
|
||||
|
||||
func (g Generator) WritePsToChan(psChan chan int) {
|
||||
for i := 1; i <= cap(psChan); i++ {
|
||||
psChan <- i
|
||||
}
|
||||
close(psChan)
|
||||
}
|
||||
|
||||
func (g Generator) GetCountPorts() int {
|
||||
return 65536
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package producers
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerator_WritePsToChan(t *testing.T) {
|
||||
cntPs := 10
|
||||
psChan := make(chan int, cntPs)
|
||||
|
||||
g := Generator{}
|
||||
g.WritePsToChan(psChan)
|
||||
for i := 1; i <= cntPs; i++ {
|
||||
assert.Equal(t, i, <-psChan)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerator_GetCountPorts(t *testing.T) {
|
||||
assert.Equal(t, 65536, Generator{}.GetCountPorts())
|
||||
}
|
||||
Reference in New Issue
Block a user