<?php
namespace ccxt;

// ----------------------------------------------------------------------------

// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

// -----------------------------------------------------------------------------


function test_remove_repeated_elements_from_array() {
    $exchange = new \ccxt\Exchange(array(
        'id' => 'sampleexchange',
    ));
    // CASE 1: by id
    $array1 = [array(
    'id' => 'a',
    'timestamp' => 1,
    'uniq' => 'x1',
), array(
    'id' => 'b',
    'timestamp' => 2,
    'uniq' => 'x2',
), array(
    'id' => 'a',
    'timestamp' => 3,
    'uniq' => 'x3',
), array(
    'id' => 'c',
    'timestamp' => 1,
    'uniq' => 'x4',
)];
    $res1 = $exchange->remove_repeated_elements_from_array($array1, false);
    $res1_length = count($res1);
    assert($res1_length === 3);
    assert($res1[0]['uniq'] === 'x1');
    assert($res1[1]['uniq'] === 'x2');
    assert($res1[2]['uniq'] === 'x4');
    // CASE 2: by timestamp
    $array2 = [array(
    'id' => null,
    'timestamp' => 1,
    'uniq' => 'x1',
), array(
    'id' => null,
    'timestamp' => 2,
    'uniq' => 'x2',
), array(
    'id' => null,
    'timestamp' => 1,
    'uniq' => 'x3',
), array(
    'id' => null,
    'timestamp' => 3,
    'uniq' => 'x4',
)];
    $res2 = $exchange->remove_repeated_elements_from_array($array2, true);
    $res2_length = count($res2);
    assert($res2_length === 3);
    assert($res2[0]['uniq'] === 'x1');
    assert($res2[1]['uniq'] === 'x2');
    assert($res2[2]['uniq'] === 'x4');
    // CASE 3: by timestamp index (used in ohlcv)
    $array3 = [[555, 1, 1, 'x1'], [666, 1, 1, 'x2'], [555, 1, 1, 'x3']];
    $res3 = $exchange->remove_repeated_elements_from_array($array3, true);
    assert(count($res3) === 2);
    assert($res3[0][3] === 'x1');
    assert($res3[1][3] === 'x2');
}
