Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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
25
26
27using util::_Fmt;
28using util::isnil;
29using std::string;
30
31
32namespace steam {
33namespace asset{
34namespace test {
35
36
37
38
39 /*******************************************************************/
45 class AssetCategory_test : public Test
46 {
47 virtual void
48 run(Arg)
49 {
52 ordering();
53 }
54
55
56
57
59 {
60 Category c1 (AUDIO);
61 Category c2 (VIDEO,"bin1");
62 Category c3 (VIDEO,"bin1/subbin");
63 Category c4 (EFFECT,"some_kind");
64
65 _Fmt fmt ("Category: %s");
66
67 cout << fmt % c1 << "\n";
68 cout << fmt % c2 << "\n";
69 cout << fmt % c3 << "\n";
70 cout << fmt % c4 << "\n";
71 }
72
73
75 {
76 Category c1 (VIDEO);
77 Category c2 (VIDEO,"bin1");
78 Category c3 (VIDEO,"bin1/subbin");
79 Category c4 (EFFECT,"some_kind");
80
81 CHECK ( c1.hasKind(VIDEO) );
82 CHECK (!c1.hasKind(AUDIO) );
83 CHECK ( c2.isWithin(c1) );
84 CHECK ( c3.isWithin(c2) );
85 CHECK ( c3.isWithin(c1) );
86 CHECK (!c1.isWithin(c2) );
87 CHECK (!c2.isWithin(c3) );
88 CHECK (!c1.isWithin(c3) );
89 CHECK (!c3.isWithin(c4) );
90 CHECK (!c4.isWithin(c3) );
91 }
92
93
94 void ordering()
95 {
96 Category c1 (AUDIO);
97 Category c2 (VIDEO);
98 Category c3 (EFFECT);
99 Category c4 (CODEC);
100 Category c5 (STRUCT);
101 Category c6 (META);
102
103 CHECK (0 > c1 <=> c2 );
104 CHECK (0 > c2 <=> c3 );
105 CHECK (0 > c3 <=> c4 );
106 CHECK (0 > c4 <=> c5 );
107 CHECK (0 > c5 <=> c6 );
108
109 CHECK (0 ==c1 <=> c1 );
110 CHECK (0 > c1 <=> c6 );
111
112 Category c21 (VIDEO,"bin1");
113 Category c22 (VIDEO,"bin2");
114 Category c23 (VIDEO,"bin2/sub");
115
116 CHECK (0 > c1 <=> c21 );
117 CHECK (0 > c2 <=> c21 );
118 CHECK (0 < c22 <=> c21 );
119 CHECK (0 < c23 <=> c22 );
120 CHECK (0 < c23 <=> c21 );
121 CHECK (0 ==c22 <=> c22 );
122
123
124 CHECK ( c2 == c2 );
125 CHECK ( c2 != c22 );
126 CHECK ( c2 != c3 );
127 }
128 };
129
130
133
134
135
136}}} // namespace steam::asset::test
Definition of Asset categorisation.
Tree like classification of Assets.
Definition category.hpp:68
bool isWithin(Category const &) const
hierarchical inclusion test.
Definition category.cpp:60
bool hasKind(Kind refKind) const
Definition category.hpp:79
A front-end for using printf-style formatting.
Automatically use custom string conversion in C++ stream output.
Front-end for printf-style string template interpolation.
The asset subsystem of the Steam-Layer.
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...