diff --git a/lab1/main_test.js b/lab1/main_test.js index 74a716b4..9ce6dd01 100644 --- a/lab1/main_test.js +++ b/lab1/main_test.js @@ -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"); -}); \ No newline at end of file + assert.strictEqual(myclass.getStudentById(0).getName(),student.name); + student2 = new Student(); + myclass.addStudent(student2); + assert.strictEqual(myclass.getStudentById(2).getName(),''); +}); diff --git a/lab3/main_test.js b/lab3/main_test.js index 0663faf5..cb218e01 100644 --- a/lab3/main_test.js +++ b/lab3/main_test.js @@ -1,6 +1,7 @@ const {describe, it} = require('node:test'); const assert = require('assert'); const { Calculator } = require('./main'); + const test = require('node:test'); // TODO: write your tests here test("Calculator's exp",()=>{