PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/tests/llallocator_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 80 lines | 41 code | 10 blank | 29 comment | 0 complexity | 30c19b66213603c9a202c09b0b081c63 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llallocator_test.cpp
  3. * @author Brad Kittenbrink
  4. * @date 2008-02-
  5. * @brief Test for llallocator.cpp.
  6. *
  7. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "../llallocator.h"
  29. #include "../test/lltut.h"
  30. namespace tut
  31. {
  32. struct llallocator_data
  33. {
  34. LLAllocator llallocator;
  35. };
  36. typedef test_group<llallocator_data> factory;
  37. typedef factory::object object;
  38. }
  39. namespace
  40. {
  41. tut::factory llallocator_test_factory("LLAllocator");
  42. }
  43. namespace tut
  44. {
  45. template<> template<>
  46. void object::test<1>()
  47. {
  48. llallocator.setProfilingEnabled(false);
  49. ensure("Profiler disable", !llallocator.isProfiling());
  50. }
  51. #if LL_USE_TCMALLOC
  52. template<> template<>
  53. void object::test<2>()
  54. {
  55. llallocator.setProfilingEnabled(true);
  56. ensure("Profiler enable", llallocator.isProfiling());
  57. }
  58. template <> template <>
  59. void object::test<3>()
  60. {
  61. llallocator.setProfilingEnabled(true);
  62. char * test_alloc = new char[1024];
  63. llallocator.getProfile();
  64. delete [] test_alloc;
  65. llallocator.getProfile();
  66. // *NOTE - this test isn't ensuring anything right now other than no
  67. // exceptions are thrown.
  68. }
  69. #endif // LL_USE_TCMALLOC
  70. };