Skip to content

[LAB1] m091545 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2024
Merged
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
45 changes: 40 additions & 5 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,55 @@ const { MyClass, Student } = require('./main');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
var myClass = new MyClass();
var student = new Student();

var res = myClass.addStudent();
assert.equal(res, -1);

res = myClass.addStudent(student);
assert.equal(res, 0);
// throw new Error("Test not implemented");
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
var myClass = new MyClass();
var student = new Student();

myClass.addStudent(student);
var res = myClass.getStudentById(0);
assert.equal(res, student);

res = myClass.getStudentById(-1);
assert.equal(res, null);

res = myClass.getStudentById(2);
assert.equal(res, null);

});

test("Test Student's setName", () => {
// TODO
throw new Error("Test not implemented");
// throw new Error("Test not implemented");
var student = new Student();
student.setName("Quan");

var res = student.name;
assert.equal(res, "Quan");

student.setName(123);
res = student.name;
assert.equal(res, "Quan");
});

test("Test Student's getName", () => {
// TODO
throw new Error("Test not implemented");
var student = new Student();

var res = student.getName();
assert.equal(res, "");

student.setName("Quan");
res = student.getName();
assert.equal(res, "Quan");
});