refactor: move setup of chapter 2 tests out of main
This commit is contained in:
parent
a3c2e3728c
commit
9dbfc54b76
@ -1,5 +1,6 @@
|
||||
add_library(
|
||||
chapter_02
|
||||
src/chapter_2_tests.cpp
|
||||
src/constexp.cpp
|
||||
src/if_constexpr.cpp
|
||||
src/ifswitch.cpp
|
||||
|
5
chapters/chapter_02/include/chapter_2_tests.h
Normal file
5
chapters/chapter_02/include/chapter_2_tests.h
Normal file
@ -0,0 +1,5 @@
|
||||
#include "chapter_interface.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
std::vector<std::unique_ptr<ChapterTest>> chapter_2_tests();
|
30
chapters/chapter_02/src/chapter_2_tests.cpp
Normal file
30
chapters/chapter_02/src/chapter_2_tests.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "chapter_2_tests.h"
|
||||
#include "constexp.h"
|
||||
#include "delegate_constructor.h"
|
||||
#include "if_constexpr.h"
|
||||
#include "ifswitch.h"
|
||||
#include "inheritance_constructor.h"
|
||||
#include "initlist.h"
|
||||
#include "null.h"
|
||||
#include "range_based_for.h"
|
||||
#include "structured_binding.h"
|
||||
#include "type_inference.h"
|
||||
#include "variadic_templates.h"
|
||||
|
||||
std::vector<std::unique_ptr<ChapterTest>> chapter_2_tests() {
|
||||
std::vector<std::unique_ptr<ChapterTest>> chapter_2_tests;
|
||||
|
||||
chapter_2_tests.emplace_back(std::make_unique<NullTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<IfswitchTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<ConstExpTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<InitListTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<StructuredBindingTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<TypeInferenceTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<IfConstexprTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<RangeBasedForTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<VariadicTemplates>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<DelegateConstructor>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<InheritanceConstructor>());
|
||||
|
||||
return chapter_2_tests;
|
||||
}
|
28
src/main.cpp
28
src/main.cpp
@ -3,17 +3,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "constexp.h"
|
||||
#include "delegate_constructor.h"
|
||||
#include "if_constexpr.h"
|
||||
#include "ifswitch.h"
|
||||
#include "inheritance_constructor.h"
|
||||
#include "initlist.h"
|
||||
#include "null.h"
|
||||
#include "range_based_for.h"
|
||||
#include "structured_binding.h"
|
||||
#include "type_inference.h"
|
||||
#include "variadic_templates.h"
|
||||
#include "chapter_2_tests.h"
|
||||
#include "version.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@ -21,21 +11,7 @@ int main(int argc, char **argv) {
|
||||
std::cout << "Running " << PROJECT_NAME << ", version " << VERSION
|
||||
<< std::endl;
|
||||
|
||||
std::vector<std::unique_ptr<ChapterTest>> chapter_2_tests;
|
||||
|
||||
chapter_2_tests.emplace_back(std::make_unique<NullTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<IfswitchTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<ConstExpTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<InitListTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<StructuredBindingTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<TypeInferenceTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<IfConstexprTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<RangeBasedForTest>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<VariadicTemplates>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<DelegateConstructor>());
|
||||
chapter_2_tests.emplace_back(std::make_unique<InheritanceConstructor>());
|
||||
|
||||
for (auto &test : chapter_2_tests) {
|
||||
for (auto &test : chapter_2_tests()) {
|
||||
std::cout << "\n" << test->name() << ":" << std::endl;
|
||||
test->run();
|
||||
}
|
||||
|
Reference in New Issue
Block a user