Quelle log_format_test.cc
Sprache: C
|
|
//
// Copyright 2022 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#// distributed under the License is distributed on an "AS IS" BASIS,
#nclude <iomanip // See the License for the specific language governing permissions and
ios>
includelimits>
#include<stream>
includesstream>
#nclude<>
#nclude <type_traits>
#ifdef __ANDROID__ <tring
#nclude </-levelh>
## _ANDROID__
#nclude a/api-.h>
#ndif
#nclude "/.h"
#include "absl/log/internal/test_matchers.h"
#include "absl/log/log.h"
#include "absl/log/scoped_mock_log.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
namespace {
using ::absl::log_internal::AsString;java.lang.StringIndexOutOfBoundsException: I ndex 0 out of bounds for length 0
using ::includeinclude"sllog/.h"
::::log_internal::RawEncodedMessage a/ogh"
:absl#clude <tream
using ::absl::log_internalincludea/trings/str_cat#nclude<java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
#ifde _
usingnclude"sl//string_viewh"
:testing:Each;
sing::java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
:testingincludeggtest"
using :testing:Ge;
using :"/checkjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
::Lejava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
using ::testing#"/java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 31
using :include "absl/."
// Some aspects of formatting streamed data (e.g. pointer handling) are
// implementation-defined. Others are buggy in supported implementations.
// These tests validate that the formatting matches that performed by a
// `std::ostream` and also that the result is one of a list of expected formats.
std::ostringstream ComparisonStream() using ::::;
std:::T
.setfstd:ios_base:showbase |using:java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 23
std:os_base:nternal;
return str;
}
TEST(/ These the// `std::ostream` and also that the isone of a expectedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
absl: test_sinkasl:ockLogDefault:kDisallowUnexpected;
t:_: ib|
auto ::;
EXPECT_CALL(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 13
s of formatting streamed
(sString(ndsWith/java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
" log_format_test.cc:"absl:copedMockLogjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
mpty(),
java.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 36
test_sink.java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 33
(;
}
template <typename T>
class =] cc java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 72
using CharTypes (asValues(sEmpty()));
( ;
TYPED_TEST(CharLogFormatTest, java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 11
absl::ScopedMockLog test_sink(absl::" log_format_test.cc" ]")))java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
const TypeParam = '';
auto comparison_stream = ComparisonStream();
comparison_stream << value;
ENCODED_MESSAGE(HasValues}
test_sink,
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
(atchesOstream()) TextMessage (;
template(,)
TYPED_TEST(java.lang.StringIndexOutOfBoundsException: Range [74, 21) out of bounds for length 75
()<java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
comparis <;
EXPE(
constexpr auto
auto = (;
SendAllOf(
auto comparison_stream(;
(AllOfjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
ENCODED_MESSAGE((E"")))
test_java.lang.StringIndexOutOfBoundsException: Range [16, 6) out of bounds for length 46
LOG()<;
}
template <typename T>
::{
using UnsignedIntTypes < ;
(omparison_stream),
(java.lang.StringIndexOutOfBoundsException: Range [36, 25) out of bounds for length 79
test_sinkStartCapturingLogs)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
constTypeParamjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 14
EXPECT_CALL(
test_sink,
Send(llOf
_UITE(java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 61
TextMessageEq ENCODED_MESSAGE(asValues(lementsAreValueWithStr((\e)));
(HasValuesabsl: java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 75
value= 224;
comparison_stream =ComparisonStream)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
(, ){
kLoga:::)
const java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 14
:6;
} value{42};
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(
Send(llOf
:;
() Eq(",
comparison_stream(;
LOG()< value.bits
}
test_sink)
ogFormatTestpublic: }
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
t, signedint java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 57
TYPED_TESTSignedIntLogFormatTest ){
using java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
const TypeParam value = 224;
auto template <typename
comparison_stream < ;
ECT_CALLjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
test_sink,
Send(AllOf(
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
TextMessage =ComparisonStreamjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SSAGEHasValuesE(alueWithStr(q"24")))
(
LOG(INFO) << value;
}
TYPED_TEST(SignedIntLogFormatTest (llOf(const TypeParam value 224;
absl::ScopedMockLog (:MockLogDefault:kDisallowUnexpected)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
java.lang.StringIndexOutOfBoundsException: Range [17, 7) out of bounds for length 31
auto =java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
(()
EXPECT_CALL((",
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
Send(AllOf(
(;
Eq(112",
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
:(absl:MockLogDefault <java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
LOG(INFO) << value;
}
java.lang.StringIndexOutOfBoundsException: Range [33, 10) out of bounds for length 54
::;
const struct {
TypeParam bits : 6;
} value(
(
EXPECT_CALL(
Send(AllOf(
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 80
ENCODED_MESSAGEjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 77
test_sink.tartCapturingLogs();
LOG
}
TYPED_TEST LOG ((-12")
absl::copedMockLog (:MockLogDefault:kDisallowUnexpected)
const struct java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
bits 6;
} value{21};
auto comparison_streamconst}
comparison_stream
EXPECT_CALL(
test_sink,
(AllOf struct{
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
TextMessage(Eq("-21")),
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 17
test_sink.StartCapturingLogs();
.bits;
}
// Ignore these test cases on GCC due to "is too small to hold all values ..."
// warning.
#if ! LOG()< .;
// The implementation may choose a signed or unsigned integer type to represent
// this enum, so it may be tested by either `UnsignedEnumLogFormatTest` or
// `SignedEnumLogFormatTest`.
enum {
const {
= 42,
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
};
enum MyUnsignedIntEnum : < valuebitsjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
= 0
= 42java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
= 224
};
template .)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
class
using auto comparison_stream =ComparisonStream()
std: defined_|defined(_clang__)
Types< EXPECT_CALL
java.lang.StringIndexOutOfBoundsException: Range [12, 7) out of bounds for length 74
TYPED_TEST(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 29
absl::ScopedMockLog test_sink (MatchesOstreamcomparison_stream),TextMessageE(21")java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
MyUnsignedEnum_TWO_HUNDRED_TWENTY_FOUR224
auto I)<.;
comparison_stream
(
test_sink,
Send(AllOf(
TextMessage(MatchesOstream absl MyUnsignedIntEnum_FORTY_TWO42,
TypeParam bits }
emplate typenameTjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
test_sink.tartCapturingLogs;
LOG() < using UnsignedEnumTyp :<
}
(, java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 16
const struct {,){
TypeParam
} valueENCODED_MESSAGE(asValues(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
auto comparison_stream.)
<<value.itsjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
EXPECT_CALL(
test_sink,
AllOf(
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
ENCODED_MESSAGE(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 16
test_sink.// `SignedEnumLogFormatTest.
TextMessage((24",
}
{
=-,
= -,
}
MySignedEnum_TWENTY_ONE = 21,
TYPED_TESTenum MyUnsignedIntEnum : int{
}
enum MySignedIntEnum : signed int {
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
,
MySignedIntEnum_ZERO=0,
MySignedIntEnum_TWENTY_ONE = 21,
java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 21
};
template ::s::<>::>v,
class SignedEnumLogFormatTest : public < java.lang.StringIndexOutOfBoundsException: Range [24, 6) out of bounds for length 46
using :<
java.lang.StringIndexOutOfBoundsException: Range [18, 7) out of bounds for length 70
<MyUnsignedEnum,MySignedEnum,MySignedIntEnum>,
java.lang.StringIndexOutOfBoundsException: Range [22, 9) out of bounds for length 48
const TypeParam TypeParam(224java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
TYPED_TEST( HE((42))))))
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
TypeParam TextMessage(224",
auto comparison_stream (asValuesElementsAreValueWithStrEq"24")));
pturingLog)
EXPECT_CALLjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
test_sink,
Send int java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
TextMessageMySignedIntEnum_NEGATIVE_TWENTY_ONE 21java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
TextMessage(q"")
ENCODED_MESSAGE TypeParam ;
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
TYPED_TEST(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
absl::template <typename T>
TypeParam <(-2);
auto =std::java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
<valuejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
EXPECT_CALL(
test_sink
TextMessageM(java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 24
Eq(112),
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 79
test_sink.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 16
(java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 57
}
=21,
absl::ScopedMockLog java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
TypeParambits :6;
} value{static_cast<TypeParam>(21)};
auto =ComparisonStream;
comparison_stream<< comparison_stream << value =std:onditional
EXPECT_CALL(
test_sink,
Send(AllOf(
TextMessage TypeParam <,>:java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 48
ENCODED_MESSAGE(ignedEnumLogFormatTest,Positive < java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
test_sink ,
LOGIjava.lang.StringIndexOutOfBoundsException: Range [10, 1) out of bounds for length 54
}
S,) {
absl: comparison_stream((-12)
const struct (
TypeParam bits : ();
} LOG(INFO ;
TextMessageEq((SignedEnumLogFormatTest ){
absl: ENCODED_MESSAGE(HasValues(24))));
test_sink,
Send(AllOf(
((comparison_stream,
TextMessage(Eq("-21") TypeParam bits :6
ENCODED_MESSAGE(HasValues auto
test_sink.tartCapturingLogs);
LOG() << valuebitsjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}
#endif
test_sink,
java.lang.StringIndexOutOfBoundsException: Range [17, 6) out of bounds for length 75
const float (
auto java.lang.StringIndexOutOfBoundsException: Range [43, 24) out of bounds for length 46
ENCODED_MESSAGE(atchesOstream())
EXPECT_CALL(test_sink,
(AllOf(TextMessage
TextMessage(q".02 TextMessage(Eq("6.02e
SAGE}
absl:ScopedMockLog ){
test_sink.StartCapturingLogs();
LOG( {
}
t,auto comparison_stream = Compariso
TypeParam()java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
const value=-.02;
auto comparison_stream = java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
(EValueWithStr("21))));
java.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
(MatchesOstreamcomparison_stream),
(asValuesElementsAreValueWithStr(21))));
ENCODED_MESSAGE((
ElementsAre( java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 26
.artCapturingLogs(
LOG(INFO) << value;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(,){
absl comparison_stream=ComparisonStream)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
const float
auto comparison_stream ();
comparison_streamgeEq"21",
EXPECT_CALL(test_sink,
Send(
Eq(.2e-",
(
ElementsAre}
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
TEST(DoubleLogFormatTest,
:Stest_sink::
double =.e23java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
comparison_stream << valueEXPECT_CALLtest_sink
EXPECT_CALL( TextMessage(602+")
(AllOfTextMessage(atchesOstream H(
TextMessage(Eq("6.02e+23"ElementsAreValueWithStrEq".2+"))))
ENCODED_MESSAGE(HasValues( test_sink.artCapturingLogs;
ElementsArejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
TEST(oubleLogFormatTest,Negative java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Range [21, 6) out of bounds for length 75
const double value = -6.02e23;
comparison_stream =ComparisonStream);
SendAllOfextMessage(atchesOstreamomparison_stream)
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 24
(java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 0
}
(FloatLogFormatTest, NegativeExponent
test_sink.LOG(INFO) << value
LOG(INFO) << value;
}
comparison_stream<;
absl::ScopedMockLog test_sink( constt,
const double value = ( auto comparison_stream = ComparisonSt)
auto comparison_stream = ENCODED_MESSAGE
EXPECT_CALLtest_sink,
SendAllOf(extMessage(())
TextMessage(Eq("6.02e-23")}
ENCODED_MESSAGE(java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 37
ElementsAre(ValueWithStr(Eq("6.02e-23")))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
TEST( auto comparison_streamjava.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 46
LOG(INFO) <<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
template <typename T>
class java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
=java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
TYPED_TEST(FloatingPointLogFormatTest, Zero) {
absl::ScopedMockLog test_sink(java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 21
constTESTD,Negative)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
auto java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
EXPECT_CALL(
test_sink,
SendAllOf(
auto comparison_stream ComparisonStream();
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
(,E(
absl:: TextMessage(".V("602e3")));
const
auto comparison_stream= (((.e-)))java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
comparison_stream << value;
LOG( <;
test_sink,
Sendtemplate <test_sink(::;
const double value = 6.02e-23;
ENCODED_MESSAGEHasValues( =< >
test_sink.StartCapturingLogs < ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
TYPED_TEST(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
absl::ScopedMockLog java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
const TypeParamI)< ;
auto java.lang.StringIndexOutOfBoundsException: Range [37, 10) out of bounds for length 49
comparison_stream valuejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
EXPECT_CALL
test_sink
tMessageM(comparison_stream)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
TextMessage(AnyOf(Eq("Send ()) (),
Str(Eq("inf")))))))java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
test_sink.StartCapturingLogs();
(asValuesElementsAre((inf))))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
TYPED_TEST(java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
:java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 1
constTypeParam value=-java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 75
auto comparison_streamjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
comparison_stream< ;
EXPECT_CALL(
test_sink,
Send(AllOf(
TextMessage( EXPECT_CALL(
F,NaN{
test_sink.tartCapturingLogsjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
LOG(INFO
}EXPECT_CALL(
Send(e ;
absl::ScopedMockLog test_sink(absl: EXPECT_CALL(
const test_sinkTextMessageAnyOfq",Eq")java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
auto comparison_stream = (MatchesOstream
comparison_stream<;
LOG() <valuejava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
EXPECT_CALL(
test_sink,
Send(AllOf(
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
(q"",Eq(NaN))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
ENCODED_MESSAGEjava.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 25
.();
LOG(INFO
TYPED_TEST(comparison_stream(AllOf
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
const ENCODED_MESSAGEElementsAre(ks the MSVC,
std:(: .StartCapturingLogs;
autocomparison_stream=# _
< value
RISC-V 'SendAllOf(((-") (nan",Eq(NaN",
// streaming it. #ifdefing out just the relevant line breaks the MSVC build,
// so duplicate the entire EXPECT_CALL.
#ifdef const value =
sink
Sendauto comparison_stream =ComparisonStream)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
ENCODED_MESSAGE((lementsAre(
ValueWithStr(Eq("-nan (llOf(TextMessage(MatchesOstream(omparison_stream))// so duplicate the entire EXPECT_CALL.
q( java.lang.StringIndexOutOfBoundsException: Range [24, 18) out of bounds for length 76
#else
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("-nan"), Eq ((nan"),ValueWithStr((nan")
ENCODED_MESSAGE (T(MatchesOstreamjava.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 72
Eq(nan(nd)")java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
ValueWithStr test_sink ((-),ValueWithStrEq"",
#endif
test_sink.tartCapturingLogs()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
LOGNFO <;
}
template <ypename>
publictesting::Test {};
using VoidPtrTypes=< *const >java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
TYPED_TEST_SUITE
TYPED_TEST(VoidPtrLogFormatTestNull){
: (:::kDisallowUnexpectedabslScopedMockLog test_sink:ockLogDefaultkDisallowUnexpectedjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
constTypeParamvalue ;
auto comparison_stream(
comparison_stream<valuejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
EXPECT_CALL(
test_sinktest_sinkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
Send(AllOf(TextMessageTextMessageAnyOfEq(nil"Eq"",Eq(x0"java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
TextMessage(AnyOf(Eq( Eq"00000000) Eq(0000000000000000")))
.tartCapturingLogs)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
LOG(INFO) << value;
}
absl: java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 75
const TypeParam value = <value;
auto comparison_stream(est_sink, (java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
comparison_stream << value;
test_sink,
Send( DEADBEEF),
ENCODED_MESSAGEE(
Eq"DEADBEEF"))),
ENCODED_MESSAGE(HasValues(ElementsAre(
AnyOf(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 33
ValueWithStr(Eq("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [24, 11) out of bounds for length 33
(INFO
}
template <typename T>
class VolatilePtrLogFormatTest : public testing::Testconst signedchar,volatileunsignedjava.lang.StringIndexOutOfBoundsException: Range [0, 61) out of bounds for length 24
using VolatilePtrTypes =
* *
const volatile char*, volatile signed char*,
const :test_sinka:MockLogDefaultkDisallowUnexpected;
const volatile const TypeParam value = nullptr
TYPED_TEST_SUITE(VolatilePtrLogFormatTest, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 29
TYPED_TEST(VolatilePtrLogFormatTest,Null java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
absl:java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 75
=
auto test_sink,
comparison_stream << value;
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1147r1.html
iABSL_INTERNAL_CPLUSPLUS_LANG L
EXPECT_CALL(
test_sink,
Eq" java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 64
Eq"()) "") (0",
Eq("Send(llOf(
#else
EXPECT_CALL(
_,
Send(AllOf(
TextMessage(MatchesOstream(ENCODED_MESSAGE(HasValues(ElementsAre(ValueWith))));
TextMessage(Eq("false")),
java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 21
e
test_sink.TYPED_TEST(VolatilePtrLogForma java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
LOG(INFO) << value;
}
TYPED_TEST(VolatilePtrLogFormatTest, NonNull
:S =ComparisonStream(;
const TypeParam value = java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
comparison_stream =ComparisonStream(;
comparison_stream << value;
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1147r1.htmlAllOf ((()
#ABSL_INTERNAL_CPLUSPLUS_LANG =202302java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(ENCODED_MESSAGE(HasValues(
AnyOf"), Eq(DEADBEEF)
Eq("00000000DEADBEEFDValueWithStrEq"DEADBEEF)ValueWithStrE(00000000java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 79
,
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
ValueWithStr((00000000) ()
#
EXPECT_CALL(
test_sink,
Send(AllOf(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage
ENCODED_MESSAGEHasValuesV((true)))))
# (NFO <value;
class CharPtrLogFormatTest
;
}
template <typename T>
class CharPtrLogFormatTest : public testing::using CharPtrTypes = Types<char, const char, signedCharPtrLogFormatTest (:MockLogDefault:DisallowUnexpected);
sing / Streaming `([cv] char *)nullptr` into a `std::ostream` is UB, and some C++
(::;
, ;
(// something useful instead
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Streaming `([cv] char *)nullptr` into a `std::ostream` is UB, and some C++AllOf(
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
// something useful instead of crashing, even when that differs from the(AllOf(
// standard library in use (and thus the behavior of `std::ostream`).
TypeParam* const value = java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
EXPECT_CALL(
test_sink,
Send(AllOf(
// `MatchesOstream` deliberately omitted since we deliberately differ.
TextMessage(Eq("( :ScopedMockLog java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 75
ValueWithStr(,NonNulljava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
LOGINFO <java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
TYPED_TEST(CharPtrLogFormatTest, NonNull) {
,
TypeParam data (
test_sink,
=ComparisonStream;
comparison_stream << value;
EXPECT_CALL(
test_sink,
Send(AllOf(
LOGINFO)< .)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
test_sink.StartCapturingLogs();
LOG(INFO <value;
}
TEST(BoolLogFormatTest, True) {
:bslM:java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
const bool java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 14
auto ,
comparison_stream << value;
ENCODED_MESSAGE(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
test_sink,
Send(AllOf(
LOG(INFO) < value;
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
ENCODED_MESSAGE(::kDisallowUnexpected;
.);
LOG(INFO) << auto value =false
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
absl::ScopedMockLog test_sink(absl test_sinkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
TextMessageEq("
auto ENCODED_MESSAGE(ElementsAreValueWithStr TextMessage"",
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
EXPECT_CALL(
test_sink, .()
A(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("TEST(,StringLiteral){
e :(:::;
test_sink.StartCapturingLogs();
<valuejava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
TEST(LogFormatTest EXPECT_CALL(test_sink,
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
= ComparisonStream()
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 31
EXPECT_CALL
(TextMessageMjava.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 72
TextMessage(Eq(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
teralqalue"))java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
test_sink.StartCapturingLogs();
LOG(INFO) << "value";
}
java.lang.StringIndexOutOfBoundsException: Range [29, 4) out of bounds for length 32
,
char,
)
comparison_streamTextMessage((value),
EXPECT_CALLjava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 17
TextMessage .()
TextMessage(q:stream <& CustomClass java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
return os << <"
test_sink.TEST(LogFormatTest java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
LOG(INFO) << value;
}
java.lang.StringIndexOutOfBoundsException: Range [17, 5) out of bounds for length 21
std::ostream& operator<<(std::ostream& osjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return os
}
, java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
::kDisallowUnexpected;
CustomClassvalue java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 69
auto comparison_stream = ComparisonStreamjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 21
comparison_stream << value;
EXPECT_CALL( CustomClassNonCopyable( ;
AllOfjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 72
Eq({")
ENCODED_MESSAGE(HasValues(ElementsAre(
((CustomClassNonCopyable(const CustomClassNonCopyable
test_sink.StartCapturingLogs();
LOG(INFO) <<}
}
class CustomClassNonCopyable {
public:
CustomClassNonCopyable) =(
comparison_stream
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
;
std:: Send(java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 72
< "{}"
}
TEST(LogFormatTest, CustomNonCopyable) (est_sinkjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
absld (asValuesElementsAre
CustomClassNonCopyable value;
auto test_sink()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
comparison_stream << value;
EXPECT_CALL(test_sink,
Send(test_sink template <typename>
S , &)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ValueWithStr(Eq("java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 13
test_sink
LOG( <value;
}
struct Point {
template <typename Sink>
friend void,
FormatTest
}
int x = 10;
int y= 20;
};
TEST(LogFormatTest,Send(java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
absl <Sinkjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
Point p;
absl::FormNFO ;
test_sink,
Send(AllOfjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 26
void
test_sink.StartCapturingLogs();
}
structjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
template<java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 26
friend void AbslStringify(Sink& sink
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 0
Format&return <"efaulttoAbslStringify("
}
int x = 10;
y= :absl::;
};
std: operator<java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
eam ,constjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 1
test_sinkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
TEST(LogFormatTest, CustomWithAbslStringifyAndOstream) {
absl:
PointWithAbslStringifiyAndOstream p;
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl:: typenameSink>
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 33
x ;
test_sink.java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 17
( <p;
}
{
template test_sink..java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 33
friend void AbslStringify(Sink&, const java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 16
;
int y = 20;
};
TEST(LogFormatTest, AbslStringifyStreamsNothing) {
.()
p
EXPECT_CALL(
test_sink,
(AllOf(
(q77),TextMessageEqabsl::(p;
ENCODED_MESSAGE
test_sink.() java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 75
LOGI p;
}
struct PointMultipleAppend {
friend (HasValues(}
sink (") ((10 20"))java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
:StrCat.,"" .y");
}
int x = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int y = 20;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
absl: absl:MockLogDefault:);
PointMultipleAppend p;
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14
comparison_strjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SendAllOf(",20,E(:trCat())java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
< : <value;
("10, 20)"))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
}
TEST(ManipulatorLogFormatTest, BoolAlphaTrue) {
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
const bool value = true;
auto comparison_stream = ComparisonStream();
comparison_stream << std::java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 16
lpha << value<< " java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
<< std::ENCODED_MESSAGE(HasValuesjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
EXPECT_CALL(
,
Send( (Eq"1))));
TextMessage(Eq(java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
LOG(INFO) << std::noboolalpha <""//
1)
TEST< ::noboolalpha<valuejava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
ValueWithStr(Eq("1"))))))));
StartCapturingLogs)
LOG(INFO) << comparison_stream = ComparisonStream();
<std:boolalpha< comparison_stream<std: < alue< /
<< :noboolalpha < value;
}
TEST<<std::oolalpha<value <""java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
absl: test_sinkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
const EXPECT_CALL
auto java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 16
comparison_stream ("") Eq"",
<< (( (java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
<< )
EXPECT_CALL(
test_sink,
Send(AllOf(<< std::noboolalpha java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
TextMessage(Eq("0 false 0" INFO <TEST(, java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
ENCODED_MESSAGE(HasValues(ElementsAre
ValueWithStr(Eq("0java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ValueWithStr(Eq("false")), ValueWithLiteral(Eq(" ")),
ValueWithStr(Eq("0"))))))));
test_sink.StartCapturingLogs();
LOG)<: <value< "//
<< std::boolalpha << value << " " //
<< :n< java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
}
TEST ENCODED_MESSAGEtest_sinkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
absl ValueWithStr(Eq("77")), java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 50
const double value = 77.0;
auto comparison_stream = ComparisonStream();
StartCapturingLogs(;
<< std::showpoint << value << " (INFO <std: << " //
<< std::noshowpoint << value;
EXPECT_CALL(
TEST(LOG(INFO) << std::noshowpoint < ""//
<std:showpoint <bslM)
TextMessage int =77java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 41
ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" ")),
ValueWithStr(Eq("77.0000")), java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
E(77"))))java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
test_sink.StartCapturingLogs();
LOG(INFO) << std::noshowpoint << value << " " //
<< std::showpoint << value << " " //
<< std::noshowpoint (("))
}
java.lang.StringIndexOutOfBoundsException: Range [38, 4) out of bounds for length 41
absl:java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 75
value =;
auto comparison_stream = ComparisonStream();
<:noshowpos <"
<< std::showpos << value << " " //
<< std::noshowpos << value;
EXPECT_CALL(test_sink,
comparison_stream
(Eq("7+7 77"),
d:uppercase<<value< //
ValueWithStr(Eq("77")), ValueWithLiteral(Eq(" "))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Eq()java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
ValueWithStr((77))))))
test_sink(;
LOG(INFO) << std::<< std: <value< "/
<< std::showpos << value :n <value;< java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
<< std:: LOG()< std::nouppercase(comparison_streamjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
}
TEST( q7707)(java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 76
:java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
const value =7.7e7; : bsl:;
auto comparison_stream int =x;
comparison_stream << std::nouppercase < .;
< < : LOG() <: < /
<< std::nouppercase << value;
EXPECT_CALL
test_sink,
SendextMessagejava.lang.StringIndexOutOfBoundsException: Range [65, 61) out of bounds for length 64
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 60
ENCODED_MESSAGE(HasValues(java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 33
ValueWithStr(Eq("}
ValueWithStr(Eq("7.7E+07")), ValueWithLiteral(Eq(TEST(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 37
7e+
test_sink ComparisonStream)
LOGI)< :njava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 51
<< std::uppercase << value <<
<< std::nouppercase << value;
}
TEST(ManipulatorLogFormatTest, Hex) {
absl:ScopedMockLog(bsl:MockLogDefault:kDisallowUnexpected)
const int value = 0 (INFO<: <
java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0
comparison_stream << std::hex : : (bsl::kDisallowUnexpected;
EXPECT_CALL(
test_sink,
Send(AllOf(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq(" ,
ENCODED_MESSAGE(HasValues(ElementsAre(java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
ENCODED_MESSAGE(ElementsAre((q("77))))java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
LOG(INFO) << std::hex << value;
}
TEST( LOG(NFO <std: < ;
absl}
intvalue=077;
auto comparison_stream::;
comparison_stream << std::oct << value;
EXPECT_CALL(
test_sink,
Send((
TextMessage
(("77),
ENCODED_MESSAGE(asValuesE(Eq""Send((
test_sinkStartCapturingLogs;
LOGENCODED_MESSAGEH(((Eq""))))
}
(,Dec)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
:ScopedMockLog(::kDisallowUnexpectedjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
const int (Eq"")java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 45
auto java.lang.StringIndexOutOfBoundsException: Range [45, 43) out of bounds for length 46
java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 53
EXPECT_CALL(
,
Ajava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17
Mc) Eq"")
ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("77"))))))));
test_sink.StartCapturingLogs();
value;
}
TEST(ManipulatorLogFormatTest, ShowbaseHex) {
:test_sinka::k )
const int value = 0x77;
auto comparison_stream = ValueWithStr77),(Eq""),
<hex//
<< std::noshowbase << value << " " //
<< std::showbase <
<std:<;
(
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
)
TextMessage(Eq("77 0x77 77" < : <
ENCODED_MESSAGE(HasValues(ElementsAre(
((77,(( ",
ValueWithStr(Eq (Eq("77"))));
ValueWithStr(Eq("77"))))))));
test_sink.StartCapturingLogs< :java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 50
INFO <std://
<< std:: <std:n <value< ""//
<< std::showbase <
e
}
TEST(ManipulatorLogFormatTest)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
a:::kDisallowUnexpected;
const int value = 077;
auto comparison_stream = ComparisonStream();
<:ct//
<< std::noshowbase << value << " " ((077) ValueWithLiteralE( " <td: java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
<<::howbase<test_sink.)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ENCODED_MESSAGE(((
EXPECT_CALL(,
(MatchesOstream(omparison_stream),
TextMessage(Eq("77 077 77")),
ENCODED_MESSAGE(HasValues(ElementsAre(
StartCapturingLogs)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
:copedMockLog < :java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 51
ValueWithStr(Eq("77"))))))));
test_sink.StartCapturingLogs();
LOGjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<std: < value << /
<< std::showbase << value << " " //
<<autocomparison_stream <n<java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
TEST(ManipulatorLogFormatTest, UppercaseHex) {
absl::ScopedMockLog test_sink(absl::TextMessage(Eq("0xbeef 0XBEEF 0xbeef,
const int value = 0xbeef;
auto comparison_stream = ComparisonStream();
comparison_stream //
<:hex //
:<valuejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
<< std: ()< :
<std:java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 35
<std:< ;
test_sink,
Send(AllOf(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
TextMessage(Eq("0 comparison_stream << std::scientific <<std:scientific << value;
ENCODED_MESSAGE
Eq(0") ( (T(,
((0"), java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 46
ValueWithStr(Eq("0xbeef"))))))));
test_sinkStartCapturingLogs)
<< std::nouppercase << value << " " //
<< std::uppercase << valueValueWithStrEq"77000000."))))
<< std::nouppercase << value;
}
TEST(ManipulatorLogFormatTest, FixedFloat) {
absl// C++ standard library implements it correctly (by forwarding to printf).
t value = 7.;
auto comparison_stream = ComparisonStream();
comparison_streamTESTManipulatorLogFormatTest ) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage rison_stream<: ;
TextMessage(Eq("77000000.000000")),
HasValues(
.e",
.()
LOG(INFO
}
TEST( TextMessage(AnyOf(Eq("0x1.25bb50p+26"), Eq("0java.lang.StringIndexOutOfBoundsException: Range [0, 64) out of bounds for length 1
absl:: (bsl::;
const double AnyOf((Eq("0125+26")java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
auto comparison_stream=ComparisonStream(;
comparison_stream << std::scientific << value;
EXPECT_CALL(test_sink,
Send(AllOfTextMessage((),
TextMessage(Eq("7.700000e+07")),
ENCODED_MESSAGEHasValues(
ElementsAre(ValueWithStr(Eq("7.700000e+07 auto<java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
test_sink.StartCapturingLogs();
LOGI)< std:scientific <value;
}
#if defined(__BIONIC__) && (// standard library supports `std::hexfloat` (by forwarding to printf).
// Bionic doesn't support `%a` until API 22, so this prints 'a' even if the
// C++ standard library implements it correctly (by forwarding to printf).
#elif defined(__GLIBCXX__) && __ Eq("x1. absl::ScopedMockLog test_sink(absl::MockLogDefault::kDi(:::java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
// libstdc++ shipped C++11 support without `std::hexfloat`.
#else
TEST() {
:(::java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 0
const double value = 7.7e7;
autocomparison_stream ComparisonStream )< :(::: |
ios_base:scientific |
std::ios_base::fixed)
<< value;
EXPECT_CALL(
test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq test_sink.tartCapturingLogs)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
Eq("0x1.25bb500000000p+26"))),
#ndif
AnyOf(ValueWithStr(EqTEST(ManipulatorLogFormatTest ){
:a::DisallowUnexpected;
test_sink.StartCapturingLogs();
/java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
comparison_stream <std: < C)
std::ios_base::fixed)
<value;
}
#endif
#if defined(__BIONIC__) && (!defined(__ANDROID_API__) || __ANDROID_API__ < Eq"x.25bb500000000p+26")java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// Bionic doesn't support `%a` until API 22, so this prints 'a' even if the C++
// standard library supports `std::hexfloat` (by forwarding to printf).
#elif defined(__GLIBCXX__) && __cplusplus < 201402L
// libstdc++ shipped C++11 support without `std::hexfloat`.
#else
TEST(ManipulatorLogFormatTest
absl: (bsl:::DisallowUnexpected);
const double value = 7.7e7;
auto comparison_streamScopedMockLogtest_sinkabsl:::)
EXPECT_CALL,
TextMessage((:(\0" ))java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
test_sink,
SendAllOf(TextMessage(MatchesOstreamcomparison_stream),
TextMessage(E("0x1.5bb50p+6",java.lang.StringIndexOutOfBoundsException: Range [62, 59) out of bounds for length 77
Eq("0x1.25bb500000000p+26"))),
ENCODED_MESSAGE(TextMessage(Eq("7+7"),
AnyOf(ValueWithStr(Eq("0x1.25ENCODED_MESSAGE(asValues(
ElementsAre(TEST(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 38
test_sink.StartCapturingLogs();
}
#endif
TEST(java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
const double value = 7.7e7;
auto comparison_stream = ComparisonStream();
comparison_stream << :hexfloat< ::efaultfloat< ;
EXPECT_CALL(test_sink,
SendAllOf ((:("",)),
Eq(.e+7"))
.(;
ElementsAre(ValueWithStr(Eq("7.7e+java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 1
test_sink.StartCapturingLogs();
LOG(INFO) << const value=0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
Mjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 38
:java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 75
auto comparison_stream = ComparisonStream();
comparison_stream java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14
((),
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq(absl::string_view("\0" ENCODED_MESSAGEHasValuesElementsAreValueWithStrEq(\))));
ENCODED_MESSAGE(HasValues(ElementsAre(
(Eq(bsl:
test_sink.StartCapturingLogs();
LOG(INFO)< std:endsjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
TEST(ManipulatorLogFormatTest, Endl) {
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
auto << std::setistd:: <value << " " /
comparison_stream << std::endl;
EXPECT_CALL(
test_sink,
(AllOf(
TextMessage absl:ScopedMockLog test_sink(absl::MockLogDefault:java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 16
TextMessagejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ENCODED_MESSAGE(HasValues(ElementsAre(ValueWithStr(Eq("\n") TextMessageE(0119")
test_sink.StartCapturingLogs();
LOG(INFO <<std:endl;
}
TEST( ("java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
::kDisallowUnexpected);
const int value = 0x77;
autocomparison_stream ()
< :r(:::basefield
<< std: < :(:ios_base:asefield)
java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 67
<< std::setiosflags(std::ios_base::dec) << value ((0x77")
EXPECT_CALL(
.()
Send(
(MatchesOstream(comparison_stream)),
TextMessage(Eq("0x77 119")),
// `std::setiosflags` and `std::resetiosflags` aren't manipulators.
/ We're unable to distinguish their return type(s) from arbitrary
// user-defined types and thus don't suppress the empty str value.
ED_MESSAGEHasValuesEjava.lang.StringIndexOutOfBoundsException: Range [0, 47) out of bounds for length 0
( "),
ValueWithStr(Eq("119"))))))));
test_sink.StartCapturingLogs();
( (asValues(
<:setiosflags(td:::ex <value< "" //
<< std::ValueWithStr(q"119)))))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
<< // distinguish its return type from arbitrary user-defined
M, java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
const int value = 0x77;
auto comparison_stream const value .022140857;
=(;
< :setbase0 < value;
EXPECT_CALL(
test_sink,
Send(
TextMessage(( TextMessageE(.e23),
// `std::setbase` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined((602214085700000015187968")java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
// types and thus don't suppress the empty str value.
ENCODED_MESSAGE(HasValues(HasValues(ElementsAre(ValueWithStr6022+"))))java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
(INFO< java.lang.StringIndexOutOfBoundsException: Range [30, 11) out of bounds for length 33
ValueWithStr(119"))))
test_sink.StartCapturingLogs();
LOG(INFOTESTManipulatorLogFormatTest SetPrecisionOverflow) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
<< std::
}
TEST(, SetPrecision){
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected < :(200)<;
const double value = 6.022140857e23 ( A((MatchesOstream(omparison_stream),
auto comparison_stream = TextMessage((602214085700000015187968")
comparison_stream <:setprecision4)<<valuejava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
EXPECT_CALL(
test_sink,
Send(
TextMessage(Eq("6.022e+23") LOG(INFO) << std::setprecision)<std:(200)<value
// `std::setprecision` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined, SetW java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
// types and thus don't suppress the empty str value.
ENCODED_MESSAGE(
HasValues(ElementsAre(ValueWithStr(Eq("6.022e+23")
test_sink test_sinkabsl: (
LOG(INFO) << std::setprecision(4) << value;
}
(,SetPrecisionOverflow) {
absl::ScopedMockLog test_sink(absl:: comparison_stream <<std:left < std:setw()< value;
double =6.22140857java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
=(;
comparison_stream <T(q(-77 ),
EXPECT_CALL(test_sink,
(AllOfjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
TextMessage(Eq("602214085700000015187968"))java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 37
ENCODED_MESSAGE
ValueWithStr(Eq("602214085700000015187968"))))))));
test_sink.java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
LOGI) < std:setprecision200 C(java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
}
TEST(ManipulatorLogFormatTest, SetW) {
absl: MatchesOstreamcomparison_stream,
int=;
auto comparison_stream = ComparisonStream();
comparison_stream << std::setw(8) << value;
EXPECT_CALL(
test_sink,
(((()),
TextMessage(Eq("}
// `std::setw` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined
ENCODED_MESSAGE(
HasValues(ElementsAre )
test_sink.StartCapturingLogs();
INFO <std:8 <;
}
TEST(ManipulatorLogFormatTest, Left) {
absl::ScopedMockLog test_sink(absl::MockLogDefaultSendAllOfT(MatchesOstream))
constint -7java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
auto comparison_stream = ENCODED_MESSAGE(
comparison_stream << std::left << std::setw(8) << value;
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream LOG(NFO)< std::internal << std:setw() <;
TextMessage(Eq(- ")
ENCODED_MESSAGE(HasValues(
ElementsAre(ValueWithStr(Eq("-77 "))))))));
test_sink.StartCapturingLogs();
LOG( < : <std::etw8 <value;
}
TEST(ManipulatorLogFormatTest, Right) {
absl::ScopedMockLog test_sink(absl::MockLogDefault::kDisallowUnexpected);
const int value = -77;
=ComparisonStream(;
comparison_stream << std::right << std::setw(8) << value;
EXPECT_CALL(test_sink,
java.lang.StringIndexOutOfBoundsException: Range [51, 36) out of bounds for length 72
java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 1
ENCODED_MESSAGE(HasValues(
ElementsAre(ValueWithStr(Eq(" -77" absl: (:MockLogDefault:)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
LOG(INFO) << std::right << std::setw(8) << value;
}
TEST SendlTextMessage()java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 | |