[llvm] r218783 - Add an immovable type to test Optional<T>::emplace more rigorously after r218732.
David Blaikie
dblaikie at gmail.com
Wed Oct 1 14:34:20 PDT 2014
On Wed, Oct 1, 2014 at 12:09 PM, Justin Bogner <mail at justinbogner.com>
wrote:
> David Blaikie <dblaikie at gmail.com> writes:
> > Author: dblaikie
> > Date: Wed Oct 1 13:29:44 2014
> > New Revision: 218783
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=218783&view=rev
> > Log:
> > Add an immovable type to test Optional<T>::emplace more rigorously
> > after r218732.
> >
> > Modified:
> > llvm/trunk/unittests/ADT/OptionalTest.cpp
> >
> > Modified: llvm/trunk/unittests/ADT/OptionalTest.cpp
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/OptionalTest.cpp?rev=218783&r1=218782&r2=218783&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/unittests/ADT/OptionalTest.cpp (original)
> > +++ llvm/trunk/unittests/ADT/OptionalTest.cpp Wed Oct 1 13:29:44 2014
> > @@ -324,15 +324,36 @@ TEST_F(OptionalTest, MoveOnlyAssigningAs
> > EXPECT_EQ(1u, MoveOnly::Destructions);
> > }
> >
> > +struct Immovable {
> > + static unsigned Constructions;
> > + static unsigned Destructions;
> > + int val;
> > + explicit Immovable(int val) : val(val) {
> > + ++Constructions;
> > + }
> > + ~Immovable() {
> > + ++Destructions;
> > + }
> > + static void ResetCounts() {
> > + Constructions = 0;
> > + Destructions = 0;
> > + }
> > +private:
> > + // This should disable all move/copy operations.
> > + Immovable(Immovable&& other) LLVM_DELETED_FUNCTION;
> > +};
> > +
> > +unsigned Immovable::Constructions = 0;
> > +unsigned Immovable::Destructions = 0;
> > +
> > TEST_F(OptionalTest, MoveOnlyEmplace) {
>
> This test name is a little misleading now.
>
Right you are. Addressed in r218821.
Thanks!
>
> > - Optional<MoveOnly> A;
> > - MoveOnly::ResetCounts();
> > + Optional<Immovable> A;
> > + Immovable::ResetCounts();
> > A.emplace(4);
> > EXPECT_TRUE((bool)A);
> > EXPECT_EQ(4, A->val);
> > - EXPECT_EQ(0u, MoveOnly::MoveConstructions);
> > - EXPECT_EQ(0u, MoveOnly::MoveAssignments);
> > - EXPECT_EQ(0u, MoveOnly::Destructions);
> > + EXPECT_EQ(1u, Immovable::Constructions);
> > + EXPECT_EQ(0u, Immovable::Destructions);
> > }
> >
> > #if LLVM_HAS_RVALUE_REFERENCE_THIS
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141001/9dcef5c4/attachment.html>
More information about the llvm-commits
mailing list