mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 16:30:29 +00:00
Consistent naming between unique/shared ptr tests
This commit is contained in:
parent
524f1fd2c2
commit
530a5d0480
1 changed files with 17 additions and 17 deletions
|
@ -36,23 +36,23 @@ using ctl::make_unique_for_overwrite;
|
||||||
// object.
|
// object.
|
||||||
static int g = 0;
|
static int g = 0;
|
||||||
|
|
||||||
struct SetsGCtor
|
struct ConstructG
|
||||||
{
|
{
|
||||||
SetsGCtor()
|
ConstructG()
|
||||||
{
|
{
|
||||||
++g;
|
++g;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SetsGDtor
|
struct DestructG
|
||||||
{
|
{
|
||||||
~SetsGDtor()
|
~DestructG()
|
||||||
{
|
{
|
||||||
++g;
|
++g;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SetsGDeleter
|
struct CallG
|
||||||
{
|
{
|
||||||
void operator()(auto* x) const noexcept
|
void operator()(auto* x) const noexcept
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ main()
|
||||||
|
|
||||||
{
|
{
|
||||||
// Deleter is called if the pointer is non-null when reset.
|
// Deleter is called if the pointer is non-null when reset.
|
||||||
unique_ptr<int, SetsGDeleter> x(&a);
|
unique_ptr<int, CallG> x(&a);
|
||||||
x.reset();
|
x.reset();
|
||||||
if (g != 1)
|
if (g != 1)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -102,7 +102,7 @@ main()
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
// Deleter is not called if the pointer is null when reset.
|
// Deleter is not called if the pointer is null when reset.
|
||||||
unique_ptr<int, SetsGDeleter> x(&a);
|
unique_ptr<int, CallG> x(&a);
|
||||||
x.release();
|
x.release();
|
||||||
x.reset();
|
x.reset();
|
||||||
if (g)
|
if (g)
|
||||||
|
@ -113,7 +113,7 @@ main()
|
||||||
g = 0;
|
g = 0;
|
||||||
// Deleter is called when the pointer goes out of scope.
|
// Deleter is called when the pointer goes out of scope.
|
||||||
{
|
{
|
||||||
unique_ptr<int, SetsGDeleter> x(&a);
|
unique_ptr<int, CallG> x(&a);
|
||||||
}
|
}
|
||||||
if (!g)
|
if (!g)
|
||||||
return 18;
|
return 18;
|
||||||
|
@ -123,7 +123,7 @@ main()
|
||||||
g = 0;
|
g = 0;
|
||||||
// Deleter is called if scope ends exceptionally.
|
// Deleter is called if scope ends exceptionally.
|
||||||
try {
|
try {
|
||||||
unique_ptr<int, SetsGDeleter> x(&a);
|
unique_ptr<int, CallG> x(&a);
|
||||||
throw 'a';
|
throw 'a';
|
||||||
} catch (char) {
|
} catch (char) {
|
||||||
}
|
}
|
||||||
|
@ -149,17 +149,17 @@ main()
|
||||||
|
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
unique_ptr<SetsGCtor> x;
|
unique_ptr<ConstructG> x;
|
||||||
if (g)
|
if (g)
|
||||||
return 5;
|
return 5;
|
||||||
x = make_unique<SetsGCtor>();
|
x = make_unique<ConstructG>();
|
||||||
if (g != 1)
|
if (g != 1)
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
auto x = make_unique<SetsGDtor>();
|
auto x = make_unique<DestructG>();
|
||||||
if (g)
|
if (g)
|
||||||
return 7;
|
return 7;
|
||||||
x.reset();
|
x.reset();
|
||||||
|
@ -171,9 +171,9 @@ main()
|
||||||
|
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
unique_ptr<SetsGDtor> x, y;
|
unique_ptr<DestructG> x, y;
|
||||||
x = make_unique<SetsGDtor>();
|
x = make_unique<DestructG>();
|
||||||
y = make_unique<SetsGDtor>();
|
y = make_unique<DestructG>();
|
||||||
#if 0
|
#if 0
|
||||||
// shouldn't compile
|
// shouldn't compile
|
||||||
x = y;
|
x = y;
|
||||||
|
@ -188,7 +188,7 @@ main()
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
{
|
{
|
||||||
auto x = make_unique<SetsGDtor>();
|
auto x = make_unique<DestructG>();
|
||||||
}
|
}
|
||||||
if (g != 1)
|
if (g != 1)
|
||||||
return 12;
|
return 12;
|
||||||
|
@ -197,7 +197,7 @@ main()
|
||||||
{
|
{
|
||||||
g = 0;
|
g = 0;
|
||||||
{
|
{
|
||||||
auto x = make_unique<SetsGDtor>();
|
auto x = make_unique<DestructG>();
|
||||||
delete x.release();
|
delete x.release();
|
||||||
}
|
}
|
||||||
if (g != 1)
|
if (g != 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue