PageRenderTime 100ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llcommon/tests/llmemtype_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 117 lines | 70 code | 16 blank | 31 comment | 0 complexity | 68466e57cd564cc45e98ef16909bcc0e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmemtype_test.cpp
  3. * @author Palmer Truelson
  4. * @date 2008-03-
  5. * @brief Test for llmemtype.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 "../llmemtype.h"
  29. #include "../test/lltut.h"
  30. #include "../llallocator.h"
  31. #include <stack>
  32. std::stack<S32> memTypeStack;
  33. void LLAllocator::pushMemType(S32 i)
  34. {
  35. memTypeStack.push(i);
  36. }
  37. S32 LLAllocator::popMemType(void)
  38. {
  39. S32 ret = memTypeStack.top();
  40. memTypeStack.pop();
  41. return ret;
  42. }
  43. namespace tut
  44. {
  45. struct llmemtype_data
  46. {
  47. };
  48. typedef test_group<llmemtype_data> factory;
  49. typedef factory::object object;
  50. }
  51. namespace
  52. {
  53. tut::factory llmemtype_test_factory("LLMemType");
  54. }
  55. namespace tut
  56. {
  57. template<> template<>
  58. void object::test<1>()
  59. {
  60. ensure("Simplest test ever", true);
  61. }
  62. // test with no scripts
  63. template<> template<>
  64. void object::test<2>()
  65. {
  66. {
  67. LLMemType m1(LLMemType::MTYPE_INIT);
  68. }
  69. ensure("Test that you can construct and destruct the mem type");
  70. }
  71. // test creation and stack testing
  72. template<> template<>
  73. void object::test<3>()
  74. {
  75. {
  76. ensure("Test that creation and destruction properly inc/dec the stack");
  77. ensure_equals(memTypeStack.size(), 0);
  78. {
  79. LLMemType m1(LLMemType::MTYPE_INIT);
  80. ensure_equals(memTypeStack.size(), 1);
  81. LLMemType m2(LLMemType::MTYPE_STARTUP);
  82. ensure_equals(memTypeStack.size(), 2);
  83. }
  84. ensure_equals(memTypeStack.size(), 0);
  85. }
  86. }
  87. // test with no scripts
  88. template<> template<>
  89. void object::test<4>()
  90. {
  91. // catch the begining and end
  92. std::string test_name = LLMemType::getNameFromID(LLMemType::MTYPE_INIT.mID);
  93. ensure_equals("Init name", test_name, "Init");
  94. std::string test_name2 = LLMemType::getNameFromID(LLMemType::MTYPE_VOLUME.mID);
  95. ensure_equals("Volume name", test_name2, "Volume");
  96. std::string test_name3 = LLMemType::getNameFromID(LLMemType::MTYPE_OTHER.mID);
  97. ensure_equals("Other name", test_name3, "Other");
  98. std::string test_name4 = LLMemType::getNameFromID(-1);
  99. ensure_equals("Invalid name", test_name4, "INVALID");
  100. }
  101. };