Software /
code /
prosody
Annotate
spec/util_ringbuffer_spec.lua @ 10898:c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 29 May 2020 18:11:42 +0200 |
parent | 10897:37df1e757f02 |
child | 10899:8048255ae61e |
rev | line source |
---|---|
10897
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local rb = require "util.ringbuffer"; |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 describe("util.ringbuffer", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 describe("#new", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 it("has a constructor", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 assert.Function(rb.new); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 end); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 it("can be created", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 assert.truthy(rb.new()); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 end); |
10898
c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
Kim Alvefur <zash@zash.se>
parents:
10897
diff
changeset
|
10 it("won't create an empty buffer", function () |
c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
Kim Alvefur <zash@zash.se>
parents:
10897
diff
changeset
|
11 assert.has_error(function () |
c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
Kim Alvefur <zash@zash.se>
parents:
10897
diff
changeset
|
12 rb.new(0); |
c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
Kim Alvefur <zash@zash.se>
parents:
10897
diff
changeset
|
13 end); |
c6465fb3c839
util.ringbuffer: Prevent creation of zero-size buffer
Kim Alvefur <zash@zash.se>
parents:
10897
diff
changeset
|
14 end); |
10897
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 describe(":write", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 local b = rb.new(); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 it("works", function () |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 assert.truthy(b:write("hi")); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 end); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end); |
37df1e757f02
util.ringbuffer: Add some initial tests
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 end); |