Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/String.h

Issue 29685634: Noissue - Allow displaying String in tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add utf8 conversion Created Feb. 1, 2018, 7:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | meson.build » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/String.h
===================================================================
--- a/compiled/String.h
+++ b/compiled/String.h
@@ -16,16 +16,20 @@
*/
#pragma once
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <type_traits>
+#ifdef INSIDE_TESTS
+#include <iostream>
+#include <codecvt>
+#endif
#include "debug.h"
#include "library.h"
inline void String_assert_writable(bool isWritable);
class String
{
@@ -188,16 +192,25 @@
else if (currChar >= 128)
{
mBuf[i] = CharToLower(currChar);
}
}
}
};
+#ifdef INSIDE_TESTS
+inline std::ostream& operator<<(std::ostream& os, const String& str)
+{
+ std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> converter;
+ os << converter.to_bytes(str.data(), str.data() + str.length());
+ return os;
+}
+#endif
+
class DependentString : public String
{
public:
explicit DependentString()
: String(nullptr, 0, INVALID)
{
}
@@ -252,16 +265,23 @@
void erase()
{
*this = DependentString();
mLen = DELETED;
}
};
+#ifdef INSIDE_TESTS
+inline std::ostream& operator<<(std::ostream& os, const DependentString& str)
+{
+ return os << static_cast<const String&>(str);
+}
+#endif
+
inline DependentString operator "" _str(const String::value_type* str,
String::size_type len)
{
return DependentString(str, len);
}
inline void String_assert_writable(bool isWritable)
{
@@ -415,8 +435,15 @@
for (int i = size - 1; i >= 0; i--)
{
mBuf[pos + i] = '0' + (num % 10);
num /= 10;
}
}
};
+
+#ifdef INSIDE_TESTS
+inline std::ostream& operator<<(std::ostream& os, const OwnedString& str)
+{
+ return os << static_cast<const String&>(str);
+}
+#endif
« no previous file with comments | « no previous file | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld