Skip to content

Commit

Permalink
Merge pull request #61 from visitorckw/312551071
Browse files Browse the repository at this point in the history
[LAB1] 312551071
  • Loading branch information
TaiYou-TW authored Mar 8, 2024
2 parents 95502c6 + 243e795 commit 1320ae1
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ const assert = require('assert');
const { MyClass, Student } = require('./main');

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

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

test("Test Student's setName", () => {
// TODO
throw new Error("Test not implemented");
let student = new Student();
student.setName("John");
assert.strictEqual(student.name, "John");
student.setName(123);
assert.strictEqual(student.name, "John");
});

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

0 comments on commit 1320ae1

Please sign in to comment.