Lumiera  0.pre.03
»edit your freedom«
ordering-of-assets-test.cpp
Go to the documentation of this file.
1 /*
2  OrderingOfAssets(Test) - equality and comparisons
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/util.hpp"
30 
31 #include "steam/assetmanager.hpp"
32 #include "steam/asset/media.hpp"
33 #include "steam/asset/proc.hpp"
34 
37 #include "lib/depend-inject.hpp"
38 
39 using util::isnil;
40 using std::string;
41 
42 
43 namespace steam {
44 namespace asset{
45 namespace test {
46 
47  using MediaAccessMock = lib::DependInject<vault::MediaAccessFacade>
48  ::Local<vault::test::MediaAccessMock>;
49 
50 
51 
52 
53  /**************************************************/
66  class OrderingOfAssets_test : public Test
67  {
68  virtual void run(Arg)
69  {
70  MediaAccessMock useMockMedia;
71 
72 
73  Asset::Ident key1("test-1", Category(AUDIO), "ichthyo", 5);
74  PAsset mm1 = asset::Media::create(key1, "Name-1");
75 
76  Asset::Ident key2("test-1", Category(AUDIO), "ichthyo", 7);
77  PAsset mm2 = asset::Media::create(key2, "Name-2");
78 
79  Asset::Ident key3("test-2", Category(AUDIO), "ichthyo", 5);
80  PAsset mm3 = asset::Media::create(key3, "Name-3");
81 
82  Asset::Ident key4("test-2", Category(AUDIO), "stega", 5);
83  PAsset mm4 = asset::Media::create(key4, "Name-4");
84 
85  Asset::Ident key5("test-1", Category(VIDEO), "ichthyo", 5);
86  PAsset mm5 = asset::Media::create(key5, "Name-5");
87 
88 
89  // ordering of keys
90  CHECK (key1 == key2);
91  CHECK (key2 != key3);
92  CHECK (key3 != key4);
93  CHECK (key4 != key5);
94  CHECK (key1 != key5);
95 
96  CHECK ( 0 > key2.compare(key3));
97  CHECK ( 0 < key3.compare(key2));
98 
99  CHECK ( 0 > key3.compare(key4));
100  CHECK ( 0 > key4.compare(key5));
101  CHECK ( 0 > key1.compare(key5));
102  CHECK ( 0 > key2.compare(key5));
103  CHECK ( 0 > key3.compare(key5));
104  CHECK ( 0 > key1.compare(key3));
105  CHECK ( 0 > key1.compare(key4));
106  CHECK ( 0 > key2.compare(key4));
107 
108 
109  // ordering of Asset smart ptrs
110  CHECK (mm1 == mm2);
111  CHECK (mm2 != mm3);
112  CHECK (mm3 != mm4);
113  CHECK (mm4 != mm5);
114  CHECK (mm1 != mm5);
115 
116  CHECK (mm2 < mm3);
117  CHECK (mm2 <= mm3);
118  CHECK (mm3 > mm2);
119  CHECK (mm3 >= mm2);
120 
121  CHECK (mm3 < mm4);
122  CHECK (mm4 < mm5);
123  CHECK (mm1 < mm5);
124  CHECK (mm2 < mm5);
125  CHECK (mm3 < mm5);
126  CHECK (mm1 < mm3);
127  CHECK (mm1 < mm4);
128  CHECK (mm2 < mm4);
129 
130  }
131  };
132 
133 
135  LAUNCHER (OrderingOfAssets_test, "unit asset");
136 
137 
138 
139 }}} // namespace steam::asset::test
int compare(Ident const &other) const
ordering of Assets is based on the ordering of Ident tuples, which are supposed to be unique...
Definition: asset.hpp:321
Steam-Layer Interface: Asset Lookup and Organisation.
Media data represented a specific kind of Asset.
Tree like classification of Assets.
Definition: category.hpp:75
Definition: run.hpp:49
Per type specific configuration of instances created as service dependencies.
Unit test helper to access an emulated media file.
static MediaFactory create
storage for the static MediaFactory instance
Definition: media.hpp:84
Steam-Layer implementation namespace root.
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
Data processing Plugins and Codecs can be treated as a specific Kind of Asset.
a POD comprised of all the information sufficiently identifying any given Asset.
Definition: asset.hpp:158
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Small helper and diagnostic functions related to Asset and AssetManager.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:80
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44