<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210790] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210790">210790</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2017-01-16 14:23:55 -0800 (Mon, 16 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add the ability to use numbers in makeString()
https://bugs.webkit.org/show_bug.cgi?id=167087

Reviewed by Darin Adler.

Source/WTF:

Allow numbers to be easily used in makeString() and tryMakeString().

For instance, you can now write:
    int amount = 7;
    auto foo = makeString(&quot;There are &quot;, amount, &quot; apples in the cart&quot;);

* WTF.xcodeproj/project.pbxproj:
Add new file.

* wtf/text/IntegerToStringConversion.h:
(WTF::writeNumberToBufferImpl):
(WTF::writeNumberToBufferSigned):
(WTF::writeNumberToBufferUnsigned):
(WTF::lengthOfNumberAsStringImpl):
(WTF::lengthOfNumberAsStringSigned):
(WTF::lengthOfNumberAsStringUnsigned):
Add variants of integer writing code that compute the length of the string
that would be produced and writes the string to an existing buffer.

(WTF::IntegerToStringConversionTrait&lt;AtomicString&gt;::flush): Deleted.
(WTF::IntegerToStringConversionTrait&lt;String&gt;::flush): Deleted.
(WTF::IntegerToStringConversionTrait&lt;StringBuilder&gt;::flush): Deleted.
Move these traits to their respective classes.

* wtf/text/AtomicString.h:
(WTF::IntegerToStringConversionTrait&lt;AtomicString&gt;::flush):
* wtf/text/StringBuilder.h:
(WTF::IntegerToStringConversionTrait&lt;StringBuilder&gt;::flush):
* wtf/text/WTFString.h:
(WTF::IntegerToStringConversionTrait&lt;String&gt;::flush):
Traits moved here from IntegerToStringConversion.h

* wtf/text/StringConcatenateNumbers.h: Added.
(WTF::StringTypeAdapter&lt;int&gt;::StringTypeAdapter&lt;int&gt;):
(WTF::StringTypeAdapter&lt;int&gt;::length):
(WTF::StringTypeAdapter&lt;int&gt;::is8Bit):
(WTF::StringTypeAdapter&lt;int&gt;::writeTo):
(WTF::StringTypeAdapter&lt;int&gt;::toString):
(WTF::StringTypeAdapter&lt;unsigned&gt;::StringTypeAdapter&lt;unsigned&gt;):
(WTF::StringTypeAdapter&lt;unsigned&gt;::length):
(WTF::StringTypeAdapter&lt;unsigned&gt;::is8Bit):
(WTF::StringTypeAdapter&lt;unsigned&gt;::writeTo):
(WTF::StringTypeAdapter&lt;unsigned&gt;::toString):
(WTF::StringTypeAdapter&lt;float&gt;::StringTypeAdapter&lt;float&gt;):
(WTF::StringTypeAdapter&lt;float&gt;::length):
(WTF::StringTypeAdapter&lt;float&gt;::is8Bit):
(WTF::StringTypeAdapter&lt;float&gt;::writeTo):
(WTF::StringTypeAdapter&lt;float&gt;::toString):
(WTF::StringTypeAdapter&lt;double&gt;::StringTypeAdapter&lt;double&gt;):
(WTF::StringTypeAdapter&lt;double&gt;::length):
(WTF::StringTypeAdapter&lt;double&gt;::is8Bit):
(WTF::StringTypeAdapter&lt;double&gt;::writeTo):
(WTF::StringTypeAdapter&lt;double&gt;::toString):
Add basic adaptors for int, unsigned, float, and double.

(WTF::FormattedNumber::fixedPrecision):
(WTF::FormattedNumber::fixedWidth):
(WTF::FormattedNumber::length):
(WTF::FormattedNumber::buffer):
(WTF::FormattedNumber::stringView):
(WTF::StringTypeAdapter&lt;FormattedNumber&gt;::StringTypeAdapter&lt;FormattedNumber&gt;):
(WTF::StringTypeAdapter&lt;FormattedNumber&gt;::length):
(WTF::StringTypeAdapter&lt;FormattedNumber&gt;::is8Bit):
(WTF::StringTypeAdapter&lt;FormattedNumber&gt;::writeTo):
(WTF::StringTypeAdapter&lt;FormattedNumber&gt;::toString):
Add a special class, FormattedNumber, and an adaptor for it, allowing for
fixedPrecision and fixedWidth representation of doubles.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/StringConcatenate.cpp: Added.
Add tests for StringConcatenate, focusing on new numeric additions.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtftextAtomicStringh">trunk/Source/WTF/wtf/text/AtomicString.h</a></li>
<li><a href="#trunkSourceWTFwtftextIntegerToStringConversionh">trunk/Source/WTF/wtf/text/IntegerToStringConversion.h</a></li>
<li><a href="#trunkSourceWTFwtftextStringBuilderh">trunk/Source/WTF/wtf/text/StringBuilder.h</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringh">trunk/Source/WTF/wtf/text/WTFString.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtftextStringConcatenateNumbersh">trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFStringConcatenatecpp">trunk/Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/ChangeLog        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -1,3 +1,78 @@
</span><ins>+2017-01-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Add the ability to use numbers in makeString()
+        https://bugs.webkit.org/show_bug.cgi?id=167087
+
+        Reviewed by Darin Adler.
+
+        Allow numbers to be easily used in makeString() and tryMakeString().
+
+        For instance, you can now write:
+            int amount = 7;
+            auto foo = makeString(&quot;There are &quot;, amount, &quot; apples in the cart&quot;);
+
+        * WTF.xcodeproj/project.pbxproj:
+        Add new file.
+
+        * wtf/text/IntegerToStringConversion.h:
+        (WTF::writeNumberToBufferImpl):
+        (WTF::writeNumberToBufferSigned):
+        (WTF::writeNumberToBufferUnsigned):
+        (WTF::lengthOfNumberAsStringImpl):
+        (WTF::lengthOfNumberAsStringSigned):
+        (WTF::lengthOfNumberAsStringUnsigned):
+        Add variants of integer writing code that compute the length of the string
+        that would be produced and writes the string to an existing buffer.
+
+        (WTF::IntegerToStringConversionTrait&lt;AtomicString&gt;::flush): Deleted.
+        (WTF::IntegerToStringConversionTrait&lt;String&gt;::flush): Deleted.
+        (WTF::IntegerToStringConversionTrait&lt;StringBuilder&gt;::flush): Deleted.
+        Move these traits to their respective classes.
+
+        * wtf/text/AtomicString.h:
+        (WTF::IntegerToStringConversionTrait&lt;AtomicString&gt;::flush):
+        * wtf/text/StringBuilder.h:
+        (WTF::IntegerToStringConversionTrait&lt;StringBuilder&gt;::flush):
+        * wtf/text/WTFString.h:
+        (WTF::IntegerToStringConversionTrait&lt;String&gt;::flush):
+        Traits moved here from IntegerToStringConversion.h
+
+        * wtf/text/StringConcatenateNumbers.h: Added.
+        (WTF::StringTypeAdapter&lt;int&gt;::StringTypeAdapter&lt;int&gt;):
+        (WTF::StringTypeAdapter&lt;int&gt;::length):
+        (WTF::StringTypeAdapter&lt;int&gt;::is8Bit):
+        (WTF::StringTypeAdapter&lt;int&gt;::writeTo):
+        (WTF::StringTypeAdapter&lt;int&gt;::toString):
+        (WTF::StringTypeAdapter&lt;unsigned&gt;::StringTypeAdapter&lt;unsigned&gt;):
+        (WTF::StringTypeAdapter&lt;unsigned&gt;::length):
+        (WTF::StringTypeAdapter&lt;unsigned&gt;::is8Bit):
+        (WTF::StringTypeAdapter&lt;unsigned&gt;::writeTo):
+        (WTF::StringTypeAdapter&lt;unsigned&gt;::toString):
+        (WTF::StringTypeAdapter&lt;float&gt;::StringTypeAdapter&lt;float&gt;):
+        (WTF::StringTypeAdapter&lt;float&gt;::length):
+        (WTF::StringTypeAdapter&lt;float&gt;::is8Bit):
+        (WTF::StringTypeAdapter&lt;float&gt;::writeTo):
+        (WTF::StringTypeAdapter&lt;float&gt;::toString):
+        (WTF::StringTypeAdapter&lt;double&gt;::StringTypeAdapter&lt;double&gt;):
+        (WTF::StringTypeAdapter&lt;double&gt;::length):
+        (WTF::StringTypeAdapter&lt;double&gt;::is8Bit):
+        (WTF::StringTypeAdapter&lt;double&gt;::writeTo):
+        (WTF::StringTypeAdapter&lt;double&gt;::toString):
+        Add basic adaptors for int, unsigned, float, and double.
+
+        (WTF::FormattedNumber::fixedPrecision):
+        (WTF::FormattedNumber::fixedWidth):
+        (WTF::FormattedNumber::length):
+        (WTF::FormattedNumber::buffer):
+        (WTF::FormattedNumber::stringView):
+        (WTF::StringTypeAdapter&lt;FormattedNumber&gt;::StringTypeAdapter&lt;FormattedNumber&gt;):
+        (WTF::StringTypeAdapter&lt;FormattedNumber&gt;::length):
+        (WTF::StringTypeAdapter&lt;FormattedNumber&gt;::is8Bit):
+        (WTF::StringTypeAdapter&lt;FormattedNumber&gt;::writeTo):
+        (WTF::StringTypeAdapter&lt;FormattedNumber&gt;::toString):
+        Add a special class, FormattedNumber, and an adaptor for it, allowing for
+        fixedPrecision and fixedWidth representation of doubles.
+
</ins><span class="cx"> 2017-01-14  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: Suppress warnings &amp; errors in GCC
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -148,6 +148,7 @@
</span><span class="cx">                 7C3F723A1D78811A00674E26 /* Brigand.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3F72391D78811900674E26 /* Brigand.h */; };
</span><span class="cx">                 7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */; };
</span><span class="cx">                 7CD0D5A91D5534A7000CC9E1 /* Variant.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0D5A71D55322A000CC9E1 /* Variant.h */; };
</span><ins>+                7CD4C2701E2C82B900929470 /* StringConcatenateNumbers.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD4C26F1E2C82B900929470 /* StringConcatenateNumbers.h */; };
</ins><span class="cx">                 7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */; };
</span><span class="cx">                 7CDD7FFA186D2A54007433CD /* IteratorRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF9186D2A54007433CD /* IteratorRange.h */; };
</span><span class="cx">                 7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
</span><span class="lines">@@ -525,6 +526,7 @@
</span><span class="cx">                 7C3F72391D78811900674E26 /* Brigand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Brigand.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSObjectPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CD0D5A71D55322A000CC9E1 /* Variant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Variant.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7CD4C26F1E2C82B900929470 /* StringConcatenateNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConcatenateNumbers.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorAdaptors.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CDD7FF9186D2A54007433CD /* IteratorRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorRange.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcRuntimeExtras.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1202,6 +1204,7 @@
</span><span class="cx">                                 A8A47325151A825B004123FF /* StringBuilder.h */,
</span><span class="cx">                                 430B47871AAAAC1A001223DA /* StringCommon.h */,
</span><span class="cx">                                 A8A47326151A825B004123FF /* StringConcatenate.h */,
</span><ins>+                                7CD4C26F1E2C82B900929470 /* StringConcatenateNumbers.h */,
</ins><span class="cx">                                 A8A47327151A825B004123FF /* StringHash.h */,
</span><span class="cx">                                 A8A47328151A825B004123FF /* StringImpl.cpp */,
</span><span class="cx">                                 A8A47329151A825B004123FF /* StringImpl.h */,
</span><span class="lines">@@ -1331,6 +1334,7 @@
</span><span class="cx">                                 1A428B8C1C8F89DD0051E9EB /* AppKitCompatibilityDeclarations.h in Headers */,
</span><span class="cx">                                 A8A47385151A825B004123FF /* ASCIICType.h in Headers */,
</span><span class="cx">                                 A8A47434151A825B004123FF /* ASCIIFastPath.h in Headers */,
</span><ins>+                                7CD4C2701E2C82B900929470 /* StringConcatenateNumbers.h in Headers */,
</ins><span class="cx">                                 A8A47387151A825B004123FF /* Assertions.h in Headers */,
</span><span class="cx">                                 A8A47388151A825B004123FF /* Atomics.h in Headers */,
</span><span class="cx">                                 A8A47436151A825B004123FF /* AtomicString.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtftextAtomicStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/AtomicString.h (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/AtomicString.h        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/wtf/text/AtomicString.h        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;utility&gt;
</span><span class="cx"> #include &lt;wtf/text/AtomicStringImpl.h&gt;
</span><ins>+#include &lt;wtf/text/IntegerToStringConversion.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> // Define 'NO_IMPLICIT_ATOMICSTRING' before including this header,
</span><span class="lines">@@ -360,6 +361,12 @@
</span><span class="cx">     return equalIgnoringASCIICase(a.string(), b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template&lt;&gt; struct IntegerToStringConversionTrait&lt;AtomicString&gt; {
+    using ReturnType = AtomicString;
+    using AdditionalArgumentType = void;
+    static AtomicString flush(LChar* characters, unsigned length, void*) { return { characters, length }; }
+};
+
</ins><span class="cx"> } // namespace WTF
</span><span class="cx"> 
</span><span class="cx"> #ifndef ATOMICSTRING_HIDE_GLOBALS
</span></span></pre></div>
<a id="trunkSourceWTFwtftextIntegerToStringConversionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/IntegerToStringConversion.h (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/IntegerToStringConversion.h        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/wtf/text/IntegerToStringConversion.h        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -22,8 +22,6 @@
</span><span class="cx"> #ifndef IntegerToStringConversion_h
</span><span class="cx"> #define IntegerToStringConversion_h
</span><span class="cx"> 
</span><del>-#include &quot;StringBuilder.h&quot;
-
</del><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><span class="cx"> enum PositiveOrNegativeNumber {
</span><span class="lines">@@ -33,22 +31,6 @@
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T&gt; struct IntegerToStringConversionTrait;
</span><span class="cx"> 
</span><del>-template&lt;&gt; struct IntegerToStringConversionTrait&lt;AtomicString&gt; {
-    typedef AtomicString ReturnType;
-    typedef void AdditionalArgumentType;
-    static ReturnType flush(LChar* characters, unsigned length, void*) { return AtomicString(characters, length); }
-};
-template&lt;&gt; struct IntegerToStringConversionTrait&lt;String&gt; {
-    typedef String ReturnType;
-    typedef void AdditionalArgumentType;
-    static ReturnType flush(LChar* characters, unsigned length, void*) { return String(characters, length); }
-};
-template&lt;&gt; struct IntegerToStringConversionTrait&lt;StringBuilder&gt; {
-    typedef void ReturnType;
-    typedef StringBuilder AdditionalArgumentType;
-    static ReturnType flush(LChar* characters, unsigned length, StringBuilder* stringBuilder) { stringBuilder-&gt;append(characters, length); }
-};
-
</del><span class="cx"> template&lt;typename T, typename UnsignedIntegerType, PositiveOrNegativeNumber NumberType, typename AdditionalArgumentType&gt;
</span><span class="cx"> static typename IntegerToStringConversionTrait&lt;T&gt;::ReturnType numberToStringImpl(UnsignedIntegerType number, AdditionalArgumentType additionalArgument)
</span><span class="cx"> {
</span><span class="lines">@@ -81,6 +63,72 @@
</span><span class="cx">     return numberToStringImpl&lt;T, UnsignedIntegerType, PositiveNumber&gt;(number, additionalArgument);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+template&lt;typename CharacterType, typename UnsignedIntegerType, PositiveOrNegativeNumber NumberType&gt;
+static void writeNumberToBufferImpl(UnsignedIntegerType number, CharacterType* destination)
+{
+    LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
+    LChar* end = buf + WTF_ARRAY_LENGTH(buf);
+    LChar* p = end;
+
+    do {
+        *--p = static_cast&lt;LChar&gt;((number % 10) + '0');
+        number /= 10;
+    } while (number);
+
+    if (NumberType == NegativeNumber)
+        *--p = '-';
+    
+    while (p &lt; end)
+        *destination++ = static_cast&lt;CharacterType&gt;(*p++);
+}
+
+template&lt;typename CharacterType, typename SignedIntegerType&gt;
+inline void writeNumberToBufferSigned(SignedIntegerType number, CharacterType* destination)
+{
+    if (number &lt; 0)
+        return writeNumberToBufferImpl&lt;CharacterType, typename std::make_unsigned&lt;SignedIntegerType&gt;::type, NegativeNumber&gt;(-number, destination);
+    return writeNumberToBufferImpl&lt;CharacterType, typename std::make_unsigned&lt;SignedIntegerType&gt;::type, PositiveNumber&gt;(number, destination);
+}
+
+template&lt;typename CharacterType, typename UnsignedIntegerType&gt;
+inline void writeNumberToBufferUnsigned(UnsignedIntegerType number, CharacterType* destination)
+{
+    return writeNumberToBufferImpl&lt;CharacterType, UnsignedIntegerType, PositiveNumber&gt;(number, destination);
+}
+
+
+template&lt;typename UnsignedIntegerType, PositiveOrNegativeNumber NumberType&gt;
+static unsigned lengthOfNumberAsStringImpl(UnsignedIntegerType number)
+{
+    unsigned length = 0;
+
+    do {
+        ++length;
+        number /= 10;
+    } while (number);
+
+    if (NumberType == NegativeNumber)
+        ++length;
+
+    return length;
+}
+
+template&lt;typename SignedIntegerType&gt;
+inline unsigned lengthOfNumberAsStringSigned(SignedIntegerType number)
+{
+    if (number &lt; 0)
+        return lengthOfNumberAsStringImpl&lt;typename std::make_unsigned&lt;SignedIntegerType&gt;::type, NegativeNumber&gt;(-number);
+    return lengthOfNumberAsStringImpl&lt;typename std::make_unsigned&lt;SignedIntegerType&gt;::type, PositiveNumber&gt;(number);
+}
+
+template&lt;typename UnsignedIntegerType&gt;
+inline unsigned lengthOfNumberAsStringUnsigned(UnsignedIntegerType number)
+{
+    return lengthOfNumberAsStringImpl&lt;UnsignedIntegerType, PositiveNumber&gt;(number);
+}
+
+
</ins><span class="cx"> } // namespace WTF
</span><span class="cx"> 
</span><span class="cx"> #endif // IntegerToStringConversion_h
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringBuilder.h        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #define StringBuilder_h
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/text/AtomicString.h&gt;
</span><ins>+#include &lt;wtf/text/IntegerToStringConversion.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -368,6 +369,12 @@
</span><span class="cx"> inline bool operator==(const String&amp; a, const StringBuilder&amp; b) { return equal(b, a); }
</span><span class="cx"> inline bool operator!=(const String&amp; a, const StringBuilder&amp; b) { return !equal(b, a); }
</span><span class="cx"> 
</span><ins>+template&lt;&gt; struct IntegerToStringConversionTrait&lt;StringBuilder&gt; {
+    using ReturnType = void;
+    using AdditionalArgumentType = StringBuilder;
+    static void flush(LChar* characters, unsigned length, StringBuilder* stringBuilder) { stringBuilder-&gt;append(characters, length); }
+};
+
</ins><span class="cx"> } // namespace WTF
</span><span class="cx"> 
</span><span class="cx"> using WTF::StringBuilder;
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringConcatenateNumbersh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h (0 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h                                (rev 0)
+++ trunk/Source/WTF/wtf/text/StringConcatenateNumbers.h        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -0,0 +1,175 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;wtf/dtoa.h&gt;
+#include &lt;wtf/text/IntegerToStringConversion.h&gt;
+#include &lt;wtf/text/StringConcatenate.h&gt;
+
+namespace WTF {
+
+template&lt;&gt;
+class StringTypeAdapter&lt;int&gt; {
+public:
+    StringTypeAdapter&lt;int&gt;(int number)
+        : m_number(number)
+    {
+    }
+
+    unsigned length() const { return lengthOfNumberAsStringSigned(m_number); }
+    bool is8Bit() const { return true; }
+
+    void writeTo(LChar* destination) const { writeNumberToBufferSigned(m_number, destination); }
+    void writeTo(UChar* destination) const { writeNumberToBufferSigned(m_number, destination); }
+
+    String toString() const { return String::number(m_number); }
+
+private:
+    int m_number;
+};
+
+template&lt;&gt;
+class StringTypeAdapter&lt;unsigned&gt; {
+public:
+    StringTypeAdapter&lt;unsigned&gt;(unsigned number)
+        : m_number(number)
+    {
+    }
+
+    unsigned length() const { return lengthOfNumberAsStringUnsigned(m_number); }
+    bool is8Bit() const { return true; }
+
+    void writeTo(LChar* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
+    void writeTo(UChar* destination) const { writeNumberToBufferUnsigned(m_number, destination); }
+
+    String toString() const { return String::number(m_number); }
+
+private:
+    unsigned m_number;
+};
+
+template&lt;&gt;
+class StringTypeAdapter&lt;double&gt; {
+public:
+    StringTypeAdapter&lt;double&gt;(double number)
+    {
+        numberToString(number, m_buffer);
+        m_length = strlen(m_buffer);
+    }
+
+    unsigned length() const { return m_length; }
+    bool is8Bit() const { return true; }
+
+    void writeTo(LChar* destination) const
+    {
+        for (unsigned i = 0; i &lt; m_length; ++i)
+            destination[i] = m_buffer[i];
+    }
+
+    void writeTo(UChar* destination) const
+    {
+        for (unsigned i = 0; i &lt; m_length; ++i)
+            destination[i] = m_buffer[i];
+    }
+
+    String toString() const { return { m_buffer, m_length }; }
+
+private:
+    NumberToStringBuffer m_buffer;
+    unsigned m_length;
+};
+
+template&lt;&gt;
+class StringTypeAdapter&lt;float&gt; : public StringTypeAdapter&lt;double&gt; {
+public:
+    StringTypeAdapter&lt;float&gt;(float number)
+        : StringTypeAdapter&lt;double&gt;(number)
+    {
+    }
+};
+
+class FormattedNumber {
+public:
+    static FormattedNumber fixedPrecision(double number, unsigned significantFigures = 6, bool truncateTrailingZeros = false)
+    {
+        FormattedNumber numberFormatter;
+        numberToFixedPrecisionString(number, significantFigures, numberFormatter.m_buffer, truncateTrailingZeros);
+        numberFormatter.m_length = strlen(numberFormatter.m_buffer);
+        return numberFormatter;
+    }
+
+    static FormattedNumber fixedWidth(double number, unsigned decimalPlaces)
+    {
+        FormattedNumber numberFormatter;
+        numberToFixedWidthString(number, decimalPlaces, numberFormatter.m_buffer);
+        numberFormatter.m_length = strlen(numberFormatter.m_buffer);
+        return numberFormatter;
+    }
+
+    unsigned length() const { return m_length; }
+    const LChar* buffer() const { return reinterpret_cast&lt;const LChar*&gt;(m_buffer); }
+
+private:
+    NumberToStringBuffer m_buffer;
+    unsigned m_length;
+};
+
+template&lt;&gt;
+class StringTypeAdapter&lt;FormattedNumber&gt; {
+public:
+    StringTypeAdapter&lt;FormattedNumber&gt;(const FormattedNumber&amp; numberFormatter)
+        : m_numberFormatter(numberFormatter)
+    {
+    }
+
+    unsigned length() const { return m_numberFormatter.length(); }
+    bool is8Bit() const { return true; }
+
+    void writeTo(LChar* destination) const
+    {
+        auto buffer = m_numberFormatter.buffer();
+        auto length = m_numberFormatter.length();
+        for (unsigned i = 0; i &lt; length; ++i)
+            destination[i] = buffer[i];
+    }
+
+    void writeTo(UChar* destination) const
+    {
+        auto buffer = m_numberFormatter.buffer();
+        auto length = m_numberFormatter.length();
+        for (unsigned i = 0; i &lt; length; ++i)
+            destination[i] = buffer[i];
+    }
+
+    String toString() const { return { m_numberFormatter.buffer(), m_numberFormatter.length() }; }
+
+private:
+    const FormattedNumber&amp; m_numberFormatter;
+};
+
+}
+
+using WTF::FormattedNumber;
</ins></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.h (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.h        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Source/WTF/wtf/text/WTFString.h        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> // on systems without case-sensitive file systems.
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/text/ASCIIFastPath.h&gt;
</span><ins>+#include &lt;wtf/text/IntegerToStringConversion.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringImpl.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #ifdef __OBJC__
</span><span class="lines">@@ -713,6 +714,12 @@
</span><span class="cx">     return startsWithLettersIgnoringASCIICase(string.impl(), lowercaseLetters);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template&lt;&gt; struct IntegerToStringConversionTrait&lt;String&gt; {
+    using ReturnType = String;
+    using AdditionalArgumentType = void;
+    static String flush(LChar* characters, unsigned length, void*) { return { characters, length }; }
+};
+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> using WTF::CString;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Tools/ChangeLog        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-01-15  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Add the ability to use numbers in makeString()
+        https://bugs.webkit.org/show_bug.cgi?id=167087
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/StringConcatenate.cpp: Added.
+        Add tests for StringConcatenate, focusing on new numeric additions.
+
</ins><span class="cx"> 2017-01-15  Michael Catanzaro  &lt;mcatanzaro@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, remove stale comment.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (210789 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-16 22:14:27 UTC (rev 210789)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -425,6 +425,7 @@
</span><span class="cx">                 7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2943BE84161DFEB800999E3D /* UserContentTest.mm */; };
</span><span class="cx">                 7CCE7F2E1A411B1000447C4C /* WKBrowsingContextGroupTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7D14587AA60025FB62 /* WKBrowsingContextGroupTest.mm */; };
</span><span class="cx">                 7CCE7F2F1A411B1000447C4C /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
</span><ins>+                7CD4C26E1E2C0E6E00929470 /* StringConcatenate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD4C26C1E2C0E6E00929470 /* StringConcatenate.cpp */; };
</ins><span class="cx">                 7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
</span><span class="cx">                 7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
</span><span class="cx">                 8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8349D3C11DB96DDA004A9F65 /* ContextMenuDownload.mm */; };
</span><span class="lines">@@ -1077,6 +1078,7 @@
</span><span class="cx">                 7CCE7E8C1A41144E00447C4C /* libTestWebKitAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTestWebKitAPI.a; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 7CCE7EA31A4115CB00447C4C /* TestWebKitAPILibrary.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = TestWebKitAPILibrary.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CD0D5AA1D5534DE000CC9E1 /* Variant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Variant.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7CD4C26C1E2C0E6E00929470 /* StringConcatenate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConcatenate.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKUserContentExtensionStore.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1876,7 +1878,6 @@
</span><span class="cx">                 BC9096461255618900083756 /* WTF */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                AD7C434C1DD2A5470026888B /* Expected.cpp */,
</del><span class="cx">                                 C0991C4F143C7D68007998F2 /* cf */,
</span><span class="cx">                                 7CBBA07519BB8A0900BBF025 /* darwin */,
</span><span class="cx">                                 BC029B1A1486B23800817DA9 /* ns */,
</span><span class="lines">@@ -1891,6 +1892,7 @@
</span><span class="cx">                                 1A3524A91D627BD40031729B /* DeletedAddressOfOperator.h */,
</span><span class="cx">                                 E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */,
</span><span class="cx">                                 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */,
</span><ins>+                                AD7C434C1DD2A5470026888B /* Expected.cpp */,
</ins><span class="cx">                                 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */,
</span><span class="cx">                                 0BCD833414857CE400EA2003 /* HashMap.cpp */,
</span><span class="cx">                                 26B2DFF815BDE599004F691D /* HashSet.cpp */,
</span><span class="lines">@@ -1918,6 +1920,7 @@
</span><span class="cx">                                 DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */,
</span><span class="cx">                                 CD5393C91757BAC400C07123 /* SHA1.cpp */,
</span><span class="cx">                                 81B50192140F232300D9EB58 /* StringBuilder.cpp */,
</span><ins>+                                7CD4C26C1E2C0E6E00929470 /* StringConcatenate.cpp */,
</ins><span class="cx">                                 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */,
</span><span class="cx">                                 26F1B44315CA434F00D1E4BF /* StringImpl.cpp */,
</span><span class="cx">                                 C01363C713C3997300EF3964 /* StringOperators.cpp */,
</span><span class="lines">@@ -2417,6 +2420,7 @@
</span><span class="cx">                                 1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */,
</span><span class="cx">                                 7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */,
</span><span class="cx">                                 7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
</span><ins>+                                7CD4C26E1E2C0E6E00929470 /* StringConcatenate.cpp in Sources */,
</ins><span class="cx">                                 7C83DEF61D0A590C00FEBCF3 /* MetaAllocator.cpp in Sources */,
</span><span class="cx">                                 7C83DEFE1D0A590C00FEBCF3 /* NakedPtr.cpp in Sources */,
</span><span class="cx">                                 531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFStringConcatenatecpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp (0 => 210790)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp        2017-01-16 22:23:55 UTC (rev 210790)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#include &quot;WTFStringUtilities.h&quot;
+#include &lt;wtf/text/StringConcatenate.h&gt;
+#include &lt;wtf/text/StringConcatenateNumbers.h&gt;
+
+namespace TestWebKitAPI {
+
+TEST(WTF, StringConcatenate)
+{
+    EXPECT_EQ(&quot;hello world&quot;, makeString(&quot;hello&quot;, &quot; &quot;, &quot;world&quot;));
+}
+
+TEST(WTF, StringConcatenate_Int)
+{
+    EXPECT_EQ(5u, WTF::lengthOfNumberAsStringSigned(17890));
+    EXPECT_EQ(&quot;hello 17890 world&quot;, makeString(&quot;hello &quot;, 17890 , &quot; world&quot;));
+
+    EXPECT_EQ(6u, WTF::lengthOfNumberAsStringSigned(-17890));
+    EXPECT_EQ(&quot;hello -17890 world&quot;, makeString(&quot;hello &quot;, -17890 , &quot; world&quot;));
+
+    EXPECT_EQ(1u, WTF::lengthOfNumberAsStringSigned(0));
+    EXPECT_EQ(&quot;hello 0 world&quot;, makeString(&quot;hello &quot;, 0 , &quot; world&quot;));
+}
+
+TEST(WTF, StringConcatenate_Unsigned)
+{
+    EXPECT_EQ(5u, WTF::lengthOfNumberAsStringUnsigned(17890u));
+    EXPECT_EQ(&quot;hello 17890 world&quot;, makeString(&quot;hello &quot;, 17890u , &quot; world&quot;));
+
+    EXPECT_EQ(1u, WTF::lengthOfNumberAsStringSigned(0u));
+    EXPECT_EQ(&quot;hello 0 world&quot;, makeString(&quot;hello &quot;, 0u , &quot; world&quot;));
+}
+
+TEST(WTF, StringConcatenate_Float)
+{
+    EXPECT_EQ(&quot;hello 17890 world&quot;, makeString(&quot;hello &quot;, 17890.0f , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.5 world&quot;, makeString(&quot;hello &quot;, 17890.5f , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello -17890 world&quot;, makeString(&quot;hello &quot;, -17890.0f , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.5 world&quot;, makeString(&quot;hello &quot;, -17890.5f , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello 0 world&quot;, makeString(&quot;hello &quot;, 0.0f , &quot; world&quot;));
+}
+
+TEST(WTF, StringConcatenate_Double)
+{
+    EXPECT_EQ(&quot;hello 17890 world&quot;, makeString(&quot;hello &quot;, 17890.0 , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.5 world&quot;, makeString(&quot;hello &quot;, 17890.5 , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello -17890 world&quot;, makeString(&quot;hello &quot;, -17890.0 , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.5 world&quot;, makeString(&quot;hello &quot;, -17890.5 , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello 0 world&quot;, makeString(&quot;hello &quot;, 0.0 , &quot; world&quot;));
+}
+
+TEST(WTF, StringConcatenate_FormattedDoubleFixedPrecision)
+{
+    EXPECT_EQ(&quot;hello 17890.0 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.0) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 1.79e+4 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.0, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.0, 8) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.0, 8, true) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello 17890.5 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.5) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 1.79e+4 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.5, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.500 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.5, 8) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.5 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(17890.5, 8, true) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello -17890.0 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.0) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -1.79e+4 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.0, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.0, 8) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.0, 8, true) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello -17890.5 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.5) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -1.79e+4 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.5, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.500 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.5, 8) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.5 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(-17890.5, 8, true) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello 0.00000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(0.0) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 0.00 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(0.0, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 0.0000000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(0.0, 8) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 0 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedPrecision(0.0, 8, true) , &quot; world&quot;));
+}
+
+TEST(WTF, StringConcatenate_FormattedDoubleFixedWidth)
+{
+    EXPECT_EQ(&quot;hello 17890.000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedWidth(17890.0, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello 17890.500 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedWidth(17890.5, 3) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello -17890.000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedWidth(-17890.0, 3) , &quot; world&quot;));
+    EXPECT_EQ(&quot;hello -17890.500 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedWidth(-17890.5, 3) , &quot; world&quot;));
+
+    EXPECT_EQ(&quot;hello 0.000 world&quot;, makeString(&quot;hello &quot;, FormattedNumber::fixedWidth(0.0, 3) , &quot; world&quot;));
+}
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>