toolkit/devtools/sourcemap/tests/unit/test_base64.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/sourcemap/tests/unit/test_base64.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/*
     1.5 + * WARNING!
     1.6 + *
     1.7 + * Do not edit this file directly, it is built from the sources at
     1.8 + * https://github.com/mozilla/source-map/
     1.9 + */
    1.10 +
    1.11 +Components.utils.import('resource://test/Utils.jsm');
    1.12 +/* -*- Mode: js; js-indent-level: 2; -*- */
    1.13 +/*
    1.14 + * Copyright 2011 Mozilla Foundation and contributors
    1.15 + * Licensed under the New BSD license. See LICENSE or:
    1.16 + * http://opensource.org/licenses/BSD-3-Clause
    1.17 + */
    1.18 +define("test/source-map/test-base64", ["require", "exports", "module"], function (require, exports, module) {
    1.19 +
    1.20 +  var base64 = require('source-map/base64');
    1.21 +
    1.22 +  exports['test out of range encoding'] = function (assert, util) {
    1.23 +    assert.throws(function () {
    1.24 +      base64.encode(-1);
    1.25 +    });
    1.26 +    assert.throws(function () {
    1.27 +      base64.encode(64);
    1.28 +    });
    1.29 +  };
    1.30 +
    1.31 +  exports['test out of range decoding'] = function (assert, util) {
    1.32 +    assert.throws(function () {
    1.33 +      base64.decode('=');
    1.34 +    });
    1.35 +  };
    1.36 +
    1.37 +  exports['test normal encoding and decoding'] = function (assert, util) {
    1.38 +    for (var i = 0; i < 64; i++) {
    1.39 +      assert.equal(base64.decode(base64.encode(i)), i);
    1.40 +    }
    1.41 +  };
    1.42 +
    1.43 +});
    1.44 +function run_test() {
    1.45 +  runSourceMapTests('test/source-map/test-base64', do_throw);
    1.46 +}

mercurial