This repository was archived by the owner on Apr 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
52 lines (40 loc) · 1.57 KB
/
tests.py
File metadata and controls
52 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import main
from utils import *
class Test:
"""
Test class
"""
def __init__(self, pages_list, frames_number, expected_matrix=None):
"""
Constructor
:param pages_list:
:param frames_number:
"""
self.pages_list = pages_list.split()
self.frames_number = frames_number
self.expected_matrix = expected_matrix
self.result_matrix = [[]]
def run(self):
self.result_matrix = main.apply_optimal_algorithm(self.pages_list, self.frames_number)
print("Test finished")
print("Result: ")
print(self.pages_list)
print_format_matrix(self.result_matrix)
print("\n")
if self.expected_matrix:
print("Expected Matrix")
print_format_matrix(self.expected_matrix)
def test():
"""
Create tests and run them
:return: None
"""
test1 = Test(pages_list="7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7", frames_number=3)
expected_matrix2 = [
[["7"], ["7"], ["7"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["2"], ["7"], ["7"], ["7"]],
[["E"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["4"], ["4"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"], ["0"]],
[["E"], ["E"], ["1"], ["1"], ["1"], ["3"], ["3"], ["3"], ["3"], ["3"], ["3"], ["3"], ["1"], ["1"], ["1"], ["1"], ["1"], ["1"], ["1"], ["1"]]
]
test2 = Test(pages_list="7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1", frames_number=3, expected_matrix=expected_matrix2)
test2.run()
test()