xref: /freebsd/contrib/kyua/model/test_program.hpp (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 // Copyright 2010 The Kyua Authors.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 //   notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 //   notice, this list of conditions and the following disclaimer in the
12 //   documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 //   may be used to endorse or promote products derived from this software
15 //   without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 /// \file model/test_program.hpp
30 /// Definition of the "test program" concept.
31 
32 #if !defined(MODEL_TEST_PROGRAM_HPP)
33 #define MODEL_TEST_PROGRAM_HPP
34 
35 #include "model/test_program_fwd.hpp"
36 
37 #include <memory>
38 #include <ostream>
39 #include <string>
40 #include <vector>
41 
42 #include "model/metadata_fwd.hpp"
43 #include "model/test_case_fwd.hpp"
44 #include "utils/fs/path_fwd.hpp"
45 #include "utils/noncopyable.hpp"
46 
47 namespace model {
48 
49 
50 /// Representation of a test program.
51 class test_program {
52     struct impl;
53 
54     /// Pointer to the shared internal implementation.
55     std::shared_ptr< impl > _pimpl;
56 
57 protected:
58     void set_test_cases(const model::test_cases_map&);
59 
60 public:
61     test_program(const std::string&, const utils::fs::path&,
62                  const utils::fs::path&, const std::string&,
63                  const model::metadata&, const model::test_cases_map&);
64     virtual ~test_program(void);
65 
66     const std::string& interface_name(void) const;
67     const utils::fs::path& root(void) const;
68     const utils::fs::path& relative_path(void) const;
69     const utils::fs::path absolute_path(void) const;
70     const std::string& test_suite_name(void) const;
71     const model::metadata& get_metadata(void) const;
72 
73     const model::test_case& find(const std::string&) const;
74     virtual const model::test_cases_map& test_cases(void) const;
75 
76     bool operator==(const test_program&) const;
77     bool operator!=(const test_program&) const;
78     bool operator<(const test_program&) const;
79 };
80 
81 
82 std::ostream& operator<<(std::ostream&, const test_program&);
83 
84 
85 /// Builder for a test_program object.
86 class test_program_builder : utils::noncopyable {
87     struct impl;
88 
89     /// Pointer to the shared internal implementation.
90     std::auto_ptr< impl > _pimpl;
91 
92 public:
93     test_program_builder(const std::string&, const utils::fs::path&,
94                          const utils::fs::path&, const std::string&);
95     ~test_program_builder(void);
96 
97     test_program_builder& add_test_case(const std::string&);
98     test_program_builder& add_test_case(const std::string&,
99                                         const model::metadata&);
100 
101     test_program_builder& set_metadata(const model::metadata&);
102 
103     test_program build(void) const;
104     test_program_ptr build_ptr(void) const;
105 };
106 
107 
108 }  // namespace model
109 
110 #endif  // !defined(MODEL_TEST_PROGRAM_HPP)
111