diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/net_spec.lua | 2 | ||||
| -rw-r--r-- | spec/rng_spec.lua | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/spec/net_spec.lua b/spec/net_spec.lua index f3c24eb..82686e6 100644 --- a/spec/net_spec.lua +++ b/spec/net_spec.lua @@ -7,7 +7,7 @@ describe("net module", function() assert(net.Peer) local peer = assert(net.Peer()) end) - it("should generate a random id when not supplied #dev", function() + it("should generate a random id when not supplied", function() require("preload") local net = require("net") local peer = assert(net.Peer()) diff --git a/spec/rng_spec.lua b/spec/rng_spec.lua new file mode 100644 index 0000000..731e842 --- /dev/null +++ b/spec/rng_spec.lua @@ -0,0 +1,25 @@ +describe("rng module #dev", function() + it("should load",function() + require("rng") + end) + it("should have a function to generate a random string",function() + local rng = require("rng") + assert(rng.randomstring) + assert(type(rng.randomstring) == "function") + end) + it("should generate a string",function() + local rng = require("rng") + local s = rng.randomstring("a",5) + assert(#s == 5) + assert(s == string.rep("a",5)) + end) + it("should generate a string of the right length", function() + local rng = require("rng") + for i = 1,5 do + local ranlength = math.random(100) + local s = rng.randomstring("a",ranlength) + assert(#s == ranlength) + assert(s == string.rep("a",ranlength)) + end + end) +end) |
