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

Function testSafeMethods

ts/src/test/base/test.safeMethods.ts:19–403  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17}
18
19function testSafeMethods () {
20
21 const exchange = new ccxt.Exchange ({
22 'id': 'regirock',
23 });
24
25 const inputDict = {
26 'i': 1,
27 'f': 0.123,
28 'bool': true,
29 'list': [ 1, 2, 3 ],
30 'dict': { 'a': 1 },
31 'listOfDicts': [ { 'a': 1 } ],
32 'str': 'heLlo',
33 'strNumber': '3',
34 //
35 'zeroNumeric': 0,
36 'zeroString': '0',
37 'undefined': undefined,
38 'emptyString': '',
39 'floatNumeric': 0.123,
40 'floatString': '0.123',
41 'longInt': 123456789012345,
42 };
43
44 const inputList = [ 'Hi', 2 ];
45
46 const compareDict = {
47 'a': 1,
48 };
49
50 const compareList = [ 1, 2, 3 ];
51
52 const factor = 10;
53
54 // safeValue
55 assert (exchange.safeValue (inputDict, 'i') === 1);
56 assert (exchange.safeValue (inputDict, 'f') === 0.123);
57 assert (exchange.safeValue (inputDict, 'bool') === true);
58 assert (equals (exchange.safeValue (inputDict, 'list'), compareList));
59 let dictObject = exchange.safeValue (inputDict, 'dict');
60 assert (equals (dictObject, compareDict));
61 assert (exchange.safeValue (inputDict, 'str') === 'heLlo');
62 assert (exchange.safeValue (inputDict, 'strNumber') === '3');
63 assert (exchange.safeValue (inputList, 0) === 'Hi');
64
65 // safeValue2
66 assert (exchange.safeValue2 (inputDict, 'a', 'i') === 1);
67 assert (exchange.safeValue2 (inputDict, 'a', 'f') === 0.123);
68 assert (exchange.safeValue2 (inputDict, 'a', 'bool') === true);
69 assert (equals (exchange.safeValue2 (inputDict, 'a', 'list'), compareList));
70 dictObject = exchange.safeValue2 (inputDict, 'a', 'dict');
71 assert (equals (dictObject, compareDict));
72 assert (exchange.safeValue2 (inputDict, 'a', 'str') === 'heLlo');
73 assert (exchange.safeValue2 (inputDict, 'a', 'strNumber') === '3');
74 assert (exchange.safeValue2 (inputList, 2, 0) === 'Hi');
75
76 // safeValueN

Callers 1

baseTestsInitFunction · 0.70

Calls 15

safeValueMethod · 0.95
safeValue2Method · 0.95
safeValueNMethod · 0.95
safeDictMethod · 0.95
safeDict2Method · 0.95
safeDictNMethod · 0.95
safeListMethod · 0.95
safeList2Method · 0.95
safeListNMethod · 0.95
safeStringMethod · 0.95
safeString2Method · 0.95
safeStringNMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…