Skip to content
Open
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
6 changes: 6 additions & 0 deletions Bit-Manipulation/test/IsPowerOfTwo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ test('Check if 1025 is a power of 2 or not:', () => {
const res = IsPowerOfTwo(1025)
expect(res).toBe(false)
})

test('Check negative numbers are not powers of 2:', () => {
expect(IsPowerOfTwo(-1)).toBe(false)
expect(IsPowerOfTwo(-2)).toBe(false)
expect(IsPowerOfTwo(-16)).toBe(false)
})
32 changes: 32 additions & 0 deletions work/R50-T022/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import subprocess
import json
import sys

def run_checks():
work_dir = "work/R50-T022"
os.makedirs(work_dir, exist_ok=True)

# 1. Capture environment versions
node_ver = subprocess.check_output(["node", "-v"]).decode().strip()
npm_ver = subprocess.check_output(["npm", "-v"]).decode().strip()
with open(f"{work_dir}/versions.json", "w") as f:
json.dump({"node": node_ver, "npm": npm_ver}, f, indent=2)

# 2. Run Vitest for IsPowerOfTwo
cmd = ["npx", "vitest", "run", "Bit-Manipulation/test/IsPowerOfTwo.test.js"]
res = subprocess.run(cmd, capture_output=True, text=True)

with open(f"{work_dir}/test_output.log", "w") as f:
f.write(res.stdout + "\n" + res.stderr)

if res.returncode == 0:
with open(f"{work_dir}/fixture_results.json", "w") as f:
json.dump({"status": "PASSED", "task": "R50-T022"}, f, indent=2)
print("All checks passed.")
else:
print("Tests failed!")
sys.exit(1)

if __name__ == "__main__":
run_checks()
4 changes: 4 additions & 0 deletions work/R50-T022/fixture_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status": "PASSED",
"task": "R50-T022"
}
11 changes: 11 additions & 0 deletions work/R50-T022/test_output.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

 RUN  v5.1.0 /Users/fabulous_tarun8/Library/Mobile Documents/com~apple~CloudDocs/Studies/s&ai/diwaliHomework/TheAlgorithms-JavaScript

✓ Bit-Manipulation/test/IsPowerOfTwo.test.js (6 tests) 1ms

 Test Files  1 passed (1)
 Tests  6 passed (6)
 Start at  08:05:33
 Duration  80ms (transform 51%, import 20%, worker 20%, tests 9%)


4 changes: 4 additions & 0 deletions work/R50-T022/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"node": "v26.12.1",
"npm": "11.20.0"
}