File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 5
5
cmake_path(GET JSON_SOURCE_PATH STEM json_source_basename)
6
6
7
7
file (READ ${JSON_SOURCE_PATH} hex_content HEX)
8
- string (REGEX REPLACE "................" "\\ 0\n " formatted_bytes "${hex_content} " )
9
- string (REGEX REPLACE "[^\n ][^\n ]" "'\\\\ x\\ 0'," formatted_bytes "${formatted_bytes} " )
8
+ string (STRIP "${hex_content} " hex_content)
10
9
11
10
set (header_content
12
- "#include <string_view>
11
+ "#include <util/strencodings.h>
12
+
13
+ #include <string_view>
14
+ #include <cstddef>
15
+
16
+ using namespace util::hex_literals;
13
17
14
18
namespace json_tests {
15
- inline constexpr char detail_${json_source_basename} _bytes[] {
16
- ${formatted_bytes}
17
- };
19
+ inline auto detail_${json_source_basename} _bytes = \" ${hex_content} \" _hex;
18
20
19
- inline constexpr std::string_view ${json_source_basename} {std::begin (detail_${json_source_basename} _bytes), std::end( detail_${json_source_basename} _bytes)};
21
+ inline std::string_view ${json_source_basename} {reinterpret_cast<const char*> (detail_${json_source_basename} _bytes.data()), detail_${json_source_basename} _bytes.size( )};
20
22
}
21
23
" )
24
+
22
25
file (WRITE ${HEADER_PATH} "${header_content} " )
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ static void runtest(std::string filename, const std::string& jdata)
97
97
}
98
98
99
99
#define TEST_FILE (name ) {#name, json_tests::name}
100
- inline constexpr std::array tests{std::to_array<std::tuple<std::string_view, std::string_view>>({
100
+ inline std::array tests{std::to_array<std::tuple<std::string_view, std::string_view>>({
101
101
TEST_FILE (fail1),
102
102
TEST_FILE (fail10),
103
103
TEST_FILE (fail11),
You can’t perform that action at this time.
0 commit comments