void operator () () const { try { V v1 (N), v2 (N), v3 (N); (*this) (v1, v2, v3); #ifdef USE_RANGE ublas::vector_range<V> vr1 (v1, ublas::range (0, N)), vr2 (v2, ublas::range (0, N)), vr3 (v3, ublas::range (0, N)); (*this) (vr1, vr2, vr3); #endif #ifdef USE_SLICE ublas::vector_slice<V> vs1 (v1, ublas::slice (0, 1, N)), vs2 (v2, ublas::slice (0, 1, N)), vs3 (v3, ublas::slice (0, 1, N)); (*this) (vs1, vs2, vs3); #endif } catch (std::exception &e) { std::cout << e.what () << std::endl; } catch (...) { std::cout << "unknown exception" << std::endl; } }
void operator () () const { V v1 (N), v2 (N), v3 (N); test_expression_with (v1, v2, v3); test_container_with (v1); #ifdef USE_RANGE ublas::vector_range<V> vr1 (v1, ublas::range (0, N)), vr2 (v2, ublas::range (0, N)), vr3 (v3, ublas::range (0, N)); test_expression_with (vr1, vr2, vr3); #endif #ifdef USE_SLICE ublas::vector_slice<V> vs1 (v1, ublas::slice (0, 1, N)), vs2 (v2, ublas::slice (0, 1, N)), vs3 (v3, ublas::slice (0, 1, N)); test_expression_with (vs1, vs2, vs3); #endif }
void operator () (int runs, fast_tag) const { try { static V v1 (N), v2 (N), v3 (N); ublas::vector_range<V> vr1 (v1, ublas::range (0, N)), vr2 (v2, ublas::range (0, N)), vr3 (v2, ublas::range (0, N)); initialize_vector (vr1); initialize_vector (vr2); boost::timer t; for (int i = 0; i < runs; ++ i) { vr3.assign (- (vr1 + vr2)); // sink_vector (vr3); } footer<value_type> () (0, 2 * N, runs, t.elapsed ()); } catch (std::exception &e) { std::cout << e.what () << std::endl; } }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
int main() { poc(); try { TestSection("SVector"); TestSubsection("Matrix"); { SMatrix<5> matrix; matrix[1][2][1][0][1] = 123; matrix[2][1][0][1][4] = 777; TEST("matrix_1", matrix[1][2][1][0][1].GetInt(), 123); TEST("matrix_2", matrix[2][1][0][1][4].GetInt(), 777); } TestSubsection("Matrix_has_you"); { SVector m; SVector m0; SVector m1; SVector m00; SVector m01; SVector m10; SVector m11; m10[1] = SReference(25); m0[0] = m00; m0[1] = m01; m1[0] = m10; m1[1] = m11; m[0] = m0; m[1] = m1; SMatrixRef<3> matr(m); TEST("matrix_has_you", matr[1][0][1].GetInt(), 25); } TestSubsection("resize"); { SVector v; v[7] = 5; TEST("resize_1", v->Size(), 8); v[12] = 5; TEST("resize_2", v->Size(), 13); v[13] = 5; TEST("resize_3", v->Size(), 14); } #if INTELIB_DEBUG_COUNTERS == 1 TestSubsection("leaks"); { int before = SExpression::object_counter; { SVector v; v[7] = 5; SVectorRef vr(v); SVectorRef vr2; vr2 = vr; SVectorRef vr3(vr2); for(int i=0; i<200; i++) vr3[vr3->Size()] = SReference(i); } TEST("no_leaks", SExpression::object_counter, before); } #endif TestSubsection("TextRepresentation"); { SVector v; for(int i=0; i<5; i++) v[i]=i; TEST("text_rep", v->TextRepresentation().c_str(), "#~(0 1 2 3 4)"); } TestSubsection("Range Copying"); { SVector v; for(int i=0; i<15; i++) v[i]=i; SVectorRange r(v,5,3); TEST("range_copy", r.Copy()->TextRepresentation().c_str(), "#~(5 6 7)"); TESTB("copy_keeps_positive_resizeability", r.Copy()->IsResizeable()); SVector vn(5); for(int i=0; i<5; i++) vn[i]=i*100; SVectorRange rn(vn,1,2); TESTB("copy_keeps_negative_resizeability", !rn.Copy()->IsResizeable()); TESTB("copy_positive_resizeability", rn.Copy(true)->IsResizeable()); TESTB("copy_negative_resizeability", !rn.Copy(false)->IsResizeable()); SVectorRange r200(v,5,200); TEST("range_size_limited", r200.Copy()->Size(), 10); } TestSubsection("Range Erasing"); { SVector v; for(int i=0; i<15; i++) v[i]=i; SVectorRange r(v,3,10); r.Erase(); TEST("range_erase", v->TextRepresentation().c_str(), "#~(0 1 2 13 14)"); TEST("range_erase_size", v->Size(), 5); TEST("range_erase_range_len", r.Copy()->Size(), 0); } TestSubsection("Range Replacing"); { SVector v, w; for(int i=0; i<15; i++) v[i]=i; for(int i=0; i<5; i++) w[i]=i*100; SVectorRange r(v,3,10); r.Replace(w); TEST("range_replace_less", v->TextRepresentation().c_str(), "#~(0 1 2 0 100 200 300 400 13 14)"); TEST("range_replace_less_size", v->Size(), 10); TEST("range_replace_less_range_len", r.Copy()->Size(), 5); } { SVector v, w; for(int i=0; i<10; i++) v[i]=i; for(int i=0; i<5; i++) w[i]=i*100; SVectorRange r(w,1,2); r.Replace(v); TEST("range_replace_more", w->TextRepresentation().c_str(), "#~(0 0 1 2 3 4 5 6 7 8 9 300 400)"); TEST("range_replace_more_size", w->Size(), 13); TEST("range_replace_more_range_len", r.Copy()->Size(), 10); } TestScore(); } catch(const IntelibX &ex) { printf("Caught IntelibX: %s\n%s\n", ex.Description(), ex.Parameter().GetPtr() ? ex.Parameter()->TextRepresentation().c_str() : ""); } catch(...) { printf("Something strange caught\n"); } poc(); return 0; }