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

[LAB2] 312555018 #87

Merged
merged 12 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
lab1 100% coverage
nyeee0622 committed Feb 29, 2024
commit 5ff74a5c5cc8aabb3f195a162341f3adf617208f
14 changes: 11 additions & 3 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
@@ -2,23 +2,31 @@ const test = require('node:test');
const assert = require('assert');
const { MyClass, Student } = require('./main');
const cs = new MyClass();
const john = new Student();
john.setName("John");
var id;

test("Test MyClass's addStudent", () => {
assert(cs.addStudent("John") == -1, "Test not implemented");
assert(cs.addStudent(john) != -1, "Test not implemented");
});

test("Test MyClass's getStudentById", () => {
id = cs.addStudent(john);
assert(cs.getStudentById(-1) == null, "Test not implemented");
assert(cs.getStudentById(id+1) == null, "Test not implemented");
assert(cs.getStudentById(id) == john, "Test not implemented");
});

const st = new Student();
const st2 = new Student();

test("Test Student's setName", () => {
assert(st.setName(123) == undefined, "Test not implemented");
st.setName(123);
st2.setName("John");
});

test("Test Student's getName", () => {
st2.setName("John")
assert(st.getName() == '', "Test not implemented");
assert(st2.getName() == 'John', "Test not implemented");
assert(st2.getName() == 'John', "Test not implemented");
});