Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38c5f7c

Browse files
committed
Updated test_storaget.cpp
1 parentb8bbb74 commit38c5f7c

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

‎buildcc/lib/env/test/test_storage.cpp‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,32 @@
1111
TEST_GROUP(ScopedStorageTestGroup)
1212
{
1313
};
14+
15+
TEST_GROUP(StorageTestGroup)
16+
{
17+
voidsetup() {
18+
buildcc::Storage::Init();
19+
}
20+
voidteardown() {
21+
buildcc::Storage::Deinit();
22+
}
23+
};
1424
// clang-format on
1525

1626
classBigObj {};
1727

1828
classBigObjWithParameters {
1929
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) {
2232
(void)id;
2333
(void)obj;
2434
}
2535

26-
std::stringGetName()const {return __FUNCTION__; }
36+
const std::string &GetName()const {return name_; }
37+
38+
private:
39+
std::string name_;
2740
};
2841

2942
static BigObj obj;
@@ -59,6 +72,20 @@ TEST(ScopedStorageTestGroup, NullptrDelete) {
5972
storage.Remove<std::string>(nullptr);
6073
}
6174

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+
6289
intmain(int ac,char **av) {
6390
returnCommandLineTestRunner::RunAllTests(ac, av);
6491
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp