Skip to content

Commit

Permalink
almost finish
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-blog committed Feb 29, 2024
1 parent 92ad692 commit f25b344
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,42 @@ test("Test MyClass's addStudent", () => {
const myClass = new MyClass();
const student = new Student();
const name="Daniel";
student.setName(name);
assert.strictEqual(myClass.addStudent(student),1);
throw new Error("Test not implemented");
student.name=name;
assert.strictEqual(myClass.addStudent(student),0);
assert.strictEqual(myClass.addStudent("Daniel"),-1);
//throw new Error("Test not implemented");
});

test("Test MyClass's getStudentById", () => {
// TODO
const myClass = new MyClass();
const student = new Student();
const name="Daniel";
student.setName(name);
const newStudentId=myClass.addStudent(student);
assert.strictEqual(myClass.getStudentById(newStudentId).getName(),"Daniel");
throw new Error("Test not implemented");
student.name=name;
myClass.students.push(student);
assert.strictEqual(myClass.getStudentById(0).name,"Daniel");
assert.strictEqual(myClass.getStudentById(1),null);
//throw new Error("Test not implemented");
});

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

test("Test Student's getName", () => {
// TODO
const myClass = new MyClass();
const student = new Student();
const name="Daniel";
student.name=name;
assert.strictEqual(student.getName(),"Daniel")
throw new Error("Test not implemented");
assert.strictEqual(student.getName(),"Daniel");
student.name=undefined;
assert.strictEqual(student.getName(),"");
//throw new Error("Test not implemented");
});

0 comments on commit f25b344

Please sign in to comment.