Skip to content

Commit

Permalink
finished lab1
Browse files Browse the repository at this point in the history
  • Loading branch information
HanHongChen committed Feb 29, 2024
1 parent 69aebc4 commit f35c9d0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,35 @@ test("Test MyClass's addStudent", () => {
test("Test MyClass's getStudentById", () => {
// TODO
const myClass = new MyClass();
assert.strictEqual(myClass.getStudentById(-1), null);
assert.strictEqual(myClass.getStudentById(10), null);
const names = ['John', 'Jane', 'Doe', 'Smith'];
names.forEach(name => {
const student = new Student();
student.setName(name);
const newStudentId = myClass.addStudent(student);
const newStudentName = myClass.getStudentById(newStudentId).getName();
console.log('[+] Added student with id: %d, name: %s', newStudentId, newStudentName);
});
assert.strictEqual(myClass.getStudentById())
throw new Error("Test not implemented");
assert.strictEqual(myClass.getStudentById(0).getName(), 'John');
assert.strictEqual(myClass.getStudentById(1).getName(), 'Jane');
assert.strictEqual(myClass.getStudentById(2).getName(), 'Doe');
assert.strictEqual(myClass.getStudentById(3).getName(), 'Smith');
});

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

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

0 comments on commit f35c9d0

Please sign in to comment.