Skip to content
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

[LAB1] 312551084 #33

Merged
merged 3 commits into from
Mar 7, 2024
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
43 changes: 35 additions & 8 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,48 @@ const assert = require('assert');
const { MyClass, Student } = require('./main');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
// Case 0
let testStudent0 = new Student();
let testClass0 = new MyClass();
testStudent0.setName(userName='testStudent');
assert.strictEqual(testClass0.addStudent(testStudent0), 0);

// Case 1
let testStudent1 = null;
let testClass1 = new MyClass();
assert.strictEqual(testClass1.addStudent(testStudent1), -1);
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
// Case 0
let testStudent0 = new Student();
let testClass0 = new MyClass();

testStudent0.setName(userName='testStudent');
testClass0.addStudent(testStudent0);

selectedStudent0 = testClass0.getStudentById(0);
assert.strictEqual(selectedStudent0.getName(), 'testStudent');

// Case 1
selectedStudent1 = testClass0.getStudentById(1);
assert.strictEqual(selectedStudent1, null);
});

test("Test Student's setName", () => {
// TODO
throw new Error("Test not implemented");
// Case 0
let testStudent0 = new Student();
testStudent0.setName(userName='testStudent');
assert.strictEqual(testStudent0.getName(), 'testStudent');

// Case 1
let testStudent1 = new Student();
testStudent1.setName(userName=123);
assert.strictEqual(testStudent1.getName(), '');
});

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