Skip to content

Commit

Permalink
Merge pull request #67 from martintl25/312552020
Browse files Browse the repository at this point in the history
[LAB1] 312552020
  • Loading branch information
TaiYou-TW authored Mar 7, 2024
2 parents 2d41d26 + 00b44d2 commit 42eded5
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,39 @@ const { MyClass, Student } = require('./main');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
const studentInstance = new Student();
const classInstance = new MyClass();
assert.strictEqual(classInstance.addStudent(studentInstance), 0);
assert.strictEqual(classInstance.addStudent(1), -1);
// throw new Error("Test not implemented");
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
const studentInstance = new Student();
const classInstance = new MyClass();
classInstance.addStudent(studentInstance);
assert.strictEqual(classInstance.getStudentById(-1), null);
assert.strictEqual(classInstance.getStudentById(1), null);
assert.deepStrictEqual(classInstance.getStudentById(0), studentInstance);
// throw new Error("Test not implemented");
});

test("Test Student's setName", () => {
// TODO
throw new Error("Test not implemented");
const studentInstance = new Student();
studentInstance.setName(1);
assert.deepStrictEqual(studentInstance.name, undefined);
studentInstance.setName('a');
assert.strictEqual(studentInstance.name, 'a');
// throw new Error("Test not implemented");
});

test("Test Student's getName", () => {
// TODO
throw new Error("Test not implemented");
const studentInstance = new Student();
assert.strictEqual(studentInstance.getName(), '');
studentInstance.setName('b');
assert.strictEqual(studentInstance.getName(), 'b');
// throw new Error("Test not implemented");
});

0 comments on commit 42eded5

Please sign in to comment.