Lumiera  0.pre.03
»edit your freedom«
asset-category-test.cpp
Go to the documentation of this file.
1 /*
2  AssetCategory(Test) - verifying Asset category tuple functions
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
28 #include "lib/test/run.hpp"
29 #include "lib/format-cout.hpp"
30 #include "lib/format-string.hpp"
31 #include "lib/util.hpp"
32 
33 #include "steam/asset/category.hpp"
34 
35 
36 using util::_Fmt;
37 using util::isnil;
38 using std::string;
39 
40 
41 namespace steam {
42 namespace asset{
43 namespace test {
44 
45 
46 
47 
48  /*******************************************************************/
54  class AssetCategory_test : public Test
55  {
56  virtual void run(Arg)
57  {
58  createCategory();
59  containmentQuery();
60  ordering();
61  }
62 
63 
64 
65 
66  void createCategory()
67  {
68  Category c1 (AUDIO);
69  Category c2 (VIDEO,"bin1");
70  Category c3 (VIDEO,"bin1/subbin");
71  Category c4 (EFFECT,"some_kind");
72 
73  _Fmt fmt ("Category: %s");
74 
75  cout << fmt % c1 << "\n";
76  cout << fmt % c2 << "\n";
77  cout << fmt % c3 << "\n";
78  cout << fmt % c4 << "\n";
79  }
80 
81 
82  void containmentQuery()
83  {
84  Category c1 (VIDEO);
85  Category c2 (VIDEO,"bin1");
86  Category c3 (VIDEO,"bin1/subbin");
87  Category c4 (EFFECT,"some_kind");
88 
89  CHECK ( c1.hasKind(VIDEO) );
90  CHECK (!c1.hasKind(AUDIO) );
91  CHECK ( c2.isWithin(c1) );
92  CHECK ( c3.isWithin(c2) );
93  CHECK ( c3.isWithin(c1) );
94  CHECK (!c1.isWithin(c2) );
95  CHECK (!c2.isWithin(c3) );
96  CHECK (!c1.isWithin(c3) );
97  CHECK (!c3.isWithin(c4) );
98  CHECK (!c4.isWithin(c3) );
99  }
100 
101 
102  void ordering()
103  {
104  Category c1 (AUDIO);
105  Category c2 (VIDEO);
106  Category c3 (EFFECT);
107  Category c4 (CODEC);
108  Category c5 (STRUCT);
109  Category c6 (META);
110 
111  CHECK (0 > c1.compare(c2));
112  CHECK (0 > c2.compare(c3));
113  CHECK (0 > c3.compare(c4));
114  CHECK (0 > c4.compare(c5));
115  CHECK (0 > c5.compare(c6));
116 
117  CHECK (0 ==c1.compare(c1));
118  CHECK (0 > c1.compare(c6));
119 
120  Category c21 (VIDEO,"bin1");
121  Category c22 (VIDEO,"bin2");
122  Category c23 (VIDEO,"bin2/sub");
123 
124  CHECK (0 > c1.compare(c21));
125  CHECK (0 > c2.compare(c21));
126  CHECK (0 < c22.compare(c21));
127  CHECK (0 < c23.compare(c22));
128  CHECK (0 < c23.compare(c21));
129  CHECK ( 0==c22.compare(c22));
130 
131 
132  CHECK ( c2 == c2 );
133  CHECK ( c2 != c22 );
134  CHECK ( c2 != c3 );
135  }
136  };
137 
138 
140  LAUNCHER (AssetCategory_test, "unit asset");
141 
142 
143 
144 }}} // namespace steam::asset::test
bool isWithin(Category const &) const
hierarchical inclusion test.
Definition: category.cpp:69
Automatically use custom string conversion in C++ stream output.
Tree like classification of Assets.
Definition: category.hpp:75
Definition: run.hpp:49
Front-end for printf-style string template interpolation.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44
Definition of Asset categorisation.