Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Enhancing Tests.js logic #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions LeetcodeProblemsTests/Algorithms/2Sum_Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ const twoSum = require("../../LeetcodeProblems/Algorithms/2Sum").twoSum;
const twoSum2 = require("../../LeetcodeProblems/Algorithms/2Sum").twoSum2;


var test = function () {
var testFirstSolution = function () {
assert.deepEqual([0,1], twoSum([2,7,11,15], 9));
assert.deepEqual([1,2], twoSum([3,2,4], 6));
assert.deepEqual([0,1], twoSum([3,3], 6));

};

var testSecondSolution = function() {
assert.deepEqual([0,1], twoSum2([2,7,11,15], 9));
assert.deepEqual([1,2], twoSum2([3,2,4], 6));
assert.deepEqual([0,1], twoSum2([3,3], 6));
};


module.exports.test = test;
module.exports.testFirstSolution = testFirstSolution;
module.exports.testSecondSolution = testSecondSolution;
20 changes: 8 additions & 12 deletions Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ var test_all = async function () {
const problems = await loadProblems();
for (i in problems) {
console.log("Solving: " + problems[i]);
const problem = require(TESTS_FOLDER + problems[i]);

if (typeof problem.test !== "undefined") {
problem.test();
console.log("✅ Tests for " + problems[i] + " run successfully \n");
} else {
console.warn(
problem,
"🔴 The problem " +
problems[i] +
" doesn't have a test method implemented.\n"
);
const tests = require(TESTS_FOLDER + problems[i]);
if (Object.keys(tests).length == 0) {
console.warn("🔴 The problem " + problems[i] + " doesn't have a test method implemented.\n");
continue;
}
for(testIdx in tests) {
tests[testIdx]();
}
console.log("✅ Tests for " + problems[i] + " run successfully \n");
}
} catch (error) {
throw new Error(error);
Expand Down