Skip to content

Commit

Permalink
Merge pull request #9 from pudding0803/312552057
Browse files Browse the repository at this point in the history
[LAB1] 312552057
  • Loading branch information
TaiYou-TW authored Mar 7, 2024
2 parents 2d41d26 + 3076117 commit 1273e05
Showing 1 changed file with 30 additions and 12 deletions.
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);
});

0 comments on commit 1273e05

Please sign in to comment.