(tc, cfg, expected)
| 43 | }; |
| 44 | |
| 45 | const testAsync = function (tc, cfg, expected) { |
| 46 | return new Promise(function (resolve, reject) { |
| 47 | const opencc = new OpenCC(cfg + '.json'); |
| 48 | opencc.convert(tc.input, function (err, converted) { |
| 49 | if (err) return reject(err); |
| 50 | try { |
| 51 | assert.equal(converted, expected); |
| 52 | resolve(); |
| 53 | } catch (e) { |
| 54 | reject(e); |
| 55 | } |
| 56 | }); |
| 57 | }); |
| 58 | }; |
| 59 | |
| 60 | async function testAsyncPromise(tc, cfg, expected) { |
| 61 | const opencc = new OpenCC(cfg + '.json'); |