Example #1
0
int
main (void)
{
  float64_t v1 = 3.14159265359;
  float64_t v2 = 1.383894;

  /* Constant * constant, shouldn't generete fmulx or fmul, only fmov.  */
  SETUP_TEST_CASE_SCALAR (1, vmulxd_f64, float64_t, v1, v2, v1 * v2);
  SETUP_TEST_CASE_SCALAR (2, vmulxd_f64, float64_t, 0.0,
			  __builtin_huge_val (), 2.0);
  SETUP_TEST_CASE_SCALAR (3, vmulxd_f64, float64_t, 0.0,
			  -__builtin_huge_val (), -2.0);
  SETUP_TEST_CASE_SCALAR (4, vmulxd_f64, float64_t, -0.0,
			  __builtin_huge_val (), -2.0);
  SETUP_TEST_CASE_SCALAR (5, vmulxd_f64, float64_t, -0.0,
			  -__builtin_huge_val (), 2.0);
  /* Constant +/- 0 or +/- inf * non-constant should generate fmulx.  */
  SETUP_TEST_CASE_SCALAR (6, vmulxd_f64, float64_t, foo64 (),
			  -__builtin_huge_val (), -__builtin_huge_val ());
  SETUP_TEST_CASE_SCALAR (7, vmulxd_f64, float64_t, foo64 (),
			  __builtin_huge_val (), __builtin_huge_val ());
  SETUP_TEST_CASE_SCALAR (8, vmulxd_f64, float64_t, foo64 (),
			  0, 0);
  SETUP_TEST_CASE_SCALAR (9, vmulxd_f64, float64_t, foo64 (),
			  -0.0, -0.0);
  /* Constant non +/- 0 or non +/- inf * non-constant should generate fmul.  */
  SETUP_TEST_CASE_SCALAR (10, vmulxd_f64, float64_t, foo64 (),
			  v1, v1);

  return 0;
}
Example #2
0
void testUint64()
{
    {
        // test constructors and setting value and null
        Uint64Arg argNull;
        String x =  argNull.toString();
        VCOUT << x << endl;
        PEGASUS_TEST_ASSERT(x == String("NULL"));

        //PEGASUS_TEST_ASSERT(x == "NULL");

        Uint64Arg arg(102958);

        PEGASUS_TEST_ASSERT(arg.getValue() == 102958);
        PEGASUS_TEST_ASSERT(arg.isNull() == false);

        VCOUT << arg.toString() << endl;
        PEGASUS_TEST_ASSERT(arg.toString() == String("102958"));

        arg.setNullValue();
        PEGASUS_TEST_ASSERT(arg.getValue() == 0);
        PEGASUS_TEST_ASSERT(arg.isNull() == true);

        String val = arg.toString();
        VCOUT << val << endl;

        PEGASUS_TEST_ASSERT(val == String("NULL"));
    }

    {
        // test starting with Null constructor and setting value
        Uint64Arg arg;

        PEGASUS_TEST_ASSERT(arg.getValue() == 0);
        PEGASUS_TEST_ASSERT(arg.isNull() == true);

        arg.setValue(10);
        PEGASUS_TEST_ASSERT(arg.getValue() == 10);
        PEGASUS_TEST_ASSERT(arg.isNull() == false);
    }
   {
        // test copy operations.
        Uint64Arg arg;
        PEGASUS_TEST_ASSERT(arg.getValue() == 0);
        PEGASUS_TEST_ASSERT(arg.isNull() == true);

        Uint64Arg arg2 = arg;
        PEGASUS_TEST_ASSERT(arg2.getValue() == 0);
        PEGASUS_TEST_ASSERT(arg2.isNull() == true);

        arg.setValue(10);
        PEGASUS_TEST_ASSERT(arg.getValue() == 10);
        PEGASUS_TEST_ASSERT(arg.isNull() == false);

        Uint64Arg arg3 = arg;
        PEGASUS_TEST_ASSERT(arg3.getValue() == 10);
        PEGASUS_TEST_ASSERT(arg3.isNull() == false);
    }

    {
        // test setting to max Uint32 value
        Uint64Arg arg;
        arg.setValue(18446744073709551615ULL);

        PEGASUS_TEST_ASSERT(arg.getValue() == 18446744073709551615ULL);
        PEGASUS_TEST_ASSERT(arg.isNull() == false);

        VCOUT << arg.toString() << endl;
        PEGASUS_TEST_ASSERT(arg.toString() == String("18446744073709551615"));
    }
    {
        // test equal function
        Uint64Arg arg1;
        Uint64Arg arg2;
        PEGASUS_TEST_ASSERT(arg1.equal(arg2));
        PEGASUS_TEST_ASSERT(arg1 == arg2);
        Uint64Arg arg3(987654);
        Uint64Arg arg4(987654);
        PEGASUS_TEST_ASSERT(arg3.equal(arg4));
        PEGASUS_TEST_ASSERT(arg3 == arg4);
        PEGASUS_TEST_ASSERT(!arg1.equal(arg3));
        PEGASUS_TEST_ASSERT(!(arg1 == arg3));
        arg4.setValue(2);
        PEGASUS_TEST_ASSERT(!arg3.equal(arg4));
        PEGASUS_TEST_ASSERT(!(arg3 == arg4));
    }

    foo64(12345678);
}
Example #3
0
void OctreeTests::byteCountCodingTests(bool verbose) {
    int testsTaken = 0;
    int testsPassed = 0;
    int testsFailed = 0;

    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
    
    qDebug() << "OctreeTests::byteCountCodingTests()";
    
    QByteArray encoded;
    
    if (verbose) {
        qDebug() << "ByteCountCodedUINT zero(0)";
    }
    ByteCountCodedUINT zero(0);
    encoded = zero.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedZero;
    decodedZero.decode(encoded);
    if (verbose) {
        qDebug() << "decodedZero=" << decodedZero.data;
        qDebug() << "decodedZero==zero" << (decodedZero == zero) << " { expected true } ";
    }
    testsTaken++;
    bool result1 = (decodedZero.data == 0);
    bool expected1 = true;
    if (result1 == expected1) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 1: ByteCountCodedUINT zero(0) decodedZero.data == 0";
    }

    testsTaken++;
    bool result2 = (decodedZero == zero);
    bool expected2 = true;
    if (result2 == expected2) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 2: ByteCountCodedUINT zero(0) (decodedZero == zero)";
    }

    ByteCountCodedUINT decodedZeroB(encoded);
    if (verbose) {
        qDebug() << "decodedZeroB=" << decodedZeroB.data;
    }
    testsTaken++;
    bool result3 = (decodedZeroB.data == 0);
    bool expected3 = true;
    if (result3 == expected3) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 3: (decodedZeroB.data == 0)";
    }

    if (verbose) {
        qDebug() << "ByteCountCodedUINT foo(259)";
    }
    ByteCountCodedUINT foo(259);
    encoded = foo.encode();

    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedFoo;
    decodedFoo.decode(encoded);

    if (verbose) {
        qDebug() << "decodedFoo=" << decodedFoo.data;
        qDebug() << "decodedFoo==foo" << (decodedFoo == foo) << " { expected true } ";
    }
    testsTaken++;
    bool result4 = (decodedFoo.data == 259);
    bool expected4 = true;
    if (result4 == expected4) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 4: ByteCountCodedUINT zero(0) (decodedFoo.data == 259)";
    }

    testsTaken++;
    bool result5 = (decodedFoo == foo);
    bool expected5 = true;
    if (result5 == expected5) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 5: (decodedFoo == foo)";
    }

    ByteCountCodedUINT decodedFooB(encoded);
    if (verbose) {
        qDebug() << "decodedFooB=" << decodedFooB.data;
    }
    testsTaken++;
    bool result6 = (decodedFooB.data == 259);
    bool expected6 = true;
    if (result6 == expected6) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 6: (decodedFooB.data == 259)";
    }


    if (verbose) {
        qDebug() << "ByteCountCodedUINT bar(1000000)";
    }
    ByteCountCodedUINT bar(1000000);
    encoded = bar.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedBar;
    decodedBar.decode(encoded);
    if (verbose) {
        qDebug() << "decodedBar=" << decodedBar.data;
        qDebug() << "decodedBar==bar" << (decodedBar == bar) << " { expected true } ";
    }
    testsTaken++;
    bool result7 = (decodedBar.data == 1000000);
    bool expected7 = true;
    if (result7 == expected7) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 7: ByteCountCodedUINT zero(0) (decodedBar.data == 1000000)";
    }

    testsTaken++;
    bool result8 = (decodedBar == bar);
    bool expected8 = true;
    if (result8 == expected8) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 8: (decodedBar == bar)";
    }

    if (verbose) {
        qDebug() << "ByteCountCodedUINT spam(4294967295/2)";
    }
    ByteCountCodedUINT spam(4294967295/2);
    encoded = spam.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedSpam;
    decodedSpam.decode(encoded);
    if (verbose) {
        qDebug() << "decodedSpam=" << decodedSpam.data;
        qDebug() << "decodedSpam==spam" << (decodedSpam==spam) << " { expected true } ";
    }
    testsTaken++;
    bool result9 = (decodedSpam.data == 4294967295/2);
    bool expected9 = true;
    if (result9 == expected9) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 9: (decodedSpam.data == 4294967295/2)";
    }

    testsTaken++;
    bool result10 = (decodedSpam == spam);
    bool expected10 = true;
    if (result10 == expected10) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 10: (decodedSpam == spam)";
    }

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 foo64(259)";
    }
    ByteCountCodedQUINT64 foo64(259);
    encoded = foo64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }
    
    if (verbose) {
        qDebug() << "testing... quint64 foo64POD = foo64;";
    }
    quint64 foo64POD = foo64;
    if (verbose) {
        qDebug() << "foo64POD=" << foo64POD;
    }

    testsTaken++;
    bool result11 = (foo64POD == 259);
    bool expected11 = true;
    if (result11 == expected11) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 11: quint64 foo64POD = foo64";
    }

    if (verbose) {
        qDebug() << "testing... encoded = foo64;";
    }
    encoded = foo64;

    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedFoo64;
    decodedFoo64 = encoded;

    if (verbose) {
        qDebug() << "decodedFoo64=" << decodedFoo64.data;
        qDebug() << "decodedFoo64==foo64" << (decodedFoo64==foo64) << " { expected true } ";
    }
    testsTaken++;
    bool result12 = (decodedFoo64.data == 259);
    bool expected12 = true;
    if (result12 == expected12) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 12: decodedFoo64.data == 259";
    }

    testsTaken++;
    bool result13 = (decodedFoo64==foo64);
    bool expected13 = true;
    if (result13 == expected13) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 13: decodedFoo64==foo64";
    }

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 bar64(1000000)";
    }
    ByteCountCodedQUINT64 bar64(1000000);
    encoded = bar64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedBar64;
    decodedBar64.decode(encoded);
    if (verbose) {
        qDebug() << "decodedBar64=" << decodedBar64.data;
        qDebug() << "decodedBar64==bar64" << (decodedBar64==bar64) << " { expected true } ";
    }
    testsTaken++;
    bool result14 = (decodedBar64.data == 1000000);
    bool expected14 = true;
    if (result14 == expected14) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 14: decodedBar64.data == 1000000";
    }

    testsTaken++;
    bool result15 = (decodedBar64==bar64);
    bool expected15 = true;
    if (result15 == expected15) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 15: decodedBar64==bar64";
    }

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 spam64(4294967295/2)";
    }
    ByteCountCodedQUINT64 spam64(4294967295/2);
    encoded = spam64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedSpam64;
    decodedSpam64.decode(encoded);
    if (verbose) {
        qDebug() << "decodedSpam64=" << decodedSpam64.data;
        qDebug() << "decodedSpam64==spam64" << (decodedSpam64==spam64) << " { expected true } ";
    }
    testsTaken++;
    bool result16 = (decodedSpam64.data == 4294967295/2);
    bool expected16 = true;
    if (result16 == expected16) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 16: decodedSpam64.data == 4294967295/2";
    }

    testsTaken++;
    bool result17 = (decodedSpam64==spam64);
    bool expected17 = true;
    if (result17 == expected17) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 17: decodedSpam64==spam64";
    }

    if (verbose) {
        qDebug() << "testing encoded << spam64";
    }
    encoded.clear();
    encoded << spam64;
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    if (verbose) {
        qDebug() << "testing encoded >> decodedSpam64";
    }
    encoded >> decodedSpam64;

    if (verbose) {
        qDebug() << "decodedSpam64=" << decodedSpam64.data;
    }
    testsTaken++;
    bool result18 = (decodedSpam64==spam64);
    bool expected18 = true;
    if (result18 == expected18) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 18: decodedSpam64==spam64";
    }

    //ByteCountCodedINT shouldFail(-100);
    
    if (verbose) {
        qDebug() << "NOW...";
    }
    quint64 now = usecTimestampNow();
    ByteCountCodedQUINT64 nowCoded = now;
    QByteArray nowEncoded = nowCoded;

    if (verbose) {
        outputBufferBits((const unsigned char*)nowEncoded.constData(), nowEncoded.size());
    }
    ByteCountCodedQUINT64 decodedNow = nowEncoded;

    testsTaken++;
    bool result19 = (decodedNow.data==now);
    bool expected19 = true;
    if (result19 == expected19) {
        testsPassed++;
    } else {
        testsFailed++;
        qDebug() << "FAILED - Test 19: now test...";
    }
    
    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
    qDebug() << "   tests passed:" << testsPassed << "out of" << testsTaken;
    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
}
Example #4
0
void OctreeTests::byteCountCodingTests() {
    bool verbose = true;
    
    qDebug() << "FIXME: this test is broken and needs to be fixed.";
    qDebug() << "We're disabling this so that ALL_BUILD works";
    return;

    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
    
    qDebug() << "OctreeTests::byteCountCodingTests()";
    
    QByteArray encoded;
    
    if (verbose) {
        qDebug() << "ByteCountCodedUINT zero(0)";
    }
    ByteCountCodedUINT zero(0);
    encoded = zero.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedZero;
    decodedZero.decode(encoded);
    
    QCOMPARE(decodedZero.data, static_cast<decltype(decodedZero.data)>( 0 ));
    QCOMPARE(decodedZero, zero);

    ByteCountCodedUINT decodedZeroB(encoded);
    
    QCOMPARE(decodedZeroB.data, (unsigned int) 0);

    if (verbose) {
        qDebug() << "ByteCountCodedUINT foo(259)";
    }
    ByteCountCodedUINT foo(259);
    encoded = foo.encode();

    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedFoo;
    decodedFoo.decode(encoded);

    QCOMPARE(decodedFoo.data, (unsigned int) 259);

    QCOMPARE(decodedFoo, foo);

    ByteCountCodedUINT decodedFooB(encoded);
    QCOMPARE(decodedFooB.data, (unsigned int) 259);

    if (verbose) {
        qDebug() << "ByteCountCodedUINT bar(1000000)";
    }
    ByteCountCodedUINT bar(1000000);
    encoded = bar.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedBar;
    decodedBar.decode(encoded);
    QCOMPARE(decodedBar.data, (unsigned int) 1000000);

    QCOMPARE(decodedBar, bar);

    if (verbose) {
        qDebug() << "ByteCountCodedUINT spam(4294967295/2)";
    }
    ByteCountCodedUINT spam(4294967295/2);
    encoded = spam.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedUINT decodedSpam;
    decodedSpam.decode(encoded);
    if (verbose) {
        qDebug() << "decodedSpam=" << decodedSpam.data;
        qDebug() << "decodedSpam==spam" << (decodedSpam==spam) << " { expected true } ";
    }
    QCOMPARE(decodedSpam.data, (unsigned int) 4294967295/2);

    QCOMPARE(decodedSpam, spam);

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 foo64(259)";
    }
    ByteCountCodedQUINT64 foo64(259);
    encoded = foo64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }
    
    if (verbose) {
        qDebug() << "testing... quint64 foo64POD = foo64;";
    }
    quint64 foo64POD = foo64;
    if (verbose) {
        qDebug() << "foo64POD=" << foo64POD;
    }

    QCOMPARE(foo64POD, (quint64) 259);
    if (verbose) {
        qDebug() << "testing... encoded = foo64;";
    }
    encoded = foo64;

    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedFoo64;
    decodedFoo64 = encoded;

    if (verbose) {
        qDebug() << "decodedFoo64=" << decodedFoo64.data;
        qDebug() << "decodedFoo64==foo64" << (decodedFoo64==foo64) << " { expected true } ";
    }
    QCOMPARE(decodedFoo.data, (unsigned int) 259);
    
    QCOMPARE(decodedFoo64, foo64);

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 bar64(1000000)";
    }
    ByteCountCodedQUINT64 bar64(1000000);
    encoded = bar64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedBar64;
    decodedBar64.decode(encoded);
    QCOMPARE(decodedBar64.data, static_cast<decltype(decodedBar.data)>( 1000000 ));

    QCOMPARE(decodedBar64, bar64);

    if (verbose) {
        qDebug() << "ByteCountCodedQUINT64 spam64(4294967295/2)";
    }
    ByteCountCodedQUINT64 spam64(4294967295/2);
    encoded = spam64.encode();
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    ByteCountCodedQUINT64 decodedSpam64;
    decodedSpam64.decode(encoded);
    QCOMPARE(decodedSpam64.data, static_cast<decltype(decodedSpam64.data)>( 4294967295/2 ));

    QCOMPARE(decodedSpam64, spam64);
    if (verbose) {
        qDebug() << "testing encoded << spam64";
    }
    encoded.clear();
    encoded << spam64;
    if (verbose) {
        outputBufferBits((const unsigned char*)encoded.constData(), encoded.size());
    }

    if (verbose) {
        qDebug() << "testing encoded >> decodedSpam64";
    }
    encoded >> decodedSpam64;

    QCOMPARE(decodedSpam64, spam64);
    
    if (verbose) {
        qDebug() << "NOW...";
    }
    quint64 now = usecTimestampNow();
    ByteCountCodedQUINT64 nowCoded = now;
    QByteArray nowEncoded = nowCoded;

    ByteCountCodedQUINT64 decodedNow = nowEncoded;
    QCOMPARE(decodedNow.data, static_cast<decltype(decodedNow.data)>( now ));
    
    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
    if (verbose) {
        qDebug() << "******************************************************************************************";
    }
}
Example #5
0
int
bar()
{
        return (foo64());
}