<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 12:09 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> writes:<br>
> Author: dblaikie<br>
> Date: Wed Oct 1 13:29:44 2014<br>
> New Revision: 218783<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218783&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218783&view=rev</a><br>
> Log:<br>
> Add an immovable type to test Optional<T>::emplace more rigorously<br>
> after r218732.<br>
><br>
> Modified:<br>
> llvm/trunk/unittests/ADT/OptionalTest.cpp<br>
><br>
> Modified: llvm/trunk/unittests/ADT/OptionalTest.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/OptionalTest.cpp?rev=218783&r1=218782&r2=218783&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/OptionalTest.cpp?rev=218783&r1=218782&r2=218783&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/unittests/ADT/OptionalTest.cpp (original)<br>
> +++ llvm/trunk/unittests/ADT/OptionalTest.cpp Wed Oct 1 13:29:44 2014<br>
> @@ -324,15 +324,36 @@ TEST_F(OptionalTest, MoveOnlyAssigningAs<br>
> EXPECT_EQ(1u, MoveOnly::Destructions);<br>
> }<br>
><br>
> +struct Immovable {<br>
> + static unsigned Constructions;<br>
> + static unsigned Destructions;<br>
> + int val;<br>
> + explicit Immovable(int val) : val(val) {<br>
> + ++Constructions;<br>
> + }<br>
> + ~Immovable() {<br>
> + ++Destructions;<br>
> + }<br>
> + static void ResetCounts() {<br>
> + Constructions = 0;<br>
> + Destructions = 0;<br>
> + }<br>
> +private:<br>
> + // This should disable all move/copy operations.<br>
> + Immovable(Immovable&& other) LLVM_DELETED_FUNCTION;<br>
> +};<br>
> +<br>
> +unsigned Immovable::Constructions = 0;<br>
> +unsigned Immovable::Destructions = 0;<br>
> +<br>
> TEST_F(OptionalTest, MoveOnlyEmplace) {<br>
<br>
</div></div>This test name is a little misleading now.<br></blockquote><div><br></div><div>Right you are. Addressed in r218821.</div><div><br></div><div>Thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
> - Optional<MoveOnly> A;<br>
> - MoveOnly::ResetCounts();<br>
> + Optional<Immovable> A;<br>
> + Immovable::ResetCounts();<br>
> A.emplace(4);<br>
> EXPECT_TRUE((bool)A);<br>
> EXPECT_EQ(4, A->val);<br>
> - EXPECT_EQ(0u, MoveOnly::MoveConstructions);<br>
> - EXPECT_EQ(0u, MoveOnly::MoveAssignments);<br>
> - EXPECT_EQ(0u, MoveOnly::Destructions);<br>
> + EXPECT_EQ(1u, Immovable::Constructions);<br>
> + EXPECT_EQ(0u, Immovable::Destructions);<br>
> }<br>
><br>
> #if LLVM_HAS_RVALUE_REFERENCE_THIS<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>