UNPKG

muschema

Version:
36 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var test = require("tape"); var string_1 = require("../string"); var mustreams_1 = require("mustreams"); test('string', function (t) { var defaultValue = ''; var s = new string_1.MuString(); t.equals(s.identity, defaultValue); t.equals(s.alloc(), defaultValue); t.equals(s.clone(''), ''); var ascii = 'I <3 you.'; var twoBytes = 'אני אוהבת אותך'; var threeBytes = '我♥你'; var fourBytes = '👩👨❤️👨👩'; var varBytes = fourBytes + twoBytes + ascii + threeBytes; s = new string_1.MuString(varBytes); t.equals(s.identity, varBytes); t.equals(s.alloc(), varBytes); t.equals(s.clone(varBytes), varBytes); var longStr = ''; for (var i = 0; i < 100000; ++i) { longStr += varBytes; } s = new string_1.MuString(longStr); t.equals(s.identity, longStr); t.equals(s.alloc(), longStr); t.equals(s.clone(longStr), longStr); var ws = new mustreams_1.MuWriteStream(2); t.equals(s.diff(longStr, longStr, ws), false); t.equals(s.diff(longStr, longStr.substring(0, longStr.length - 1), ws), true); var rs = new mustreams_1.MuReadStream(ws.bytes()); t.equals(s.patch(longStr, rs), longStr.substring(0, longStr.length - 1)); t.end(); }); //# sourceMappingURL=string.js.map