mirror of
https://github.com/xenia-project/SPIRV-Tools.git
synced 2024-11-27 05:00:26 +00:00
PrintTo on WordVector should preserve the fill char
This commit is contained in:
parent
5947c40483
commit
590ff131ac
@ -43,4 +43,17 @@ TEST(MakeVector, Samples) {
|
||||
EXPECT_THAT(MakeVector("abcde"), Eq(Words{0x64636261, 0x0065}));
|
||||
}
|
||||
|
||||
TEST(WordVectorPrintTo, PreservesFlagsAndFill) {
|
||||
std::stringstream s;
|
||||
s << std::setw(4) << std::oct << std::setfill('x') << 8 << " ";
|
||||
PrintTo(spvtest::WordVector({10, 16}), &s);
|
||||
// The octal setting and fill character should be preserved
|
||||
// from before the PrintTo.
|
||||
// Width is reset after each emission of a regular scalar type.
|
||||
// So set it explicitly again.
|
||||
s << std::setw(4) << 9;
|
||||
|
||||
EXPECT_THAT(s.str(), Eq("xx10 0x0000000a 0x00000010 xx11"));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -100,6 +100,7 @@ class WordVector {
|
||||
inline void PrintTo(const WordVector& words, ::std::ostream* os) {
|
||||
size_t count = 0;
|
||||
const auto saved_flags = os->flags();
|
||||
const auto saved_fill = os->fill();
|
||||
for (uint32_t value : words.value()) {
|
||||
*os << "0x" << std::setw(8) << std::setfill('0') << std::hex << value
|
||||
<< " ";
|
||||
@ -108,6 +109,7 @@ inline void PrintTo(const WordVector& words, ::std::ostream* os) {
|
||||
}
|
||||
}
|
||||
os->flags(saved_flags);
|
||||
os->fill(saved_fill);
|
||||
}
|
||||
|
||||
// Returns a vector of words representing a single instruction with the
|
||||
|
Loading…
Reference in New Issue
Block a user