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
4 # found in the LICENSE file.
9 Classname
, CloseNamespace
, GenerateIfndefName
, OpenNamespace
)
11 class CppUtilTest(unittest
.TestCase
):
12 def testClassname(self
):
13 self
.assertEquals('Permissions', Classname('permissions'))
14 self
.assertEquals('UpdateAllTheThings',
15 Classname('updateAllTheThings'))
16 self
.assertEquals('Aa_Bb_Cc', Classname('aa.bb.cc'))
18 def testNamespaceDeclaration(self
):
19 self
.assertEquals('namespace foo {',
20 OpenNamespace('foo').Render())
21 self
.assertEquals('} // namespace foo',
22 CloseNamespace('foo').Render())
25 'namespace extensions {\n'
27 OpenNamespace('extensions::foo').Render())
29 '} // namespace foo\n'
30 '} // namespace extensions',
31 CloseNamespace('extensions::foo').Render())
34 'namespace extensions {\n'
37 OpenNamespace('extensions::gen::api').Render())
39 '} // namespace api\n'
40 '} // namespace gen\n'
41 '} // namespace extensions',
42 CloseNamespace('extensions::gen::api').Render())
45 'namespace extensions {\n'
49 OpenNamespace('extensions::gen::api::foo').Render())
51 '} // namespace foo\n'
52 '} // namespace api\n'
53 '} // namespace gen\n'
54 '} // namespace extensions',
55 CloseNamespace('extensions::gen::api::foo').Render())
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'))
62 if __name__
== '__main__':