Mercurial > prosody-hg
comparison spec/util_bitcompat_spec.lua @ 12366:c640717e01ca
util.bitcompat: Add some simple tests
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 04 Mar 2022 19:48:01 +0000 |
| parents | |
| children | 9912baa541c0 |
comparison
equal
deleted
inserted
replaced
| 12365:af02b033bd7f | 12366:c640717e01ca |
|---|---|
| 1 describe("util.bitcompat", function () | |
| 2 -- bitcompat will pass through to an appropriate implementation. Our | |
| 3 -- goal here is to check that whatever implementation is in use passes | |
| 4 -- these basic sanity checks. | |
| 5 | |
| 6 local bit = require "util.bitcompat"; | |
| 7 | |
| 8 it("bor works", function () | |
| 9 assert.equal(0xF0FF, bit.bor(0xF000, 0x00F0, 0x000F)); | |
| 10 end); | |
| 11 | |
| 12 it("band works", function () | |
| 13 assert.equal(0x0F, bit.band(0xFF, 0x1F, 0x0F)); | |
| 14 end); | |
| 15 | |
| 16 it("bxor works", function () | |
| 17 assert.equal(0x13, bit.bxor(0x10, 0x0F, 0x0C)); | |
| 18 end); | |
| 19 | |
| 20 it("rshift works", function () | |
| 21 assert.equal(0x0F, bit.rshift(0xFF, 4)); | |
| 22 end); | |
| 23 | |
| 24 it("lshift works", function () | |
| 25 assert.equal(0xFF00, bit.lshift(0xFF, 8)); | |
| 26 end); | |
| 27 end); |
