Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template <template <typename ValueType> class RedBlackTree>
- class RBTreeTester {
- template <class WrappedType>
- class DeleteWrapper {
- WrappedType value_;
- bool *marker{};
- public:
- template <class ...Args>
- DeleteWrapper(Args &&...args) : value_(std::forward<Args>(args)...), marker(nullptr) {
- }
- void bindMarker(bool *marker_arg) {
- marker = marker_arg;
- }
- ~DeleteWrapper() {
- if (marker != nullptr) {
- *marker = true;
- }
- }
- };
- enum class ErrorCodes { OK = 0, TL, WA, RE };
- static std::string to_string(ErrorCodes code) {
- if (code == ErrorCodes::TL) {
- return "TL";
- }
- if (code == ErrorCodes::WA) {
- return "WA";
- }
- if (code == ErrorCodes::RE) {
- return "RE";
- }
- return "OK";
- }
- public:
- static std::string checkTree() {
- ErrorCodes code;
- code = destructorCheck();
- if (code != ErrorCodes::OK) {
- return "Destructor Error!" + to_string(code);
- }
- code = constructorCheck();
- if (code != ErrorCodes::OK) {
- return "Constructor Error!" + to_string(code);
- }
- code = emptyCheck();
- if (code != ErrorCodes::OK) {
- return "Empty Error!" + to_string(code);
- }
- code = sizeCheck();
- if (code != ErrorCodes::OK) {
- return "Size Error!" + to_string(code);
- }
- code = heightCheck();
- if (code != ErrorCodes::OK) {
- return "Height Error!" + to_string(code);
- }
- code = loweBoundCheck();
- if (code != ErrorCodes::OK) {
- return "LowerBound Error!" + to_string(code);
- }
- code = findCheck();
- if (code != ErrorCodes::OK) {
- return "Find Error!" + to_string(code);
- }
- code = insertCheck();
- if (code != ErrorCodes::OK) {
- return "Insert Error!" + to_string(code);
- }
- }
- private:
- static ErrorCodes destructorCheck() {
- }
- static ErrorCodes constructorCheck() {
- }
- static ErrorCodes emptyCheck() {
- }
- static ErrorCodes sizeCheck() {
- }
- static ErrorCodes heightCheck() {
- }
- static ErrorCodes loweBoundCheck() {
- }
- static ErrorCodes findCheck() {
- }
- static ErrorCodes insertCheck() {
- }
- };
- int main() {
- std::cout << "Hello, World!" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement