Comparison

spec/util_strbitop.lua @ 11168:cde600e2fdf9 0.11

util.strbitop: Add tests covering basics Also as docs
author Kim Alvefur <zash@zash.se>
date Thu, 15 Oct 2020 16:41:51 +0200
comparison
equal deleted inserted replaced
11167:ba32b9a6d75b 11168:cde600e2fdf9
1 local strbitop = require "util.strbitop";
2 describe("util.strbitop", function ()
3 describe("sand()", function ()
4 it("works", function ()
5 assert.equal(string.rep("Aa", 100), strbitop.sand(string.rep("a", 200), "Aa"));
6 end);
7 it("returns empty string if first argument is empty", function ()
8 assert.equal("", strbitop.sand("", ""));
9 assert.equal("", strbitop.sand("", "key"));
10 end);
11 it("returns initial string if key is empty", function ()
12 assert.equal("hello", strbitop.sand("hello", ""));
13 end);
14 end);
15
16 describe("sor()", function ()
17 it("works", function ()
18 assert.equal(string.rep("a", 200), strbitop.sor(string.rep("Aa", 100), "a"));
19 end);
20 it("returns empty string if first argument is empty", function ()
21 assert.equal("", strbitop.sor("", ""));
22 assert.equal("", strbitop.sor("", "key"));
23 end);
24 it("returns initial string if key is empty", function ()
25 assert.equal("hello", strbitop.sor("hello", ""));
26 end);
27 end);
28
29 describe("sxor()", function ()
30 it("works", function ()
31 assert.equal(string.rep("Aa", 100), strbitop.sxor(string.rep("a", 200), " \0"));
32 end);
33 it("returns empty string if first argument is empty", function ()
34 assert.equal("", strbitop.sxor("", ""));
35 assert.equal("", strbitop.sxor("", "key"));
36 end);
37 it("returns initial string if key is empty", function ()
38 assert.equal("hello", strbitop.sxor("hello", ""));
39 end);
40 end);
41 end);