• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
5
6import cpp_util
7import unittest
8
9class CppUtilTest(unittest.TestCase):
10  def testClassname(self):
11    self.assertEquals('Permissions', cpp_util.Classname('permissions'))
12    self.assertEquals('UpdateAllTheThings',
13        cpp_util.Classname('updateAllTheThings'))
14    self.assertEquals('Aa_Bb_Cc', cpp_util.Classname('aa.bb.cc'))
15
16  def testNamespaceDeclaration(self):
17    self.assertEquals('namespace extensions {',
18                      cpp_util.OpenNamespace('extensions').Render())
19    self.assertEquals('}  // namespace extensions',
20                      cpp_util.CloseNamespace('extensions').Render())
21    self.assertEquals('namespace extensions {\n'
22                      'namespace gen {\n'
23                      'namespace api {',
24                      cpp_util.OpenNamespace('extensions::gen::api').Render())
25    self.assertEquals('}  // namespace api\n'
26                      '}  // namespace gen\n'
27                      '}  // namespace extensions',
28                      cpp_util.CloseNamespace('extensions::gen::api').Render())
29
30if __name__ == '__main__':
31  unittest.main()
32