michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cr = Components.results; michael@0: michael@0: const util = Cc["@mozilla.org/io-util;1"].getService(Ci.nsIIOUtil); michael@0: michael@0: function run_test() michael@0: { michael@0: try { michael@0: util.inputStreamIsBuffered(null); michael@0: do_throw("inputStreamIsBuffered should have thrown"); michael@0: } catch (e) { michael@0: do_check_eq(e.result, Cr.NS_ERROR_INVALID_POINTER); michael@0: } michael@0: michael@0: try { michael@0: util.outputStreamIsBuffered(null); michael@0: do_throw("outputStreamIsBuffered should have thrown"); michael@0: } catch (e) { michael@0: do_check_eq(e.result, Cr.NS_ERROR_INVALID_POINTER); michael@0: } michael@0: michael@0: var s = Cc["@mozilla.org/io/string-input-stream;1"] michael@0: .createInstance(Ci.nsIStringInputStream); michael@0: var body = "This is a test"; michael@0: s.setData(body, body.length); michael@0: do_check_eq(util.inputStreamIsBuffered(s), true); michael@0: }