fune/devtools/shared/transport/tests/unit/test_delimited_read.js
Ruturaj K. Vartak b7b3908f8f Bug 1326410 - Fixing ESLint Errors. r=ntim
MozReview-Commit-ID: HZ3iBCW0hEf
2017-02-06 06:53:00 +00:00

27 lines
843 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const StreamUtils = require("devtools/shared/transport/stream-utils");
const StringInputStream = CC("@mozilla.org/io/string-input-stream;1",
"nsIStringInputStream", "setData");
function run_test() {
add_task(function* () {
yield test_delimited_read("0123:", "0123:");
yield test_delimited_read("0123:4567:", "0123:");
yield test_delimited_read("012345678901:", "0123456789");
yield test_delimited_read("0123/0123", "0123/0123");
});
run_next_test();
}
/** * Tests ***/
function test_delimited_read(input, expected) {
input = new StringInputStream(input, input.length);
let result = StreamUtils.delimitedRead(input, ":", 10);
do_check_eq(result, expected);
}