|
11 | 11 | TEST_GROUP(ScopedStorageTestGroup) |
12 | 12 | { |
13 | 13 | }; |
| 14 | + |
| 15 | +TEST_GROUP(StorageTestGroup) |
| 16 | +{ |
| 17 | +voidsetup() { |
| 18 | +buildcc::Storage::Init(); |
| 19 | + } |
| 20 | +voidteardown() { |
| 21 | +buildcc::Storage::Deinit(); |
| 22 | + } |
| 23 | +}; |
14 | 24 | // clang-format on |
15 | 25 |
|
16 | 26 | classBigObj {}; |
17 | 27 |
|
18 | 28 | classBigObjWithParameters { |
19 | 29 | public: |
20 | | -BigObjWithParameters(const std::string &name,int id,const BigObj &obj) { |
21 | | -(void)name; |
| 30 | +BigObjWithParameters(const std::string &name,int id,const BigObj &obj) |
| 31 | + : name_(name) { |
22 | 32 | (void)id; |
23 | 33 | (void)obj; |
24 | 34 | } |
25 | 35 |
|
26 | | - std::stringGetName()const {return __FUNCTION__; } |
| 36 | +const std::string &GetName()const {return name_; } |
| 37 | + |
| 38 | +private: |
| 39 | + std::string name_; |
27 | 40 | }; |
28 | 41 |
|
29 | 42 | static BigObj obj; |
@@ -59,6 +72,20 @@ TEST(ScopedStorageTestGroup, NullptrDelete) { |
59 | 72 | storage.Remove<std::string>(nullptr); |
60 | 73 | } |
61 | 74 |
|
| 75 | +TEST(StorageTestGroup, BasicUsage) { |
| 76 | + buildcc::Storage::Add<BigObjWithParameters>("identifier","name",10, obj); |
| 77 | + buildcc::Storage::Add<BigObjWithParameters>("identifier2","name2",12, obj); |
| 78 | + |
| 79 | +// Usage |
| 80 | +constauto &bigobj = |
| 81 | + buildcc::Storage::ConstRef<BigObjWithParameters>("identifier").GetName(); |
| 82 | +constauto &bigobj2 = |
| 83 | + buildcc::Storage::Ref<BigObjWithParameters>("identifier2").GetName(); |
| 84 | + |
| 85 | +STRCMP_EQUAL(bigobj.c_str(),"name"); |
| 86 | +STRCMP_EQUAL(bigobj2.c_str(),"name2"); |
| 87 | +} |
| 88 | + |
62 | 89 | intmain(int ac,char **av) { |
63 | 90 | returnCommandLineTestRunner::RunAllTests(ac, av); |
64 | 91 | } |