Skip to content

Commit 1c3156a

Browse files
committed
Adding tests for "Dead men's shot".
1 parent 7fcf305 commit 1c3156a

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* The "Credit card verifier (Luhn’s algorithm)" puzzle.
3+
*/
4+
function execute(readline) {
5+
const n = parseInt(readline());
6+
for (let i = 0; i < n; i++) {
7+
const card = readline();
8+
}
9+
10+
// Write an answer using console.log()
11+
// To debug: console.error('Debug messages...');
12+
13+
console.log('YES or NO');
14+
}
15+
16+
export { execute };
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { assert } from 'chai';
2+
import sinon from 'sinon';
3+
import File from '../../../../File.js';
4+
import { assertOutputAnswer } from '../../../../assertOutputAnswer.js';
5+
import { execute } from '../../../../../lib/community/training/easy/creditCardVerifier/creditCardVerifier.js';
6+
7+
const __dirname = new URL('.', import.meta.url).pathname;
8+
9+
suite('Container terminal', function() {
10+
const sandbox = sinon.createSandbox();
11+
12+
setup(function () {
13+
sandbox.stub(console, "log");
14+
});
15+
16+
teardown(function () {
17+
sandbox.restore();
18+
});
19+
20+
21+
test('Tests', function() {
22+
let inputFile = new File(__dirname + 'input/01 - tests.txt');
23+
24+
execute(inputFile.readline.bind(inputFile));
25+
26+
assertOutputAnswer(__dirname + 'output/01 - tests.txt');
27+
});
28+
29+
test('MasterCard', function() {
30+
let inputFile = new File(__dirname + 'input/02 - MasterCard.txt');
31+
32+
execute(inputFile.readline.bind(inputFile));
33+
34+
assertOutputAnswer(__dirname + 'output/02 - MasterCard.txt');
35+
});
36+
37+
test('Discover', function() {
38+
let inputFile = new File(__dirname + 'input/03 - Discover.txt');
39+
40+
execute(inputFile.readline.bind(inputFile));
41+
42+
assertOutputAnswer(__dirname + 'output/03 - Discover.txt');
43+
});
44+
45+
test('VISA', function() {
46+
let inputFile = new File(__dirname + 'input/04 - VISA.txt');
47+
48+
execute(inputFile.readline.bind(inputFile));
49+
50+
assertOutputAnswer(__dirname + 'output/04 - VISA.txt');
51+
});
52+
});

0 commit comments

Comments
 (0)