AsmGrader 0.0.0
Loading...
Searching...
No Matches
test_base.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <optional>
7#include <string_view>
8
9namespace asmgrader {
10
11class Assignment;
12
17{
18public:
19 template <typename... MetadataAttrs>
20 explicit TestBase(const Assignment& assignment, std::string_view name,
22 : name_{name}
23 , assignment_{&assignment}
24 , is_prof_only_{metadata.template get<metadata::ProfOnlyTag>()}
25 , weight_{metadata.template get<metadata::Weight>()} {}
26
27 virtual ~TestBase() noexcept = default;
28
29 virtual void run(TestContext& ctx) = 0;
30
31 const Assignment& get_assignment() const { return *assignment_; }
32
33 std::string_view get_name() const noexcept { return name_; }
34
35 bool get_is_prof_only() const noexcept { return is_prof_only_; }
36
37 std::optional<metadata::Weight> get_weight() const noexcept { return weight_; }
38
39private:
40 std::string_view name_;
41 const Assignment* assignment_;
42
43 // TODO: Probably want a more versatile way to handle metadata, but this should suffice for now
44 // Name could also be considered metadata...
45 bool is_prof_only_;
46 std::optional<metadata::Weight> weight_;
47};
48
49} // namespace asmgrader
Declaration for the logic and data encapsulating a class assignment.
Definition assignment.hpp:23
Base class primarily for a user-written test.
Definition test_base.hpp:17
const Assignment & get_assignment() const
Definition test_base.hpp:31
std::optional< metadata::Weight > get_weight() const noexcept
Definition test_base.hpp:37
virtual ~TestBase() noexcept=default
bool get_is_prof_only() const noexcept
Definition test_base.hpp:35
TestBase(const Assignment &assignment, std::string_view name, metadata::Metadata< MetadataAttrs... > metadata=metadata::Metadata< MetadataAttrs... >{}) noexcept
Definition test_base.hpp:20
virtual void run(TestContext &ctx)=0
std::string_view get_name() const noexcept
Definition test_base.hpp:33
User-facing API for use within an assignment test case for: Interacting with or querying data for the...
Definition test_context.hpp:40
Definition metadata.hpp:117
Definition asm_buffer.hpp:19