summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-17 17:00:29 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-17 17:00:29 +0200
commit27f48694bf3e54d822e3283d608f70462ec3beae (patch)
tree39f8eb1535ae148f0eff2014f5cd5f7888aabd4a /tests
parente48f50f43fea588337116a195fb8a709e1fcd885 (diff)
parent0f1e177277bcc61a123bfa58e77eeb19a573aee6 (diff)
Release 0.0.2HEADmaster
'eoparser' package, with tools 'eorepo' is provided with base classes
Diffstat (limited to 'tests')
-rw-r--r--tests/test_data.in28
-rw-r--r--tests/tests.py98
2 files changed, 126 insertions, 0 deletions
diff --git a/tests/test_data.in b/tests/test_data.in
new file mode 100644
index 0000000..d2512e2
--- /dev/null
+++ b/tests/test_data.in
@@ -0,0 +1,28 @@
1
2#define MY_TEST_CLASS_NAME "test_class_name"
3
4static const Eo_Op_Description _elm_pan_op_desc[] = {
5 EO_OP_DESCRIPTION(ELM_OBJ_PAN_SUB_ID_POS_SET, "description here"),
6 EO_OP_DESCRIPTION(ELM_OBJ_PAN_SUB_ID_POS_GET, "description here"),
7 EO_OP_DESCRIPTION_SENTINEL
8};
9
10static const Eo_Event_Description *event_desc[] = {
11 EO_EV_CALLBACK_ADD,
12 EO_EV_CALLBACK_DEL,
13 EO_EV_DEL,
14 NULL
15};
16
17static const Eo_Class_Description test_class_desc = {
18 EO_VERSION,
19 MY_TEST_CLASS_NAME,
20 EO_CLASS_TYPE_REGULAR,
21 EO_CLASS_DESCRIPTION_OPS(&ELM_OBJ_PAN_BASE_ID, _elm_pan_op_desc, ELM_OBJ_PAN_SUB_ID_LAST),
22 event_desc,
23 sizeof(Elm_Pan_Smart_Data),
24 _elm_pan_class_constructor,
25 NULL
26};
27
28EO_DEFINE_CLASS(class_get, &test_class_desc, parent, brother, NULL)
diff --git a/tests/tests.py b/tests/tests.py
new file mode 100644
index 0000000..35e0f66
--- /dev/null
+++ b/tests/tests.py
@@ -0,0 +1,98 @@
1import unittest
2import os
3from eoparser.xmlparser import XMLparser
4from eoparser.cparser import Cparser
5from eoparser.helper import dir_files_get, abs_path_get, isC, isH, isXML, normalize_names
6
7class testP(unittest.TestCase):
8
9 def setUp(self):
10 self.c_parser = Cparser(False)
11
12 def test_fetch_data(self):
13 f = open('test_data.in', 'r')
14 s = f.read()
15 f.close()
16
17 class_def_answer = {"class_get" : ["parent",
18 ["brother"],
19 "test_class_name",
20 "EO_CLASS_TYPE_REGULAR",
21 ["ELM_OBJ_PAN_BASE_ID",
22 [("ELM_OBJ_PAN_SUB_ID_POS_SET", "pos_set"),
23 ("ELM_OBJ_PAN_SUB_ID_POS_GET", "pos_get")],
24 "ELM_OBJ_PAN_SUB_ID_LAST"],
25 ["EO_EV_CALLBACK_ADD", "EO_EV_CALLBACK_DEL", "EO_EV_DEL"]
26 ]}
27 answer = class_def_answer
28
29 ret = self.c_parser.fetch_data(s)
30 self.assertEqual(ret, answer)
31
32 def test_isC(self):
33 self.assertTrue(isC("abc.c"))
34 self.assertTrue(isC("abc.cc"))
35 self.assertTrue(isC("abc.cpp"))
36 self.assertFalse(isC("abc.cp"))
37 self.assertFalse(isC("abc.def.c"))
38 self.assertTrue(isC("/abc/def/file.c"))
39 self.assertTrue(isC("/abc/def2.7/file.c"))
40
41 def test_isH(self):
42 self.assertTrue(isH("abc.h"))
43 self.assertFalse(isH("abc.c"))
44 self.assertFalse(isH("abc.def.h"))
45 self.assertTrue(isH("/abc/def/file.h"))
46 self.assertTrue(isH("/abc/def2.7/file.h"))
47
48 def test_isXML(self):
49 self.assertTrue(isXML("abc.xml"))
50 self.assertFalse(isXML("abc.h"))
51 self.assertFalse(isXML("abc.qwe.xml"))
52 self.assertTrue(isXML("/abc/def/abc.xml"))
53 self.assertTrue(isXML("/abc/py2.7/abc.xml"))
54
55 def test_abs_path_get(self):
56 _in = "test_data.in"
57 _in_list = [_in]
58 _out = _in
59 _out = os.path.expanduser(_out)
60 _out = os.path.abspath(_out)
61
62 self.assertEqual(abs_path_get(_in_list), [_out])
63
64 def test_normalize_names(self):
65 _in = ["hello world", "elm_Box", "evas Object-SmaRt", "EvAs-common InTeRface"]
66 _out = ["HelloWorld", "ElmBox", "EvasObjectSmart", "EvasCommonInterface"]
67
68 self.assertEqual(normalize_names(_in), _out)
69
70
71 def test_get_param_dir_from_comment(self):
72 s = """
73 @param[in,out] a
74 @param[in] a
75 @param[out] a
76 parem[in]
77 @param [in] a
78 @param [out] a
79 @param[in, out] a
80 @param in
81 @param [ in ]
82 @param [ out, in ]
83 @param sdf [ out ]
84 """
85 _out = ["in,out", "in", "out", "in", "out", "in,out", "in,out", "in", "in,out", "in,out"]
86 ret = self.c_parser.get_param_dir_from_comment(s)
87 self.assertEqual(ret, _out)
88
89
90
91def suite():
92 suite = unittest.TestSuite()
93 suite.addTest(unittest.makeSuite(testP))
94 return suite
95
96if __name__ == '__main__':
97
98 unittest.main()