Added strategy pattern test case
This commit is contained in:
@@ -38,16 +38,15 @@ protected:
|
||||
|
||||
class A1 : public A {
|
||||
protected:
|
||||
void method1() override { }
|
||||
void method2() override { }
|
||||
void method1() override {}
|
||||
void method2() override {}
|
||||
};
|
||||
|
||||
class A2 : public A {
|
||||
protected:
|
||||
void method1() override { }
|
||||
void method2() override { }
|
||||
void method1() override {}
|
||||
void method2() override {}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
65
docs/test_cases/t00023.md
Normal file
65
docs/test_cases/t00023.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# t00023 - Strategy pattern
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t00023_class:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00023/t00023.cc
|
||||
using_namespace:
|
||||
- clanguml::t00023
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00023
|
||||
|
||||
```
|
||||
## Source code
|
||||
File t00023.cc
|
||||
```cpp
|
||||
#include <memory>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t00023 {
|
||||
|
||||
class Strategy {
|
||||
public:
|
||||
virtual ~Strategy() = default;
|
||||
virtual void algorithm() = 0;
|
||||
};
|
||||
|
||||
class StrategyA : public Strategy {
|
||||
public:
|
||||
void algorithm() override { }
|
||||
};
|
||||
|
||||
class StrategyB : public Strategy {
|
||||
public:
|
||||
void algorithm() override { }
|
||||
};
|
||||
|
||||
class StrategyC : public Strategy {
|
||||
public:
|
||||
void algorithm() override { }
|
||||
};
|
||||
|
||||
class Context {
|
||||
public:
|
||||
Context(std::unique_ptr<Strategy> strategy)
|
||||
: m_strategy(std::move(strategy))
|
||||
{
|
||||
}
|
||||
|
||||
void apply() { m_strategy->algorithm(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<Strategy> m_strategy;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t00023_class.png
Normal file
BIN
docs/test_cases/t00023_class.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Reference in New Issue
Block a user