forked from sigasi/SigasiProjectCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibraryMappingFileCreatorTest.py
56 lines (50 loc) · 2.67 KB
/
LibraryMappingFileCreatorTest.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
# -*- coding: utf-8 -*-
"""
:copyright: (c) 2008-2013 Sigasi
:license: BSD, see LICENSE for more details.
"""
import unittest
from SigasiProjectCreator import LibraryMappingFileCreator
class LibraryMappingFileCreatorTest(unittest.TestCase):
def test_empty_file(self):
creator = LibraryMappingFileCreator()
expected = '''<?xml version="1.0" encoding="UTF-8"?>
<com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings xmlns:com.sigasi.hdt.vhdl.scoping.librarymapping.model="com.sigasi.hdt.vhdl.scoping.librarymapping" Version="2">
<Mappings Location="Common Libraries" Library="not mapped"/>
<Mappings Location="Common Libraries/IEEE" Library="ieee"/>
<Mappings Location="Common Libraries/IEEE Synopsys" Library="ieee"/>
<Mappings Location="Common Libraries/STD" Library="std"/>
</com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings>
'''
self.assertEqual(str(creator), expected)
def test_simple_mapping(self):
creator = LibraryMappingFileCreator()
expected = '''<?xml version="1.0" encoding="UTF-8"?>
<com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings xmlns:com.sigasi.hdt.vhdl.scoping.librarymapping.model="com.sigasi.hdt.vhdl.scoping.librarymapping" Version="2">
<Mappings Location="" Library="not mapped"/>
<Mappings Location="Common Libraries" Library="not mapped"/>
<Mappings Location="Common Libraries/IEEE" Library="ieee"/>
<Mappings Location="Common Libraries/IEEE Synopsys" Library="ieee"/>
<Mappings Location="Common Libraries/STD" Library="std"/>
<Mappings Location="test.vhd" Library="work"/>
</com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings>
'''
creator.add_mapping("test.vhd", "work")
creator.add_mapping("", "not mapped")
self.assertEqual(str(creator), expected)
def test_duplicate_mapping(self):
creator = LibraryMappingFileCreator()
expected = '''<?xml version="1.0" encoding="UTF-8"?>
<com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings xmlns:com.sigasi.hdt.vhdl.scoping.librarymapping.model="com.sigasi.hdt.vhdl.scoping.librarymapping" Version="2">
<Mappings Location="Common Libraries" Library="not mapped"/>
<Mappings Location="Common Libraries/IEEE" Library="ieee"/>
<Mappings Location="Common Libraries/IEEE Synopsys" Library="ieee"/>
<Mappings Location="Common Libraries/STD" Library="std"/>
<Mappings Location="test.vhd" Library="work"/>
</com.sigasi.hdt.vhdl.scoping.librarymapping.model:LibraryMappings>
'''
creator.add_mapping("test.vhd", "test")
creator.add_mapping("test.vhd", "work")
self.assertEqual(str(creator), expected)
if __name__ == '__main__':
unittest.main()