Ejemplo n.º 1
0
void print(const arrp::testing::array & data, int dim, int & index)
{
    for (int i = 0; i < data.size()[dim]; ++i)
    {
        if (dim > 0 && i > 0)
            cout << ",";
        if (dim == data.size().size() - 1)
        {
            cout << data(index);
            ++index;
        }
        else
        {
            cout << '(';
            print(data, dim+1, index);
            cout << ')';
        }
        if (dim == 0)
            cout << endl;
    }
}
Ejemplo n.º 2
0
void print(const arrp::testing::array & data)
{
    cout << std::fixed << std::setprecision(3);

    if (data.size().empty())
    {
        cout << data(0) << endl;
    }
    else
    {
        int index = 0;
        print(data, 0, index);
    }
}
Ejemplo n.º 3
0
bool compare(const arrp::testing::array & actual, const arrp::testing::array & expected)
{
    using namespace std;

    if (actual.size().size() != expected.size().size())
    {
        cout << "Different number of dimensions." << endl;
        return false;
    }

    for (int i = 1; i < actual.size().size(); ++i)
    {
        if (actual.size()[i] != expected.size()[i])
        {
            cout << "Different element sizes." << endl;
            return false;
        }
    }

    if (actual.count() < expected.count())
    {
        cout << "Too few elements in output." << endl;
        return false;
    }

    bool ok = true;

    for (int i = 0; i < expected.total_count(); ++i)
    {
        const auto & e = expected(i);
        const auto & v = actual(i);
        if (!compare(e,v))
        {
            ok = false;
#if 1
            cout << "Output " << i << ":"
                 << " expected = " << e
                 << " but actual = " << v
                 << "." << endl;
#endif
        }
    }

    return ok;
}