Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2007-09-04 13:37:51


Author: asutton
Date: 2007-09-04 13:37:49 EDT (Tue, 04 Sep 2007)
New Revision: 39115
URL: http://svn.boost.org/trac/boost/changeset/39115

Log:
Added a couple of test files

Added:
   sandbox/graph-v2/libs/property_map/test/compile/
   sandbox/graph-v2/libs/property_map/test/compile/compile.cpp (contents, props changed)
   sandbox/graph-v2/libs/property_map/test/compile/identity.cpp (contents, props changed)

Added: sandbox/graph-v2/libs/property_map/test/compile/compile.cpp
==============================================================================
--- (empty file)
+++ sandbox/graph-v2/libs/property_map/test/compile/compile.cpp 2007-09-04 13:37:49 EDT (Tue, 04 Sep 2007)
@@ -0,0 +1,97 @@
+// (C) Andrew Sutton 2007
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <vector>
+#include <map>
+#include <boost/property_map/archetypes.hpp>
+#include <boost/property_map/iterator_property_map.hpp>
+#include <boost/property_map/associative_property_map.hpp>
+#include <boost/property_map/reference_property_map.hpp>
+#include <boost/property_map/constant_property_map.hpp>
+#include <boost/property_map/identity_property_map.hpp>
+#include <boost/property_map/dummy_property_map.hpp>
+
+int main()
+{
+ using namespace std;
+ using namespace boost;
+ using namespace boost::property_map;
+
+ // Use this for the index map for now...
+ typedef size_t Key;
+ typedef size_t Value;
+ Value v;
+ Key k;
+ {
+ typedef vector<Value> Vector;
+ typedef readable_property_map_archetype<Key, Value> IndexMap;
+ typedef iterator_property_map<Vector::iterator, IndexMap> IteratorMap;
+
+ Vector v;
+ IndexMap& indices = static_object<IndexMap>::get();
+ IteratorMap imap = make_iterator_property_map(v.begin(), indices);
+ get(imap, Key());
+ put(imap, Key(), Value());
+ imap[Key()];
+ }
+
+ {
+ typedef vector<Value> Vector;
+ typedef readable_property_map_archetype<Key, Value> IndexMap;
+ typedef safe_iterator_property_map<Vector::iterator, IndexMap> IteratorMap;
+
+ Vector v;
+ IndexMap& indices = static_object<IndexMap>::get();
+ IteratorMap imap = make_safe_iterator_property_map(v.begin(), Key(), indices);
+ get(imap, Key());
+ put(imap, Key(), Value());
+ imap[Key()];
+ }
+
+ {
+ typedef map<Key, Value> Map;
+ typedef associative_property_map<Map> AssociativeMap;
+
+ Map m;
+ AssociativeMap amap = make_associative_property_map(m);
+ get(amap, Key());
+ put(amap, Key(), Value());
+ amap[Key()];
+ }
+
+ {
+ typedef reference_property_map<Key, Value> ReferenceMap;
+
+ ReferenceMap rmap = make_reference_property_map<Key>(v);
+ get(rmap, k);
+ put(rmap, k, v);
+ rmap[k];
+ rmap[k] = v;
+ }
+
+ {
+ typedef constant_property_map<Key, Value> ReferenceMap;
+
+ ReferenceMap rmap = make_constant_property_map<Key>(v);
+ get(rmap, k);
+ }
+
+ {
+ typedef identity_property_map<Value> IdentityMap;
+
+ IdentityMap imap;
+ get(imap, k);
+ imap[k];
+ imap[k] = v;
+ }
+
+ {
+ typedef dummy_property_map<Key, Value> DummyMap;
+
+ DummyMap dmap;
+ put(dmap, k, v);
+ }
+}

Added: sandbox/graph-v2/libs/property_map/test/compile/identity.cpp
==============================================================================
--- (empty file)
+++ sandbox/graph-v2/libs/property_map/test/compile/identity.cpp 2007-09-04 13:37:49 EDT (Tue, 04 Sep 2007)
@@ -0,0 +1,49 @@
+// (C) Andrew Sutton 2007
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/concept_check.hpp>
+#include <boost/property_map/concepts.hpp>
+#include <boost/property_map/archetypes.hpp>
+
+// This is a simple compiler check that feeds archetypes directly into
+// their concept checks. Basically, we're testing the testing tools.
+
+int main()
+{
+ using namespace boost;
+ using namespace boost::property_map;
+
+ // TODO: Are there requirements on the key and value of a property map?
+ // I don't think so - either that or they vary with the intent of the map.
+ // This should be fine for now...
+ typedef int Key;
+ typedef int Value;
+
+ {
+ typedef readable_property_map_archetype<Key, Value> ReadablePropertyMap;
+ function_requires< ReadablePropertyMapConcept<ReadablePropertyMap, Key> >();
+ }
+
+ {
+ typedef writable_property_map_archetype<Key, Value> WritablePropertyMap;
+ function_requires< WritablePropertyMapConcept<WritablePropertyMap, Key> >();
+ }
+
+ {
+ typedef read_write_property_map_archetype<Key, Value> ReadWritePropertyMap;
+ function_requires< ReadWritePropertyMapConcept<ReadWritePropertyMap, Key> >();
+ }
+
+ {
+ typedef lvalue_property_map_archetype<Key, Value> LvaluePropertyMap;
+ function_requires< LvaluePropertyMapConcept<LvaluePropertyMap, Key> >();
+ }
+
+ {
+ typedef mutable_lvalue_property_map_archetype<Key, Value> MutableLvaluePropertyMap;
+ function_requires< MutableLvaluePropertyMapConcept<MutableLvaluePropertyMap, Key> >();
+ }
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk