PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 6ms 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
 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
29#include "../llallocator.h"
30#include "../test/lltut.h"
31
32namespace tut
33{
34    struct llallocator_data
35    {
36        LLAllocator llallocator;
37    };
38    typedef test_group<llallocator_data> factory;
39    typedef factory::object object;
40}
41namespace
42{
43        tut::factory llallocator_test_factory("LLAllocator");
44}
45
46namespace tut
47{
48    template<> template<>
49    void object::test<1>()
50    {
51        llallocator.setProfilingEnabled(false);
52        ensure("Profiler disable", !llallocator.isProfiling());
53    }
54
55#if LL_USE_TCMALLOC
56    template<> template<>
57    void object::test<2>()
58    {
59        llallocator.setProfilingEnabled(true);
60        ensure("Profiler enable", llallocator.isProfiling());
61    }
62
63    template <> template <>
64    void object::test<3>()
65    {
66        llallocator.setProfilingEnabled(true);
67
68        char * test_alloc = new char[1024];
69
70        llallocator.getProfile();
71
72        delete [] test_alloc;
73
74        llallocator.getProfile();        
75
76        // *NOTE - this test isn't ensuring anything right now other than no
77        // exceptions are thrown.
78    }
79#endif // LL_USE_TCMALLOC
80};