Skip to content

Commit

Permalink
Merge pull request #64 from veture7275/310552064
Browse files Browse the repository at this point in the history
[LAB1] 310552064
  • Loading branch information
TaiYou-TW authored Mar 7, 2024
2 parents 2d41d26 + 402e1bd commit 030acb9
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
const test = require('node:test');
const assert = require('assert');
const { MyClass, Student } = require('./main');
myclass = new MyClass();
student = new Student();
student.setName('John');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
assert.strictEqual(myclass.addStudent(1), -1);
assert.strictEqual(myclass.addStudent(student), 0);
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
myclass.addStudent(student);
assert.strictEqual(myclass.getStudentById(0),student);
assert.strictEqual(myclass.getStudentById(-1),null);
});

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

test("Test Student's getName", () => {
// TODO
throw new Error("Test not implemented");
});
assert.strictEqual(myclass.getStudentById(0).getName(),student.name);
student2 = new Student();
myclass.addStudent(student2);
assert.strictEqual(myclass.getStudentById(2).getName(),'');
});

0 comments on commit 030acb9

Please sign in to comment.