Skip to content

Commit 567f172

Browse files
committed
Minor fixes
1 parent e66277a commit 567f172

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ semaphore
44
[![Build Status](https://travis-ci.org/marusama/semaphore.svg?branch=master)](https://travis-ci.org/marusama/semaphore)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/marusama/semaphore)](https://goreportcard.com/report/github.com/marusama/semaphore)
66
[![Coverage Status](https://coveralls.io/repos/github/marusama/semaphore/badge.svg?branch=master)](https://coveralls.io/github/marusama/semaphore?branch=master)
7-
[![GoDoc](https://godoc.org/github.com/kamilsk/semaphore?status.svg)](https://godoc.org/github.com/marusama/semaphore)
7+
[![GoDoc](https://godoc.org/github.com/marusama/semaphore?status.svg)](https://godoc.org/github.com/marusama/semaphore)
88
[![License](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](LICENSE)
99

1010
Fast resizable golang semaphore based on CAS
1111

1212
* allows weighted acquire/release;
1313
* supports cancellation via context;
1414
* allows change semaphore limit after creation;
15-
* faster than channels based semaphores.
15+
* faster than channel based semaphores.
1616

1717
### Usage
1818
Initiate
1919
```go
2020
import "github.com/marusama/semaphore"
2121
...
22-
sem := semaphore.New(5) // new semaphore with limit=5
22+
sem := semaphore.New(5) // new semaphore with limit = 5
2323
```
2424
Acquire
2525
```go

semaphore_test.go

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,31 @@ func checkLimitAndCount(t *testing.T, sem Semaphore, expectedLimit, expectedCoun
2929
}
3030

3131
func TestNew(t *testing.T) {
32-
sem := New(1)
33-
checkLimitAndCount(t, sem, 1, 0)
34-
}
35-
36-
func TestNew_zero_limit_panic_expected(t *testing.T) {
37-
defer func() {
38-
if recover() == nil {
39-
t.Error("Panic expected")
40-
}
41-
}()
42-
_ = New(0)
43-
}
44-
45-
func TestNew_negative_limit_panic_expected(t *testing.T) {
46-
defer func() {
47-
if recover() == nil {
48-
t.Error("Panic expected")
49-
}
50-
}()
51-
_ = New(-1)
32+
tests := []func(){
33+
func() {
34+
sem := New(1)
35+
checkLimitAndCount(t, sem, 1, 0)
36+
},
37+
func() {
38+
defer func() {
39+
if recover() == nil {
40+
t.Error("Panic expected")
41+
}
42+
}()
43+
_ = New(0)
44+
},
45+
func() {
46+
defer func() {
47+
if recover() == nil {
48+
t.Error("Panic expected")
49+
}
50+
}()
51+
_ = New(-1)
52+
},
53+
}
54+
for _, test := range tests {
55+
test()
56+
}
5257
}
5358

5459
func TestSemaphore_Acquire(t *testing.T) {

0 commit comments

Comments
 (0)