Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: tools/json_schema_compiler/cpp_util_test.py

Issue 437883002: Make the root_namespace argument to json_schema_compiler.gypi a string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-escape %% for windows Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import cpp_util
7 import unittest 6 import unittest
8 7
8 from cpp_util import (
9 Classname, CloseNamespace, GenerateIfndefName, OpenNamespace)
10
9 class CppUtilTest(unittest.TestCase): 11 class CppUtilTest(unittest.TestCase):
10 def testClassname(self): 12 def testClassname(self):
11 self.assertEquals('Permissions', cpp_util.Classname('permissions')) 13 self.assertEquals('Permissions', Classname('permissions'))
12 self.assertEquals('UpdateAllTheThings', 14 self.assertEquals('UpdateAllTheThings',
13 cpp_util.Classname('updateAllTheThings')) 15 Classname('updateAllTheThings'))
14 self.assertEquals('Aa_Bb_Cc', cpp_util.Classname('aa.bb.cc')) 16 self.assertEquals('Aa_Bb_Cc', Classname('aa.bb.cc'))
15 17
16 def testNamespaceDeclaration(self): 18 def testNamespaceDeclaration(self):
17 self.assertEquals('namespace extensions {', 19 self.assertEquals('namespace foo {',
18 cpp_util.OpenNamespace('extensions').Render()) 20 OpenNamespace('foo').Render())
19 self.assertEquals('} // namespace extensions', 21 self.assertEquals('} // namespace foo',
20 cpp_util.CloseNamespace('extensions').Render()) 22 CloseNamespace('foo').Render())
21 self.assertEquals('namespace extensions {\n' 23
22 'namespace gen {\n' 24 self.assertEquals(
23 'namespace api {', 25 'namespace extensions {\n'
24 cpp_util.OpenNamespace('extensions::gen::api').Render()) 26 'namespace foo {',
25 self.assertEquals('} // namespace api\n' 27 OpenNamespace('extensions::foo').Render())
26 '} // namespace gen\n' 28 self.assertEquals(
27 '} // namespace extensions', 29 '} // namespace foo\n'
28 cpp_util.CloseNamespace('extensions::gen::api').Render()) 30 '} // namespace extensions',
31 CloseNamespace('extensions::foo').Render())
32
33 self.assertEquals(
34 'namespace extensions {\n'
35 'namespace gen {\n'
36 'namespace api {',
37 OpenNamespace('extensions::gen::api').Render())
38 self.assertEquals(
39 '} // namespace api\n'
40 '} // namespace gen\n'
41 '} // namespace extensions',
42 CloseNamespace('extensions::gen::api').Render())
43
44 self.assertEquals(
45 'namespace extensions {\n'
46 'namespace gen {\n'
47 'namespace api {\n'
48 'namespace foo {',
49 OpenNamespace('extensions::gen::api::foo').Render())
50 self.assertEquals(
51 '} // namespace foo\n'
52 '} // namespace api\n'
53 '} // namespace gen\n'
54 '} // namespace extensions',
55 CloseNamespace('extensions::gen::api::foo').Render())
56
57 def testGenerateIfndefName(self):
58 self.assertEquals('FOO_BAR_BAZ_H__', GenerateIfndefName('foo\\bar\\baz.h'))
59 self.assertEquals('FOO_BAR_BAZ_H__', GenerateIfndefName('foo/bar/baz.h'))
60
29 61
30 if __name__ == '__main__': 62 if __name__ == '__main__':
31 unittest.main() 63 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698