Skip to content
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
42 changes: 30 additions & 12 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
const test = require('node:test');
const assert = require('assert');
const { MyClass, Student } = require('./main');
const test = require("node:test");
const assert = require("assert");
const { MyClass, Student } = require("./main");

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
const myClass = new MyClass();
assert.strictEqual(myClass.addStudent('Not a student'), -1);
const student = new Student();
for (let i = 0; i < 3; i++) {
const student = new Student();
assert.strictEqual(myClass.addStudent(student), i);
}
});

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

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

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