Skip to content

Commit 125ff74

Browse files
Move tests to its own files Round 3
1 parent e400414 commit 125ff74

10 files changed

+9
-68
lines changed

LeetcodeProblems/Deletion_Distance.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,6 @@ var min = function(a, b) {
106106
return (a < b) ? a : b;
107107
}
108108

109-
function main() {
110-
test();
111-
}
112-
113-
function test() {
114-
assert.equal(deletionDistance("dog", "frog"), 3);
115-
assert.equal(deletionDistance("some", "some"), 0);
116-
assert.equal(deletionDistance("some", "thing"), 9);
117-
assert.equal(deletionDistance("", ""), 0);
118-
119-
assert.equal(deletionDistance2("dog", "frog"), 3);
120-
assert.equal(deletionDistance2("some", "some"), 0);
121-
assert.equal(deletionDistance2("some", "thing"), 9);
122-
assert.equal(deletionDistance2("", ""), 0);
123-
124-
assert.equal(deletionDistanceDP("dog", "frog"), 3);
125-
assert.equal(deletionDistanceDP("some", "some"), 0);
126-
assert.equal(deletionDistanceDP("some", "thing"), 9);
127-
assert.equal(deletionDistanceDP("", ""), 0);
128-
}
129-
130109
module.exports.deletionDistance = deletionDistance;
131110
module.exports.deletionDistance2 = deletionDistance2;
132111
module.exports.deletionDistanceDP = deletionDistanceDP;
133-

LeetcodeProblems/Flood_Fill.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,4 @@ var floodFill = function(image, sr, sc, newColor) {
5353
return image;
5454
};
5555

56-
function main() {
57-
test();
58-
}
59-
60-
function test() {
61-
assert.deepEqual(
62-
[ [ 2, 2, 2 ], [ 2, 2, 0 ], [ 2, 0, 1 ] ],
63-
floodFill([[1,1,1],[1,1,0],[1,0,1]], 1, 1, 2)
64-
);
65-
}
66-
67-
module.exports.main = main;
56+
module.exports.floodFill = floodFill;

LeetcodeProblems/Generate_Parenthesis.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,4 @@ var insertAt = function(str, position, value) {
7777
return str.slice(0, position) + value + str.slice(position);
7878
}
7979

80-
function main() {
81-
console.log("Approach 1");
82-
[0, 1, 2, 3].forEach(function(elem) {
83-
console.log(`${elem}: ${generateParenthesisApproach2(elem)}`);
84-
})
85-
86-
console.log("-------------");
87-
88-
console.log("Approach 2");
89-
[0, 1, 2, 3].forEach(function(elem) {
90-
console.log(`${elem}: ${generateParenthesisApproach2(elem)}`);
91-
})
92-
}
93-
94-
module.exports.main = main
80+
module.exports.generateParenthesisApproach2 = generateParenthesisApproach2;

LeetcodeProblems/Group_Anagrams.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ All inputs will be in lowercase.
1919
The order of your output does not matter.
2020
*/
2121

22-
2322
var groupAnagrams = function(strs) {
2423
var ret = [];
2524
var hashMap = {};
@@ -48,15 +47,4 @@ var sortString = function(str) {
4847
return str.split("").sort().join("");
4948
}
5049

51-
var main = function() {
52-
test();
53-
}
54-
55-
function test() {
56-
assert.deepEqual(
57-
groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]),
58-
[ [ 'eat', 'tea', 'ate' ], [ 'tan', 'nat' ], [ 'bat' ] ]
59-
)
60-
}
61-
62-
module.exports.main = main;
50+
module.exports.groupAnagrams = groupAnagrams;

LeetcodeProblems/Regular_Expression_Matching.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var main = function(){
9494
test();
9595
}
9696

97-
var test = function(n) {
97+
var test = function() {
9898
assert.equal(isMatch("aa", "a"), false);
9999
assert.equal(isMatch("aa", "a*"), true);
100100
assert.equal(isMatch("a","ab*"), true);

LeetcodeProblems/Remove_Invalid_Parentheses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var main = function() {
7474
test();
7575
}
7676

77-
var test = function(n) {
77+
var test = function() {
7878
assert.equal(removeInvalidParentheses("))))(()"), "()");
7979
assert.equal(removeInvalidParentheses("(()"), "()");
8080
assert.equal(removeInvalidParentheses("(d))()"), "(d)()");

LeetcodeProblems/Restore_IP_Addresses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var main = function() {
4545
test();
4646
}
4747

48-
var test = function(n) {
48+
var test = function() {
4949
assert.deepEqual(restoreIpAddresses("010010"), [ '0.10.0.10', '0.100.1.0']);
5050
assert.deepEqual(restoreIpAddresses("25525511135"), [ '255.255.11.135', '255.255.111.35' ]);
5151
}

LeetcodeProblems/Reverse_String_II.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var main = function(){
4343
test();
4444
}
4545

46-
var test = function(n) {
46+
var test = function() {
4747
assert.equal(reverseStr("abcdefg", 2), "bacdfeg");
4848
assert.equal(reverseStr("abcdefg", 3), "cbadefg");
4949
assert.equal(reverseStr("abcdefg", 1), "abcdefg");

LeetcodeProblems/Search_a_2D_Matrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var main = function(){
6363
test();
6464
}
6565

66-
var test = function(n) {
66+
var test = function() {
6767
assert.equal(searchMatrix([], 0), false);
6868
assert.equal(searchMatrix([[1], [3]], 3), true);
6969
assert.equal(searchMatrix([[1], [3]], 1), true);

LeetcodeProblems/Search_a_2D_Matrix_II.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var main = function(n) {
5555
test();
5656
}
5757

58-
var test = function(n) {
58+
var test = function() {
5959
assert.equal(searchMatrix(matrix1, 5), true);
6060
assert.equal(searchMatrix(matrix1, 0), false);
6161
assert.equal(searchMatrix(matrix1, 15), true);

0 commit comments

Comments
 (0)