Software /
code /
prosody
Changeset
12366:c640717e01ca
util.bitcompat: Add some simple tests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 04 Mar 2022 19:48:01 +0000 |
parents | 12365:af02b033bd7f |
children | 12367:7a2f036f73b3 |
files | spec/util_bitcompat_spec.lua |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spec/util_bitcompat_spec.lua Fri Mar 04 19:48:01 2022 +0000 @@ -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);