2015-08-10 22:11:37 +02:00
|
|
|
|
var chai = require('chai');
|
2017-01-26 10:24:14 +01:00
|
|
|
|
var utils = require('../packages/web3-utils');
|
|
|
|
|
|
2015-08-10 22:11:37 +02:00
|
|
|
|
var assert = chai.assert;
|
|
|
|
|
|
|
|
|
|
var tests = [
|
2017-03-02 16:20:39 +01:00
|
|
|
|
{ value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', expected: '0x486565c3a4c3b6c3b6c3a4f09f9185443334c99dc9a33234d084cdbd2d2e2cc3a4c3bc2b232f'},
|
2015-08-10 22:11:37 +02:00
|
|
|
|
{ value: 'myString', expected: '0x6d79537472696e67'},
|
2017-03-02 17:23:38 +01:00
|
|
|
|
{ value: 'myString\x00', expected: '0x6d79537472696e67'},
|
|
|
|
|
{ value: 'expected value\u0000\u0000\u0000', expected: '0x65787065637465642076616c7565'},
|
|
|
|
|
{ value: 'expect\u0000\u0000ed value\u0000\u0000\u0000', expected: '0x657870656374000065642076616c7565'}
|
2015-08-10 22:11:37 +02:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
describe('lib/utils/utils', function () {
|
|
|
|
|
describe('fromUtf8', function () {
|
|
|
|
|
tests.forEach(function (test) {
|
|
|
|
|
it('should turn ' + test.value + ' to ' + test.expected, function () {
|
2015-10-08 04:09:51 +02:00
|
|
|
|
assert.strictEqual(utils.fromUtf8(test.value), test.expected);
|
2015-08-10 22:11:37 +02:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|