[Pkg-javascript-commits] [node-sha.js] 91/237: tests for fakebuffer

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:03:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-sha.js.

commit 391fc9f84988ebc32e8e14687568d8a2418fa34f
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Sun Jan 12 00:01:53 2014 +0700

    tests for fakebuffer
---
 test/fakebuffer.js | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/test/fakebuffer.js b/test/fakebuffer.js
new file mode 100644
index 0000000..afa5ed6
--- /dev/null
+++ b/test/fakebuffer.js
@@ -0,0 +1,31 @@
+
+var RealBuffer = require('buffer').Buffer
+var FakeBuffer = require('../fakebuffer')
+
+var length = 12
+var rb = new RealBuffer(length)
+var fb = new FakeBuffer(length)
+
+for(var i = 0; i < length; i += 4) {
+  var r = (Math.random()*0x80000000)|0
+  fb.writeUInt32BE(r, i)
+  rb.writeUInt32BE(r, i)
+}
+
+console.log(fb)
+console.log(rb)
+
+var equal = require('assert').equal
+
+for(var i = 0; i < length; i += 4) {
+  equal(rb.readUInt32BE(i), fb.readUInt32BE(i))
+  equal(rb.readInt32BE(i), fb.readInt32BE(i))
+  equal(rb.readUInt32LE(i), fb.readUInt32LE(i))
+  equal(rb.readInt32LE(i), fb.readInt32LE(i))
+}
+
+for(var i = 0; i < length; i ++) {
+  equal(rb[i], fb[i])
+}
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git



More information about the Pkg-javascript-commits mailing list