MCPcopy Index your code
hub / github.com/ccxt/ccxt / testBinaryToBase64

Function testBinaryToBase64

js/src/test/base/test.binaryToBase64.js:6–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 return exchange.base64ToBinary(exchange.stringToBase64(str));
5}
6function testBinaryToBase64() {
7 const exchange = new ccxt.Exchange({
8 'id': 'sampleexchange',
9 });
10 // In JavaScript, we use Uint8Array or Buffer for binary data
11 // The encode() method converts string to bytes
12 // @SKIP_START_GO
13 // Test 1: Simple binary from string
14 const binary1 = helperStrToBinary(exchange, 'hello');
15 assert(exchange.binaryToBase64(binary1) === 'aGVsbG8=');
16 // Test 2: Binary with space in original
17 const binary2 = helperStrToBinary(exchange, 'hello world');
18 assert(exchange.binaryToBase64(binary2) === 'aGVsbG8gd29ybGQ=');
19 // Test 3: Short binary
20 const binary3 = helperStrToBinary(exchange, 'test');
21 assert(exchange.binaryToBase64(binary3) === 'dGVzdA==');
22 // Test 4: Empty binary
23 const binary4 = helperStrToBinary(exchange, '');
24 assert(exchange.binaryToBase64(binary4) === '');
25 // Test 5: Single byte
26 const binary5 = helperStrToBinary(exchange, 'a');
27 assert(exchange.binaryToBase64(binary5) === 'YQ==');
28 // Test 6: Two bytes
29 const binary6 = helperStrToBinary(exchange, 'ab');
30 assert(exchange.binaryToBase64(binary6) === 'YWI=');
31 // Test 7: Three bytes (no padding)
32 const binary7 = helperStrToBinary(exchange, 'abc');
33 assert(exchange.binaryToBase64(binary7) === 'YWJj');
34 // Test 8: JSON-like binary
35 const binary8 = helperStrToBinary(exchange, '{"key":"value"}');
36 assert(exchange.binaryToBase64(binary8) === 'eyJrZXkiOiJ2YWx1ZSJ9');
37 // Test 9: Numbers as binary
38 const binary9 = helperStrToBinary(exchange, '123456');
39 assert(exchange.binaryToBase64(binary9) === 'MTIzNDU2');
40 // Test 10: Special characters
41 const binary10 = helperStrToBinary(exchange, 'hello+world/test');
42 assert(exchange.binaryToBase64(binary10) === 'aGVsbG8rd29ybGQvdGVzdA==');
43 // @SKIP_END_GO
44 assert(exchange.safeString(undefined, 'key') === undefined, "GO_WORKAROUND");
45}
46export default testBinaryToBase64;

Callers 1

baseTestsInitFunction · 0.70

Calls 4

binaryToBase64Method · 0.95
safeStringMethod · 0.95
helperStrToBinaryFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…