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

Function testBinaryToBase64

ts/src/test/base/test.binaryToBase64.ts:9–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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