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: Created Jan. 31, 2018, 8:45 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,17 @@
*/
#pragma once
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <type_traits>
+#include <iostream>
sergei 2018/02/01 16:10:46 Could you please wrap it by #ifdef INSIDE_TESTS to
hub 2018/02/01 19:16:29 Done.
#include "debug.h"
#include "library.h"
inline void String_assert_writable(bool isWritable);
class String
{
@@ -188,16 +189,25 @@
else if (currChar >= 128)
{
mBuf[i] = CharToLower(currChar);
}
}
}
};
+#ifdef INSIDE_TESTS
+inline std::ostream& operator<<(std::ostream& os, const String& str)
+{
+ for (String::size_type i = 0; i < str.length(); i++)
+ os << static_cast<char>(str[i]);
sergei 2018/02/01 16:10:46 Even for tests I would like to have a helper funct
hub 2018/02/01 19:16:30 Done
+ return os;
+}
+#endif
+
class DependentString : public String
{
public:
explicit DependentString()
: String(nullptr, 0, INVALID)
{
}
@@ -252,16 +262,23 @@
void erase()
{
*this = DependentString();
mLen = DELETED;
}
};
+#ifdef INSIDE_TESTS
+inline std::ostream& operator<<(std::ostream& os, const DependentString& str)
sergei 2018/02/01 16:10:46 It should not be required.
hub 2018/02/01 19:16:30 Without this it operator<< doesn't get called, unl
sergei 2018/02/02 15:03:32 Acknowledged. I think it is worth investigation, b
+{
+ 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)
{
« no previous file with comments | « no previous file | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld