Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add test by BBv2.

  • Loading branch information...
commit a2c7201a3735d1dbd8cf97d48a1603b0d0631c68 1 parent 9d9d3e4
Akira Takahashi authored March 14, 2011
6  Jamrules
... ...
@@ -0,0 +1,6 @@
  1
+#  Copyright Shunsuke Sogame 2005-2007.
  2
+#  Use, modification, and distribution are subject to the
  3
+#  Boost Software License, Version 1.0. (See accompanying file
  4
+#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5
+
  6
+# For some reason, bjam needs this file.
26  boost-build.jam
... ...
@@ -0,0 +1,26 @@
  1
+#  Copyright Shunsuke Sogame 2005-2007.
  2
+#  Use, modification, and distribution are subject to the
  3
+#  Boost Software License, Version 1.0. (See accompanying file
  4
+#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5
+
  6
+# Thanks to:
  7
+#
  8
+# Hamigaki Library build settings
  9
+
  10
+#  Copyright Takeshi Mouri 2006, 2007.
  11
+#  Use, modification, and distribution are subject to the
  12
+#  Boost Software License, Version 1.0. (See accompanying file
  13
+#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  14
+
  15
+# Original Copyright
  16
+# ============================================================================>
  17
+#~ Copyright (C) 2002-2003, David Abrahams.
  18
+#~ Copyright (C) 2002-2003, Vladimir Prus.
  19
+#~ Copyright (C) 2003, Rene Rivera.
  20
+#~ Use, modification and distribution are subject to the
  21
+#~ Boost Software License, Version 1.0. (See accompanying file
  22
+#~ LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  23
+# <============================================================================
  24
+
  25
+PSTADE_ROOT = $(.boost-build-file:D) ;
  26
+boost-build $(BOOST_ROOT)/tools/build/v2 ;
49  libs/range/test/Jamfile.v2
... ...
@@ -0,0 +1,49 @@
  1
+# Boost.Range 2.0 Extension library
  2
+# via PStade Oven Library
  3
+#
  4
+# Copyright Akira Takahashi 2011.
  5
+# Copyright Shunsuke Sogame 2005-2007.
  6
+# Use, modification and distribution is subject to the Boost Software License,
  7
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+# http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+# bring in rules for testing
  11
+import testing ;
  12
+
  13
+project
  14
+	: requirements
  15
+		<link>static
  16
+		<threading>multi
  17
+	;
  18
+
  19
+rule range-test ( name : includes * )
  20
+{
  21
+    return [
  22
+        run $(name).cpp
  23
+        :
  24
+        :
  25
+        : <toolset>gcc:<cxxflags>"-Wall -Wunused"
  26
+        ] ;
  27
+}
  28
+
  29
+test-suite range_extension :
  30
+	[ range-test adaptor_test/dropped ]
  31
+	[ range-test adaptor_test/dropped_while ]
  32
+	[ range-test adaptor_test/elements ]
  33
+	[ range-test adaptor_test/elements_key ]
  34
+	[ range-test adaptor_test/outdirected ]
  35
+	[ range-test adaptor_test/taken ]
  36
+	[ range-test adaptor_test/taken_while ]
  37
+	[ range-test access_test/at ]
  38
+	[ range-test access_test/back ]
  39
+	[ range-test access_test/front ]
  40
+#    [ range-test directory_range ]
  41
+	[ range-test iteration ]
  42
+	[ range-test member_select_example ]
  43
+	[ range-test regular ]
  44
+	[ range-test regular_example ]
  45
+	[ range-test regular_operator_example ]
  46
+	[ range-test single ]
  47
+	[ range-test split_at ]
  48
+    ;
  49
+
72  libs/range/test/directory_range.cpp
... ...
@@ -0,0 +1,72 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#include <iostream>
  11
+#include <boost/detail/lightweight_test.hpp>
  12
+
  13
+#include <boost/range/directory_range.hpp>
  14
+
  15
+#include <vector>
  16
+#include <string>
  17
+#include <boost/assign/list_of.hpp>
  18
+#include <boost/range/begin.hpp>
  19
+#include <boost/range/end.hpp>
  20
+#include <boost/range/algorithm/for_each.hpp>
  21
+#include <boost/range/algorithm/find.hpp>
  22
+
  23
+template <class InputIterator, class Pred>
  24
+bool all(InputIterator first, InputIterator last, Pred pred)
  25
+{
  26
+    for (; first != last; ++first) {
  27
+        if (!pred(*first))
  28
+            return false;
  29
+    }
  30
+    return true;
  31
+}
  32
+
  33
+template <class SinglePassRange, class Pred>
  34
+bool all(const SinglePassRange& rng, Pred pred)
  35
+{
  36
+    return all(boost::begin(rng), boost::end(rng), pred);
  37
+}
  38
+
  39
+namespace {
  40
+    const std::vector<std::string> filenames = boost::assign::list_of
  41
+        ("a.txt")
  42
+        ("b.png")
  43
+        ("c_dir")
  44
+        ;
  45
+
  46
+    const std::vector<std::string> recursive_filenames = boost::assign::list_of
  47
+        ("a.txt")
  48
+        ("b.png")
  49
+        ("c_dir")
  50
+        ("d.cpp")
  51
+        ;
  52
+}
  53
+
  54
+bool exist_check(const boost::filesystem::path& p)
  55
+{
  56
+    return boost::find(filenames, p.filename()) != boost::end(filenames);
  57
+}
  58
+
  59
+bool recursive_exist_check(const boost::filesystem::path& p)
  60
+{
  61
+    return boost::find(recursive_filenames, p.filename()) != boost::end(recursive_filenames);
  62
+}
  63
+
  64
+int main()
  65
+{
  66
+    const boost::filesystem::path path("./directory_range_test_dir");
  67
+
  68
+    BOOST_TEST(all(boost::directory_range(path), exist_check));
  69
+    BOOST_TEST(all(boost::recursive_directory_range(path), recursive_exist_check));
  70
+
  71
+    return boost::report_errors();
  72
+}
0  libs/range/test/directory_range_test_dir/a.txt
No changes.
0  libs/range/test/directory_range_test_dir/b.png
0  libs/range/test/directory_range_test_dir/c_dir/d.cpp
No changes.
49  libs/range/test/iteration.cpp
... ...
@@ -0,0 +1,49 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#include <iostream>
  11
+#include <boost/detail/lightweight_test.hpp>
  12
+
  13
+#include <boost/range/iteration.hpp>
  14
+
  15
+#include <vector>
  16
+#include <boost/assign/list_of.hpp>
  17
+#include <boost/range/adaptor/taken.hpp>
  18
+#include <boost/range/adaptor/dropped.hpp>
  19
+#include <boost/range/access/front.hpp>
  20
+#include <boost/range/algorithm/equal.hpp>
  21
+
  22
+int next(int x)
  23
+{
  24
+    return x * 2;
  25
+}
  26
+
  27
+int main()
  28
+{
  29
+    {
  30
+        const std::vector<int> expected = boost::assign::list_of(1)(2)(4)(8)(16);
  31
+
  32
+        BOOST_TEST(boost::equal(
  33
+            boost::iteration(1, next) | boost::adaptors::taken(5),
  34
+            expected
  35
+        ));
  36
+    }
  37
+    {
  38
+        const int expected = 4;
  39
+
  40
+        BOOST_TEST(
  41
+            (boost::iteration(1, next) | boost::adaptors::dropped(2) | boost::range::access::front)
  42
+            == expected
  43
+        );
  44
+    }
  45
+
  46
+    return boost::report_errors();
  47
+}
  48
+
  49
+
51  libs/range/test/member_select_example.cpp
... ...
@@ -0,0 +1,51 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#include <iostream>
  11
+#include <vector>
  12
+#include <string>
  13
+#include <boost/assign/list_of.hpp>
  14
+#include <boost/range/adaptor/regular_extension/transformed.hpp>
  15
+#include <boost/range/algorithm/for_each.hpp>
  16
+#include <boost/lambda/lambda.hpp>
  17
+
  18
+struct X {
  19
+    int a;
  20
+    std::string s;
  21
+
  22
+    X(int a_, const std::string& s_) : a(a_), s(s_) {}
  23
+};
  24
+
  25
+struct disper {
  26
+    template <class T>
  27
+    void operator()(const T& x) const
  28
+    {
  29
+        std::cout << x << std::endl;
  30
+    }
  31
+};
  32
+
  33
+int main()
  34
+{
  35
+    const std::vector<X> v = boost::assign::list_of
  36
+        (X(1, "a"))
  37
+        (X(2, "b"))
  38
+        (X(3, "c"))
  39
+        ;
  40
+
  41
+    using boost::lambda::_1;
  42
+
  43
+    boost::for_each(v |+ boost::adaptors::transformed(&_1 ->* &X::s), disper());
  44
+}
  45
+
  46
+/*
  47
+a
  48
+b
  49
+c
  50
+
  51
+*/
33  libs/range/test/regular.cpp
... ...
@@ -0,0 +1,33 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#include <iostream>
  11
+#include <boost/detail/lightweight_test.hpp>
  12
+
  13
+#include <boost/range/regular.hpp>
  14
+#include <boost/lambda/lambda.hpp>
  15
+
  16
+template< class F >
  17
+void regular_check(F const f)
  18
+{
  19
+    F f1(f);
  20
+    F f2; // Default Constructible
  21
+    f2 = f1; // Copy Assignable
  22
+}
  23
+
  24
+int main()
  25
+{
  26
+    namespace bll = boost::lambda;
  27
+    ::regular_check(boost::regular(bll::_1 != 'c'));
  28
+    ::regular_check(boost::regular(bll::_1 += 1));
  29
+
  30
+    return boost::report_errors();
  31
+}
  32
+
  33
+
47  libs/range/test/regular_cpp0x_lambda_example.cpp
... ...
@@ -0,0 +1,47 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#define BOOST_RESULT_OF_USE_DECLTYPE
  11
+#include <iostream>
  12
+#include <vector>
  13
+#include <boost/assign/list_of.hpp>
  14
+#include <boost/range/adaptor/transformed.hpp>
  15
+#include <boost/range/regular.hpp>
  16
+
  17
+template <class InputIterator, class F>
  18
+void for_each_(InputIterator first, InputIterator last, F f)
  19
+{
  20
+    InputIterator it; // Default Constructible
  21
+    it = first; // Copy Assignable
  22
+    for (; it != last; ++it) {
  23
+        f(*it);
  24
+    }
  25
+}
  26
+
  27
+template <class SinglePassRange, class F>
  28
+void for_each_(const SinglePassRange& rng, F f)
  29
+{
  30
+    return for_each_(boost::begin(rng), boost::end(rng), f);
  31
+}
  32
+
  33
+void disp(int x)
  34
+{
  35
+    std::cout << x << ' ';
  36
+}
  37
+
  38
+int main()
  39
+{
  40
+    const std::vector<int> v = boost::assign::list_of(1)(2)(3)(4)(5);
  41
+    for_each_(v | boost::adaptors::transformed(boost::regular([](int x) { return x + 1; })), disp);
  42
+}
  43
+
  44
+/*
  45
+2 3 4 5 6 
  46
+*/
  47
+
3  libs/range/test/regular_operator_example.cpp
@@ -10,6 +10,7 @@
10 10
 
11 11
 #include <iostream>
12 12
 #include <vector>
  13
+#include <boost/assign/list_of.hpp>
13 14
 #include <boost/range/adaptor/taken_while.hpp>
14 15
 #include <boost/range/adaptor/dropped_while.hpp>
15 16
 #include <boost/range/adaptor/regular_extension/filtered.hpp>
@@ -49,7 +50,7 @@ int main()
49 50
     using boost::lambda::_1;
50 51
     using namespace boost::adaptors;
51 52
 
52  
-    const std::vector<int> v = {1, 2, 3, 4, 5, 6};
  53
+    const std::vector<int> v = boost::assign::list_of(1)(2)(3)(4)(5)(6);
53 54
     for_each_(v |+ taken_while(_1 < 3) |+ dropped_while(_1 == 1), disp);
54 55
 
55 56
     std::cout << std::endl;
55  libs/range/test/single.cpp
... ...
@@ -0,0 +1,55 @@
  1
+
  2
+// Boost.Range 2.0 Extension library
  3
+// via PStade Oven Library
  4
+//
  5
+// Copyright Akira Takahashi 2011.
  6
+// Copyright Shunsuke Sogame 2005-2007.
  7
+// Use, modification and distribution is subject to the Boost Software License,
  8
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9
+// http://www.boost.org/LICENSE_1_0.txt)
  10
+
  11
+#include <iostream>
  12
+#include <boost/detail/lightweight_test.hpp>
  13
+#include <boost/range/algorithm/equal.hpp>
  14
+
  15
+#include <boost/range/single.hpp>
  16
+
  17
+#include <vector>
  18
+#include <string>
  19
+#include <boost/lexical_cast.hpp>
  20
+#include <boost/range/adaptor/transformed.hpp>
  21
+#include <boost/assign/list_of.hpp>
  22
+
  23
+struct to_s {
  24
+    typedef std::string result_type;
  25
+
  26
+    std::string operator()(int x) const
  27
+    {
  28
+        return boost::lexical_cast<std::string>(x);
  29
+    }
  30
+};
  31
+
  32
+int main()
  33
+{
  34
+    {
  35
+        const char c = 'a';
  36
+        const std::string expected("a");
  37
+        BOOST_TEST(boost::equal(boost::single(c), expected));
  38
+    }
  39
+    {
  40
+        char c = 'a';
  41
+        const std::string expected("a");
  42
+        BOOST_TEST(boost::equal(boost::single(c), expected));
  43
+    }
  44
+    {
  45
+        const int a = 1;
  46
+        const std::vector<std::string> expected = boost::assign::list_of("1");
  47
+        BOOST_TEST(boost::equal(
  48
+            boost::single(a) | boost::adaptors::transformed(to_s()),
  49
+            expected
  50
+        ));
  51
+    }
  52
+
  53
+    return boost::report_errors();
  54
+}
  55
+
45  libs/range/test/split_at.cpp
... ...
@@ -0,0 +1,45 @@
  1
+// Boost.Range 2.0 Extension library
  2
+// via PStade Oven Library
  3
+//
  4
+// Copyright Akira Takahashi 2011.
  5
+// Copyright Shunsuke Sogame 2005-2007.
  6
+// Use, modification and distribution is subject to the Boost Software License,
  7
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8
+// http://www.boost.org/LICENSE_1_0.txt)
  9
+
  10
+#include <iostream>
  11
+#include <boost/detail/lightweight_test.hpp>
  12
+#include <boost/range/algorithm/equal.hpp>
  13
+
  14
+#include <boost/range/split_at.hpp>
  15
+
  16
+#include <vector>
  17
+#include <boost/assign/list_of.hpp>
  18
+
  19
+int main()
  20
+{
  21
+    {
  22
+        const std::vector<int> v = boost::assign::list_of(3)(1)(4)(2)(5);
  23
+        const std::vector<int> left = boost::assign::list_of(3)(1);
  24
+        const std::vector<int> right = boost::assign::list_of(4)(2)(5);
  25
+
  26
+        boost::range::result_of::split_at<const std::vector<int> >::type r = boost::split_at(v, 2);
  27
+
  28
+        BOOST_TEST(boost::equal(r.first, left));
  29
+        BOOST_TEST(boost::equal(r.second, right));
  30
+    }
  31
+    {
  32
+        std::vector<int> v = boost::assign::list_of(3)(1)(4)(2)(5);
  33
+        const std::vector<int> left = boost::assign::list_of(3)(1);
  34
+        const std::vector<int> right = boost::assign::list_of(4)(2)(5);
  35
+
  36
+        boost::range::result_of::split_at<std::vector<int> >::type r = boost::split_at(v, 2);
  37
+
  38
+        BOOST_TEST(boost::equal(r.first, left));
  39
+        BOOST_TEST(boost::equal(r.second, right));
  40
+    }
  41
+
  42
+    return boost::report_errors();
  43
+}
  44
+
  45
+
29  project-root.jam
... ...
@@ -0,0 +1,29 @@
  1
+#  Copyright Shunsuke Sogame 2005-2007.
  2
+#  Use, modification, and distribution are subject to the
  3
+#  Boost Software License, Version 1.0. (See accompanying file
  4
+#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5
+
  6
+# Thanks to:
  7
+#
  8
+# Hamigaki Library root settings
  9
+#
  10
+#  Copyright Takeshi Mouri 2006, 2007.
  11
+#  Use, modification, and distribution are subject to the
  12
+#  Boost Software License, Version 1.0. (See accompanying file
  13
+#  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  14
+
  15
+import modules ;
  16
+
  17
+path-constant OVEN_TO_BOOST_ROOT : . ;
  18
+path-constant BOOST_ROOT : [ modules.peek : BOOST_ROOT ] ;
  19
+
  20
+use-project /boost : $(BOOST_ROOT) ;
  21
+
  22
+project oven_to_boost
  23
+    : build-dir
  24
+        ../oven_to_boost_bin
  25
+    : requirements
  26
+        <include>$(OVEN_TO_BOOST_ROOT)
  27
+        <include>$(BOOST_ROOT)
  28
+    ;
  29
+

0 notes on commit a2c7201

Please sign in to comment.
Something went wrong with that request. Please try again.