bool ArrayData::equal(const ArrayData *v2, bool strict) const { ASSERT(v2); int count1 = size(); int count2 = v2->size(); if (count1 != count2) return false; if (count1 == 0) return true; // prevent circular referenced objects/arrays or deep ones DECLARE_THREAD_INFO; RECURSION_INJECTION; if (strict) { for (ArrayIter iter1(this), iter2(v2); iter1 && iter2; ++iter1, ++iter2) { Variant key1(iter1.first()); Variant key2(iter2.first()); if (!key1.same(key2)) return false; Variant value1(iter1.second()); Variant value2(iter2.second()); if (!value1.same(value2)) return false; } } else { for (ArrayIter iter(this); iter; ++iter) { Variant key(iter.first()); if (!v2->exists(key)) return false; Variant value1(iter.second()); Variant value2(v2->get(key)); if (!value1.equal(value2)) return false; } } return true; }
int ArrayData::compare(const ArrayData *v2, bool strict) const { ASSERT(v2); int count1 = size(); int count2 = v2->size(); if (count1 < count2) return -1; if (count1 > count2) return 1; if (count1 == 0) return 0; if (strict) { for (ArrayIter iter1(this), iter2(v2); iter1 && iter2; ++iter1, ++iter2) { Variant key1(iter1.first()); Variant key2(iter2.first()); if (!key1.same(key2)) return 1; // or -1 Variant value1(iter1.second()); Variant value2(iter2.second()); if (!value1.same(value2)) return 1; // or -1 } } else { for (ArrayIter iter(this); iter; ++iter) { Variant key(iter.first()); if (!v2->exists(key)) return 1; Variant value1(iter.second()); Variant value2(v2->get(key)); if (value1.more(value2)) return 1; if (value1.less(value2)) return -1; } } return 0; }
void tst_QVersitProperty::testParameters() { QString typeParameterName(QLatin1String("TYPE")); QString name(QLatin1String("type")); QString value1(QLatin1String("home")); mVersitProperty->insertParameter(name,value1); QMultiHash<QString,QString> parameters = mVersitProperty->parameters(); QCOMPARE(parameters.count(), 1); QVERIFY(parameters.contains(typeParameterName,QLatin1String("home"))); QString value2(QLatin1String("voice")); mVersitProperty->insertParameter(name,value2); parameters = mVersitProperty->parameters(); QCOMPARE(parameters.count(), 2); QVERIFY(parameters.contains(typeParameterName,QLatin1String("home"))); QVERIFY(parameters.contains(typeParameterName,QLatin1String("voice"))); mVersitProperty->removeParameter(name,value1); QCOMPARE(mVersitProperty->parameters().count(), 1); QVERIFY(parameters.contains(typeParameterName,QLatin1String("home"))); mVersitProperty->removeParameter(name,value2); QCOMPARE(mVersitProperty->parameters().count(), 0); mVersitProperty->insertParameter(name, value1); mVersitProperty->insertParameter(name, value2); QCOMPARE(mVersitProperty->parameters().count(), 2); mVersitProperty->removeParameters(name); QCOMPARE(mVersitProperty->parameters().count(), 0); }
bool DbIndexKey::operator < (const DbIndexKey &other) const { // compare the values of the attributes in the keys uint32 numAttributes = (uint32) mIndex.mAttributes.size(); uint32 valueOffset1 = 0, valueOffset2 = 0; for (uint32 i = 0; i < numAttributes; i++) { const MetaAttribute &metaAttribute = *mIndex.mAttributes[i]; auto_ptr<DbValue> value1(metaAttribute.createValue(mKeySection.subsection(mKeyRange), valueOffset1)); auto_ptr<DbValue> value2(metaAttribute.createValue(other.mKeySection.subsection(other.mKeyRange), valueOffset2)); if (metaAttribute.evaluate(value1.get(), value2.get(), CSSM_DB_LESS_THAN)) return true; else if (metaAttribute.evaluate(value2.get(), value1.get(), CSSM_DB_LESS_THAN)) return false; } // if we are here, the keys are equal return false; }
void PhosimParser::readSegmentation(std::istream& in_stream) { // Read segmentation.txt std::string line; while (std::getline(in_stream, line, '\n')) { std::vector<std::string> tokens; bool goodLine = stringTokenize(line,tokens); if(!goodLine){ continue; } std::string chipID(tokens[0]); std::string value(tokens[1]); for (size_t i(2); i < tokens.size(); i++) { value += " " + tokens[i]; } std::vector<PhosimPar> values; values.push_back(PhosimPar(value)); m_data.insert(std::make_pair(chipID, values)); int numAmplifiers = std::atoi(tokens[1].c_str()); for (int j(0); j < numAmplifiers; j++) { std::string line2; std::getline(in_stream, line2, '\n'); std::vector<std::string> tokens2; bool goodLine = stringTokenize(line2,tokens2); if(!goodLine){ j--; continue; } std::string value2(tokens2[0]); for (size_t i(1); i < tokens2.size(); i++) { value2 += " " + tokens2[i]; } m_data[chipID].push_back(PhosimPar(value2)); } } }
TEST_F(CTestInterfaceBase, GetTestCase_07_dateNotExpire) { data_entry key1("04_07_key_01"); data_entry value1("04_07_data_01"); data_entry key2("04_07_key_02"); data_entry value2("04_07_data_02"); data_entry value3("04_07_data_03"); data_entry* p; int ret = 0; //data1:area equals,key not equal DO_WITH_RETRY(client_handle.put(1, key1, value1, 0, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); //data2:area not equas, key equal DO_WITH_RETRY(client_handle.put(2, key2, value2, 0, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); DO_WITH_RETRY(client_handle.put(1, key2, value3, 3, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); ret = client_handle.get(1, key2, p); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); ASSERT_EQ(true, compareDataValue(value3, *p)); delete p; p = NULL; client_handle.remove(1, key1); client_handle.remove(2, key2); client_handle.remove(1, key2); }
uint32_t hash_sub(const char **s, int len) { const char *p; uint32_t v; uint8_t value; int i; p = *s; v = 0; i = 4; do { value = 0; if (*p != '/') { if (!--len) return 0; if (!((*p >= 'a' && *p <= 'z') || (*p >= '0' && *p <= '9'))) return 0; value = value2(*p++) + 1; } else if (i == 3) { /* dont allow 1 letter sub names */ return 0; } if (i) { v *= 38; v += value; i--; } } while (i || *p != '/'); *s = p + 1; return v; }
void compareValue(const T1& param1, const T2& param2, const RDOType::TypeID& type1, const RDOType::TypeID& type2) { T1 val1 = param1; T2 val2 = param2; RDOValue value1(val1); RDOValue value2(val2); compare(value1, value2); value1 = value2; BOOST_CHECK(value1 == value2); value1 = val1; value2 = val2; value1 += value2; BOOST_CHECK(value1 == T1(param1 + param2)); BOOST_CHECK(value1.typeID() == type1); value1 -= value2; BOOST_CHECK(value1 == param1); value1 *= value2; BOOST_CHECK(value1 == param1 * param2); value1 /= value2; BOOST_CHECK(value1 == param1); BOOST_CHECK(value1.typeID() == type2); }
TEST_F(CTestInterfaceBase, GetTestCase_08_dateExpired) { data_entry key1("04_08_key_01"); data_entry value1("04_08_data_01"); data_entry key2("04_08_key_02"); data_entry value2("04_08_data_02"); data_entry value3("04_08_data_03"); data_entry* p; int ret = 0; //data1:area equals,key not equal DO_WITH_RETRY(client_handle.put(1, key1, value1, 0, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); //data2:area not equas, key equal DO_WITH_RETRY(client_handle.put(2, key2, value2, 0, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); DO_WITH_RETRY(client_handle.put(1, key2, value3, 1, 0), ret, TAIR_RETURN_SUCCESS); ASSERT_EQ(TAIR_RETURN_SUCCESS, ret); sleep(2); ret = client_handle.get(1, key2, p); ASSERT_EQ(TAIR_RETURN_DATA_EXPIRED, ret); client_handle.remove(1, key1); client_handle.remove(2, key2); client_handle.remove(1, key2); }
int ArrayData::compare(const ArrayData *v2) const { ASSERT(v2); int count1 = size(); int count2 = v2->size(); if (count1 < count2) return -1; if (count1 > count2) return 1; if (count1 == 0) return 0; // prevent circular referenced objects/arrays or deep ones DECLARE_THREAD_INFO; RECURSION_INJECTION; for (ArrayIter iter(this); iter; ++iter) { Variant key(iter.first()); if (!v2->exists(key)) return 1; Variant value1(iter.second()); Variant value2(v2->get(key)); if (value1.more(value2)) return 1; if (value1.less(value2)) return -1; } return 0; }
TEST(Protocol, McResultSerialize) { { McResult codeResult(R_DELETED); std::string result; StringWBuffer buffer(3, &result); codeResult.Serialize(&buffer); buffer.Flush(); ASSERT_EQ(result, "DELETED\r\n"); } { McResult errResult("Length of key is too long"); std::string result; StringWBuffer buffer(3, &result); errResult.Serialize(&buffer); buffer.Flush(); ASSERT_EQ(result, "ERROR Length of key is too long\r\n"); } { McValue value1("user_123", 1445128601, std::vector<char>({'1', '2', '3', '4', '5', 'a'})); McValue value2("user_876", 1446128601, std::vector<char>({'6', '7', '8', '9', '0', 'z'})); McResult valResult(std::vector<McValue>({value1, value2})); std::string result; StringWBuffer buffer(3, &result); valResult.Serialize(&buffer); buffer.Flush(); ASSERT_EQ(result, "user_123 1445128601 6\r\n12345a\r\nuser_876 1446128601 6\r\n67890z\r\nEND\r\n"); } }
void CStatTreeItemTotalClients::AddECValues(CECTag *tag) const { CECTag value1(EC_TAG_STAT_NODE_VALUE, (uint64)(m_known->GetValue() + m_unknown->GetValue())); tag->AddTag(value1); CECTag value2(EC_TAG_STAT_NODE_VALUE, (uint64)m_known->GetValue()); tag->AddTag(value2); }
void compareStr(const T1& param1, const T2& param2) { T1 val1 = param1; T2 str1 = param2; RDOValue value1(val1); RDOValue value2(str1); testing(value1, value2); }
TEST (uint256_union, big_endian_union_constructor) { boost::multiprecision::uint256_t value1 (1); rai::uint256_union bytes1 (value1); ASSERT_EQ (1, bytes1.bytes [31]); boost::multiprecision::uint512_t value2 (1); rai::uint512_union bytes2 (value2); ASSERT_EQ (1, bytes2.bytes [63]); }
TEST(TestUint128_t, test_init){ ASSERT_EQ(16, sizeof(yunomi::types::uint128_t)); yunomi::types::uint128_t value(0); EXPECT_EQ(0, (uint64_t)value); yunomi::types::uint128_t value2(0, 0); EXPECT_EQ(0, (uint64_t)value2); }
bool test_multiplyAssignSameType() { bool status = false; INT value1(TEST_VALUE_1); INT value2(TEST_VALUE_2); value1 *= value2; status = (value1==TEST_VALUE_1*TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); return status; }
bool test_subtractAssignSameType() { bool status = false; INT value1(TEST_VALUE_1); INT value2(TEST_VALUE_2); value1 -= value2; status = (value1==TEST_VALUE_1-TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); return status; }
bool test_addAssignSameType() { bool status = false; INT value1(TEST_VALUE_1); INT value2(TEST_VALUE_2); value1 += value2; status = (value1==TEST_VALUE_1+TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); return status; }
int main() { Complex value1(5, 2); Complex value2(3, -3); cout << "First num:" << value1 << "\n" << "Second num:" << value2 << endl; cout << "Plus: " << value1 + value2 << endl; cout << "Minus: " << value1 - value2 << endl; cout << "Multiplication: " << value1 * value2 << endl; value1 = value2; cout << "Assimilation: " << value1 << " = " << value2 << endl; cout << "\n\n"; Matrixx matr1(2, 3); for (int i = 0; i < 6; i++) { Complex temp(rand() % 20, rand() % 10); matr1.data[i] = temp; } Matrixx matr2(3, 4); for (int i = 0; i < 12; i++) { Complex temp(rand() % 20, rand() % 10); matr2.data[i] = temp; } Matrixx matr3(2, 3); for (int i = 0; i < 6; i++) { Complex temp(rand() % 20, rand() % 10); matr3.data[i] = temp; } cout << "matr1: \n" << matr1 << "matr2: \n" << matr2 << "matr3: \n" << matr3 << endl; cout << "matr1+matr3: \n" << (matr1+matr3) << endl; cout << "matr1*matr2: \n" << matr1*matr2 << endl; //cout << ~matr1 << endl; cout << "matr1: \n" << matr1 << "matr2: \n" << matr2 << "matr3: \n" << matr3 << endl; cout << "matr1(1,1) = " << Matrindex(matr1, 1, 1) << endl; //Запись в файл при использовании потоков ofstream out("text.txt", ios::app); if (!out) { cout << "Create a file first \n"; system("pause"); return 0; } out << matr1 << endl; out.close(); system("pause"); return 0; }
char * Environment::getExternalStorageDirectory(char *buffer, size_t max_size) { JNIEnv *env = Java::GetEnv(); jstring value = ::getExternalStorageDirectory(env); if (value == NULL) return NULL; Java::String value2(env, value); value2.CopyTo(env, buffer, max_size); return buffer; }
// ----------------------------------------------------------------------------- // CTestPlatAlfVisual::TestTimedValueConstructor // ----------------------------------------------------------------------------- // TInt CTestPlatAlfVisual::TestTimedValueConstructor( CStifItemParser& /*aItem*/ ) { // Print to UI _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" ); _LIT( KTestTimedValueConstructor, "TestTimedValueConstructor" ); TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestTimedValueConstructor ); // Print to log file iLog->Log( KTestTimedValueConstructor ); TAlfTimedValue value1; TAlfTimedValue value2( 1.0 ); TAlfTimedValue value3( 1.0, 1 ); return KErrNone; }
void AcsAlarmTestCase::testProps() { acsalarm::Properties properties; // test getProperty and setProperty methods std::string key("key"); std::string value("value"); properties.setProperty(key, value); CPPUNIT_ASSERT_MESSAGE("Properties::getProperty/setProperty appears to be broken", (value == properties.getProperty(key)) ); // test propertyNames method std::string key2("key2"); std::string value2("value2"); properties.setProperty(key2, value2); properties.setProperty(key2, value2); std::auto_ptr< std::vector<std::string> > keys = properties.propertyNames(); CPPUNIT_ASSERT_MESSAGE("Properties::propertyNames appears to be broken", (keys->size() == 2) ); for(unsigned int i = 0; i < keys->size(); i++) { CPPUNIT_ASSERT_MESSAGE("Properties::propertyNames appears to be broken", (keys->at(i) == key || keys->at(i) == key2) ); } // test copy constructor acsalarm::Properties properties2(properties); CPPUNIT_ASSERT_MESSAGE("Properties::Properties(&properties) - copy constructor appears to be broken", (value == properties2.getProperty(key)) ); std::auto_ptr< std::vector<std::string> > keys2 = properties2.propertyNames(); CPPUNIT_ASSERT_MESSAGE("Properties::Properties(&properties) - copy constructor appears to be broken", (keys2->size() == 2) ); for(unsigned int i = 0; i < keys2->size(); i++) { CPPUNIT_ASSERT_MESSAGE("Properties::(&properties) - copy constructor appears to be broken", (keys2->at(i) == key || keys2->at(i) == key2) ); } // test == operator CPPUNIT_ASSERT_MESSAGE("Properties:: == operator appears to be broken", (properties == properties2) ); // test = operator acsalarm::Properties properties3 = properties2; CPPUNIT_ASSERT_MESSAGE("Properties:: = operator appears to be broken", (value == properties3.getProperty(key)) ); std::auto_ptr< std::vector<std::string> > keys3 = properties3.propertyNames(); CPPUNIT_ASSERT_MESSAGE("Properties:: = operator appears to be broken", (keys3->size() == 2) ); for(unsigned int i = 0; i < keys3->size(); i++) { CPPUNIT_ASSERT_MESSAGE("Properties:: = operator appears to be broken", (keys3->at(i) == key || keys3->at(i) == key2) ); } }
TEST(CollectionUtilsTest, mapInsertOrReplaceCopy) { typedef std::map<std::string, std::string> TestMap; TestMap testMap; const std::string key("Key"); std::string value1("Value"); std::string value2("Value2"); MapUtils::insertOrReplace(testMap, key, value1); ASSERT_EQ(1u, testMap.size()); ASSERT_EQ(value1, testMap[key]); MapUtils::insertOrReplace(testMap, key, value2); ASSERT_EQ(1u, testMap.size()); ASSERT_EQ(value2, testMap[key]); }
void StructFieldValueTest::testEmptyStruct() { FixedTypeRepo repo(doc_repo, *doc_repo.getDocumentType(42)); const DataType &type = *repo.getDataType("test.header"); StructFieldValue value(type); // Serialize & equality std::unique_ptr<ByteBuffer> buffer(value.serialize()); buffer->flip(); CPPUNIT_ASSERT_EQUAL(buffer->getLength(), buffer->getLimit()); StructFieldValue value2(type); deserialize(*buffer, value2, repo); CPPUNIT_ASSERT(value == value2); }
void compareOne(const T1& param1, const T1& param2) { const T1 val1 = param1; const T1 val2 = param2; RDOValue value1(val1); RDOValue value2(val2); BOOST_CHECK(value1 != value2); BOOST_CHECK(value1 > value2); BOOST_CHECK(value2 < value1); BOOST_CHECK(value1 >= value2); BOOST_CHECK(value2 <= value1); value2 = val1; BOOST_CHECK(value1 >= value2); BOOST_CHECK(value2 <= value1); }
int main(int argc,char** argv) { GLDebugDrawer gDebugDrawer; ///testing the btHashMap btHashMap<btHashKey<OurValue>,OurValue> map; OurValue value1(btVector3(2,3,4)); btHashKey<OurValue> key1(value1.getUid()); map.insert(key1,value1); OurValue value2(btVector3(5,6,7)); btHashKey<OurValue> key2(value2.getUid()); map.insert(key2,value2); { OurValue value3(btVector3(7,8,9)); btHashKey<OurValue> key3(value3.getUid()); map.insert(key3,value3); } map.remove(key2); const OurValue* ourPtr = map.find(key1); for (int i=0;i<map.size();i++) { OurValue* tmp = map.getAtIndex(i); //printf("tmp value=%f,%f,%f\n",tmp->m_position.getX(),tmp->m_position.getY(),tmp->m_position.getZ()); } BasicDemo ccdDemo; ccdDemo.initPhysics(); ccdDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer); #ifdef CHECK_MEMORY_LEAKS ccdDemo.exitPhysics(); #else return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&ccdDemo); #endif //default glut doesn't return from mainloop return 0; }
bool test_subtractAssignCompatibleType() { bool status = false; INT value1(TEST_VALUE_1); DOUBLE value2(TEST_VALUE_2); value1 -= value2; bool status1 = (value1==TEST_VALUE_1-TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); value1 = TEST_VALUE_1; value2 = TEST_VALUE_2; value2 -= value1; bool status2 = (value2==TEST_VALUE_2-TEST_VALUE_1 && value1==TEST_VALUE_1 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); status = status1 && status2; return status; }
bool test_multiplyAssignCompatibleType() { bool status = false; INT value1(TEST_VALUE_1); DOUBLE value2(TEST_VALUE_2); value1 *= value2; bool status1 = (value1==TEST_VALUE_1*TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); value1 = TEST_VALUE_1; value2 = TEST_VALUE_2; value2 *= value1; bool status2 = (value2==TEST_VALUE_1*TEST_VALUE_2 && value1==TEST_VALUE_1 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); status = status1 && status2; return status; }
bool test_divideAssignCompatibleType() { bool status = false; INT value1(TEST_VALUE_1); DOUBLE value2(TEST_VALUE_2); value1 /= value2; bool status1 = (value1==TEST_VALUE_1/TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); value1 = TEST_VALUE_1; value2 = TEST_VALUE_2; value2 /= value1; bool status2 = (value2==double(TEST_VALUE_2)/double(TEST_VALUE_1) && value1==TEST_VALUE_1 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); status = status1 && status2; return status; }
bool test_moduloAssignCompatibleType() { bool status = false; INT value1(TEST_VALUE_1); LONG_INT value2(TEST_VALUE_2); value1 %= value2; bool status1 = (value1==TEST_VALUE_1%TEST_VALUE_2 && value2==TEST_VALUE_2 && TEST_VALUE_1!=TEST_VALUE_2 && value1!=value2); value1 = TEST_VALUE_1; value2 = TEST_VALUE_3; value2 %= value1; bool status2 = (value2==TEST_VALUE_3%TEST_VALUE_1 && value1==TEST_VALUE_1 && TEST_VALUE_1!=TEST_VALUE_3 && value1!=value2); status = status1 && status2; return status; }