diff --git a/tests/test-buffer.js b/tests/test-buffer.js index 7d77c8816..f2a087781 100644 --- a/tests/test-buffer.js +++ b/tests/test-buffer.js @@ -1,11 +1,34 @@ -// Copyright (c) 2016-2017, Intel Corporation. +// Copyright (c) 2016-2018, Intel Corporation. // Buffer Testing +console.log("Test buffer APIs"); var assert = require("Assert.js"); -// Attribute: readonly unsigned long length var buff; + +// Creat buffer: array (not test out of memory) +var lens = [1, 10, 100, 1024]; +buff = new Buffer(lens); +assert(buff !== null && typeof buff === "object", + "Creating buffer with array [1, 10, 100, 1024]"); +assert(buff.length === 4, + "Creating buffer of length " + buff.length + " with array"); + +var lens = [[1, 10], "ZJS", "w"]; +buff = new Buffer(lens); +assert(buff !== null && typeof buff === "object" && buff.length === 3, + "Creating buffer with not array and treating as 0"); + +// Creat buffer: string (not test out of memory) +var lens = ["w", "ZJS", "1234567890", "!@#$%^&*()"]; +for (var i = 0; i < lens.length; i++) { + buff = new Buffer(lens[i]); + assert(buff !== null && typeof buff === "object", + "Creating buffer with string " + lens[i]); +} + +// Attribute: readonly unsigned long length var lens = [[-1, 0], [0, 0], [8, 8],