#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)

        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_SUITE_END()
}


#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();

        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_SUITE_END()
}


{
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });


#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem =

        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_SUITE_END()
}


#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_SUITE_END()
}


#include "stdafx.h"

#include <stdlib.h>
#include <boost/test/unit_test.hpp>
#include "Common/boost-taef.h"

using namespace ktl;
using namespace Data::Utilities;
using namespace TxnReplicator;
using namespace Data::StateManager;

namespace StateManagerTests
{
    class CopyNamedOperationDataTest
    {
        // load the config object as its needed for the tracing to work
        Common::CommonConfig config;
    public:
        VOID Test_Serialization_Success(
            __in SerializationMode::Enum mode,
            __in KAllocator & allocator,
            __in_opt OperationData const & userOperationData);
    };

    void CopyNamedOperationDataTest::Test_Serialization_Success(
        __in SerializationMode::Enum mode,
        __in KAllocator & allocator,
        __in OperationData const & userOperationData)
    {
        NTSTATUS status = STATUS_UNSUCCESSFUL;

        // Inputs and Expected Results
        const LONG64 expectedStateProviderId = 17;

        // Setup
        CopyNamedOperationData::CSPtr copyNamedOperationDataSPtr;
        status = CopyNamedOperationData::Create(expectedStateProviderId,
            mode,
            allocator,
            userOperationData,
            copyNamedOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Input
        VERIFY_ARE_EQUAL2(expectedStateProviderId, copyNamedOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, copyNamedOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));

        // Serialization and Deserialization
        OperationData const & replicatorOperationData = static_cast<OperationData const &>(*copyNamedOperationDataSPtr);
        CopyNamedOperationData::CSPtr outputOperationDataSPtr = nullptr;
        status = CopyNamedOperationData::Create(allocator, replicatorOperationData, outputOperationDataSPtr);
        VERIFY_IS_TRUE(NT_SUCCESS(status));

        // Test Output
        VERIFY_ARE_EQUAL2(expectedStateProviderId, outputOperationDataSPtr->StateProviderId);
        VERIFY_IS_TRUE(TestHelper::Equals(&userOperationData, outputOperationDataSPtr->UserOperationDataCSPtr.RawPtr()));
    }

    BOOST_FIXTURE_TEST_SUITE(CopyNamedOperationDataTestSuite, CopyNamedOperationDataTest)

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_EmptyUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_OneBufferUserOperationData_Managed_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKt

lSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            KBuffer::SPtr tmpBufferSPtr = nullptr;
            NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
            CODING_ERROR_ASSERT(NT_SUCCESS(status));
            userOperationDataSPtr->Append(*tmpBufferSPtr);

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Native, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_CASE(Serialization_MultipleBufferUserOperationData_Native_SUCCESS)
    {
        KtlSystem* underlyingSystem = TestHelper::CreateKtlSystem();
        KFinally([&]() { KtlSystem::Shutdown(); });
        {
            KAllocator& allocator = underlyingSystem->PagedAllocator();

            OperationData::SPtr userOperationDataSPtr = OperationData::Create(allocator);
            for (int i = 0; i < 64; i++)
            {
                KBuffer::SPtr tmpBufferSPtr = nullptr;
                NTSTATUS status = KBuffer::Create(16, tmpBufferSPtr, allocator);
                CODING_ERROR_ASSERT(NT_SUCCESS(status));
                userOperationDataSPtr->Append(*tmpBufferSPtr);
            }

            Test_Serialization_Success(SerializationMode::Managed, allocator, *userOperationDataSPtr);
        }
    }

    BOOST_AUTO_TEST_SUITE_END()
}


// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

{
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


{
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run()

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const

        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );

// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;

        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].pu

 }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


if( x && y )
                binmatch.insert( x, y );

// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }

// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );

    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {


// 最小覆盖点集 Konig 定理

// 注意读题，At the beginning they are both work at mode_0.

#include <vector>
#include <algorithm>
using namespace std;

class BinMatch {

    int     X,  Y,  M;
    vector<vector<int> >   G;
    vector<int>     back;
    vector<bool>    mark;

    bool find( int v ) {
        for( int i = 0, w; i < G[v].size(); ++i ) {
            w = G[v][i];
            if( !mark[w] ) {
                mark[w] = true;
                if( back[w] == -1 || find( back[w] ) ) {
                    back[w] = v;
                    return  true;
                }
            }
        }
        return  false;
    }

public:

    void init( int x, int y ) {
        X = x;  Y = y;
        G.assign( X + 1, vector<int>( 0 ) );
    }

    void insert( int v, int w ) { G[v].push_back( w ); }

    void run() {
        back.assign( Y + 1, -1 );
        for( int v = M = 0; v <= X; ++v ) {
            mark.assign( Y + 1, false );
            M += find( v );
        }
    }

    int matchCnt() const { return M; }

    vector<pair<int, int> > getMatch() const {
        vector<pair<int, int> > ans;
        for( int i = 0; i < Y; ++i )
            if( back[i] != -1 )
                 ans.push_back( make_pair( back[i], i ) );
        return  ans;
    }

};

#include <iostream>
using namespace std;

int     U,  V,  E;

BinMatch    binmatch;

int main() {

    while( cin >> U && U ) {

        cin >> V >> E;

        binmatch.init( U, V );

        while( E-- ) {

            int x,  y;

            cin >> x >> x >> y;

            if( x && y )
                binmatch.insert( x, y );

        }

        binmatch.run();

        cout << binmatch.matchCnt() << endl;

    }

}


inline void buildDP_01Pack(int cost, int value)

#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}

{
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read()

inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main()

    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {


#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }


#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = get

    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }

#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {

        }
        write(f[V]), putchar('\n');
    }

}


for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }

#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));

        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


#include<cstdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }

    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


tdio>
#include<cstring>
#define maxv 100010
#define maxn 10010
typedef long long ll;
ll f[maxv];
int n, V;
int t;
ll value[maxn], cost[maxn], like[maxn];
inline void write(ll x) {
    if (x < 0)putchar('-'), x = -x;
    if (x > 9)write(x / 10);
    putchar(x % 10 + 48);
}
inline ll read() {
    ll k = 0, f = 1;
    char c = getchar();
    while (c < '0' || c>'9') {
        if (c == '-')f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = (k << 1) + (k << 3) + c - 48;
        c = getchar();
    }
    return k * f;
}
inline void buildDP_01Pack(int cost, int value) {
    for (int v = V; v >= cost; --v) {
        if (f[v - cost] + value > f[v])f[v] = f[v - cost] + value;
    }
}
int main() {
    while (scanf("%d", &n) != EOF) {
        memset(f, 0, sizeof(f));
        memset(value, 0, sizeof(value));
        memset(cost, 0, sizeof(cost));
        memset(like, 0, sizeof(like));
        for (int i = 1; i <= n; ++i) {
            cost[i] = read(), value[i] = read(), like[i] = read();
        }
        V = read();
        for (int i = 1; i <= n; ++i) {
            if (like[i] && value[i] > 0) {
                buildDP_01Pack(cost[i], value[i]);
            }
        }
        write(f[V]), putchar('\n');
    }

}


//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;
    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }
#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}


{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;

//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)

    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }
#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}


{
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }

//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)
{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;

#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}


#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}

//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)
{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;
    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }


//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)
{
    TestResource R(42);
    auto& P = R.get

    memory_resource& M = R;
    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }
#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}


try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }

//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/memory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)
{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;
    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }
#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;


//  A) 'memory_resource' contains a member 'allocate' with the required
//     signature, including the default alignment parameter.
//  C) 'allocate' is not marked as 'noexcept'.
//  D) Invoking 'allocate' invokes 'do_allocate' with the same arguments.
//  E) If 'do_allocate' throws then 'allocate' propagates that exception.

#include <experimental/me

mory_resource>
#include <type_traits>
#include <cstddef>
#include <cassert>

#include "test_macros.h"
#include "test_memory_resource.h"

using std::experimental::pmr::memory_resource;

int main(int, char**)
{
    TestResource R(42);
    auto& P = R.getController();
    memory_resource& M = R;
    {
        static_assert(
            std::is_same<decltype(M.allocate(0, 0)), void*>::value
          , "Must be void*"
          );
        static_assert(
            std::is_same<decltype(M.allocate(0)), void*>::value
          , "Must be void*"
          );
    }
    {
        static_assert(
            ! noexcept(M.allocate(0, 0))
          , "Must not be noexcept."
          );
        static_assert(
            ! noexcept(M.allocate(0))
          , "Must not be noexcept."
          );
    }
    {
        int s = 42;
        int a = 64;
        void* p = M.allocate(s, a);
        assert(P.alloc_count == 1);
        assert(P.checkAlloc(p, s, a));

        s = 128;
        a = MaxAlignV;
        p = M.allocate(s);
        assert(P.alloc_count == 2);
        assert(P.checkAlloc(p, s, a));
    }
#ifndef TEST_HAS_NO_EXCEPTIONS
    {
        TestResource R2;
        auto& P2 = R2.getController();
        P2.throw_on_alloc = true;
        memory_resource& M2 = R2;
        try {
            M2.allocate(42);
            assert(false);
        } catch (TestException const&) {
        } catch (...) {
            assert(false);
        }
    }
#endif

  return 0;
}


bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)

//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>

{
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()

};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);

//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()

  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);

//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);

  BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}

//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);


//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m,

  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.owns_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.owns_lock() == false);
  lk.release();


//                     The LLVM Compiler Infrastructure

#include <boost/thread/lock_types.hpp>
#include <boost/detail/lightweight_test.hpp>

bool try_lock_for_called = false;

typedef boost::chrono::milliseconds ms;

struct shared_mutex
{
  template <class Rep, class Period>
  bool try_lock_shared_for(const boost::chrono::duration<Rep, Period>& rel_time)
  {
    BOOST_TEST(rel_time == ms(5));
    try_lock_for_called = !try_lock_for_called;
    return try_lock_for_called;
  }
  void unlock_shared()
  {
  }
};

shared_mutex m;

int main()
{
  boost::shared_lock<shared_mutex> lk(m, boost::defer_lock);
  BOOST_TEST(lk.try_lock_for(ms(5)) == true);
  BOOST_TEST(try_lock_for_called == true);
  BOOST_TEST(lk.owns_lock() == true);
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::resource_deadlock_would_occur);
  }
  lk.unlock();
  BOOST_TEST(lk.try_lock_for(ms(5)) == false);
  BOOST_TEST(try_lock_for_called == false);
  BOOST_TEST(lk.own

s_lock() == false);
  lk.release();
  try
  {
    lk.try_lock_for(ms(5));
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


/**
 */

#include <aws/application-insights/model/ApplicationInfo.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace ApplicationInsights
{
namespace Model
{

ApplicationInfo::ApplicationInfo() :
    m_resourceGroupNameHasBeenSet(false),
    m_lifeCycleHasBeenSet(false),
    m_opsItemSNSTopicArnHasBeenSet(false),
    m_opsCenterEnabled(false),
    m_opsCenterEnabledHasBeenSet(false),
    m_cWEMonitorEnabled(false),
    m_cWEMonitorEnabledHasBeenSet(false),
    m_remarksHasBeenSet(false),
    m_autoConfigEnabled(false),
    m_autoConfigEnabledHasBeenSet(false),
    m_discoveryType(DiscoveryType::NOT_SET),
    m_discoveryTypeHasBeenSet(false)
{
}

ApplicationInfo::ApplicationInfo(JsonView jsonValue) :
    m_resourceGroupNameHasBeenSet(false),
    m_lifeCycleHasBeenSet(false),
    m_opsItemSNSTopicArnHasBeenSet(false),
    m_opsCenterEnabled(false),
    m_opsCenterEnabledHasBeenSet(false),
    m_cWEMonitorEnabled(false),
    m_cWEMonitorEnabledHasBeenSet(false),
    m_remarksHasBeenSet(false),
    m_autoConfigEnabled(false),
    m_autoConfigEnabledHasBeenSet(false),
    m_discoveryType(DiscoveryType::NOT_SET),
    m_discoveryTypeHasBeenSet(false)
{
  *this = jsonValue;
}

ApplicationInfo& ApplicationInfo::operator =(JsonView jsonValue)
{
  if(jsonValue.ValueExists("ResourceGroupName"))
  {
    m_resourceGroupName = jsonValue.GetString("ResourceGroupName");

    m_resourceGroupNameHasBeenSet = true;
  }

  if(jsonValue.ValueExists("LifeCycle"))
  {
    m_lifeCycle = jsonValue.GetString("LifeCycle");

    m_lifeCycleHasBeenSet = true;
  }

  if(jsonValue.ValueExists("OpsItemSNSTopicArn"))
  {
    m_opsItemSNSTopicArn = jsonValue.GetString("OpsItemSNSTopicArn");

    m_opsItemSNSTopicArnHasBeenSet = true;
  }

  if(jsonValue.ValueExists("OpsCenterEnabled"))
  {
    m_opsCenterEnabled = jsonValue.GetBool("OpsCenterEnabled");

    m_opsCenterEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("CWEMonitorEnabled"))
  {
    m_cWEMonitorEnabled = jsonValue.GetBool("CWEMonitorEnabled");

    m_cWEMonitorEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Remarks"))
  {
    m_remarks = jsonValue.GetString("Remarks");

    m_remarksHasBeenSet = true;
  }

  if(jsonValue.ValueExists("AutoConfigEnabled"))
  {
    m_autoConfigEnabled = jsonValue.GetBool("AutoConfigEnabled");

    m_autoConfigEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("DiscoveryType"))
  {
    m_discoveryType = DiscoveryTypeMapper::GetDiscoveryTypeForName(jsonValue.GetString("DiscoveryType"));

    m_discoveryTypeHasBeenSet = true;
  }

  return *this;
}

{
  JsonValue payload;

  if(m_resourceGroupNameHasBeenSet)
  {
   payload.WithString("ResourceGroupName", m_resourceGroupName);

  }

  if(m_lifeCycleHasBeenSet)
  {
   payload.WithString("LifeCycle", m_lifeCycle);

  }

  if(m_opsItemSNSTopicArnHasBeenSet)
  {
   payload.WithString("OpsItemSNSTopicArn", m_opsItemSNSTopicArn);

  }

  if(m_opsCenterEnabledHasBeenSet)
  {
   payload.WithBool("OpsCenterEnabled", m_opsCenterEnabled);

  }

  if(m_cWEMonitorEnabledHasBeenSet)
  {
   payload.WithBool("CWEMonitorEnabled", m_cWEMonitorEnabled);

  }

  if(m_remarksHasBeenSet)
  {
   payload.WithString("Remarks", m_remarks);

  }

  if(m_autoConfigEnabledHasBeenSet)
  {
   payload.WithBool("AutoConfigEnabled", m_autoConfigEnabled);

  }

  if(m_discoveryTypeHasBeenSet)
  {
   payload.WithString("DiscoveryType", DiscoveryTypeMapper::GetNameForDiscoveryType(m_discoveryType));
  }

  return payload;
}

} // namespace Model
} // namespace ApplicationInsights
} // namespace Aws


/**
 */

#include <aws/application-insights/model/ApplicationInfo.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace ApplicationInsights
{
namespace Model
{

ApplicationInfo::ApplicationInfo() :
    m_resourceGroupNameHasBeenSet(false),
    m_lifeCycleHasBeenSet(false),
    m_opsItemSNSTopicArnHasBeenSet(false),
    m_opsCenterEnabled(false),
    m_opsCenterEnabledHasBeenSet(false),
    m_cWEMonitorEnabled(false),
    m_cWEMonitorEnabledHasBeenSet(false),
    m_remarksHasBeenSet(false),
    m_autoConfigEnabled(false),
    m_autoConfigEnabledHasBeenSet(false),
    m_discoveryType(DiscoveryType::NOT_SET),
    m_discoveryTypeHasBeenSet(false)

ApplicationInfo::ApplicationInfo(JsonView jsonValue) :
    m_resourceGroupNameHasBeenSet(false),
    m_lifeCycleHasBeenSet(false),
    m_opsItemSNSTopicArnHasBeenSet(false),
    m_opsCenterEnabled(false),
    m_opsCenterEnabledHasBeenSet(false),
    m_cWEMonitorEnabled(false),
    m_cWEMonitorEnabledHasBeenSet(false),
    m_remarksHasBeenSet(false),
    m_autoConfigEnabled(false),
    m_autoConfigEnabledHasBeenSet(false),
    m_discoveryType(DiscoveryType::NOT_SET),
    m_discoveryTypeHasBeenSet(false)
{
  *this = jsonValue;
}

ApplicationInfo& ApplicationInfo::operator =(JsonView jsonValue)
{
  if(jsonValue.ValueExists("ResourceGroupName"))
  {
    m_resourceGroupName = jsonValue.GetString("ResourceGroupName");

    m_resourceGroupNameHasBeenSet = true;
  }

  if(jsonValue.ValueExists("LifeCycle"))
  {
    m_lifeCycle = jsonValue.GetString("LifeCycle");

    m_lifeCycleHasBeenSet = true;
  }

  if(jsonValue.ValueExists("OpsItemSNSTopicArn"))
  {
    m_opsItemSNSTopicArn = jsonValue.GetString("OpsItemSNSTopicArn");

    m_opsItemSNSTopicArnHasBeenSet = true;
  }

  if(jsonValue.ValueExists("OpsCenterEnabled"))
  {
    m_opsCenterEnabled = jsonValue.GetBool("OpsCenterEnabled");

    m_opsCenterEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("CWEMonitorEnabled"))
  {
    m_cWEMonitorEnabled = jsonValue.GetBool("CWEMonitorEnabled");

    m_cWEMonitorEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Remarks"))
  {
    m_remarks = jsonValue.GetString("Remarks");

    m_remarksHasBeenSet = true;
  }

  if(jsonValue.ValueExists("AutoConfigEnabled"))
  {
    m_autoConfigEnabled = jsonValue.GetBool("AutoConfigEnabled");

    m_autoConfigEnabledHasBeenSet = true;
  }

  if(jsonValue.ValueExists("DiscoveryType"))
  {
    m_discoveryType = DiscoveryTypeMapper::GetDiscoveryTypeForName(jsonValue.GetString("DiscoveryType"));

    m_discoveryTypeHasBeenSet = true;
  }

  return *this;
}

JsonValue ApplicationInfo::Jsonize() const
{
  JsonValue payload;

  if(m_resourceGroupNameHasBeenSet)
  {
   payload.WithString("ResourceGroupName", m_resourceGroupName);

  }

  if(m_lifeCycleHasBeenSet)
  {
   payload.WithString("LifeCycle", m_lifeCycle);

  }

  if(m_opsItemSNSTopicArnHasBeenSet)
  {
   payload.WithString("OpsItemSNSTopicArn", m_opsItemSNSTopicArn);

  }

  if(m_opsCenterEnabledHasBeenSet)
  {
   payload.WithBool("OpsCenterEnabled", m_opsCenterEnabled);

  }

  if(m_cWEMonitorEnabledHasBeenSet)
  {
   payload.WithBool("CWEMonitorEnabled", m_cWEMonitorEnabled);

  }

  if(m_remarksHasBeenSet)
  {
   payload.WithString("Remarks", m_remarks);

  }

  if(m_autoConfigEnabledHasBeenSet)
  {
   payload.WithBool("AutoConfigEnabled", m_autoConfigEnabled);

  }

  if(m_discoveryTypeHasBeenSet)
  {
   payload.WithString("DiscoveryType", DiscoveryTypeMapper::GetNameForDiscoveryType(m_discoveryType));
  }

  return payload;
}

} // namespace Model
} // namespace ApplicationInsights
} // namespace Aws