Skip to content

Commit

Permalink
Update main_test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
veture7275 authored Mar 4, 2024
1 parent e3463eb commit 402e1bd
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 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 402e1bd

Please sign in to comment.