spec/util_strbitop_spec.lua
changeset 13431 9677df320992
parent 11172 cde600e2fdf9
child 13433 6cdc6923d65a
equal deleted inserted replaced
13430:581899aef96f 13431:9677df320992
       
     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);