mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Other minor dependencies updates in 7.1.x patch
This commit is contained in:
+1
@@ -10,6 +10,7 @@ test('convert big data to base64', function (t) {
|
||||
b64str = b64.fromByteArray(big)
|
||||
arr = b64.toByteArray(b64str)
|
||||
t.ok(equal(arr, big))
|
||||
t.equal(b64.byteLength(b64str), arr.length)
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
+40
@@ -29,6 +29,46 @@ test('convert to base64 and back', function (t) {
|
||||
}
|
||||
})
|
||||
|
||||
var data = [
|
||||
[[0, 0, 0], 'AAAA'],
|
||||
[[0, 0, 1], 'AAAB'],
|
||||
[[0, 1, -1], 'AAH/'],
|
||||
[[1, 1, 1], 'AQEB'],
|
||||
[[0, -73, 23], 'ALcX']
|
||||
]
|
||||
|
||||
test('convert known data to string', function (t) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var bytes = data[i][0]
|
||||
var expected = data[i][1]
|
||||
var actual = b64.fromByteArray(bytes)
|
||||
t.equal(actual, expected, 'Ensure that ' + bytes + ' serialise to ' + expected)
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('convert known data from string', function (t) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var expected = data[i][0]
|
||||
var string = data[i][1]
|
||||
var actual = b64.toByteArray(string)
|
||||
t.ok(equal(actual, expected), 'Ensure that ' + string + ' deserialise to ' + expected)
|
||||
var length = b64.byteLength(string)
|
||||
t.equal(length, expected.length, 'Ensure that ' + string + ' has byte lentgh of ' + expected.length)
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
function equal (a, b) {
|
||||
var i
|
||||
var length = a.length
|
||||
if (length !== b.length) return false
|
||||
for (i = 0; i < length; ++i) {
|
||||
if ((a[i] & 0xFF) !== (b[i] & 0xFF)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function map (arr, callback) {
|
||||
var res = []
|
||||
var kValue, mappedValue
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
var test = require('tape')
|
||||
var b64 = require('../')
|
||||
|
||||
test('padding bytes found inside base64 string', function (t) {
|
||||
// See https://github.com/beatgammit/base64-js/issues/42
|
||||
var str = 'SQ==QU0='
|
||||
t.deepEqual(b64.toByteArray(str), new Uint8Array([73]))
|
||||
t.equal(b64.byteLength(str), 1)
|
||||
t.end()
|
||||
})
|
||||
+8
-2
@@ -4,15 +4,21 @@ var b64 = require('../')
|
||||
test('decode url-safe style base64 strings', function (t) {
|
||||
var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]
|
||||
|
||||
var actual = b64.toByteArray('//++/++/++//')
|
||||
var str = '//++/++/++//'
|
||||
var actual = b64.toByteArray(str)
|
||||
for (var i = 0; i < actual.length; i++) {
|
||||
t.equal(actual[i], expected[i])
|
||||
}
|
||||
|
||||
actual = b64.toByteArray('__--_--_--__')
|
||||
t.equal(b64.byteLength(str), actual.length)
|
||||
|
||||
str = '__--_--_--__'
|
||||
actual = b64.toByteArray(str)
|
||||
for (i = 0; i < actual.length; i++) {
|
||||
t.equal(actual[i], expected[i])
|
||||
}
|
||||
|
||||
t.equal(b64.byteLength(str), actual.length)
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user