diff options
author | Matthew Wild <mwild1@gmail.com> | 2022-03-04 19:48:01 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2022-03-04 19:48:01 +0000 |
commit | 7b23d9d13628ed8032955745b9c63d68c22734e3 (patch) | |
tree | 830532724779e652b50d975f65e7584f6c0ade18 /spec/util_bitcompat_spec.lua | |
parent | a905ccb71a571649c7aed90bf444e1afed9a1318 (diff) | |
download | prosody-7b23d9d13628ed8032955745b9c63d68c22734e3.tar.gz prosody-7b23d9d13628ed8032955745b9c63d68c22734e3.zip |
util.bitcompat: Add some simple tests
Diffstat (limited to 'spec/util_bitcompat_spec.lua')
-rw-r--r-- | spec/util_bitcompat_spec.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/util_bitcompat_spec.lua b/spec/util_bitcompat_spec.lua new file mode 100644 index 00000000..34a87f5b --- /dev/null +++ b/spec/util_bitcompat_spec.lua @@ -0,0 +1,27 @@ +describe("util.bitcompat", function () + -- bitcompat will pass through to an appropriate implementation. Our + -- goal here is to check that whatever implementation is in use passes + -- these basic sanity checks. + + local bit = require "util.bitcompat"; + + it("bor works", function () + assert.equal(0xF0FF, bit.bor(0xF000, 0x00F0, 0x000F)); + end); + + it("band works", function () + assert.equal(0x0F, bit.band(0xFF, 0x1F, 0x0F)); + end); + + it("bxor works", function () + assert.equal(0x13, bit.bxor(0x10, 0x0F, 0x0C)); + end); + + it("rshift works", function () + assert.equal(0x0F, bit.rshift(0xFF, 4)); + end); + + it("lshift works", function () + assert.equal(0xFF00, bit.lshift(0xFF, 8)); + end); +end); |