Закинул общий репозиторий

This commit is contained in:
Vladislav Karmishkin
2022-04-13 20:45:14 +03:00
parent 40566525c1
commit 96be2f59a7
14 changed files with 418 additions and 1 deletions
+20
View File
@@ -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())
}