Skip to content

[LAB1] 313551010 #69

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 1 commit into from
Mar 12, 2025
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
39 changes: 35 additions & 4 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,51 @@ const { MyClass, Student } = require('./main');

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

const studentId = myClass.addStudent(student);
// const name = ['John'];
assert.strictEqual(studentId, 0);

assert.strictEqual(myClass.addStudent({}), -1);
// throw new Error("Test not implemented");
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
const myClass = new MyClass();
const student = new Student();
student.setName("John");
const studentId = myClass.addStudent(student);

const retrievedStudent = myClass.getStudentById(studentId);
assert.strictEqual(retrievedStudent, student);

assert.strictEqual(myClass.getStudentById(-1), null);
assert.strictEqual(myClass.getStudentById(100), null);
// throw new Error("Test not implemented");
});

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

student.setName("Alice");
assert.strictEqual(student.getName(), "Alice");

student.setName(123);
assert.strictEqual(student.getName(), "Alice");
// throw new Error("Test not implemented");
});

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

assert.strictEqual(student.getName(), "");

student.setName("Bob");
assert.strictEqual(student.getName(), "Bob");
// throw new Error("Test not implemented");
});
Loading