Skip to content

Commit 2d3c1ea

Browse files
committed
Add more tests. Add go 1.16 to travis cfg.
1 parent 41c532b commit 2d3c1ea

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ language: go
33
go:
44
- 1.13.x
55
- 1.14.x
6+
- 1.15.x
7+
- 1.16.x
68
- 1.x
79
- master
810

semaphore_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,26 @@ func TestSemaphore_SetLimit_decrease_limit(t *testing.T) {
412412
checkLimitAndCount(t, sem, 1, 0)
413413
}
414414

415+
func TestSemaphore_New0_SetLimit1_Acquire_Release_SetLimit0(t *testing.T) {
416+
sem := New(0)
417+
checkLimitAndCount(t, sem, 0, 0)
418+
419+
sem.SetLimit(1)
420+
checkLimitAndCount(t, sem, 1, 0)
421+
422+
sem.Acquire(nil, 1)
423+
checkLimitAndCount(t, sem, 1, 1)
424+
425+
oldCnt := sem.Release(1)
426+
if oldCnt != 1 {
427+
t.Error("semaphore must have old count = ", 1, ", but has ", oldCnt)
428+
}
429+
checkLimitAndCount(t, sem, 1, 0)
430+
431+
sem.SetLimit(0)
432+
checkLimitAndCount(t, sem, 0, 0)
433+
}
434+
415435
func TestSemaphore_SetLimit_increase_broadcast(t *testing.T) {
416436
getWGs := func(cnt int) []*sync.WaitGroup {
417437
wgs := make([]*sync.WaitGroup, cnt)

0 commit comments

Comments
 (0)