Skip to content

Commit

Permalink
Merge pull request #16 from ming-hsien/312551148
Browse files Browse the repository at this point in the history
[LAB1] 312551148
  • Loading branch information
TaiYou-TW authored Mar 7, 2024
2 parents 2d41d26 + 24f8d9f commit 98036e8
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,41 @@ const assert = require('assert');
const { MyClass, Student } = require('./main');

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

});

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

});

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

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

0 comments on commit 98036e8

Please sign in to comment.