Skip to content

Commit

Permalink
fix bazel coverage failed (alibaba#34)
Browse files Browse the repository at this point in the history
Signed-off-by: zyfjeff <[email protected]>
  • Loading branch information
zyfjeff authored Jun 5, 2024
1 parent 05e2938 commit e528f1b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
5 changes: 1 addition & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module(
name = "hessian2-codec",
repo_name = "com_alibaba_hessian2_codec",
)
module(name = "hessian2-codec")

bazel_dep(
name = "bazel_skylib",
Expand Down
2 changes: 1 addition & 1 deletion demo/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cc_binary(
srcs = [
"demo.cc",
],
copts = ABSL_GCC_FLAGS + ["-std=c++14"],
copts = ABSL_GCC_FLAGS + ["-std=c++17"],
deps = [
"@com_alibaba_hessian2_codec//hessian2:codec_impl_lib",
"@com_alibaba_hessian2_codec//hessian2/basic_codec:basic_codec_lib",
Expand Down
2 changes: 1 addition & 1 deletion demo/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "com_alibaba_hessian2_codec",
commit = "acab3fdcfe1f645729578949f61252353174a8c1",
commit = "05e29382e6c63f77d4cf84e212613b528ba98e0a",
remote = "https://github.com/alibaba/hessian2-codec.git",
)

Expand Down
8 changes: 6 additions & 2 deletions hessian2/basic_codec/string_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ bool finalReadUtf8String(std::string &output, bool &has_surrogate,

output.resize(current_pos + length);
// Read the 'length' bytes from the reader buffer to the output.
reader.readNBytes(output.data() + current_pos, length);
reader.readNBytes(
static_cast<void *>(const_cast<char *>(output.data() + current_pos)),
length);

const auto result = getUtf8StringLength(
absl::string_view(output).substr(current_pos), has_surrogate);
Expand All @@ -286,7 +288,9 @@ bool finalReadUtf8String(std::string &output, bool &has_surrogate,
}
output.resize(current_pos + raw_bytes_length);
// Read the 'padding_size' bytes from the reader buffer to the output.
reader.readNBytes(output.data() + current_pos + length, padding_size);
reader.readNBytes(static_cast<void *>(const_cast<char *>(
output.data() + current_pos + length)),
padding_size);
}

length -= utf8_length;
Expand Down
9 changes: 6 additions & 3 deletions hessian2/basic_codec/string_codec_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ std::string GenerateComplexString() {

std::string GenerateSuperComplexString() {
return "\u0088中国你好!"
"\u0088\u0088\u0088\u0088\u0088\u0088✅❓☑️😊🤔👀🫅🔒🗝️🧫🛹🚅🧻🪞🪞🪞🪞"
"🪞🪞🪞🪞🪞🕟🕟🕟🕟🕟🕟🕟🔅🔅🔅🔅🔅🔅🤍🤍🤍🤍🤍🤍🌈🌈🌈🌈🌈🌈🏦🏦🏦🏦"
"🏦🏦🚎🚎🚎🚎🚎🚎🚎⏰⏰⏰⏰⏰⏲️⏲️⏲️🗄️abcdefghijklmnopqrstuvwxyz1234567@#$"
"\u0088\u0088\u0088\u0088\u0088\u0088✅❓☑️😊🤔👀🫅🔒🗝️🧫🛹🚅"
"🧻🪞🪞🪞🪞"
"🪞🪞🪞🪞🪞🕟🕟🕟🕟🕟🕟🕟🔅🔅🔅🔅🔅🔅🤍🤍🤍🤍🤍🤍🌈🌈🌈🌈🌈🌈🏦🏦🏦"
"🏦"
"🏦🏦🚎🚎🚎🚎🚎🚎🚎⏰⏰⏰⏰⏰⏲️⏲️⏲️🗄️abcdefghijklmnopqrstuvwxyz1234567@#"
"$"
"%^&*()_+⏲️⏲️⏲️⏲️🐪🐫c⏰";
}

Expand Down

0 comments on commit e528f1b

Please sign in to comment.