<commit_before>//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "testBase.h"
#include "action_classes.h"

extern const char *IGetStatusString( cl_int status );

#define PRINT_OPS 0

int test_waitlist( cl_device_id device, cl_context context, cl_command_queue queue, Action *actionToTest, bool multiple )
{
    NDRangeKernelAction    actions[ 2 ];
    clEventWrapper events[ 3 ];
    cl_int status[ 3 ];
    cl_int error;

  if (multiple)
    log_info("\tExecuting reference event 0, then reference event 1 with reference event 0 in its waitlist, then test event 2 with reference events 0 and 1 in its waitlist.\n");
  else
    log_info("\tExecuting reference event 0, then test event 2 with reference event 0 in its waitlist.\n");

    // Set up the first base action to wait against
    error = actions[ 0 ].Setup( device, context, queue );
    test_error( error, "Unable to setup base event to wait against" );

    if( multiple )
    {
        // Set up a second event to wait against
        error = actions[ 1 ].Setup( device, context, queue );
        test_error( error, "Unable to setup second base event to wait against" );
    }

    // Now set up the actual action to test
    error = actionToTest->Setup( device, context, queue );
    test_error( error, "Unable to set up test event" );

    // Execute all events now
  if (PRINT_OPS) log_info("\tExecuting action 0...\n");
    error = actions[ 0 ].Execute( queue, 0, NULL, &events[ 0 ] );
    test_error( error, "Unable to execute first event" );

    if( multiple )
    {
    if (PRINT_OPS) log_info("\tExecuting action 1...\n");
        error = actions[ 1 ].Execute( queue, 1, &events[0], &events[ 1 ] );
        test_error( error, "Unable to execute second event" );
    }

    // Sanity check
  if( multiple ) {
    if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
    test_error( error, "Unable to get event status" );
  }
  if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
  test_error( error, "Unable to get event status" );

  log_info("\t\tEvent status after starting reference events: reference event 0: %s, reference event 1: %s, test event 2: %s.\n",
           IGetStatusString( status[ 0 ] ), (multiple ? IGetStatusString( status[ 1 ] ) : "N/A"), "N/A");

    if( ( status[ 0 ] == CL_COMPLETE ) || ( multiple && status[ 1 ] == CL_COMPLETE ) )
    {
        log_info( "WARNING: Reference event(s) already completed before we could execute test event! Possible that the reference event blocked (implicitly passing)\n" );
        return 0;
    }

  if (PRINT_OPS) log_info("\tExecuting action to test...\n");
    error = actionToTest->Execute( queue, ( multiple ) ? 2 : 1, &events[ 0 ], &events[ 2 ] );
    test_error( error, "Unable to execute test event" );

    // Hopefully, the first event is still running
  if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
    error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
    test_error( error, "Unable to get event status" );
  if( multiple ) {
    if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
    test_error( error, "Unable to get event status" );
  }
  if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
  test_error( error, "Unable to get event status" );

  log_info("\t\tEvent status after starting test event: reference event 0: %s, reference event 1: %s, test event 2: %s.\n",
           IGetStatusString( status[ 0 ] ), (multiple ? IGetStatusString( status[ 1 ] ) : "N/A"), IGetStatusString( status[ 2 ] ));

    if( multiple )
    {
        if( status[ 0 ] == CL_COMPLETE && status[ 1 ] == CL_COMPLETE )
        {
            log_info( "WARNING: Both events completed, so unable to test further (implicitly passing).\n" );
            clFinish( queue );
            return 0;
        }

    if(status[1] == CL_COMPLETE && status[0] != CL_COMPLETE)
    {
      log_error("ERROR: Test failed because the second wait event is complete and the first is not.(status: 0: %s and 1: %s)\n", IGetStatusString( status[ 0 ] ), IGetStatusString( status[ 1 ] ) );
            clFinish( queue );
            return -1;
    }
    }
    else
    {
        if( status[ 0 ] == CL_COMPLETE )
        {
            log_info( "WARNING: Reference event completed, so unable to test further (implicitly passing).\n" );
            clFinish( queue );
            return 0;
        }
        if( status[ 0 ] != CL_RUNNING && status[ 0 ] != CL_QUEUED && status[ 0 ] != CL_SUBMITTED )
        {
            log_error( "ERROR: Test failed because first wait event is not currently running, queued, or submitted! (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
            clFinish( queue );
            return -1;
        }
    }

    if( status[ 2 ] != CL_QUEUED && status[ 2 ] != CL_SUBMITTED )
    {
        log_error( "ERROR: Test event is not waiting to run! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
        clFinish( queue );
        return -1;
    }

    // Now wait for the first reference event
  if (PRINT_OPS) log_info("\tWaiting for action 1 to finish...\n");
    error = clWaitForEvents( 1, &events[ 0 ] );
    test_error( error, "Unable to wait for reference event" );

    // Grab statuses again
  if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
    error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
    test_error( error, "Unable to get event status" );
  if( multiple ) {
    if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
    test_error( error, "Unable to get event status" );
  }
  if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
  test_error( error, "Unable to get event status" );

  log_info("\t\tEvent status after waiting for reference event 0: reference event 0: %s, reference event 1: %s, test event 2: %s.\n",
           IGetStatusString( status[ 0 ] ), (multiple ? IGetStatusString( status[ 1 ] ) : "N/A"), IGetStatusString( status[ 2 ] ));

    // Sanity
    if( status[ 0 ] != CL_COMPLETE )
    {
        log_error( "ERROR: Waited for first event but it's not complete (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
        clFinish( queue );
        return -1;
    }

    // If we're multiple, and the second event isn't complete, then our test event should still be queued
    if( multiple && status[ 1 ] != CL_COMPLETE )
    {
    if( status[ 1 ] == CL_RUNNING && status[ 2 ] == CL_RUNNING ) {
      log_error("ERROR: Test event and second event are both running.\n");
      clFinish( queue );
      return -1;
    }
        if( status[ 2 ] != CL_QUEUED && status[ 2 ] != CL_SUBMITTED )
        {
            log_error( "ERROR: Test event did not wait for second event before starting! (status of ref: 1: %s, of test: 2: %s)\n", IGetStatusString( status[ 1 ] ), IGetStatusString( status[ 2 ] ) );
            clFinish( queue );
            return -1;
        }

        // Now wait for second event to complete, too
    if (PRINT_OPS) log_info("\tWaiting for action 1 to finish...\n");
        error = clWaitForEvents( 1, &events[ 1 ] );
        test_error( error, "Unable to wait for second reference event" );

        // Grab statuses again
    if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
    error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
    test_error( error, "Unable to get event status" );
    if( multiple ) {
      if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
      error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
      test_error( error, "Unable to get event status" );
    }
    if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
    test_error( error, "Unable to get event status" );

    log_info("\t\tEvent status after waiting for reference event 1: reference event 0: %s, reference event 1: %s, test event 2: %s.\n",
             IGetStatusString( status[ 0 ] ), (multiple ? IGetStatusString( status[ 1 ] ) : "N/A"), IGetStatusString( status[ 2 ] ));

        // Sanity
        if( status[ 1 ] != CL_COMPLETE )
        {
            log_error( "ERROR: Waited for second reference event but it didn't complete (status: 1: %s)\n", IGetStatusString( status[ 1 ] ) );
            clFinish( queue );
            return -1;
        }
    }

    // At this point, the test event SHOULD be running, but if it completed, we consider it a pass
    if( status[ 2 ] == CL_COMPLETE )
    {
        log_info( "WARNING: Test event already completed. Assumed valid.\n" );
        clFinish( queue );
        return 0;
    }
    if( status[ 2 ] != CL_RUNNING && status[ 2 ] != CL_SUBMITTED && status[ 2 ] != CL_QUEUED)
    {
        log_error( "ERROR: Second event did not start running after reference event(s) completed! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
        clFinish( queue );
        return -1;
    }

    // Wait for the test event, then return
  if (PRINT_OPS) log_info("\tWaiting for action 2 to test to finish...\n");
    error = clWaitForEvents( 1, &events[ 2 ] );
    test_error( error, "Unable to wait for test event" );

  error |= clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
  test_error( error, "Unable to get event status" );

  log_info("\t\tEvent status after waiting for test event: reference event 0: %s, reference event 1: %s, test event 2: %s.\n",
           IGetStatusString( status[ 0 ] ), (multiple ? IGetStatusString( status[ 1 ] ) : "N/A"), IGetStatusString( status[ 2 ] ));

  // Sanity
  if( status[ 2 ] != CL_COMPLETE )
  {
    log_error( "ERROR: Test event didn't complete (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
    clFinish( queue );
    return -1;
  }

  clFinish(queue);
    return 0;
}

#define TEST_ACTION( name ) \
    {    \
        name##Action action;    \
        log_info( "-- Testing " #name " (waiting on 1 event)...\n" );    \
        if( ( error = test_waitlist( deviceID, context, queue, &action, false ) ) != CL_SUCCESS )    \
            retVal++;            \
        clFinish( queue ); \
    }    \
    if( error == CL_SUCCESS )    /* Only run multiples test if single test passed */ \
    {    \
        name##Action action;    \
        log_info( "-- Testing " #name " (waiting on 2 events)...\n" );    \
        if( ( error = test_waitlist( deviceID, context, queue, &action, true ) ) != CL_SUCCESS )    \
            retVal++;            \
        clFinish( queue ); \
    }

int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue oldQueue, int num_elements )
{
    cl_int error;
    int retVal = 0;
    cl_command_queue_properties props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;

    if( !checkDeviceForQueueSupport( deviceID, props ) )
    {
        log_info( "WARNING: Device does not support out-of-order exec mode; skipping test.\n" );
        return 0;
    }

    clCommandQueueWrapper queue = clCreateCommandQueue( context, deviceID, props, &error );
    test_error(error, "Unable to create out-of-order queue");

    log_info( "\n" );

    TEST_ACTION( NDRangeKernel )

    TEST_ACTION( ReadBuffer )
    TEST_ACTION( WriteBuffer )
    TEST_ACTION( MapBuffer )
    TEST_ACTION( UnmapBuffer )

    if( checkForImageSupport( deviceID ) == CL_IMAGE_FORMAT_NOT_SUPPORTED )
    {
        log_info( "\nNote: device does not support images. Skipping remainder of waitlist tests...\n" );
    }
    else
    {
        TEST_ACTION( ReadImage2D )
        TEST_ACTION( WriteImage2D )
        TEST_ACTION( CopyImage2Dto2D )
        TEST_ACTION( Copy2DImageToBuffer )
        TEST_ACTION( CopyBufferTo2DImage )
        TEST_ACTION( MapImage )

        if( checkFor3DImageSupport( deviceID ) == CL_IMAGE_FORMAT_NOT_SUPPORTED )
            log_info("Device does not support 3D images. Skipping remainder of waitlist tests...\n");
        else
        {
            TEST_ACTION( ReadImage3D )
            TEST_ACTION( WriteImage3D )
            TEST_ACTION( CopyImage2Dto3D )
            TEST_ACTION( CopyImage3Dto2D )
            TEST_ACTION( CopyImage3Dto3D )
            TEST_ACTION( Copy3DImageToBuffer )
            TEST_ACTION( CopyBufferTo3DImage )
        }
    }

    return retVal;
}

<commit_msg>Fix indentation of test_waitlists.cpp (#1459)<commit_after>//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "testBase.h"
#include "action_classes.h"

extern const char *IGetStatusString( cl_int status );

#define PRINT_OPS 0

int test_waitlist( cl_device_id device, cl_context context, cl_command_queue queue, Action *actionToTest, bool multiple )
{
    NDRangeKernelAction    actions[ 2 ];
    clEventWrapper events[ 3 ];
    cl_int status[ 3 ];
    cl_int error;

    if (multiple)
        log_info("\tExecuting reference event 0, then reference event 1 with "
                 "reference event 0 in its waitlist, then test event 2 with "
                 "reference events 0 and 1 in its waitlist.\n");
    else
        log_info("\tExecuting reference event 0, then test event 2 with "
                 "reference event 0 in its waitlist.\n");

    // Set up the first base action to wait against
    error = actions[ 0 ].Setup( device, context, queue );
    test_error( error, "Unable to setup base event to wait against" );

    if( multiple )
    {
        // Set up a second event to wait against
        error = actions[ 1 ].Setup( device, context, queue );
        test_error( error, "Unable to setup second base event to wait against" );
    }

    // Now set up the actual action to test
    error = actionToTest->Setup( device, context, queue );
    test_error( error, "Unable to set up test event" );

    // Execute all events now
    if (PRINT_OPS) log_info("\tExecuting action 0...\n");
    error = actions[ 0 ].Execute( queue, 0, NULL, &events[ 0 ] );
    test_error( error, "Unable to execute first event" );

    if( multiple )
    {
    if (PRINT_OPS) log_info("\tExecuting action 1...\n");
        error = actions[ 1 ].Execute( queue, 1, &events[0], &events[ 1 ] );
        test_error( error, "Unable to execute second event" );
    }

    // Sanity check
    if (multiple)
    {
        if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
        test_error(error, "Unable to get event status");
    }
    if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
    test_error(error, "Unable to get event status");

    log_info("\t\tEvent status after starting reference events: reference "
             "event 0: %s, reference event 1: %s, test event 2: %s.\n",
             IGetStatusString(status[0]),
             (multiple ? IGetStatusString(status[1]) : "N/A"), "N/A");

    if( ( status[ 0 ] == CL_COMPLETE ) || ( multiple && status[ 1 ] == CL_COMPLETE ) )
    {
        log_info( "WARNING: Reference event(s) already completed before we could execute test event! Possible that the reference event blocked (implicitly passing)\n" );
        return 0;
    }

    if (PRINT_OPS) log_info("\tExecuting action to test...\n");
    error = actionToTest->Execute( queue, ( multiple ) ? 2 : 1, &events[ 0 ], &events[ 2 ] );
    test_error( error, "Unable to execute test event" );

    // Hopefully, the first event is still running
    if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
    error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
    test_error( error, "Unable to get event status" );
    if (multiple)
    {
        if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
        test_error(error, "Unable to get event status");
    }
    if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
    test_error(error, "Unable to get event status");

    log_info("\t\tEvent status after starting test event: reference event 0: "
             "%s, reference event 1: %s, test event 2: %s.\n",
             IGetStatusString(status[0]),
             (multiple ? IGetStatusString(status[1]) : "N/A"),
             IGetStatusString(status[2]));

    if( multiple )
    {
        if( status[ 0 ] == CL_COMPLETE && status[ 1 ] == CL_COMPLETE )
        {
            log_info( "WARNING: Both events completed, so unable to test further (implicitly passing).\n" );
            clFinish( queue );
            return 0;
        }

        if (status[1] == CL_COMPLETE && status[0] != CL_COMPLETE)
        {
            log_error(
                "ERROR: Test failed because the second wait event is complete "
                "and the first is not.(status: 0: %s and 1: %s)\n",
                IGetStatusString(status[0]), IGetStatusString(status[1]));
            clFinish( queue );
            return -1;
        }
    }
    else
    {
        if( status[ 0 ] == CL_COMPLETE )
        {
            log_info( "WARNING: Reference event completed, so unable to test further (implicitly passing).\n" );
            clFinish( queue );
            return 0;
        }
        if( status[ 0 ] != CL_RUNNING && status[ 0 ] != CL_QUEUED && status[ 0 ] != CL_SUBMITTED )
        {
            log_error( "ERROR: Test failed because first wait event is not currently running, queued, or submitted! (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
            clFinish( queue );
            return -1;
        }
    }

    if( status[ 2 ] != CL_QUEUED && status[ 2 ] != CL_SUBMITTED )
    {
        log_error( "ERROR: Test event is not waiting to run! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
        clFinish( queue );
        return -1;
    }

    // Now wait for the first reference event
    if (PRINT_OPS) log_info("\tWaiting for action 1 to finish...\n");
    error = clWaitForEvents( 1, &events[ 0 ] );
    test_error( error, "Unable to wait for reference event" );

    // Grab statuses again
    if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
    error = clGetEventInfo( events[ 2 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 2 ] ), &status[ 2 ], NULL );
    test_error( error, "Unable to get event status" );
    if (multiple)
    {
        if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
        error = clGetEventInfo( events[ 1 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 1 ] ), &status[ 1 ], NULL );
        test_error(error, "Unable to get event status");
    }
    if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
    error = clGetEventInfo( events[ 0 ], CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof( status[ 0 ] ), &status[ 0 ], NULL );
    test_error(error, "Unable to get event status");

    log_info("\t\tEvent status after waiting for reference event 0: reference "
             "event 0: %s, reference event 1: %s, test event 2: %s.\n",
             IGetStatusString(status[0]),
             (multiple ? IGetStatusString(status[1]) : "N/A"),
             IGetStatusString(status[2]));

    // Sanity
    if( status[ 0 ] != CL_COMPLETE )
    {
        log_error( "ERROR: Waited for first event but it's not complete (status: 0: %s)\n", IGetStatusString( status[ 0 ] ) );
        clFinish( queue );
        return -1;
    }

    // If we're multiple, and the second event isn't complete, then our test event should still be queued
    if( multiple && status[ 1 ] != CL_COMPLETE )
    {
        if (status[1] == CL_RUNNING && status[2] == CL_RUNNING)
        {
            log_error("ERROR: Test event and second event are both running.\n");
            clFinish(queue);
            return -1;
        }
        if( status[ 2 ] != CL_QUEUED && status[ 2 ] != CL_SUBMITTED )
        {
            log_error( "ERROR: Test event did not wait for second event before starting! (status of ref: 1: %s, of test: 2: %s)\n", IGetStatusString( status[ 1 ] ), IGetStatusString( status[ 2 ] ) );
            clFinish( queue );
            return -1;
        }

        // Now wait for second event to complete, too
        if (PRINT_OPS) log_info("\tWaiting for action 1 to finish...\n");
        error = clWaitForEvents( 1, &events[ 1 ] );
        test_error( error, "Unable to wait for second reference event" );

        // Grab statuses again
        if (PRINT_OPS) log_info("\tChecking status of action to test 2...\n");
        error = clGetEventInfo(events[2], CL_EVENT_COMMAND_EXECUTION_STATUS,
                               sizeof(status[2]), &status[2], NULL);
        test_error(error, "Unable to get event status");
        if (multiple)
        {
            if (PRINT_OPS) log_info("\tChecking status of action 1...\n");
            error = clGetEventInfo(events[1], CL_EVENT_COMMAND_EXECUTION_STATUS,
                                   sizeof(status[1]), &status[1], NULL);
            test_error(error, "Unable to get event status");
        }
        if (PRINT_OPS) log_info("\tChecking status of action 0...\n");
        error = clGetEventInfo(events[0], CL_EVENT_COMMAND_EXECUTION_STATUS,
                               sizeof(status[0]), &status[0], NULL);
        test_error(error, "Unable to get event status");

        log_info(
            "\t\tEvent status after waiting for reference event 1: reference "
            "event 0: %s, reference event 1: %s, test event 2: %s.\n",
            IGetStatusString(status[0]),
            (multiple ? IGetStatusString(status[1]) : "N/A"),
            IGetStatusString(status[2]));

        // Sanity
        if( status[ 1 ] != CL_COMPLETE )
        {
            log_error( "ERROR: Waited for second reference event but it didn't complete (status: 1: %s)\n", IGetStatusString( status[ 1 ] ) );
            clFinish( queue );
            return -1;
        }
    }

    // At this point, the test event SHOULD be running, but if it completed, we consider it a pass
    if( status[ 2 ] == CL_COMPLETE )
    {
        log_info( "WARNING: Test event already completed. Assumed valid.\n" );
        clFinish( queue );
        return 0;
    }
    if( status[ 2 ] != CL_RUNNING && status[ 2 ] != CL_SUBMITTED && status[ 2 ] != CL_QUEUED)
    {
        log_error( "ERROR: Second event did not start running after reference event(s) completed! (status: 2: %s)\n", IGetStatusString( status[ 2 ] ) );
        clFinish( queue );
        return -1;
    }

    // Wait for the test event, then return
    if (PRINT_OPS) log_info("\tWaiting for action 2 to test to finish...\n");
    error = clWaitForEvents( 1, &events[ 2 ] );
    test_error( error, "Unable to wait for test event" );

    error |= clGetEventInfo(events[2], CL_EVENT_COMMAND_EXECUTION_STATUS,
                            sizeof(status[2]), &status[2], NULL);
    test_error(error, "Unable to get event status");

    log_info("\t\tEvent status after waiting for test event: reference event "
             "0: %s, reference event 1: %s, test event 2: %s.\n",
             IGetStatusString(status[0]),
             (multiple ? IGetStatusString(status[1]) : "N/A"),
             IGetStatusString(status[2]));

    // Sanity
    if (status[2] != CL_COMPLETE)
    {
        log_error("ERROR: Test event didn't complete (status: 2: %s)\n",
                  IGetStatusString(status[2]));
        clFinish(queue);
        return -1;
    }

    clFinish(queue);
    return 0;
}

#define TEST_ACTION( name ) \
    {    \
        name##Action action;    \
        log_info( "-- Testing " #name " (waiting on 1 event)...\n" );    \
        if( ( error = test_waitlist( deviceID, context, queue, &action, false ) ) != CL_SUCCESS )    \
            retVal++;            \
        clFinish( queue ); \
    }    \
    if( error == CL_SUCCESS )    /* Only run multiples test if single test passed */ \
    {    \
        name##Action action;    \
        log_info( "-- Testing " #name " (waiting on 2 events)...\n" );    \
        if( ( error = test_waitlist( deviceID, context, queue, &action, true ) ) != CL_SUCCESS )    \
            retVal++;            \
        clFinish( queue ); \
    }

int test_waitlists( cl_device_id deviceID, cl_context context, cl_command_queue oldQueue, int num_elements )
{
    cl_int error;
    int retVal = 0;
    cl_command_queue_properties props = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;

    if( !checkDeviceForQueueSupport( deviceID, props ) )
    {
        log_info( "WARNING: Device does not support out-of-order exec mode; skipping test.\n" );
        return 0;
    }

    clCommandQueueWrapper queue = clCreateCommandQueue( context, deviceID, props, &error );
    test_error(error, "Unable to create out-of-order queue");

    log_info( "\n" );

    TEST_ACTION( NDRangeKernel )

    TEST_ACTION( ReadBuffer )
    TEST_ACTION( WriteBuffer )
    TEST_ACTION( MapBuffer )
    TEST_ACTION( UnmapBuffer )

    if( checkForImageSupport( deviceID ) == CL_IMAGE_FORMAT_NOT_SUPPORTED )
    {
        log_info( "\nNote: device does not support images. Skipping remainder of waitlist tests...\n" );
    }
    else
    {
        TEST_ACTION( ReadImage2D )
        TEST_ACTION( WriteImage2D )
        TEST_ACTION( CopyImage2Dto2D )
        TEST_ACTION( Copy2DImageToBuffer )
        TEST_ACTION( CopyBufferTo2DImage )
        TEST_ACTION( MapImage )

        if( checkFor3DImageSupport( deviceID ) == CL_IMAGE_FORMAT_NOT_SUPPORTED )
            log_info("Device does not support 3D images. Skipping remainder of waitlist tests...\n");
        else
        {
            TEST_ACTION( ReadImage3D )
            TEST_ACTION( WriteImage3D )
            TEST_ACTION( CopyImage2Dto3D )
            TEST_ACTION( CopyImage3Dto2D )
            TEST_ACTION( CopyImage3Dto3D )
            TEST_ACTION( Copy3DImageToBuffer )
            TEST_ACTION( CopyBufferTo3DImage )
        }
    }

    return retVal;
}

<|endoftext|>


<commit_before>/**
 * @file   NetworkHttpTest.cpp
 * @brief  NetworkHttp class tester.
 * @author zer0
 * @date   2017-05-19
 */

#include <gtest/gtest.h>
#include <tester/DemoAsset.hpp>

#include <libtbag/log/Log.hpp>
#include <libtbag/network/http/HttpClient.hpp>
#include <libtbag/network/http/HttpServer.hpp>
#include <libtbag/network/http/HttpBuilder.hpp>
#include <libtbag/uvpp/Loop.hpp>

#include <iostream>
#include <thread>

using namespace libtbag;
using namespace libtbag::network;
using namespace libtbag::network::http;

TEST(NetworkHttpTest, HttpClient)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);

    HttpResponse response;
    auto result = http::requestWithSync("http://osom8979.github.io", 10000, response);
    ASSERT_EQ(Err::E_SUCCESS, result);
    ASSERT_EQ(200, response.status);
}

static bool runSimpleServerTest(HttpServer::StreamType type, std::string const & bind, std::string const & method)
{
    uvpp::Loop loop;
    HttpServer server(loop, type);

    server.init(bind.c_str());

    std::string request_url = "http://localhost:";
    request_url += std::to_string(server.getPort());
    request_url += "/";

    int on_open    = 0;
    int on_request = 0;
    int on_close   = 0;

    server.setOnOpen([&](HttpServer::WeakClient node){
        ++on_open;
    });
    server.setOnRequest([&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        ++on_request;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName());
        timeout = 1000;
    });
    server.setOnClose([&](HttpServer::WeakClient node){
        ++on_close;
        server.close();
    });

    Err server_result = Err::E_UNKNOWN;
    Err client_result = Err::E_UNKNOWN;

    HttpResponse response;
    HttpRequest  request;
    request.method = method;

    std::thread server_thread([&](){ server_result = loop.run(); });
    std::thread client_thread([&](){
        if (HttpServer::StreamType::PIPE == type) {
            client_result = http::requestWithSync(type, bind, 0, Uri(request_url), request, 1000, response);
        } else {
            client_result = http::requestWithSync(request_url, request, 1000, response);
        }
    });

    client_thread.join();
    server_thread.join();

    if (Err::E_SUCCESS != server_result) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Server result {} error", method, getErrName(server_result));
        return false;
    }
    if (Err::E_SUCCESS != client_result) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Client result {} error", method, getErrName(client_result));
        return false;
    }

    if (200 != response.status) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Response is not OK({}).", method, response.status);
        return false;
    }

    if (response.body != method) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Response body error({}).", method, response.body);
        return false;
    }

    if (on_open != 1 || on_request != 1 || on_close != 1) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Counter error({}/{}/{}).",
               method, on_open, on_request, on_close);
        return false;
    }

    return true;
}

TEST(NetworkHttpTest, TcpHttpServer)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);
    runSimpleServerTest(HttpServer::StreamType::TCP, details::ANY_IPV4, "GET");
    runSimpleServerTest(HttpServer::StreamType::TCP, details::ANY_IPV4, "POST");
}

TEST(NetworkHttpTest, PipeHttpServer)
{
#if defined(TBAG_PLATFORM_WINDOWS)
    char const * const PATH = "\\\\.\\pipe\\HTTP_TEST";
#else
    char const * const TEST_FILENAME = "http.sock";
    tttDir(true, true);
    auto const PATH = tttDirGet() / TEST_FILENAME;
#endif

    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);
    runSimpleServerTest(HttpServer::StreamType::PIPE, PATH, "GET");
    runSimpleServerTest(HttpServer::StreamType::PIPE, PATH, "POST");
}

TEST(NetworkHttpTest, RoutingServer)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);

    uvpp::Loop loop;
    HttpServer server(loop);

    int on_open    = 0;
    int on_close   = 0;
    int on_request = 0;

    int on_request_doc = 0;
    int on_request_down_get  = 0;
    int on_request_down_post = 0;

    server.init(details::ANY_IPV4, 0);
    int const SERVER_PORT = server.getPort();

    std::string request_url = "http://localhost:";
    request_url += std::to_string(SERVER_PORT);
    request_url += "/";

    std::string const REQUEST_URL_DOC  = request_url + "Documents";
    std::string const REQUEST_URL_DOWN = request_url + "Downloads";

    std::cout << "Request URL: " << request_url << std::endl;

    server.setOnOpen([&](HttpServer::WeakClient node){
        ++on_open;
    });

    server.setOnRequest([&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest()\n";
        ++on_request;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("/Documents", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest(/Documents)\n";
        ++on_request_doc;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("GET", "/Downloads", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest([GET]/Downloads)\n";
        ++on_request_down_get;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("POST", "/Downloads", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest([POST]/Downloads)\n";
        ++on_request_down_post;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });

    server.setOnClose([&](HttpServer::WeakClient node){
        ++on_close;
        if (on_close == 5) {
            server.close();
        }
    });

    Err server_result = Err::E_UNKNOWN;
    Err client_result = Err::E_UNKNOWN;

    HttpResponse response;
    HttpResponse response_doc_get;
    HttpResponse response_doc_post;
    HttpResponse response_down_get;
    HttpResponse response_down_post;

    HttpRequest request_get;
    request_get.method = "GET";
    HttpRequest request_post;
    request_post.method = "POST";

    std::thread server_thread([&](){ server_result = loop.run(); });
    std::thread client1_thread([&](){ client_result = http::requestWithSync(request_url, 1000, response); });
    std::thread client2_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOC, request_get, 1000, response_doc_get); });
    std::thread client3_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOC, request_post, 1000, response_doc_post); });
    std::thread client4_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOWN, request_get, 1000, response_down_get); });
    std::thread client5_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOWN, request_post, 1000, response_down_post); });

    client1_thread.join();
    client2_thread.join();
    client3_thread.join();
    client4_thread.join();
    client5_thread.join();
    server_thread.join();

    ASSERT_EQ(200, response.status);
    ASSERT_EQ(200, response_doc_get.status);
    ASSERT_EQ(200, response_doc_post.status);
    ASSERT_EQ(200, response_down_get.status);
    ASSERT_EQ(200, response_down_post.status);

    ASSERT_EQ(5, on_open             );
    ASSERT_EQ(1, on_request          );
    ASSERT_EQ(2, on_request_doc      );
    ASSERT_EQ(1, on_request_down_get );
    ASSERT_EQ(1, on_request_down_post);
    ASSERT_EQ(5, on_close            );
}

<commit_msg>Trivial commit.<commit_after>/**
 * @file   NetworkHttpTest.cpp
 * @brief  NetworkHttp class tester.
 * @author zer0
 * @date   2017-05-19
 */

#include <gtest/gtest.h>
#include <tester/DemoAsset.hpp>

#include <libtbag/log/Log.hpp>
#include <libtbag/network/http/HttpClient.hpp>
#include <libtbag/network/http/HttpServer.hpp>
#include <libtbag/network/http/HttpBuilder.hpp>
#include <libtbag/uvpp/Loop.hpp>

#include <iostream>
#include <thread>

using namespace libtbag;
using namespace libtbag::network;
using namespace libtbag::network::http;

TEST(NetworkHttpTest, HttpClient)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);

    HttpResponse response;
    auto result = http::requestWithSync("http://osom8979.github.io", 10000, response);
    ASSERT_EQ(Err::E_SUCCESS, result);
    ASSERT_EQ(200, response.status);
}

static bool runSimpleServerTest(HttpServer::StreamType type, std::string const & bind, std::string const & method)
{
    uvpp::Loop loop;
    HttpServer server(loop, type);

    server.init(bind.c_str());

    std::string request_url = "http://localhost:";
    request_url += std::to_string(server.getPort());
    request_url += "/";

    int on_open    = 0;
    int on_request = 0;
    int on_close   = 0;

    server.setOnOpen([&](HttpServer::WeakClient node){
        ++on_open;
    });
    server.setOnRequest([&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        ++on_request;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName());
        timeout = 1000;
    });
    server.setOnClose([&](HttpServer::WeakClient node){
        ++on_close;
        server.close();
    });

    Err server_result = Err::E_UNKNOWN;
    Err client_result = Err::E_UNKNOWN;

    HttpResponse response;
    HttpRequest  request;
    request.method = method;

    std::thread server_thread([&](){ server_result = loop.run(); });
    std::thread client_thread([&](){
        if (HttpServer::StreamType::PIPE == type) {
            client_result = http::requestWithSync(type, bind, 0, Uri(request_url), request, 1000, response);
        } else {
            client_result = http::requestWithSync(request_url, request, 1000, response);
        }
    });

    client_thread.join();
    server_thread.join();

    if (Err::E_SUCCESS != server_result) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Server result {} error", method, getErrName(server_result));
        return false;
    }
    if (Err::E_SUCCESS != client_result) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Client result {} error", method, getErrName(client_result));
        return false;
    }

    if (200 != response.status) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Response is not OK({}).", method, response.status);
        return false;
    }

    if (response.body != method) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Response body error({}).", method, response.body);
        return false;
    }

    if (on_open != 1 || on_request != 1 || on_close != 1) {
        tDLogA("NetworkHttpTest.runSimpleServerTest({}) Counter error({}/{}/{}).",
               method, on_open, on_request, on_close);
        return false;
    }

    return true;
}

TEST(NetworkHttpTest, TcpHttpServer)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);
    ASSERT_TRUE(runSimpleServerTest(HttpServer::StreamType::TCP, details::ANY_IPV4, "GET"));
    ASSERT_TRUE(runSimpleServerTest(HttpServer::StreamType::TCP, details::ANY_IPV4, "POST"));
}

TEST(NetworkHttpTest, PipeHttpServer)
{
#if defined(TBAG_PLATFORM_WINDOWS)
    char const * const PATH = "\\\\.\\pipe\\HTTP_TEST";
#else
    char const * const TEST_FILENAME = "http.sock";
    tttDir(true, true);
    auto const PATH = tttDirGet() / TEST_FILENAME;
#endif

    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);
    ASSERT_TRUE(runSimpleServerTest(HttpServer::StreamType::PIPE, PATH, "GET"));
    ASSERT_TRUE(runSimpleServerTest(HttpServer::StreamType::PIPE, PATH, "POST"));
}

TEST(NetworkHttpTest, RoutingServer)
{
    log::SeverityGuard guard(log::TBAG_DEFAULT_LOGGER_NAME, log::INFO_SEVERITY);

    uvpp::Loop loop;
    HttpServer server(loop);

    int on_open    = 0;
    int on_close   = 0;
    int on_request = 0;

    int on_request_doc = 0;
    int on_request_down_get  = 0;
    int on_request_down_post = 0;

    server.init(details::ANY_IPV4, 0);
    int const SERVER_PORT = server.getPort();

    std::string request_url = "http://localhost:";
    request_url += std::to_string(SERVER_PORT);
    request_url += "/";

    std::string const REQUEST_URL_DOC  = request_url + "Documents";
    std::string const REQUEST_URL_DOWN = request_url + "Downloads";

    std::cout << "Request URL: " << request_url << std::endl;

    server.setOnOpen([&](HttpServer::WeakClient node){
        ++on_open;
    });

    server.setOnRequest([&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest()\n";
        ++on_request;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("/Documents", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest(/Documents)\n";
        ++on_request_doc;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("GET", "/Downloads", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest([GET]/Downloads)\n";
        ++on_request_down_get;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });
    server.setOnRequest("POST", "/Downloads", [&](Err code, HttpServer::WeakClient node, HttpParser const & request, HttpBuilder & response, uint64_t & timeout){
        std::cout << "Server.OnRequest([POST]/Downloads)\n";
        ++on_request_down_post;
        response.setStatus(200);
        response.setReason("OK");
        response.setBody(request.getMethodName() + request.getUrl());
        timeout = 1000;
    });

    server.setOnClose([&](HttpServer::WeakClient node){
        ++on_close;
        if (on_close == 5) {
            server.close();
        }
    });

    Err server_result = Err::E_UNKNOWN;
    Err client_result = Err::E_UNKNOWN;

    HttpResponse response;
    HttpResponse response_doc_get;
    HttpResponse response_doc_post;
    HttpResponse response_down_get;
    HttpResponse response_down_post;

    HttpRequest request_get;
    request_get.method = "GET";
    HttpRequest request_post;
    request_post.method = "POST";

    std::thread server_thread([&](){ server_result = loop.run(); });
    std::thread client1_thread([&](){ client_result = http::requestWithSync(request_url, 1000, response); });
    std::thread client2_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOC, request_get, 1000, response_doc_get); });
    std::thread client3_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOC, request_post, 1000, response_doc_post); });
    std::thread client4_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOWN, request_get, 1000, response_down_get); });
    std::thread client5_thread([&](){ client_result = http::requestWithSync(REQUEST_URL_DOWN, request_post, 1000, response_down_post); });

    client1_thread.join();
    client2_thread.join();
    client3_thread.join();
    client4_thread.join();
    client5_thread.join();
    server_thread.join();

    ASSERT_EQ(200, response.status);
    ASSERT_EQ(200, response_doc_get.status);
    ASSERT_EQ(200, response_doc_post.status);
    ASSERT_EQ(200, response_down_get.status);
    ASSERT_EQ(200, response_down_post.status);

    ASSERT_EQ(5, on_open             );
    ASSERT_EQ(1, on_request          );
    ASSERT_EQ(2, on_request_doc      );
    ASSERT_EQ(1, on_request_down_get );
    ASSERT_EQ(1, on_request_down_post);
    ASSERT_EQ(5, on_close            );
}

<|endoftext|>


<commit_before>// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR7800

class NoDestroy { ~NoDestroy(); }; // expected-note {{declared private here}}
struct A {
  virtual ~A();
};
struct B : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
struct D : public virtual B {
  virtual void foo();
  ~D();
};
void D::foo() { // expected-note {{implicit default destructor for 'B' first required here}}
}
<commit_msg>Make this test check a few more cases which didn't work correctly before r110526.<commit_after>// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR7800

class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
struct A {
  virtual ~A();
};

struct B : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
struct D : public virtual B {
  virtual void foo();
  ~D();
};
void D::foo() { // expected-note {{implicit default destructor for 'B' first required here}}
}

struct E : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
struct F : public E { // expected-note {{implicit default destructor for 'E' first required here}}
};
struct G : public virtual F {
  virtual void foo();
  ~G();
};
void G::foo() { // expected-note {{implicit default destructor for 'F' first required here}}
}

struct H : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
struct I : public virtual H {
  ~I();
};
struct J : public I {
  virtual void foo();
  ~J();
};
void J::foo() { // expected-note {{implicit default destructor for 'H' first required here}}
}
<|endoftext|>


<commit_before>#include <bits/stdc++.h>
#define UN(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define FOR(i, a, b) for (decltype(a) i(a), _B_##i(b); i < _B_##i; ++i)
#define CL(a, b) memset(a, b, sizeof a)
#define all(a) (a).begin(), (a).end()
#define REP(i, n) FOR(i, 0, n)
#define sz(a) int((a).size())
#define ll int64_t
#define pb push_back
#define Y second
#define X first

using namespace std;

typedef pair<int, int> pii;

int mod;

int add(int x, int y) { return (x += y) < mod ? x : x - mod; }
int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
int mul(int x, int y) { return (ll)x * y % mod; }

template <class X>
X qpow(X x, X n) {
	X y{1};
	for (; n; n /= 2) {
		if (n & 1) y = mul(x, y);
		x = mul(x, x);
	}
	return y;
}

int inv(int x) { return qpow(x, mod - 2); }

template <class X>
struct LinearRecurrence {
    vector<X> s, f = {1}, g = {1};
    int m = 1;
    X q = 1;

    void preduce(vector<X> &a) const {
        for (int n = sz(a); n -->= sz(f); a.pop_back()) {
            FOR (i, 1, sz(f))
                a[n - i] = sub(a[n - i], mul(a.back(), f[i]));
        }
    }

    vector<X> pmul(vector<X> &a, vector<X> &b) const {
        vector<X> r(sz(a) + sz(b));
        REP (i, sz(a)) REP (j, sz(b)) {
            r[i + j] = add(r[i + j], mul(a[i], b[j]));
        }
        preduce(r);
        return r;
    }

    X solve(ll n) const { return solve(n, n + 1)[0]; }

    vector<X> solve(ll from, ll to) const {
        vector<X> x = {0, 1}, r = {1};
        for (ll n = from; n; n /= 2) {
            if (n & 1) r = pmul(r, x);
            x = pmul(x, x);
        }
        vector<X> res;
        FOR (n, from, to) {
            res.emplace_back();
            REP (i, sz(r)) res.back() = add(res.back(), mul(r[i], s[i]));
            r.emplace(r.begin());
            preduce(r);
        }
        return res;
    }

    bool next(X x) {
        int k = sz(s);
        s.pb(x);
        X p = 0;
        REP (i, sz(f)) p = add(p, mul(f[i], s[k - i]));
        if (p) {
            auto t = f;
            f.resize(max(sz(f), sz(g) + m));
            X z = mul(p, inv(q));
            REP (i, sz(g)) f[i + m] = sub(f[i + m], mul(g[i], z));
            g = t;
            q = p;
            m = 1;
        } else if (++m > 128) {
            return false;
        }
        return true;
    }
};

void test1() {
    mod = 1e9 + 7;
    LinearRecurrence<int> a;
    auto f = [](ll x) {
        return qpow(x % mod, x % 10);
    };
    for (int x = 0; a.next(f(x)); ++x);
    assert(sz(a.f) == 101);
    REP (i, 100) {
        ll x = 1000000ll + i * 65537;
        assert(f(x) == a.solve(x));
    }
}

uint32_t xorshift128() {
    static uint32_t x = 123456, y = 234567, z = 345678, w = 456789;
    uint32_t t = x ^ (x << 11);
    t ^= t >> 8;
    x = y; y = z; z = w;
    return w ^= (w >> 19) ^ t;
}

void test2() {
    mod = 2;
    LinearRecurrence<int> r;
    ll n = 0;
    for (; ; ) {
        uint32_t x = xorshift128();
        bool ok = true;
        REP (i, 32) ok &= r.next((x >> i) & 1);
        n += 32;
        if (!ok) break;
    }
    const int SKIP = 10000000;
    const int N = 100;
    REP (k, SKIP) {
        xorshift128();
        n += 32;
    }
    vector<int> c = r.solve(n, n + 32 * N);
    REP (k, N) {
        uint32_t x = 0;
        REP (i, 32) x |= c[k * 32 + i] << i;
        assert(xorshift128() == x);
    }
}

int main() {
    test1();
    test2();
    return 0;
}
<commit_msg>Little optimize.<commit_after>#include <bits/stdc++.h>
#define UN(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define FOR(i, a, b) for (decltype(a) i(a), _B_##i(b); i < _B_##i; ++i)
#define CL(a, b) memset(a, b, sizeof a)
#define all(a) (a).begin(), (a).end()
#define REP(i, n) FOR(i, 0, n)
#define sz(a) int((a).size())
#define ll int64_t
#define pb push_back
#define Y second
#define X first

using namespace std;

typedef pair<int, int> pii;

int mod;

int add(int x, int y) { return (x += y) < mod ? x : x - mod; }
int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
int mul(int x, int y) { return (ll)x * y % mod; }

template <class X>
X qpow(X x, X n) {
	X y{1};
	for (; n; n /= 2) {
		if (n & 1) y = mul(x, y);
		x = mul(x, x);
	}
	return y;
}

int inv(int x) { return qpow(x, mod - 2); }

template <class X>
struct LinearRecurrence {
    vector<X> s, f = {1}, g = {1};
    int m = 1;
    X q = 1;

    void preduce(vector<X> &a) const {
        for (int n = sz(a); n -->= sz(f); a.pop_back()) {
            FOR (i, 1, sz(f))
                a[n - i] = sub(a[n - i], mul(a.back(), f[i]));
        }
    }

    vector<X> pmul(vector<X> &a, vector<X> &b) const {
        vector<X> r(sz(a) + sz(b));
        REP (i, sz(a)) REP (j, sz(b)) {
            r[i + j] = add(r[i + j], mul(a[i], b[j]));
        }
        preduce(r);
        return r;
    }

    X solve(ll n) const { return solve(n, n + 1)[0]; }

    vector<X> solve(ll from, ll to) const {
        vector<X> x = {0, 1}, r = {1};
        for (ll n = from; n; n /= 2) {
            if (n & 1) r = pmul(r, x);
            x = pmul(x, x);
        }
        vector<X> res;
        FOR (n, from, to) {
            res.emplace_back();
            REP (i, sz(r)) res.back() = add(res.back(), mul(r[i], s[i]));
            r.emplace(r.begin());
            preduce(r);
        }
        return res;
    }

    bool next(X x) {
        int k = sz(s);
        s.pb(x);
        X p = 0;
        REP (i, sz(f)) p = add(p, mul(f[i], s[k - i]));
        if (p) {
            auto t = f;
            f.resize(max(sz(f), sz(g) + m));
            X z = mul(p, inv(q));
            REP (i, sz(g)) f[i + m] = sub(f[i + m], mul(g[i], z));
            for (; f.back() == 0; f.pop_back());
            g = t;
            q = p;
            m = 1;
        } else if (++m > 128) {
            return false;
        }
        return true;
    }
};

void test1() {
    mod = 1e9 + 7;
    LinearRecurrence<int> a;
    auto f = [](ll x) {
        return qpow(x % mod, x % 10);
    };
    for (int x = 0; a.next(f(x)); ++x);
    assert(sz(a.f) == 101);
    REP (i, 100) {
        ll x = 1000000ll + i * 65537;
        assert(f(x) == a.solve(x));
    }
}

uint32_t xorshift128() {
    static uint32_t x = 123456, y = 234567, z = 345678, w = 456789;
    uint32_t t = x ^ (x << 11);
    t ^= t >> 8;
    x = y; y = z; z = w;
    return w ^= (w >> 19) ^ t;
}

void test2() {
    mod = 2;
    LinearRecurrence<int> r;
    ll n = 0;
    for (; ; ) {
        uint32_t x = xorshift128();
        bool ok = true;
        REP (i, 32) ok &= r.next((x >> i) & 1);
        n += 32;
        if (!ok) break;
    }
    const int SKIP = 10000000;
    const int N = 100;
    REP (k, SKIP) {
        xorshift128();
        n += 32;
    }
    vector<int> c = r.solve(n, n + 32 * N);
    REP (k, N) {
        uint32_t x = 0;
        REP (i, 32) x |= c[k * 32 + i] << i;
        assert(xorshift128() == x);
    }
}

int main() {
    test1();
    test2();
    return 0;
}
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2008-2013 The Communi Project
 *
 * This test is free, and not covered by the LGPL license. There is no
 * restriction applied to their modification, redistribution, using and so on.
 * You can study them, modify them, use them in your own program - either
 * completely or partially.
 */

#include "irclagtimer.h"
#include "ircconnection.h"
#include <QtTest/QtTest>

class tst_IrcLagTimer : public QObject
{
    Q_OBJECT

private slots:
    void testDefaults();
    void testInterval();
    void testConnection();
};

void tst_IrcLagTimer::testDefaults()
{
    IrcLagTimer timer;
    QCOMPARE(timer.lag(), -1);
    QVERIFY(!timer.connection());
    QCOMPARE(timer.interval(), 60);
}

void tst_IrcLagTimer::testInterval()
{
    IrcLagTimer timer;
    timer.setInterval(INT_MIN);
    QCOMPARE(timer.interval(), INT_MIN);
    timer.setInterval(0);
    QCOMPARE(timer.interval(), 0);
    timer.setInterval(INT_MAX);
    QCOMPARE(timer.interval(), INT_MAX);
}

void tst_IrcLagTimer::testConnection()
{
    IrcLagTimer timer;
    IrcConnection* connection = new IrcConnection(&timer);
    timer.setConnection(connection);
    QCOMPARE(timer.connection(), connection);
    timer.setConnection(0);
    QVERIFY(!timer.connection());
}

QTEST_MAIN(tst_IrcLagTimer)

#include "tst_irclagtimer.moc"
<commit_msg>Fix build<commit_after>/*
 * Copyright (C) 2008-2013 The Communi Project
 *
 * This test is free, and not covered by the LGPL license. There is no
 * restriction applied to their modification, redistribution, using and so on.
 * You can study them, modify them, use them in your own program - either
 * completely or partially.
 */

#include "irclagtimer.h"
#include "ircconnection.h"
#include <QtTest/QtTest>

class tst_IrcLagTimer : public QObject
{
    Q_OBJECT

private slots:
    void testDefaults();
    void testInterval();
    void testConnection();
};

void tst_IrcLagTimer::testDefaults()
{
    IrcLagTimer timer;
    QCOMPARE(timer.lag(), qint64(-1));
    QVERIFY(!timer.connection());
    QCOMPARE(timer.interval(), 60);
}

void tst_IrcLagTimer::testInterval()
{
    IrcLagTimer timer;
    timer.setInterval(INT_MIN);
    QCOMPARE(timer.interval(), INT_MIN);
    timer.setInterval(0);
    QCOMPARE(timer.interval(), 0);
    timer.setInterval(INT_MAX);
    QCOMPARE(timer.interval(), INT_MAX);
}

void tst_IrcLagTimer::testConnection()
{
    IrcLagTimer timer;
    IrcConnection* connection = new IrcConnection(&timer);
    timer.setConnection(connection);
    QCOMPARE(timer.connection(), connection);
    timer.setConnection(0);
    QVERIFY(!timer.connection());
}

QTEST_MAIN(tst_IrcLagTimer)

#include "tst_irclagtimer.moc"
<|endoftext|>


<commit_before>#include <FalconEngine/Platform/Direct3D/Direct3DRendererState.h>

#if defined(FALCON_ENGINE_API_DIRECT3D)
#include <FalconEngine/Graphics/Renderer/State/BlendState.h>
#include <FalconEngine/Graphics/Renderer/State/CullState.h>
#include <FalconEngine/Graphics/Renderer/State/DepthTestState.h>
#include <FalconEngine/Graphics/Renderer/State/OffsetState.h>
#include <FalconEngine/Graphics/Renderer/State/StencilTestState.h>
#include <FalconEngine/Graphics/Renderer/State/WireframeState.h>
#include <FalconEngine/Platform/Direct3D/Direct3DMapping.h>

namespace FalconEngine
{

/************************************************************************/
/* Constructors and Destructor                                          */
/************************************************************************/
PlatformRendererState::PlatformRendererState()
{
}

/************************************************************************/
/* Public Members                                                       */
/************************************************************************/
void
PlatformRendererState::Initialize(ID3D11DeviceContext4 *context,
                                  ID3D11Device4 *device,
                                  const BlendState *blendState,
                                  const CullState *cullState,
                                  const DepthTestState *depthTestState,
                                  const OffsetState *offsetState,
                                  const StencilTestState *stencilTestState,
                                  const WireframeState *wireframeState)
{
    // Blend State
    D3D11_BLEND_DESC1 blendDesc;
    ZeroMemory(&blendDesc, sizeof blendDesc);
    blendDesc.AlphaToCoverageEnable = false;

    // NEW(Wuxiang): Support MRT blending.
    blendDesc.IndependentBlendEnable = false;
    D3D11_RENDER_TARGET_BLEND_DESC1 blendDescRt;
    ZeroMemory(&blendDescRt, sizeof blendDescRt);
    blendDescRt.BlendEnable = blendState->mEnabled;
    blendDescRt.LogicOpEnable = false;
    blendDescRt.SrcBlend = Direct3DBlendFactor[BlendFactorIndex(blendState->mSourceFactor)];
    blendDescRt.DestBlend = Direct3DBlendFactor[BlendFactorIndex(blendState->mDestinationFactor)];
    blendDescRt.BlendOp = Direct3DBlendOperator[BlendOperatorIndex(blendState->mOperator)];
    blendDescRt.SrcBlendAlpha = Direct3DBlendFactor[BlendFactorIndex(blendState->mSourceFactorAlpha)];;
    blendDescRt.DestBlendAlpha = Direct3DBlendFactor[BlendFactorIndex(blendState->mDestinationFactorAlpha)];
    blendDescRt.BlendOpAlpha = Direct3DBlendOperator[BlendOperatorIndex(blendState->mOperatorAlpha)];;
    blendDescRt.LogicOp;
    UINT8          RenderTargetWriteMask;

    blendDesc.RenderTarget[0] = blendDescRt;
    device->CreateBlendState1(&blendDesc, mBlendState.ReleaseAndGetAddressOf());
    context->OMSetBlendState(mBlendState.Get(), nullptr, 0xffffffff);

    // Depth Stencil State
    D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
    ZeroMemory(&depthStencilDesc, sizeof depthStencilDesc);
    depthStencilDesc.DepthEnable = true;
    depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
    depthStencilDesc.StencilEnable = false;
    depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
    depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
    depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
    depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
    depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    device->CreateDepthStencilState(&depthStencilDesc, mDepthStencilState.ReleaseAndGetAddressOf());
    context->OMSetDepthStencilState(mDepthStencilState.Get(), 0);

    // Rasterizer State
    D3D11_RASTERIZER_DESC rasterizerDesc;
    ZeroMemory(&rasterizerDesc, sizeof rasterizerDesc);
    rasterizerDesc.AntialiasedLineEnable = false;
    rasterizerDesc.CullMode = D3D11_CULL_BACK;
    rasterizerDesc.FillMode = D3D11_FILL_SOLID;
    rasterizerDesc.FrontCounterClockwise = false;
    rasterizerDesc.DepthBias = 0;
    rasterizerDesc.DepthBiasClamp = 0.0f;
    rasterizerDesc.DepthClipEnable = true;
    rasterizerDesc.ScissorEnable = false;
    rasterizerDesc.MultisampleEnable = false;
    device->CreateRasterizerState(&rasterizerDesc, mRasterizerState.ReleaseAndGetAddressOf());
    context->RSSetState(mRasterizerState.Get());
}

}

#endif<commit_msg>Finished Blend state initialization in D3D.<commit_after>#include <FalconEngine/Platform/Direct3D/Direct3DRendererState.h>

#if defined(FALCON_ENGINE_API_DIRECT3D)
#include <FalconEngine/Graphics/Renderer/State/BlendState.h>
#include <FalconEngine/Graphics/Renderer/State/CullState.h>
#include <FalconEngine/Graphics/Renderer/State/DepthTestState.h>
#include <FalconEngine/Graphics/Renderer/State/OffsetState.h>
#include <FalconEngine/Graphics/Renderer/State/StencilTestState.h>
#include <FalconEngine/Graphics/Renderer/State/WireframeState.h>
#include <FalconEngine/Platform/Direct3D/Direct3DMapping.h>

namespace FalconEngine
{

/************************************************************************/
/* Constructors and Destructor                                          */
/************************************************************************/
PlatformRendererState::PlatformRendererState()
{
}

/************************************************************************/
/* Public Members                                                       */
/************************************************************************/
void
PlatformRendererState::Initialize(ID3D11DeviceContext4 *context,
                                  ID3D11Device4 *device,
                                  const BlendState *blendState,
                                  const CullState *cullState,
                                  const DepthTestState *depthTestState,
                                  const OffsetState *offsetState,
                                  const StencilTestState *stencilTestState,
                                  const WireframeState *wireframeState)
{
    // Blend State
    D3D11_BLEND_DESC1 blendDesc;
    ZeroMemory(&blendDesc, sizeof blendDesc);

    // NEW(Wuxiang): Add alpha to coverage support.
    blendDesc.AlphaToCoverageEnable = false;
    // NEW(Wuxiang): Support MRT blending.
    blendDesc.IndependentBlendEnable = false;

    D3D11_RENDER_TARGET_BLEND_DESC1 blendDescRt;
    ZeroMemory(&blendDescRt, sizeof blendDescRt);
    blendDescRt.BlendEnable = blendState->mEnabled;
    blendDescRt.BlendOp = Direct3DBlendOperator[BlendOperatorIndex(blendState->mOperator)];
    blendDescRt.SrcBlend = Direct3DBlendFactor[BlendFactorIndex(blendState->mSourceFactor)];
    blendDescRt.SrcBlendAlpha = Direct3DBlendFactor[BlendFactorIndex(blendState->mSourceFactorAlpha)];;
    blendDescRt.DestBlend = Direct3DBlendFactor[BlendFactorIndex(blendState->mDestinationFactor)];
    blendDescRt.DestBlendAlpha = Direct3DBlendFactor[BlendFactorIndex(blendState->mDestinationFactorAlpha)];
    blendDescRt.BlendOpAlpha = Direct3DBlendOperator[BlendOperatorIndex(blendState->mOperatorAlpha)];;
    blendDescRt.LogicOpEnable = blendState->mLogicEnabled;
    blendDescRt.LogicOp = Direct3DLogicOperator[LogicOperatorIndex(blendState->mLogicOperator)];
    blendDescRt.RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
    blendDesc.RenderTarget[0] = blendDescRt;
    device->CreateBlendState1(&blendDesc, mBlendState.ReleaseAndGetAddressOf());

    // NEW(Wuxiang): Add alpha to coverage support.
    context->OMSetBlendState(mBlendState.Get(), blendState->mConstantFactor.Data(), 0xffffffff);

    // Depth Stencil State
    D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
    ZeroMemory(&depthStencilDesc, sizeof depthStencilDesc);
    depthStencilDesc.DepthEnable = true;
    depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
    depthStencilDesc.StencilEnable = false;
    depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
    depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
    depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
    depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
    depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    device->CreateDepthStencilState(&depthStencilDesc, mDepthStencilState.ReleaseAndGetAddressOf());
    context->OMSetDepthStencilState(mDepthStencilState.Get(), 0);

    // Rasterizer State
    D3D11_RASTERIZER_DESC rasterizerDesc;
    ZeroMemory(&rasterizerDesc, sizeof rasterizerDesc);
    rasterizerDesc.AntialiasedLineEnable = false;
    rasterizerDesc.CullMode = D3D11_CULL_BACK;
    rasterizerDesc.FillMode = D3D11_FILL_SOLID;
    rasterizerDesc.FrontCounterClockwise = false;
    rasterizerDesc.DepthBias = 0;
    rasterizerDesc.DepthBiasClamp = 0.0f;
    rasterizerDesc.DepthClipEnable = true;
    rasterizerDesc.ScissorEnable = false;
    rasterizerDesc.MultisampleEnable = false;
    device->CreateRasterizerState(&rasterizerDesc, mRasterizerState.ReleaseAndGetAddressOf());
    context->RSSetState(mRasterizerState.Get());
}

}

#endif<|endoftext|>


<commit_before>#define BOOST_TEST_MODULE send_recv

#include <boost/test/included/unit_test.hpp>
#include <iostream>
#include <limits>
#include <cstddef>
#include <complex>
#include <mpl/mpl.hpp>

template<typename T>
bool send_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.send(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool bsend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0) {
    const int size{comm_world.bsend_size<T>()};
    mpl::bsend_buffer<> buff(size);
    comm_world.bsend(data, 1);
  }
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool ssend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.ssend(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool rsend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.rsend(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool sendrecv_test() {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  int rank=comm_world.rank();
  int size=comm_world.size();
  T x[2]={T(rank), T(rank)};
  comm_world.sendrecv(x[1], (rank+1)%size, mpl::tag(0),
                      x[0], (rank-1+size)%size, mpl::tag(0));
  return x[0]==T((rank-1+size)%size) and x[1]==T(rank);
}

BOOST_AUTO_TEST_CASE(send_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(send_recv_test(std::byte(77)));
#endif
  BOOST_TEST(send_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(send_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(send_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(send_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(send_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(send_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(send_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(send_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(send_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(send_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(send_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(send_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(bsend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(bsend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(bsend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(bsend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(bsend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(bsend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(bsend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(bsend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(bsend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(bsend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(bsend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(bsend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(bsend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(bsend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(ssend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(ssend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(ssend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(ssend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(ssend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(ssend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(ssend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(ssend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(ssend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(ssend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(ssend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(ssend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(ssend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(ssend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(rsend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(rsend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(rsend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(rsend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(rsend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(rsend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(rsend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(rsend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(rsend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(rsend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(rsend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(rsend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(rsend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(rsend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(sendrecv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(sendrecv_test<std::byte>());
#endif
  BOOST_TEST(sendrecv_test<char>());
  BOOST_TEST(sendrecv_test<signed char>());
  BOOST_TEST(sendrecv_test<unsigned char>());
  BOOST_TEST(sendrecv_test<signed short>());
  BOOST_TEST(sendrecv_test<unsigned short>());
  BOOST_TEST(sendrecv_test<signed int>());
  BOOST_TEST(sendrecv_test<unsigned int>());
  BOOST_TEST(sendrecv_test<signed long>());
  BOOST_TEST(sendrecv_test<unsigned long>());
  BOOST_TEST(sendrecv_test<signed long long>());
  BOOST_TEST(sendrecv_test<unsigned long long>());
  // character types
  BOOST_TEST(sendrecv_test<wchar_t>());
  BOOST_TEST(sendrecv_test<char16_t>());
  BOOST_TEST(sendrecv_test<char32_t>());
  // floating point number types
  BOOST_TEST(sendrecv_test<float>());
  BOOST_TEST(sendrecv_test<double>());
  BOOST_TEST(sendrecv_test<long double>());
  BOOST_TEST(sendrecv_test<float>());
  BOOST_TEST(sendrecv_test<double>());
  BOOST_TEST(sendrecv_test<long double>());
  // logical type
  BOOST_TEST(sendrecv_test<bool>());
}
<commit_msg>add test for sendrecv_replace<commit_after>#define BOOST_TEST_MODULE send_recv

#include <boost/test/included/unit_test.hpp>
#include <iostream>
#include <limits>
#include <cstddef>
#include <complex>
#include <mpl/mpl.hpp>

template<typename T>
bool send_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.send(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool bsend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0) {
    const int size{comm_world.bsend_size<T>()};
    mpl::bsend_buffer<> buff(size);
    comm_world.bsend(data, 1);
  }
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool ssend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.ssend(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool rsend_recv_test(const T &data) {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  if (comm_world.size()<2)
    false;
  if (comm_world.rank()==0)
    comm_world.rsend(data, 1);
  if (comm_world.rank()==1) {
    T data_r;
    comm_world.recv(data_r, 0);
    return data_r==data;
  }
  return true;
}

template<typename T>
bool sendrecv_test() {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  int rank=comm_world.rank();
  int size=comm_world.size();
  T x[2]={T(rank), T(rank)};
  comm_world.sendrecv(x[1], (rank+1)%size, mpl::tag(0),
                      x[0], (rank-1+size)%size, mpl::tag(0));
  return x[0]==T((rank-1+size)%size) and x[1]==T(rank);
}

template<typename T>
bool sendrecv_replace_test() {
  const mpl::communicator &comm_world=mpl::environment::comm_world();
  int rank=comm_world.rank();
  int size=comm_world.size();
  T x{T(rank)};
  comm_world.sendrecv_replace(x, (rank+1)%size, mpl::tag(0),
                              (rank-1+size)%size, mpl::tag(0));
  return x==T((rank-1+size)%size);
}

BOOST_AUTO_TEST_CASE(send_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(send_recv_test(std::byte(77)));
#endif
  BOOST_TEST(send_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(send_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(send_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(send_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(send_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(send_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(send_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(send_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(send_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(send_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(send_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(send_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(send_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(bsend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(bsend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(bsend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(bsend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(bsend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(bsend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(bsend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(bsend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(bsend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(bsend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(bsend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(bsend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(bsend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(bsend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(bsend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(ssend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(ssend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(ssend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(ssend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(ssend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(ssend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(ssend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(ssend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(ssend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(ssend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(ssend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(ssend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(ssend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(ssend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(ssend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(rsend_recv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(rsend_recv_test(std::byte(77)));
#endif
  BOOST_TEST(rsend_recv_test(std::numeric_limits<char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned char>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed short>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned short>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed int>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned int>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<signed long long>::max()-1));
  BOOST_TEST(rsend_recv_test(std::numeric_limits<unsigned long long>::max()-1));
  // character types
  BOOST_TEST(rsend_recv_test(static_cast<wchar_t>('A')));
  BOOST_TEST(rsend_recv_test(static_cast<char16_t>('A')));
  BOOST_TEST(rsend_recv_test(static_cast<char32_t>('A')));
  // floating point number types
  BOOST_TEST(rsend_recv_test(static_cast<float>(3.14)));
  BOOST_TEST(rsend_recv_test(static_cast<double>(3.14)));
  BOOST_TEST(rsend_recv_test(static_cast<long double>(3.14)));
  BOOST_TEST(rsend_recv_test(std::complex<float>(3.14, 2.72)));
  BOOST_TEST(rsend_recv_test(std::complex<double>(3.14, 2.72)));
  BOOST_TEST(rsend_recv_test(std::complex<long double>(3.14, 2.72)));
  // logical type
  BOOST_TEST(rsend_recv_test(true));
  // enums
  enum class my_enum : int {
    val=std::numeric_limits<int>::max()-1
  };
  BOOST_TEST(rsend_recv_test(my_enum::val));
}

BOOST_AUTO_TEST_CASE(sendrecv) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(sendrecv_test<std::byte>());
#endif
  BOOST_TEST(sendrecv_test<char>());
  BOOST_TEST(sendrecv_test<signed char>());
  BOOST_TEST(sendrecv_test<unsigned char>());
  BOOST_TEST(sendrecv_test<signed short>());
  BOOST_TEST(sendrecv_test<unsigned short>());
  BOOST_TEST(sendrecv_test<signed int>());
  BOOST_TEST(sendrecv_test<unsigned int>());
  BOOST_TEST(sendrecv_test<signed long>());
  BOOST_TEST(sendrecv_test<unsigned long>());
  BOOST_TEST(sendrecv_test<signed long long>());
  BOOST_TEST(sendrecv_test<unsigned long long>());
  // character types
  BOOST_TEST(sendrecv_test<wchar_t>());
  BOOST_TEST(sendrecv_test<char16_t>());
  BOOST_TEST(sendrecv_test<char32_t>());
  // floating point number types
  BOOST_TEST(sendrecv_test<float>());
  BOOST_TEST(sendrecv_test<double>());
  BOOST_TEST(sendrecv_test<long double>());
  BOOST_TEST(sendrecv_test<float>());
  BOOST_TEST(sendrecv_test<double>());
  BOOST_TEST(sendrecv_test<long double>());
  // logical type
  BOOST_TEST(sendrecv_test<bool>());
}

BOOST_AUTO_TEST_CASE(sendrecv_replace) {
  // integer types
#if __cplusplus>=201703L
  BOOST_TEST(sendrecv_replace_test<std::byte>());
#endif
  BOOST_TEST(sendrecv_replace_test<char>());
  BOOST_TEST(sendrecv_replace_test<signed char>());
  BOOST_TEST(sendrecv_replace_test<unsigned char>());
  BOOST_TEST(sendrecv_replace_test<signed short>());
  BOOST_TEST(sendrecv_replace_test<unsigned short>());
  BOOST_TEST(sendrecv_replace_test<signed int>());
  BOOST_TEST(sendrecv_replace_test<unsigned int>());
  BOOST_TEST(sendrecv_replace_test<signed long>());
  BOOST_TEST(sendrecv_replace_test<unsigned long>());
  BOOST_TEST(sendrecv_replace_test<signed long long>());
  BOOST_TEST(sendrecv_replace_test<unsigned long long>());
  // character types
  BOOST_TEST(sendrecv_replace_test<wchar_t>());
  BOOST_TEST(sendrecv_replace_test<char16_t>());
  BOOST_TEST(sendrecv_replace_test<char32_t>());
  // floating point number types
  BOOST_TEST(sendrecv_replace_test<float>());
  BOOST_TEST(sendrecv_replace_test<double>());
  BOOST_TEST(sendrecv_replace_test<long double>());
  BOOST_TEST(sendrecv_replace_test<float>());
  BOOST_TEST(sendrecv_replace_test<double>());
  BOOST_TEST(sendrecv_replace_test<long double>());
  // logical type
  BOOST_TEST(sendrecv_replace_test<bool>());
}
<|endoftext|>