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)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
19 #include "lib/test/run.hpp"
20 #include "lib/format-cout.hpp"
21 #include "lib/format-string.hpp"
22 #include "lib/util.hpp"
23 
24 #include "steam/asset/category.hpp"
25 
26 
27 using util::_Fmt;
28 using util::isnil;
29 using std::string;
30 
31 
32 namespace steam {
33 namespace asset{
34 namespace test {
35 
36 
37 
38 
39  /*******************************************************************/
45  class AssetCategory_test : public Test
46  {
47  virtual void run(Arg)
48  {
49  createCategory();
50  containmentQuery();
51  ordering();
52  }
53 
54 
55 
56 
57  void createCategory()
58  {
59  Category c1 (AUDIO);
60  Category c2 (VIDEO,"bin1");
61  Category c3 (VIDEO,"bin1/subbin");
62  Category c4 (EFFECT,"some_kind");
63 
64  _Fmt fmt ("Category: %s");
65 
66  cout << fmt % c1 << "\n";
67  cout << fmt % c2 << "\n";
68  cout << fmt % c3 << "\n";
69  cout << fmt % c4 << "\n";
70  }
71 
72 
73  void containmentQuery()
74  {
75  Category c1 (VIDEO);
76  Category c2 (VIDEO,"bin1");
77  Category c3 (VIDEO,"bin1/subbin");
78  Category c4 (EFFECT,"some_kind");
79 
80  CHECK ( c1.hasKind(VIDEO) );
81  CHECK (!c1.hasKind(AUDIO) );
82  CHECK ( c2.isWithin(c1) );
83  CHECK ( c3.isWithin(c2) );
84  CHECK ( c3.isWithin(c1) );
85  CHECK (!c1.isWithin(c2) );
86  CHECK (!c2.isWithin(c3) );
87  CHECK (!c1.isWithin(c3) );
88  CHECK (!c3.isWithin(c4) );
89  CHECK (!c4.isWithin(c3) );
90  }
91 
92 
93  void ordering()
94  {
95  Category c1 (AUDIO);
96  Category c2 (VIDEO);
97  Category c3 (EFFECT);
98  Category c4 (CODEC);
99  Category c5 (STRUCT);
100  Category c6 (META);
101 
102  CHECK (0 > c1.compare(c2));
103  CHECK (0 > c2.compare(c3));
104  CHECK (0 > c3.compare(c4));
105  CHECK (0 > c4.compare(c5));
106  CHECK (0 > c5.compare(c6));
107 
108  CHECK (0 ==c1.compare(c1));
109  CHECK (0 > c1.compare(c6));
110 
111  Category c21 (VIDEO,"bin1");
112  Category c22 (VIDEO,"bin2");
113  Category c23 (VIDEO,"bin2/sub");
114 
115  CHECK (0 > c1.compare(c21));
116  CHECK (0 > c2.compare(c21));
117  CHECK (0 < c22.compare(c21));
118  CHECK (0 < c23.compare(c22));
119  CHECK (0 < c23.compare(c21));
120  CHECK ( 0==c22.compare(c22));
121 
122 
123  CHECK ( c2 == c2 );
124  CHECK ( c2 != c22 );
125  CHECK ( c2 != c3 );
126  }
127  };
128 
129 
131  LAUNCHER (AssetCategory_test, "unit asset");
132 
133 
134 
135 }}} // namespace steam::asset::test
bool isWithin(Category const &) const
hierarchical inclusion test.
Definition: category.cpp:60
Automatically use custom string conversion in C++ stream output.
Tree like classification of Assets.
Definition: category.hpp:66
Definition: run.hpp:40
Front-end for printf-style string template interpolation.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Simplistic 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:35
Definition of Asset categorisation.