Line data Source code
1 : // Copyright (c) 2006-2021 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/snaplogger
4 : // contact@m2osw.com
5 : //
6 : // This program is free software; you can redistribute it and/or modify
7 : // it under the terms of the GNU General Public License as published by
8 : // the Free Software Foundation; either version 2 of the License, or
9 : // (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License along
17 : // with this program; if not, write to the Free Software Foundation, Inc.,
18 : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 :
20 : // self
21 : //
22 : #include "main.h"
23 :
24 :
25 : // snaplogger lib
26 : //
27 : #include <snaplogger/component.h>
28 :
29 :
30 :
31 :
32 :
33 :
34 3 : CATCH_TEST_CASE("component", "[component]")
35 : {
36 2 : CATCH_START_SECTION("Make sure creating component generates unique entries")
37 : {
38 : // this worked from the start since the private logger instance
39 : // uses a map to store the components
40 : //
41 30 : struct name_ptr
42 : {
43 : typedef std::vector<name_ptr> vector_t;
44 :
45 : std::string f_name = std::string();
46 : snaplogger::component::pointer_t
47 : f_component = snaplogger::component::pointer_t();
48 : };
49 1 : name_ptr::vector_t names =
50 : {
51 : { "component1", },
52 : { "component2", },
53 : { "component3", },
54 : { "component4", },
55 : { "component5", },
56 : { "component6", },
57 : { "component7", },
58 : { "component8", },
59 : { "component9", },
60 : { "component10", },
61 2 : };
62 :
63 : // create the components
64 : //
65 11 : for(auto & p : names)
66 : {
67 10 : p.f_component = snaplogger::get_component(p.f_name);
68 : }
69 :
70 : // verify the component pointers
71 : //
72 11 : for(auto & p : names)
73 : {
74 10 : CATCH_REQUIRE(p.f_component == snaplogger::get_component(p.f_name));
75 : }
76 : }
77 : CATCH_END_SECTION()
78 7 : }
79 :
80 :
81 :
82 : // vim: ts=4 sw=4 et
|