mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-10 05:26:56 +00:00
a6c3d30014
these tests were skipped as they can't record the dynamic size. however, there isn't a dynamic size to report as the type of the pointer is void. accept a dynamic size of 0 as it's the best we can do with no type knowledge.
177 lines
4.1 KiB
TOML
177 lines
4.1 KiB
TOML
includes = ["memory", "cstdint"]
|
|
definitions = '''
|
|
void void_int_deleter(void *void_ptr) {
|
|
auto *int_ptr = static_cast<int*>(void_ptr);
|
|
delete int_ptr;
|
|
}
|
|
'''
|
|
[cases]
|
|
[cases.unique_ptr_uint64_empty]
|
|
param_types = ["std::unique_ptr<std::uint64_t>&"]
|
|
setup = "return {nullptr};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 8,
|
|
"dynamicSize": 0,
|
|
"length": 0,
|
|
"capacity": 1,
|
|
"elementStaticSize": 8
|
|
}
|
|
]
|
|
'''
|
|
[cases.unique_ptr_uint64_present]
|
|
param_types = ["std::unique_ptr<std::uint64_t>&"]
|
|
setup = "return {std::make_unique<std::uint64_t>(64)};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 8,
|
|
"dynamicSize": 8,
|
|
"length": 1,
|
|
"capacity": 1,
|
|
"elementStaticSize": 8
|
|
}
|
|
]
|
|
'''
|
|
[cases.unique_ptr_vector_empty]
|
|
param_types = ["std::unique_ptr<std::vector<std::uint64_t>>&"]
|
|
setup = "return {nullptr};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 8,
|
|
"dynamicSize": 0,
|
|
"length": 0,
|
|
"capacity": 1,
|
|
"elementStaticSize": 24
|
|
}
|
|
]
|
|
'''
|
|
[cases.unique_ptr_vector_present]
|
|
param_types = ["std::unique_ptr<std::vector<std::uint64_t>>&"]
|
|
setup = "return {std::make_unique<std::vector<std::uint64_t>>(std::initializer_list<std::uint64_t>({1,2,3,4,5}))};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 8,
|
|
"dynamicSize": 64,
|
|
"length": 1,
|
|
"capacity": 1,
|
|
"elementStaticSize": 24,
|
|
"members": [
|
|
{
|
|
"staticSize": 24,
|
|
"dynamicSize": 40
|
|
}
|
|
]
|
|
}
|
|
]
|
|
'''
|
|
[cases.unique_ptr_void_empty]
|
|
param_types = ["std::unique_ptr<void, decltype(&void_int_deleter)>&"]
|
|
setup = "return {std::unique_ptr<void, decltype(&void_int_deleter)>(nullptr, &void_int_deleter)};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
'''
|
|
[cases.unique_ptr_void_present]
|
|
param_types = ["std::unique_ptr<void, decltype(&void_int_deleter)>&"]
|
|
setup = "return {std::unique_ptr<void, decltype(&void_int_deleter)>(new int, &void_int_deleter)};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_uint64_empty]
|
|
param_types = ["std::shared_ptr<std::uint64_t>&"]
|
|
setup = "return {nullptr};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0,
|
|
"length": 0,
|
|
"capacity": 1,
|
|
"elementStaticSize": 8
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_uint64_present]
|
|
param_types = ["std::shared_ptr<std::uint64_t>&"]
|
|
setup = "return std::make_shared<std::uint64_t>(64);"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 8,
|
|
"length": 1,
|
|
"capacity": 1,
|
|
"elementStaticSize": 8
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_vector_empty]
|
|
param_types = ["std::shared_ptr<std::vector<std::uint64_t>>&"]
|
|
setup = "return {nullptr};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0,
|
|
"length": 0,
|
|
"capacity": 1,
|
|
"elementStaticSize": 24
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_vector_present]
|
|
param_types = ["std::shared_ptr<std::vector<std::uint64_t>>&"]
|
|
setup = "return std::make_shared<std::vector<std::uint64_t>>(std::initializer_list<std::uint64_t>({1,2,3,4,5}));"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 64,
|
|
"length": 1,
|
|
"capacity": 1,
|
|
"elementStaticSize": 24,
|
|
"members": [
|
|
{
|
|
"staticSize": 24,
|
|
"dynamicSize": 40
|
|
}
|
|
]
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_void_empty]
|
|
param_types = ["std::shared_ptr<void>&"]
|
|
setup = "return {nullptr};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
'''
|
|
[cases.shared_ptr_void_present]
|
|
param_types = ["std::shared_ptr<void>&"]
|
|
setup = "return {std::shared_ptr<void>(new int)};"
|
|
expect_json = '''
|
|
[
|
|
{
|
|
"staticSize": 16,
|
|
"dynamicSize": 0
|
|
}
|
|
]
|
|
'''
|