-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestcases.py
73 lines (52 loc) · 2.09 KB
/
testcases.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from character import Character
from char_factory import CharFactory
from font_factory import FontFactory
from runarray import RunArray
from sizeCheck import SizeCheck
if __name__ == "__main__":
'''
Character class object which takes character as a input and store it's unicode
'''
charObj = Character()
charObj.charUnicode('A')
charObj.charUnicode('a')
charObj.charUnicode('B')
charObj.charUnicode('C')
charObj.charUnicode('!')
print(charObj.charDict())
'''
prints the character given a unicode
'''
print("Character with Unicode 65 is: ",Character.getCharacter(65))
print("Character with Unicode 99 is: ",Character.getCharacter(99))
'''
Character factory object which returns the character flyweight object given the unicode of the character
'''
charFactoryObject = CharFactory()
charFlyweightObject = charFactoryObject.getFlyweight(34)
'''
Font factory object which returns the Font class object given Font name,size and type
'''
fontFactory = FontFactory()
Fontfactory = FontFactory()
'''
Checking the Font factory object. As it has a single point of access, both the object should be same
'''
print("Font Factory object: ",fontFactory)
print("Font Factory object: ",Fontfactory)
'''
RunArray class object which stores the run of the Font in the document. Stores the Font class object given its start and end position
'''
runArray = RunArray()
runArray.addRun(0,2,fontFactory.getFontObj('Ariel',10,'Bold'))
runArray.appendRun(10,fontFactory.getFontObj('Times New Roman',10,'Bold'))
runArray.addRun(3,6,fontFactory.getFontObj('Verdana',15,'Italic'))
runArray.appendRun(15,fontFactory.getFontObj('Calibri',8,'Underline'))
'''
Prints the object size with Flyweight pattern
'''
print("Object size using Flyweight: ", SizeCheck.getSize(charFactoryObject,charFlyweightObject,fontFactory,runArray))
'''
Prints the object size without flyweight pattern
'''
print("Object size without using Flyweight: ",SizeCheck.checkSize('A'))