mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
review
This commit is contained in:
@@ -15,7 +15,7 @@ int main() {
|
||||
<< "BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE == " << BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE << '\n'
|
||||
<< "BOOST_PFR_HAS_GUARANTEED_COPY_ELISION == " << BOOST_PFR_HAS_GUARANTEED_COPY_ELISION << '\n'
|
||||
<< "BOOST_PFR_ENABLE_IMPLICIT_REFLECTION == " << BOOST_PFR_ENABLE_IMPLICIT_REFLECTION << '\n'
|
||||
<< "BOOST_PFR_ENABLE_GET_NAME_STATIC == " << BOOST_PFR_ENABLE_GET_NAME_STATIC << '\n'
|
||||
<< "BOOST_PFR_CORE_NAME_ENABLED == " << BOOST_PFR_CORE_NAME_ENABLED << '\n'
|
||||
<< "BOOST_PFR_FUNCTION_SIGNATURE == " << BOOST_PP_STRINGIZE(BOOST_PFR_FUNCTION_SIGNATURE) << '\n'
|
||||
<< "BOOST_PFR_CORE_NAME_PARSING == " << BOOST_PP_STRINGIZE(BOOST_PFR_CORE_NAME_PARSING) << '\n'
|
||||
<< "BOOST_PFR_ENABLED == " << BOOST_PFR_ENABLED << '\n'
|
||||
|
||||
@@ -43,9 +43,6 @@ project
|
||||
[ check-target-builds ../core_name//compiler_supports_cxx20_address_of_non_static_member_tplarg : : [ check-target-builds ../core_name//compiler_supports_cxx20_nontype_tplarg : : <build>no ] ]
|
||||
;
|
||||
|
||||
local ENABLED_ENGINE = <define>BOOST_PFR_ENABLE_GET_NAME_STATIC=1 ;
|
||||
local DISABLED_ENGINE = <define>BOOST_PFR_ENABLE_GET_NAME_STATIC=0 ;
|
||||
|
||||
|
||||
|
||||
actions invoke_python_generator
|
||||
@@ -53,25 +50,26 @@ actions invoke_python_generator
|
||||
python $(>) > $(<)
|
||||
}
|
||||
|
||||
make fields_names_nonascii.cpp : generate_fields_names_nonascii.cpp.py : @invoke_python_generator ;
|
||||
make fields_names_big.cpp : generate_fields_names_big.cpp.py : @invoke_python_generator ;
|
||||
|
||||
test-suite pfr_name_tests
|
||||
:
|
||||
[ run fields_names.cpp : : : : ]
|
||||
[ run fields_names_constexpr.cpp : : : : ]
|
||||
[ run fields_names_nonascii.cpp : : : <toolset>msvc:<cxxflags>"/utf-8" : ]
|
||||
[ run fields_names_big.cpp : : : <toolset>msvc:<cxxflags>"/bigobj" : ]
|
||||
[ run fields_names_correctly_configured_compiler.cpp : : : : ]
|
||||
[ run fields_names_internal_parser.cpp : : : : ]
|
||||
[ run print_name.cpp : : : <test-info>always_show_run_output ]
|
||||
;
|
||||
|
||||
for local source_file in [ glob ./run/*.cpp ]
|
||||
{
|
||||
pfr_name_tests += [ run $(source_file) : : : : ] ;
|
||||
}
|
||||
|
||||
for local source_file in [ glob ./run/*.py ]
|
||||
{
|
||||
local cpp_source_file = $(source_file[1]:B) ;
|
||||
make $(cpp_source_file) : $(source_file) : @invoke_python_generator ;
|
||||
pfr_name_tests += [ run $(cpp_source_file) : : : <toolset>msvc:<cxxflags>"/utf-8" <toolset>msvc:<cxxflags>"/bigobj" : ] ;
|
||||
}
|
||||
|
||||
for local source_file in [ glob ./compile-fail/*.cpp ]
|
||||
{
|
||||
local target_name = $(source_file[1]:B) ;
|
||||
pfr_name_tests += [ compile-fail $(source_file) : $(ENABLED_ENGINE) : $(target_name)_on ] ;
|
||||
pfr_name_tests += [ compile-fail $(source_file) : $(DISABLED_ENGINE) : $(target_name)_off ] ;
|
||||
pfr_name_tests += [ compile-fail $(source_file) : : ] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// Initial implementation by Bela Schaum, https://github.com/schaumb
|
||||
// The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
|
||||
//
|
||||
|
||||
#define BOOST_PFR_CORE_NAME_ENABLED 0
|
||||
#include <boost/pfr/core_name.hpp>
|
||||
|
||||
struct A { int field; };
|
||||
|
||||
int main() {
|
||||
(void)boost::pfr::get_name<0, A>(); // Must be a compile time error
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// Initial implementation by Bela Schaum, https://github.com/schaumb
|
||||
// The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
|
||||
//
|
||||
|
||||
#define BOOST_PFR_CORE_NAME_ENABLED 0
|
||||
#include <boost/pfr/core_name.hpp>
|
||||
|
||||
struct A { int field; };
|
||||
|
||||
int main() {
|
||||
(void)boost::pfr::names_as_array<A>(); // Must be a compile time error
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// Initial implementation by Bela Schaum, https://github.com/schaumb
|
||||
// The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
|
||||
//
|
||||
|
||||
#include <boost/pfr/core_name.hpp>
|
||||
|
||||
union test_union {
|
||||
const char* c;
|
||||
int i;
|
||||
};
|
||||
|
||||
int main() {
|
||||
(void)boost::pfr::get_name<0, test_union>(); // Must be a compile time error
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2023 Bela Schaum, X-Ryl669, Denis Mikhailov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// Initial implementation by Bela Schaum, https://github.com/schaumb
|
||||
// The way to make it union and UB free by X-Ryl669, https://github.com/X-Ryl669
|
||||
//
|
||||
|
||||
#include <boost/pfr/core_name.hpp>
|
||||
|
||||
union test_union {
|
||||
const char* c;
|
||||
int i;
|
||||
};
|
||||
|
||||
int main() {
|
||||
(void)boost::pfr::names_as_array<test_union>(); // Must be a compile time error
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ struct A {
|
||||
int second;
|
||||
};
|
||||
|
||||
struct empty {};
|
||||
|
||||
void test_get_name_by_id() {
|
||||
BOOST_TEST_EQ( ((boost::pfr::get_name<0, Aggregate>())), "member1");
|
||||
BOOST_TEST_EQ( ((boost::pfr::get_name<1, Aggregate>())), "this_is_a_name");
|
||||
@@ -64,6 +66,11 @@ void test_names_as_array() {
|
||||
}
|
||||
}
|
||||
|
||||
void test_names_as_array_for_empty() {
|
||||
const auto value = boost::pfr::names_as_array<empty>();
|
||||
BOOST_TEST_EQ(value.size(), 0);
|
||||
BOOST_TEST_EQ(value.empty(), true);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
|
||||
@@ -71,6 +78,7 @@ int main() {
|
||||
testing::test_get_name_by_id();
|
||||
testing::test_get_name_by_type();
|
||||
testing::test_names_as_array();
|
||||
testing::test_names_as_array_for_empty();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace testing
|
||||
{
|
||||
|
||||
constexpr std::string_view fake_func_name = " ******************** [fake_text1->fake_text2->fake_text3] **********";
|
||||
constexpr std::string_view fake_func_name = " ******************** [fake_text1->fake_text2->fake_text3] **********";
|
||||
|
||||
void test_general()
|
||||
{
|
||||
Reference in New Issue
Block a user