Fix modernize-raw-string-literal complaints from clang-tidy.

This commit is contained in:
2021-03-07 17:03:24 -05:00
parent 239a7d93ae
commit 7a34bd7c28
4 changed files with 38 additions and 40 deletions

View File

@@ -55,17 +55,17 @@ TEST(cryptomatte, layer)
ASSERT_EQ("{}", layer.manifest()); ASSERT_EQ("{}", layer.manifest());
layer.add_hash("Object", 123); layer.add_hash("Object", 123);
ASSERT_EQ("{\"Object\":\"0000007b\"}", layer.manifest()); ASSERT_EQ(R"({"Object":"0000007b"})", layer.manifest());
layer.add_hash("Object2", 123245678); layer.add_hash("Object2", 123245678);
ASSERT_EQ("{\"Object\":\"0000007b\",\"Object2\":\"0758946e\"}", layer.manifest()); ASSERT_EQ(R"({"Object":"0000007b","Object2":"0758946e"})", layer.manifest());
} }
TEST(cryptomatte, layer_quoted) TEST(cryptomatte, layer_quoted)
{ {
blender::bke::cryptomatte::CryptomatteLayer layer; blender::bke::cryptomatte::CryptomatteLayer layer;
layer.add_hash("\"Object\"", 123); layer.add_hash(R"("Object")", 123);
ASSERT_EQ("{\"\\\"Object\\\"\":\"0000007b\"}", layer.manifest()); ASSERT_EQ(R"({"\"Object\"":"0000007b"})", layer.manifest());
} }
static void test_cryptomatte_manifest(std::string expected, std::string manifest) static void test_cryptomatte_manifest(std::string expected, std::string manifest)
@@ -77,17 +77,15 @@ static void test_cryptomatte_manifest(std::string expected, std::string manifest
TEST(cryptomatte, layer_from_manifest) TEST(cryptomatte, layer_from_manifest)
{ {
test_cryptomatte_manifest("{}", "{}"); test_cryptomatte_manifest("{}", "{}");
test_cryptomatte_manifest("{\"Object\":\"12345678\"}", "{\"Object\": \"12345678\"}"); test_cryptomatte_manifest(R"({"Object":"12345678"})", R"({"Object": "12345678"})");
test_cryptomatte_manifest("{\"Object\":\"12345678\",\"Object2\":\"87654321\"}", test_cryptomatte_manifest(R"({"Object":"12345678","Object2":"87654321"})",
"{\"Object\":\"12345678\",\"Object2\":\"87654321\"}"); R"({"Object":"12345678","Object2":"87654321"})");
test_cryptomatte_manifest(R"({"Object":"12345678","Object2":"87654321"})",
R"( { "Object" : "12345678" , "Object2" : "87654321" } )");
test_cryptomatte_manifest(R"({"Object\"01\"":"12345678"})", R"({"Object\"01\"": "12345678"})");
test_cryptomatte_manifest( test_cryptomatte_manifest(
"{\"Object\":\"12345678\",\"Object2\":\"87654321\"}", R"({"Object\"01\"":"12345678","Object":"12345678","Object2":"87654321"})",
" { \"Object\" : \"12345678\" , \"Object2\" : \"87654321\" } "); R"({"Object\"01\"":"12345678","Object":"12345678", "Object2":"87654321"})");
test_cryptomatte_manifest("{\"Object\\\"01\\\"\":\"12345678\"}",
"{\"Object\\\"01\\\"\": \"12345678\"}");
test_cryptomatte_manifest(
"{\"Object\\\"01\\\"\":\"12345678\",\"Object\":\"12345678\",\"Object2\":\"87654321\"}",
"{\"Object\\\"01\\\"\":\"12345678\",\"Object\":\"12345678\", \"Object2\":\"87654321\"}");
} }
TEST(cryptomatte, extract_layer_hash_from_metadata_key) TEST(cryptomatte, extract_layer_hash_from_metadata_key)
@@ -155,10 +153,10 @@ TEST(cryptomatte, session_from_stamp_data)
MEM_callocN(sizeof(RenderResult), __func__)); MEM_callocN(sizeof(RenderResult), __func__));
BKE_render_result_stamp_data(render_result, "cryptomatte/qwerty/name", "layer1"); BKE_render_result_stamp_data(render_result, "cryptomatte/qwerty/name", "layer1");
BKE_render_result_stamp_data( BKE_render_result_stamp_data(
render_result, "cryptomatte/qwerty/manifest", "{\"Object\":\"12345678\"}"); render_result, "cryptomatte/qwerty/manifest", R"({"Object":"12345678"})");
BKE_render_result_stamp_data(render_result, "cryptomatte/uiop/name", "layer2"); BKE_render_result_stamp_data(render_result, "cryptomatte/uiop/name", "layer2");
BKE_render_result_stamp_data( BKE_render_result_stamp_data(
render_result, "cryptomatte/uiop/manifest", "{\"Object2\":\"87654321\"}"); render_result, "cryptomatte/uiop/manifest", R"({"Object2":"87654321"})");
CryptomatteSession *session = BKE_cryptomatte_init_from_render_result(render_result); CryptomatteSession *session = BKE_cryptomatte_init_from_render_result(render_result);
EXPECT_NE(session, nullptr); EXPECT_NE(session, nullptr);
RE_FreeRenderResult(render_result); RE_FreeRenderResult(render_result);

View File

@@ -333,37 +333,37 @@ void graph_draw(const std::string &label,
} }
f << "<div>" << label << "</div>\n<div>\n" f << "<div>" << label << "</div>\n<div>\n"
<< "<svg version=\"1.1\" " << R"(<svg version="1.1" )"
"xmlns=\"http://www.w3.org/2000/svg\" " R"(xmlns="http://www.w3.org/2000/svg" )"
"xmlns:xlink=\"http://www.w3.org/1999/xlink\" " R"(xmlns:xlink="http://www.w3.org/1999/xlink" )"
"xml:space=\"preserve\"\n" R"(xml:space="preserve"\n)"
<< "width=\"" << view_width << "\" height=\"" << view_height << "\">n"; << R"(width=")" << view_width << R"(" height=")" << view_height << R"(">n)";
for (const std::pair<int, int> &e : edges) { for (const std::pair<int, int> &e : edges) {
const vec2<T> &uco = verts[e.first]; const vec2<T> &uco = verts[e.first];
const vec2<T> &vco = verts[e.second]; const vec2<T> &vco = verts[e.second];
int strokew = thin_line; int strokew = thin_line;
f << "<line fill=\"none\" stroke=\"black\" stroke-width=\"" << strokew << "\" x1=\"" f << R"(<line fill="none" stroke="black" stroke-width=")" << strokew << R"(" x1=")"
<< SX(uco[0]) << "\" y1=\"" << SY(uco[1]) << "\" x2=\"" << SX(vco[0]) << "\" y2=\"" << SX(uco[0]) << R"(" y1=")" << SY(uco[1]) << R"(" x2=")" << SX(vco[0]) << R"(" y2=")"
<< SY(vco[1]) << "\">\n"; << SY(vco[1]) << R"(">\n)";
f << " <title>[" << e.first << "][" << e.second << "]</title>\n"; f << " <title>[" << e.first << "][" << e.second << "]</title>\n";
f << "</line>\n"; f << "</line>\n";
if (draw_edge_labels) { if (draw_edge_labels) {
f << "<text x=\"" << SX(0.5 * (uco[0] + vco[0])) << "\" y=\"" << SY(0.5 * (uco[1] + vco[1])) f << R"(<text x=")" << SX(0.5 * (uco[0] + vco[0])) << R"(" y=")"
<< "\" font-size=\"small\">"; << SY(0.5 * (uco[1] + vco[1])) << R"(" font-size="small">)";
f << "[" << e.first << "][" << e.second << "]</text>\n"; f << "[" << e.first << "][" << e.second << "]</text>\n";
} }
} }
int i = 0; int i = 0;
for (const vec2<T> &vco : verts) { for (const vec2<T> &vco : verts) {
f << "<circle fill=\"black\" cx=\"" << SX(vco[0]) << "\" cy=\"" << SY(vco[1]) << "\" r=\"" f << R"(<circle fill="black" cx=")" << SX(vco[0]) << R"(" cy=")" << SY(vco[1]) << R"(" r=")"
<< vert_radius << "\">\n"; << vert_radius << R"(">\n)";
f << " <title>[" << i << "]" << vco << "</title>\n"; f << " <title>[" << i << "]" << vco << "</title>\n";
f << "</circle>\n"; f << "</circle>\n";
if (draw_vert_labels) { if (draw_vert_labels) {
f << "<text x=\"" << SX(vco[0]) + vert_radius << "\" y=\"" << SY(vco[1]) - vert_radius f << R"(<text x=")" << SX(vco[0]) + vert_radius << R"(" y=")" << SY(vco[1]) - vert_radius
<< "\" font-size=\"small\">[" << i << "]</text>\n"; << R"(" font-size="small">[)" << i << "]</text>\n";
} }
++i; ++i;
} }

View File

@@ -845,12 +845,12 @@ TEST_F(StringEscape, Simple)
{"\\A", "\\\\A"}, {"\\A", "\\\\A"},
{"A\\B", "A\\\\B"}, {"A\\B", "A\\\\B"},
{"?", "?"}, {"?", "?"},
{"\"\\", "\\\"\\\\"}, {R"("\)", R"(\"\\)"},
{"\\\"", "\\\\\\\""}, {R"(\")", R"(\\\")"},
{"\"\\\"", "\\\"\\\\\\\""}, {R"("\")", R"(\"\\\")"},
{"\"\"\"", "\\\"\\\"\\\""}, {R"(""")", R"(\"\"\")"},
{"\\\\\\", "\\\\\\\\\\\\"}, {R"(\\\)", R"(\\\\\\)"},
}; };
testEscapeWords(equal); testEscapeWords(equal);
@@ -868,9 +868,9 @@ TEST_F(StringEscape, Control)
{"\f", "\\f"}, {"\f", "\\f"},
{"A\n", "A\\n"}, {"A\n", "A\\n"},
{"\nA", "\\nA"}, {"\nA", "\\nA"},
{"\n\r\t\a\b\f", "\\n\\r\\t\\a\\b\\f"}, {"\n\r\t\a\b\f", R"(\n\r\t\a\b\f)"},
{"\n_\r_\t_\a_\b_\f", "\\n_\\r_\\t_\\a_\\b_\\f"}, {"\n_\r_\t_\a_\b_\f", R"(\n_\r_\t_\a_\b_\f)"},
{"\n\\\r\\\t\\\a\\\b\\\f", "\\n\\\\\\r\\\\\\t\\\\\\a\\\\\\b\\\\\\f"}, {"\n\\\r\\\t\\\a\\\b\\\f", R"(\n\\\r\\\t\\\a\\\b\\\f)"},
}; };
testEscapeWords(escaped); testEscapeWords(escaped);

View File

@@ -92,12 +92,12 @@ const char *utf8_invalid_tests[][3] = {
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\" |", "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\" |",
"3.1.9 \"\" |", "\x40"}, "3.1.9 \"\" |", R"(@)"},
/* 3.2 Lonely start characters /* 3.2 Lonely start characters
* 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character: */ * 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf), each followed by a space character: */
{"3.2.1 \"\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf " {"3.2.1 \"\xc0 \xc1 \xc2 \xc3 \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf "
"\xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \" |", "\xd0 \xd1 \xd2 \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \" |",
"3.2.1 \" \" |", "\x20"}, "3.2.1 \" \" |", R"( )"},
/* 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), each followed by a space character: */ /* 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef), each followed by a space character: */
{"3.2.2 \"\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \" |", {"3.2.2 \"\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \" |",
"3.2.2 \" \" |", "\x10"}, "3.2.2 \" \" |", "\x10"},