AsmGrader 0.0.0
Loading...
Searching...
No Matches
assignment.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <range/v3/algorithm/transform.hpp>
7#include <range/v3/range/conversion.hpp>
8#include <range/v3/view/transform.hpp>
9
10#include <filesystem>
11#include <memory>
12#include <string_view>
13#include <utility>
14#include <vector>
15
16namespace asmgrader {
17
23{
24public:
25 Assignment(std::string_view name, std::filesystem::path exec_path) noexcept;
26
27 void add_test(std::unique_ptr<TestBase> test) const noexcept;
28
29 std::string_view get_name() const noexcept { return name_; }
30
31 std::filesystem::path get_exec_path() const noexcept { return exec_path_; }
32
33 void set_exec_path(std::filesystem::path path) noexcept { exec_path_ = std::move(path); }
34
35 auto get_tests() const noexcept {
36 return tests_ | ranges::views::transform([](std::unique_ptr<TestBase>& test) -> TestBase& { return *test; });
37 }
38
39 std::vector<std::string_view> get_test_names() const noexcept {
40 return tests_ |
41 ranges::views::transform([](const std::unique_ptr<TestBase>& test) { return test->get_name(); }) |
42 ranges::to<std::vector>();
43 }
44
45private:
46 std::string_view name_;
47 std::filesystem::path exec_path_;
48
49 mutable std::vector<std::unique_ptr<TestBase>> tests_;
50};
51
52} // namespace asmgrader
Declaration for the logic and data encapsulating a class assignment.
Definition assignment.hpp:23
void add_test(std::unique_ptr< TestBase > test) const noexcept
Definition assignment.cpp:16
void set_exec_path(std::filesystem::path path) noexcept
Definition assignment.hpp:33
std::string_view get_name() const noexcept
Definition assignment.hpp:29
std::vector< std::string_view > get_test_names() const noexcept
Definition assignment.hpp:39
std::filesystem::path get_exec_path() const noexcept
Definition assignment.hpp:31
Assignment(std::string_view name, std::filesystem::path exec_path) noexcept
Definition assignment.cpp:12
auto get_tests() const noexcept
Definition assignment.hpp:35
A trivially-movable, but non-copyable type.
Definition class_traits.hpp:14
Base class primarily for a user-written test.
Definition test_base.hpp:17
Definition asm_buffer.hpp:19