Screen Orientation Controller allow rotation for some orientations
[chromium-blink-merge.git] / tools / json_schema_compiler / cpp_util_test.py
blobeef4c554b5333d1ecdd976014af347c7973c38d7
1 #!/usr/bin/env python
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.
6 import unittest
8 from cpp_util import (
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())
24 self.assertEquals(
25 'namespace extensions {\n'
26 'namespace foo {',
27 OpenNamespace('extensions::foo').Render())
28 self.assertEquals(
29 '} // namespace foo\n'
30 '} // namespace extensions',
31 CloseNamespace('extensions::foo').Render())
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())
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())
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__':
63 unittest.main()