Rename assert by assertTrue

This commit is contained in:
Francis ANDRE 2018-03-29 12:25:29 +02:00
parent 5a1bf5eb4a
commit dd8c25d7ae
230 changed files with 16289 additions and 16280 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@
# Gradle #
##########
.gradle/
**/guild/
**/gradle/
**/options.txt
**/output.txt

View File

@ -36,7 +36,7 @@ void AttributesParserTest::testParser1()
std::istringstream istr("");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.begin() == attrs.end());
assertTrue (attrs.begin() == attrs.end());
}
@ -46,7 +46,7 @@ void AttributesParserTest::testParser2()
std::istringstream istr("name=value");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name") == "value");
assertTrue (attrs.getString("name") == "value");
}
@ -56,8 +56,8 @@ void AttributesParserTest::testParser3()
std::istringstream istr("name=value, name2=100");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name") == "value");
assert (attrs.getInt("name2") == 100);
assertTrue (attrs.getString("name") == "value");
assertTrue (attrs.getInt("name2") == 100);
}
@ -67,9 +67,9 @@ void AttributesParserTest::testParser4()
std::istringstream istr("name=value, name2=100, name3");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name") == "value");
assert (attrs.getInt("name2") == 100);
assert (attrs.getBool("name3"));
assertTrue (attrs.getString("name") == "value");
assertTrue (attrs.getInt("name2") == 100);
assertTrue (attrs.getBool("name3"));
}
@ -79,9 +79,9 @@ void AttributesParserTest::testParser5()
std::istringstream istr("name.a=value, name.b=100, name.c");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name.a") == "value");
assert (attrs.getInt("name.b") == 100);
assert (attrs.getBool("name.c"));
assertTrue (attrs.getString("name.a") == "value");
assertTrue (attrs.getInt("name.b") == 100);
assertTrue (attrs.getBool("name.c"));
}
@ -91,9 +91,9 @@ void AttributesParserTest::testParser6()
std::istringstream istr("name = {a=value, b=100, c}");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name.a") == "value");
assert (attrs.getInt("name.b") == 100);
assert (attrs.getBool("name.c"));
assertTrue (attrs.getString("name.a") == "value");
assertTrue (attrs.getInt("name.b") == 100);
assertTrue (attrs.getBool("name.c"));
}
@ -103,10 +103,10 @@ void AttributesParserTest::testParser7()
std::istringstream istr("name = {a=value, b=100, c}, name2=\"foo\"");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name.a") == "value");
assert (attrs.getInt("name.b") == 100);
assert (attrs.getBool("name.c"));
assert (attrs.getString("name2") == "foo");
assertTrue (attrs.getString("name.a") == "value");
assertTrue (attrs.getInt("name.b") == 100);
assertTrue (attrs.getBool("name.c"));
assertTrue (attrs.getString("name2") == "foo");
}

View File

@ -69,47 +69,47 @@ void CppParserTest::testExtractName()
{
std::string decl("int _var");
std::string name = Symbol::extractName(decl);
assert (name == "_var");
assertTrue (name == "_var");
decl = "void func(int arg1, int arg2)";
name = Symbol::extractName(decl);
assert (name == "func");
assertTrue (name == "func");
decl = "const std::vector<NS::MyType>* var";
name = Symbol::extractName(decl);
assert (name == "var");
assertTrue (name == "var");
decl = "const std::vector<NS::MyType>* func(int arg) = 0";
name = Symbol::extractName(decl);
assert (name == "func");
assertTrue (name == "func");
decl = "int (*func)(int, const std::string&)";
name = Symbol::extractName(decl);
assert (name == "func");
assertTrue (name == "func");
decl = "int ( * func )(int, const std::string&)";
name = Symbol::extractName(decl);
assert (name == "func");
assertTrue (name == "func");
decl = "template <typename A, typename B> B func(A a, B b)";
name = Symbol::extractName(decl);
assert (name == "func");
assertTrue (name == "func");
decl = "template <typename A, typename B> class Class";
name = Symbol::extractName(decl);
assert (name == "Class");
assertTrue (name == "Class");
decl = "template <> class Class<int, std::string>";
name = Symbol::extractName(decl);
assert (name == "Class");
assertTrue (name == "Class");
decl = "template <> class Class <int, std::string>";
name = Symbol::extractName(decl);
assert (name == "Class");
assertTrue (name == "Class");
decl = "template <> class Class<int, MyTemplate<int> >";
name = Symbol::extractName(decl);
assert (name == "Class");
assertTrue (name == "Class");
}

View File

@ -220,10 +220,16 @@ inline std::string TestCase::toString()
// and file name at the point of an error.
// Just goes to show that preprocessors do have some
// redeeming qualities.
// for backward compatibility only
// (may conflict with C assert, use at your own risk)
#undef assert
#define assert(condition) \
(this->assertImplementation((condition), (#condition), __LINE__, __FILE__))
#define assertTrue(condition) \
(this->assertImplementation((condition), (#condition), __LINE__, __FILE__))
#define loop_1_assert(data1line, condition) \
(this->loop1assertImplementation((condition), (#condition), __LINE__, data1line, __FILE__))

View File

@ -74,7 +74,7 @@ void CryptoTest::testEncryptDecrypt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -82,7 +82,7 @@ void CryptoTest::testEncryptDecrypt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -90,7 +90,7 @@ void CryptoTest::testEncryptDecrypt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
assertTrue (in == result);
}
}
@ -105,7 +105,7 @@ void CryptoTest::testEncryptDecryptWithSalt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -113,7 +113,7 @@ void CryptoTest::testEncryptDecryptWithSalt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -121,7 +121,7 @@ void CryptoTest::testEncryptDecryptWithSalt()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
assertTrue (in == result);
}
}
@ -138,7 +138,7 @@ void CryptoTest::testEncryptDecryptWithSaltSha1()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -146,7 +146,7 @@ void CryptoTest::testEncryptDecryptWithSaltSha1()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -154,7 +154,7 @@ void CryptoTest::testEncryptDecryptWithSaltSha1()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
assertTrue (in == result);
}
}
@ -168,7 +168,7 @@ void CryptoTest::testEncryptDecryptDESECB()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -176,7 +176,7 @@ void CryptoTest::testEncryptDecryptDESECB()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
assertTrue (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
@ -184,7 +184,7 @@ void CryptoTest::testEncryptDecryptDESECB()
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
assertTrue (in == result);
}
}
@ -206,7 +206,7 @@ void CryptoTest::testEncryptDecryptGCM()
std::string in(n, 'x');
encryptorStream << in;
encryptorStream.close();
assert (encryptorStream.good());
assertTrue (encryptorStream.good());
std::string tag = pEncryptor->getTag();
@ -216,7 +216,7 @@ void CryptoTest::testEncryptDecryptGCM()
std::string out;
decryptorStream >> out;
assert (in == out);
assertTrue (in == out);
}
}
@ -230,7 +230,7 @@ void CryptoTest::testPassword()
base64KeyEnc.write(reinterpret_cast<const char*>(&key.getKey()[0]), key.keySize());
base64KeyEnc.close();
std::string base64Key = keyStream.str();
assert (base64Key == "hIzxBt58GDd7/6mRp88bewKk42lM4QwaF78ek0FkVoA=");
assertTrue (base64Key == "hIzxBt58GDd7/6mRp88bewKk42lM4QwaF78ek0FkVoA=");
}
@ -256,8 +256,8 @@ void CryptoTest::testPasswordSha1()
// openssl enc -e -a -md sha1 -aes256 -k password -S 73616c7473616c74 -P
// (where "salt" == 73616c74 in Hex, doubled for an 8 bytes salt, openssl padds the salt with 0
// whereas Poco's implementation padds with the existing bytes using a modulo operation)
assert (hexIv == "c96049b0edc0b67af61ecc43d3de8898");
assert (hexKey == "cab86dd6261710891e8cb56ee3625691a75df344f0bff4c12cf3596fc00b39c7");
assertTrue (hexIv == "c96049b0edc0b67af61ecc43d3de8898");
assertTrue (hexKey == "cab86dd6261710891e8cb56ee3625691a75df344f0bff4c12cf3596fc00b39c7");
}
@ -268,7 +268,7 @@ void CryptoTest::testEncryptInterop()
const std::string plainText = "This is a secret message.";
const std::string expectedCipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc=";
std::string cipherText = pCipher->encryptString(plainText, Cipher::ENC_BASE64);
assert (cipherText == expectedCipherText);
assertTrue (cipherText == expectedCipherText);
}
@ -279,7 +279,7 @@ void CryptoTest::testDecryptInterop()
const std::string expectedPlainText = "This is a secret message.";
const std::string cipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc=";
std::string plainText = pCipher->decryptString(cipherText, Cipher::ENC_BASE64);
assert (plainText == expectedPlainText);
assertTrue (plainText == expectedPlainText);
}
@ -298,18 +298,18 @@ void CryptoTest::testStreams()
std::string result;
Poco::StreamCopier::copyToString(decryptor, result);
assert (result == SECRET_MESSAGE);
assert (decryptor.eof());
assert (!decryptor.bad());
assertTrue (result == SECRET_MESSAGE);
assertTrue (decryptor.eof());
assertTrue (!decryptor.bad());
std::istringstream emptyStream;
DecryptingInputStream badDecryptor(emptyStream, *pCipher);
Poco::StreamCopier::copyToString(badDecryptor, result);
assert (badDecryptor.fail());
assert (badDecryptor.bad());
assert (!badDecryptor.eof());
assertTrue (badDecryptor.fail());
assertTrue (badDecryptor.bad());
assertTrue (!badDecryptor.eof());
}
@ -327,22 +327,22 @@ void CryptoTest::testCertificate()
std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME));
std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME));
assert (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com");
assert (issuerName == subjectName);
assert (commonName == "appinf.com");
assert (country == "AT");
assert (localityName == "St. Jakob im Rosental");
assert (stateOrProvince == "Carinthia");
assert (organizationName == "Applied Informatics Software Engineering GmbH");
assert (organizationUnitName == "Development");
assertTrue (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com");
assertTrue (issuerName == subjectName);
assertTrue (commonName == "appinf.com");
assertTrue (country == "AT");
assertTrue (localityName == "St. Jakob im Rosental");
assertTrue (stateOrProvince == "Carinthia");
assertTrue (organizationName == "Applied Informatics Software Engineering GmbH");
assertTrue (organizationUnitName == "Development");
// fails with recent OpenSSL versions:
// assert (cert.issuedBy(cert));
// assertTrue (cert.issuedBy(cert));
std::istringstream otherCertStream(APPINF_PEM);
X509Certificate otherCert(otherCertStream);
assert (cert.equals(otherCert));
assertTrue (cert.equals(otherCert));
}

View File

@ -34,26 +34,26 @@ void DigestEngineTest::testMD5()
// test vectors from RFC 1321
engine.update("");
assert (DigestEngine::digestToHex(engine.digest()) == "d41d8cd98f00b204e9800998ecf8427e");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d41d8cd98f00b204e9800998ecf8427e");
engine.update("a");
assert (DigestEngine::digestToHex(engine.digest()) == "0cc175b9c0f1b6a831c399e269772661");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "0cc175b9c0f1b6a831c399e269772661");
engine.update("abc");
assert (DigestEngine::digestToHex(engine.digest()) == "900150983cd24fb0d6963f7d28e17f72");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "900150983cd24fb0d6963f7d28e17f72");
engine.update("message digest");
assert (DigestEngine::digestToHex(engine.digest()) == "f96b697d7cb7938d525a2f31aaf161d0");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "f96b697d7cb7938d525a2f31aaf161d0");
engine.update("abcdefghijklmnopqrstuvwxyz");
assert (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
engine.update("abcdefghijklmnopqrstuvwxyz0123456789");
assert (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
engine.update("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
assert (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a");
}
void DigestEngineTest::testSHA1()
@ -63,14 +63,14 @@ void DigestEngineTest::testSHA1()
// test vectors from FIPS 180-1
engine.update("abc");
assert (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
engine.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
assert (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
for (int i = 0; i < 1000000; ++i)
engine.update('a');
assert (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
}
void DigestEngineTest::setUp()

View File

@ -57,7 +57,7 @@ void ECTest::testECNewKeys()
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -94,7 +94,7 @@ void ECTest::testECNewKeysNoPassphrase()
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -128,7 +128,7 @@ void ECTest::testECDSASignSha256()
ECKey keyPub(&iPub);
ECDSADigestEngine eng2(keyPub, "SHA256");
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
assert(eng2.verify(sig));
assertTrue(eng2.verify(sig));
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -164,7 +164,7 @@ void ECTest::testECDSASignManipulated()
ECKey keyPub(&iPub);
ECDSADigestEngine eng2(keyPub, "SHA256");
eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
assert (!eng2.verify(sig));
assertTrue (!eng2.verify(sig));
}
else
std::cerr << "No elliptic curves found!" << std::endl;

View File

@ -42,29 +42,29 @@ void EVPTest::testRSAEVPPKey()
try
{
RSAKey* key = new RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL);
assert(key->type() == Poco::Crypto::KeyPair::KT_RSA);
assertTrue(key->type() == Poco::Crypto::KeyPair::KT_RSA);
// construct EVPPKey from RSAKey*
EVPPKey* pKey = new EVPPKey(key);
// EVPPKey increments reference count, so freeing the original must be ok
delete key;
assert (!pKey->isSupported(0));
assert (!pKey->isSupported(-1));
assert (pKey->isSupported(pKey->type()));
assert (pKey->type() == EVP_PKEY_RSA);
assertTrue (!pKey->isSupported(0));
assertTrue (!pKey->isSupported(-1));
assertTrue (pKey->isSupported(pKey->type()));
assertTrue (pKey->type() == EVP_PKEY_RSA);
// construct RSAKey from const EVPPKey&
key = new RSAKey(*pKey);
delete pKey;
assert(key->type() == Poco::Crypto::KeyPair::KT_RSA);
assertTrue(key->type() == Poco::Crypto::KeyPair::KT_RSA);
// construct EVPPKey from RSAKey*
pKey = new EVPPKey(key);
assert (pKey->type() == EVP_PKEY_RSA);
assertTrue (pKey->type() == EVP_PKEY_RSA);
BIO* bioPriv1 = BIO_new(BIO_s_mem());
BIO* bioPub1 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
char* pPrivData1;
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
char* pPubData1;
@ -74,39 +74,39 @@ void EVPTest::testRSAEVPPKey()
EVPPKey evpPKey(pKey->operator EVP_PKEY*());
// EVPPKey makes duplicate, so freeing the original must be ok
delete pKey;
assert (evpPKey.type() == EVP_PKEY_RSA);
assertTrue (evpPKey.type() == EVP_PKEY_RSA);
BIO* bioPriv2 = BIO_new(BIO_s_mem());
BIO* bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
char* pPrivData2;
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
char* pPubData2;
long sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
BIO_free(bioPub2);
BIO_free(bioPriv2);
// copy
EVPPKey evpPKey2(evpPKey);
assert (evpPKey2.type() == EVP_PKEY_RSA);
assertTrue (evpPKey2.type() == EVP_PKEY_RSA);
bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
#ifdef POCO_ENABLE_CPP11
@ -115,18 +115,18 @@ void EVPTest::testRSAEVPPKey()
// move
EVPPKey evpPKey3(std::move(evpPKey2));
assert (evpPKey3.type() == EVP_PKEY_RSA);
assertTrue (evpPKey3.type() == EVP_PKEY_RSA);
bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
#endif // POCO_ENABLE_CPP11
@ -158,25 +158,25 @@ void EVPTest::testRSAEVPSaveLoadStream()
std::istringstream iPriv(privKey);
EVPPKey key2(&iPub, &iPriv, "testpwd");
assert (key == key2);
assert (!(key != key2));
assertTrue (key == key2);
assertTrue (!(key != key2));
RSAKey rsaKeyNE(RSAKey::KL_1024, RSAKey::EXP_LARGE);
EVPPKey keyNE(&rsaKeyNE);
assert (key != keyNE);
assert (!(key == keyNE));
assert (key2 != keyNE);;
assert (!(key2 == keyNE));
assertTrue (key != keyNE);
assertTrue (!(key == keyNE));
assertTrue (key2 != keyNE);;
assertTrue (!(key2 == keyNE));
std::ostringstream strPub2;
std::ostringstream strPriv2;
key2.save(&strPub2, &strPriv2, "testpwd");
assert (strPub2.str() == pubKey);
assertTrue (strPub2.str() == pubKey);
std::istringstream iPriv2(strPriv2.str());
EVPPKey key3(0, &iPriv2, "testpwd");
std::ostringstream strPub3;
key3.save(&strPub3);
assert (strPub3.str() == pubKey);
assertTrue (strPub3.str() == pubKey);
}
@ -195,21 +195,21 @@ void EVPTest::testRSAEVPSaveLoadStreamNoPass()
std::istringstream iPriv(privKey);
EVPPKey key2(&iPub, &iPriv);
assert (key == key2);
assert (!(key != key2));
assertTrue (key == key2);
assertTrue (!(key != key2));
RSAKey rsaKeyNE(RSAKey::KL_1024, RSAKey::EXP_LARGE);
EVPPKey keyNE(&rsaKeyNE);
assert (key != keyNE);
assert (!(key == keyNE));
assert (key2 != keyNE);;
assert (!(key2 == keyNE));
assertTrue (key != keyNE);
assertTrue (!(key == keyNE));
assertTrue (key2 != keyNE);;
assertTrue (!(key2 == keyNE));
std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2);
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
@ -221,16 +221,16 @@ void EVPTest::testECEVPPKey()
if (!curveName.empty())
{
EVPPKey* pKey = new EVPPKey(curveName);
assert (pKey != 0);
assert (!pKey->isSupported(0));
assert (!pKey->isSupported(-1));
assert (pKey->isSupported(pKey->type()));
assert (pKey->type() == EVP_PKEY_EC);
assertTrue (pKey != 0);
assertTrue (!pKey->isSupported(0));
assertTrue (!pKey->isSupported(-1));
assertTrue (pKey->isSupported(pKey->type()));
assertTrue (pKey->type() == EVP_PKEY_EC);
BIO* bioPriv1 = BIO_new(BIO_s_mem());
BIO* bioPub1 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv1, *pKey, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub1, *pKey));
char* pPrivData1;
long sizePriv1 = BIO_get_mem_data(bioPriv1, &pPrivData1);
char* pPubData1;
@ -238,41 +238,41 @@ void EVPTest::testECEVPPKey()
// construct EVPPKey from EVP_PKEY*
EVPPKey evpPKey(pKey->operator EVP_PKEY*());
assert (evpPKey.type() == EVP_PKEY_EC);
assertTrue (evpPKey.type() == EVP_PKEY_EC);
// EVPPKey makes duplicate, so freeing the original must be ok
delete pKey;
BIO* bioPriv2 = BIO_new(BIO_s_mem());
BIO* bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey));
char* pPrivData2;
long sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
char* pPubData2;
long sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
BIO_free(bioPub2);
BIO_free(bioPriv2);
// copy
EVPPKey evpPKey2(evpPKey);
assert (evpPKey2.type() == EVP_PKEY_EC);
assertTrue (evpPKey2.type() == EVP_PKEY_EC);
bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey2, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey2));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
#ifdef POCO_ENABLE_CPP11
@ -281,18 +281,18 @@ void EVPTest::testECEVPPKey()
// move
EVPPKey evpPKey3(std::move(evpPKey2));
assert (evpPKey3.type() == EVP_PKEY_EC);
assertTrue (evpPKey3.type() == EVP_PKEY_EC);
bioPriv2 = BIO_new(BIO_s_mem());
bioPub2 = BIO_new(BIO_s_mem());
assert (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL));
assert (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
assertTrue (0 != PEM_write_bio_PrivateKey(bioPriv2, evpPKey3, NULL, NULL, 0, 0, NULL));
assertTrue (0 != PEM_write_bio_PUBKEY(bioPub2, evpPKey3));
sizePriv2 = BIO_get_mem_data(bioPriv2, &pPrivData2);
sizePub2 = BIO_get_mem_data(bioPub2, &pPubData2);
assert (sizePriv1 && (sizePriv1 == sizePriv2));
assert (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assert (sizePub1 && (sizePub1 == sizePub2));
assert (0 == memcmp(pPubData1, pPubData2, sizePub1));
assertTrue (sizePriv1 && (sizePriv1 == sizePriv2));
assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1));
assertTrue (sizePub1 && (sizePub1 == sizePub2));
assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1));
#endif // POCO_ENABLE_CPP11
BIO_free(bioPub2);
@ -333,27 +333,27 @@ void EVPTest::testECEVPSaveLoadStream()
std::ostringstream strPubE;
std::ostringstream strPrivE;
key2.save(&strPubE, &strPrivE, "testpwd");
assert (strPubE.str() == pubKey);
assert (key == key2);
assert (!(key != key2));
assertTrue (strPubE.str() == pubKey);
assertTrue (key == key2);
assertTrue (!(key != key2));
ECKey ecKeyNE(curveName);
EVPPKey keyNE(&ecKeyNE);
assert (key != keyNE);
assert (!(key == keyNE));
assert (key2 != keyNE);
assert (!(key2 == keyNE));
assertTrue (key != keyNE);
assertTrue (!(key == keyNE));
assertTrue (key2 != keyNE);
assertTrue (!(key2 == keyNE));
std::ostringstream strPub2;
std::ostringstream strPriv2;
key2.save(&strPub2, &strPriv2, "testpwd");
assert (strPub2.str() == pubKey);
assertTrue (strPub2.str() == pubKey);
std::istringstream iPriv2(strPriv2.str());
EVPPKey key3(0, &iPriv2, "testpwd");
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -388,28 +388,28 @@ void EVPTest::testECEVPSaveLoadStreamNoPass()
std::ostringstream strPubE;
std::ostringstream strPrivE;
key2.save(&strPubE, &strPrivE);
assert (strPubE.str() == pubKey);
assert (key == key2);
assert (!(key != key2));
assertTrue (strPubE.str() == pubKey);
assertTrue (key == key2);
assertTrue (!(key != key2));
ECKey ecKeyNE(curveName);
EVPPKey keyNE(&ecKeyNE);
assert (key != keyNE);
assert (!(key == keyNE));
assert (key2 != keyNE);
assert (!(key2 == keyNE));
assertTrue (key != keyNE);
assertTrue (!(key == keyNE));
assertTrue (key2 != keyNE);
assertTrue (!(key2 == keyNE));
std::ostringstream strPub2;
std::ostringstream strPriv2;
key2.save(&strPub2, &strPriv2);
assert (strPub2.str() == pubKey);
assert (strPriv2.str() == privKey);
assertTrue (strPub2.str() == pubKey);
assertTrue (strPriv2.str() == privKey);
std::istringstream iPriv2(privKey);
EVPPKey key3(0, &iPriv2);
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -445,26 +445,26 @@ void EVPTest::testECEVPSaveLoadFile()
std::ostringstream strPubE;
std::ostringstream strPrivE;
key2.save(&strPubE, &strPrivE, "testpwd");
assert (strPubE.str() == pubKey);
assert (key == key2);
assert (!(key != key2));
assertTrue (strPubE.str() == pubKey);
assertTrue (key == key2);
assertTrue (!(key != key2));
ECKey ecKeyNE(curveName);
EVPPKey keyNE(&ecKeyNE);
assert (key != keyNE);
assert (!(key == keyNE));
assert (key2 != keyNE);
assert (!(key2 == keyNE));
assertTrue (key != keyNE);
assertTrue (!(key == keyNE));
assertTrue (key2 != keyNE);
assertTrue (!(key2 == keyNE));
std::ostringstream strPub2;
std::ostringstream strPriv2;
key2.save(&strPub2, &strPriv2, "testpwd");
assert (strPub2.str() == pubKey);
assertTrue (strPub2.str() == pubKey);
EVPPKey key3("", filePriv.path(), "testpwd");
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;
@ -499,13 +499,13 @@ void EVPTest::testECEVPSaveLoadFileNoPass()
std::ostringstream strPub2;
std::ostringstream strPriv2;
key2.save(&strPub2, &strPriv2);
assert (strPub2.str() == pubKey);
assertTrue (strPub2.str() == pubKey);
EVPPKey key3("", filePriv.path());
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
else
std::cerr << "No elliptic curves found!" << std::endl;

View File

@ -80,16 +80,16 @@ void PKCS12ContainerTest::testFullPKCS12()
void PKCS12ContainerTest::full(const PKCS12Container& pkcs12)
{
assert ("vally" == pkcs12.getFriendlyName());
assertTrue ("vally" == pkcs12.getFriendlyName());
assert (pkcs12.hasKey());
assertTrue (pkcs12.hasKey());
EVPPKey pKey = pkcs12.getKey();
assert (EVP_PKEY_RSA == pKey.type());
assertTrue (EVP_PKEY_RSA == pKey.type());
RSAKey rsa(pkcs12);
assert (rsa.impl()->type() == KeyPairImpl::KT_RSA_IMPL);
assertTrue (rsa.impl()->type() == KeyPairImpl::KT_RSA_IMPL);
assert (pkcs12.hasX509Certificate());
assertTrue (pkcs12.hasX509Certificate());
fullCert(pkcs12.getX509Certificate());
std::vector<int> certOrder;
@ -111,18 +111,18 @@ void PKCS12ContainerTest::fullCert(const X509Certificate& x509)
std::string emailAddress(x509.subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS));
std::string serialNumber(x509.serialNumber());
assert (subjectName == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Server");
assert (issuerName == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assert (commonName == "CV Server");
assert (country == "CH");
assert (localityName.empty());
assert (stateOrProvince == "Zug");
assert (organizationName == "Crypto Vally");
assert (organizationUnitName.empty());
assert (emailAddress.empty());
assert (serialNumber == "1000");
assert (x509.version() == 3);
assert (x509.signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (subjectName == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Server");
assertTrue (issuerName == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assertTrue (commonName == "CV Server");
assertTrue (country == "CH");
assertTrue (localityName.empty());
assertTrue (stateOrProvince == "Zug");
assertTrue (organizationName == "Crypto Vally");
assertTrue (organizationUnitName.empty());
assertTrue (emailAddress.empty());
assertTrue (serialNumber == "1000");
assertTrue (x509.version() == 3);
assertTrue (x509.signatureAlgorithm() == "sha256WithRSAEncryption");
}
@ -130,40 +130,40 @@ void PKCS12ContainerTest::fullList(const PKCS12Container::CAList& caList,
const PKCS12Container::CANameList& caNamesList,
const std::vector<int>& certOrder)
{
assert (certOrder.size() == caList.size());
assert ((0 == caNamesList.size()) || (certOrder.size() == caNamesList.size()));
assertTrue (certOrder.size() == caList.size());
assertTrue ((0 == caNamesList.size()) || (certOrder.size() == caNamesList.size()));
if (caNamesList.size())
{
assert (caNamesList[certOrder[0]].empty());
assert (caNamesList[certOrder[1]].empty());
assertTrue (caNamesList[certOrder[0]].empty());
assertTrue (caNamesList[certOrder[1]].empty());
}
assert (caList[certOrder[0]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[0]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[0]].commonName() == "CV Root CA v3");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[0]].serialNumber() == "C3ECA1FCEAA16055");
assert (caList[certOrder[0]].version() == 3);
assert (caList[certOrder[0]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[0]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[0]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[0]].commonName() == "CV Root CA v3");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[0]].serialNumber() == "C3ECA1FCEAA16055");
assertTrue (caList[certOrder[0]].version() == 3);
assertTrue (caList[certOrder[0]].signatureAlgorithm() == "sha256WithRSAEncryption");
assert (caList[certOrder[1]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assert (caList[certOrder[1]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[1]].commonName() == "CV Intermediate CA v3");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[1]].serialNumber() == "1000");
assert (caList[certOrder[1]].version() == 3);
assert (caList[certOrder[1]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[1]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assertTrue (caList[certOrder[1]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[1]].commonName() == "CV Intermediate CA v3");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[1]].serialNumber() == "1000");
assertTrue (caList[certOrder[1]].version() == 3);
assertTrue (caList[certOrder[1]].signatureAlgorithm() == "sha256WithRSAEncryption");
}
@ -187,9 +187,9 @@ void PKCS12ContainerTest::testCertsOnlyPKCS12()
void PKCS12ContainerTest::certsOnly(const PKCS12Container& pkcs12)
{
assert (!pkcs12.hasKey());
assert (!pkcs12.hasX509Certificate());
assert (pkcs12.getFriendlyName().empty());
assertTrue (!pkcs12.hasKey());
assertTrue (!pkcs12.hasX509Certificate());
assertTrue (pkcs12.getFriendlyName().empty());
std::vector<int> certOrder;
for (int i = 0; i < 5; ++i) certOrder.push_back(i);
@ -200,82 +200,82 @@ void PKCS12ContainerTest::certsOnly(const PKCS12Container& pkcs12)
void PKCS12ContainerTest::certsOnlyList(const PKCS12Container::CAList& caList,
const PKCS12Container::CANameList& caNamesList, const std::vector<int>& certOrder)
{
assert (certOrder.size() == caList.size());
assert ((0 == caNamesList.size()) || (certOrder.size() == caNamesList.size()));
assertTrue (certOrder.size() == caList.size());
assertTrue ((0 == caNamesList.size()) || (certOrder.size() == caNamesList.size()));
if (caNamesList.size())
{
assert (caNamesList[certOrder[0]].empty());
assert (caNamesList[certOrder[1]].empty());
assert (caNamesList[certOrder[2]].empty());
assert (caNamesList[certOrder[3]] == "vally-ca");
assert (caNamesList[certOrder[4]] == "vally-ca");
assertTrue (caNamesList[certOrder[0]].empty());
assertTrue (caNamesList[certOrder[1]].empty());
assertTrue (caNamesList[certOrder[2]].empty());
assertTrue (caNamesList[certOrder[3]] == "vally-ca");
assertTrue (caNamesList[certOrder[4]] == "vally-ca");
}
assert (caList[certOrder[0]].subjectName() == "/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3");
assert (caList[certOrder[0]].issuerName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assert (caList[certOrder[0]].commonName() == "Let's Encrypt Authority X3");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Let's Encrypt");
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[0]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[0]].serialNumber() == "D3B17226342332DCF40528512AEC9C6A");
assert (caList[certOrder[0]].version() == 3);
assert (caList[certOrder[0]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[0]].subjectName() == "/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3");
assertTrue (caList[certOrder[0]].issuerName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assertTrue (caList[certOrder[0]].commonName() == "Let's Encrypt Authority X3");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Let's Encrypt");
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[0]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[0]].serialNumber() == "D3B17226342332DCF40528512AEC9C6A");
assertTrue (caList[certOrder[0]].version() == 3);
assertTrue (caList[certOrder[0]].signatureAlgorithm() == "sha256WithRSAEncryption");
assert (caList[certOrder[1]].subjectName() == "/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3");
assert (caList[certOrder[1]].issuerName() == "/O=Digital Signature Trust Co./CN=DST Root CA X3");
assert (caList[certOrder[1]].commonName() == "Let's Encrypt Authority X3");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Let's Encrypt");
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[1]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[1]].serialNumber() == "0A0141420000015385736A0B85ECA708");
assert (caList[certOrder[1]].version() == 3);
assert (caList[certOrder[1]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[1]].subjectName() == "/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3");
assertTrue (caList[certOrder[1]].issuerName() == "/O=Digital Signature Trust Co./CN=DST Root CA X3");
assertTrue (caList[certOrder[1]].commonName() == "Let's Encrypt Authority X3");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Let's Encrypt");
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[1]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[1]].serialNumber() == "0A0141420000015385736A0B85ECA708");
assertTrue (caList[certOrder[1]].version() == 3);
assertTrue (caList[certOrder[1]].signatureAlgorithm() == "sha256WithRSAEncryption");
assert (caList[certOrder[2]].subjectName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assert (caList[certOrder[2]].issuerName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assert (caList[certOrder[2]].commonName() == "ISRG Root X1");
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Internet Security Research Group");
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[2]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[2]].serialNumber() == "8210CFB0D240E3594463E0BB63828B00");
assert (caList[certOrder[2]].version() == 3);
assert (caList[certOrder[2]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[2]].subjectName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assertTrue (caList[certOrder[2]].issuerName() == "/C=US/O=Internet Security Research Group/CN=ISRG Root X1");
assertTrue (caList[certOrder[2]].commonName() == "ISRG Root X1");
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_COUNTRY) == "US");
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE).empty());
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Internet Security Research Group");
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[2]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[2]].serialNumber() == "8210CFB0D240E3594463E0BB63828B00");
assertTrue (caList[certOrder[2]].version() == 3);
assertTrue (caList[certOrder[2]].signatureAlgorithm() == "sha256WithRSAEncryption");
assert (caList[certOrder[3]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[3]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[3]].commonName() == "CV Root CA v3");
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[3]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[3]].serialNumber() == "C3ECA1FCEAA16055");
assert (caList[certOrder[3]].version() == 3);
assert (caList[certOrder[3]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[3]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[3]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[3]].commonName() == "CV Root CA v3");
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[3]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[3]].serialNumber() == "C3ECA1FCEAA16055");
assertTrue (caList[certOrder[3]].version() == 3);
assertTrue (caList[certOrder[3]].signatureAlgorithm() == "sha256WithRSAEncryption");
assert (caList[certOrder[4]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assert (caList[certOrder[4]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assert (caList[certOrder[4]].commonName() == "CV Intermediate CA v3");
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assert (caList[certOrder[4]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assert (caList[certOrder[4]].serialNumber()== "1000");
assert (caList[certOrder[4]].version() == 3);
assert (caList[certOrder[4]].signatureAlgorithm() == "sha256WithRSAEncryption");
assertTrue (caList[certOrder[4]].subjectName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Intermediate CA v3");
assertTrue (caList[certOrder[4]].issuerName() == "/C=CH/ST=Zug/O=Crypto Vally/CN=CV Root CA v3");
assertTrue (caList[certOrder[4]].commonName() == "CV Intermediate CA v3");
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_COUNTRY) == "CH");
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_LOCALITY_NAME).empty());
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_STATE_OR_PROVINCE) == "Zug");
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_ORGANIZATION_NAME) == "Crypto Vally");
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME).empty());
assertTrue (caList[certOrder[4]].subjectName(X509Certificate::NID_PKCS9_EMAIL_ADDRESS).empty());
assertTrue (caList[certOrder[4]].serialNumber()== "1000");
assertTrue (caList[certOrder[4]].version() == 3);
assertTrue (caList[certOrder[4]].signatureAlgorithm() == "sha256WithRSAEncryption");
}
@ -285,7 +285,7 @@ void PKCS12ContainerTest::testPEMReadWrite()
{
std::string file = getTestFilesPath("certs-only", "pem");
X509Certificate::List certsOnly = X509Certificate::readPEM(file);
assert (certsOnly.size() == 5);
assertTrue (certsOnly.size() == 5);
// PEM is written by openssl in reverse order from p12
std::vector<int> certOrder;
for(int i = (int)certsOnly.size() - 1; i >= 0; --i) certOrder.push_back(i);
@ -300,10 +300,10 @@ void PKCS12ContainerTest::testPEMReadWrite()
file = getTestFilesPath("full", "pem");
X509Certificate::List full = X509Certificate::readPEM(file);
assert (full.size() == 3);
assertTrue (full.size() == 3);
fullCert(full[0]);
full.erase(full.begin());
assert (full.size() == 2);
assertTrue (full.size() == 2);
certOrder.clear();
for(int i = (int)full.size() - 1; i >= 0; --i) certOrder.push_back(i);

View File

@ -102,7 +102,7 @@ void RSATest::testNewKeys()
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
@ -125,7 +125,7 @@ void RSATest::testNewKeysNoPassphrase()
std::ostringstream strPub3;
key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey);
assertTrue (pubFromPrivate == pubKey);
}
@ -146,7 +146,7 @@ void RSATest::testSign()
RSAKey keyPub(&iPub);
RSADigestEngine eng2(keyPub);
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
assert (eng2.verify(sig));
assertTrue (eng2.verify(sig));
}
@ -167,7 +167,7 @@ void RSATest::testSignSha256()
RSAKey keyPub(&iPub);
RSADigestEngine eng2(keyPub, "SHA256");
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
assert (eng2.verify(sig));
assertTrue (eng2.verify(sig));
}
@ -189,7 +189,7 @@ void RSATest::testSignManipulated()
RSAKey keyPub(&iPub);
RSADigestEngine eng2(keyPub);
eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
assert (!eng2.verify(sig));
assertTrue (!eng2.verify(sig));
}
@ -201,7 +201,7 @@ void RSATest::testRSACipher()
std::string val(n, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
assertTrue (dec == val);
}
}
@ -228,7 +228,7 @@ void RSATest::testRSACipherLarge()
std::string val(*it, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
assertTrue (dec == val);
}
}
@ -246,7 +246,7 @@ void RSATest::testCertificate()
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher2->decryptString(enc);
assert (dec == val);
assertTrue (dec == val);
}

View File

@ -576,30 +576,30 @@ void MySQLTest::testNullableInt()
int count = 0;
*_pSession << "SELECT COUNT(*) FROM NullableIntTest", into(count), now;
assert (count == 3);
assertTrue (count == 3);
Nullable<Int32> ci1;
Nullable<Int32> ci2;
Nullable<Int32> ci3;
id = 1;
*_pSession << "SELECT Value FROM NullableIntTest WHERE Id = ?", into(ci1), use(id), now;
assert (ci1 == i1);
assertTrue (ci1 == i1);
id = 2;
*_pSession << "SELECT Value FROM NullableIntTest WHERE Id = ?", into(ci2), use(id), now;
assert (ci2.isNull());
assert (!(0 == ci2));
assert (0 != ci2);
assert (!(ci2 == 0));
assert (ci2 != 0);
assertTrue (ci2.isNull());
assertTrue (!(0 == ci2));
assertTrue (0 != ci2);
assertTrue (!(ci2 == 0));
assertTrue (ci2 != 0);
ci2 = 10;
assert (10 == ci2);
assert (ci2 == 10);
assert (!ci2.isNull());
assertTrue (10 == ci2);
assertTrue (ci2 == 10);
assertTrue (!ci2.isNull());
id = 3;
*_pSession << "SELECT Value FROM NullableIntTest WHERE Id = ?", into(ci3), use(id), now;
assert (!ci3.isNull());
assert (ci3 == 3);
assert (3 == ci3);
assertTrue (!ci3.isNull());
assertTrue (ci3 == 3);
assertTrue (3 == ci3);
}
@ -621,18 +621,18 @@ void MySQLTest::testNullableString()
Nullable<std::string> resAddress;
Nullable<Int32> resAge;
*_pSession << "SELECT Address, Age FROM NullableStringTest WHERE Id = ?", into(resAddress), into(resAge), use(id), now;
assert(resAddress == address);
assert(resAge == age);
assert(resAddress.isNull());
assert(null == resAddress);
assert(resAddress == null);
assertTrue (resAddress == address);
assertTrue (resAge == age);
assertTrue (resAddress.isNull());
assertTrue (null == resAddress);
assertTrue (resAddress == null);
resAddress = std::string("Test");
assert(!resAddress.isNull());
assert(resAddress == std::string("Test"));
assert(std::string("Test") == resAddress);
assert(null != resAddress);
assert(resAddress != null);
assertTrue (!resAddress.isNull());
assertTrue (resAddress == std::string("Test"));
assertTrue (std::string("Test") == resAddress);
assertTrue (null != resAddress);
assertTrue (resAddress != null);
}
@ -667,23 +667,23 @@ void MySQLTest::testTupleWithNullable()
*_pSession << "SELECT Id, Address, Age FROM NullableStringTest", into(result), now;
assert(result[0].get<1>() == std::string("Address"));
assert(result[0].get<2>() == 10);
assertTrue (result[0].get<1>() == std::string("Address"));
assertTrue (result[0].get<2>() == 10);
assert(result[1].get<1>() == null);
assert(result[1].get<2>() == 10);
assertTrue (result[1].get<1>() == null);
assertTrue (result[1].get<2>() == 10);
assert(result[2].get<1>() == std::string("Address!"));
assert(result[2].get<2>() == null);
assertTrue (result[2].get<1>() == std::string("Address!"));
assertTrue (result[2].get<2>() == null);
assert(result[3].get<1>() == std::string("A"));
assert(result[3].get<2>() == 0);
assertTrue (result[3].get<1>() == std::string("A"));
assertTrue (result[3].get<2>() == 0);
assert(result[4].get<1>() == null);
assert(result[4].get<2>() == 12);
assertTrue (result[4].get<1>() == null);
assertTrue (result[4].get<2>() == 12);
assert(result[5].get<1>() == std::string("B"));
assert(result[5].get<2>() == null);
assertTrue (result[5].get<1>() == std::string("B"));
assertTrue (result[5].get<2>() == null);
}

File diff suppressed because it is too large Load Diff

View File

@ -70,17 +70,17 @@ void ODBCAccessTest::testSimpleAccess()
try { *_pSession << "SELECT COUNT(*) FROM PERSON", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("testSimpleAccess()"); }
catch(StatementException& ex){ std::cout << ex.toString() << std::endl; fail ("testSimpleAccess()"); }
assert (count == 1);
assertTrue (count == 1);
try { *_pSession << "SELECT LastName FROM PERSON", into(result), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("testSimpleAccess()"); }
catch(StatementException& ex){ std::cout << ex.toString() << std::endl; fail ("testSimpleAccess()"); }
assert (lastName == result);
assertTrue (lastName == result);
try { *_pSession << "SELECT Age FROM PERSON", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("testSimpleAccess()"); }
catch(StatementException& ex){ std::cout << ex.toString() << std::endl; fail ("testSimpleAccess()"); }
assert (count == age);
assertTrue (count == age);
}

View File

@ -176,7 +176,7 @@ void ODBCDB2Test::testStoredProcedure()
int i = 0;
*_pSession << "{call storedProcedure(?)}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("PROCEDURE", "storedProcedure");
*_pSession << "CREATE PROCEDURE storedProcedure(inParam INTEGER, OUT outParam INTEGER) "
@ -188,7 +188,7 @@ void ODBCDB2Test::testStoredProcedure()
i = 2;
int j = 0;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
dropObject("PROCEDURE", "storedProcedure");
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
@ -198,7 +198,7 @@ void ODBCDB2Test::testStoredProcedure()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
//TIMESTAMP is not supported as stored procedure parameter in DB2
@ -221,7 +221,7 @@ void ODBCDB2Test::testStoredProcedure()
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
std::string outParam;
*_pSession << "{call storedProcedure(?,?)}", in(inParam), out(outParam), now;
assert(inParam == outParam);
assertTrue (inParam == outParam);
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -247,7 +247,7 @@ void ODBCDB2Test::testStoredProcedureAny()
"END" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == AnyCast<int>(j));
assertTrue (4 == AnyCast<int>(j));
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
@ -257,7 +257,7 @@ void ODBCDB2Test::testStoredProcedureAny()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == AnyCast<int>(i));
assertTrue (4 == AnyCast<int>(i));
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -282,7 +282,7 @@ void ODBCDB2Test::testStoredProcedureDynamicAny()
"END" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
@ -292,7 +292,7 @@ void ODBCDB2Test::testStoredProcedureDynamicAny()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -317,7 +317,7 @@ void ODBCDB2Test::testStoredFunction()
int i = 0;
*_pSession << "{? = call storedFunction()}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("PROCEDURE", "storedFunction");
*_pSession << "CREATE PROCEDURE storedFunction(inParam INTEGER) "
@ -328,7 +328,7 @@ void ODBCDB2Test::testStoredFunction()
i = 2;
int result = 0;
*_pSession << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == result);
assertTrue (4 == result);
dropObject("PROCEDURE", "storedFunction");
*_pSession << "CREATE PROCEDURE storedFunction(inParam INTEGER, OUT outParam INTEGER) "
@ -341,8 +341,8 @@ void ODBCDB2Test::testStoredFunction()
int j = 0;
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now;
assert(4 == j);
assert(j == result);
assertTrue (4 == j);
assertTrue (j == result);
dropObject("PROCEDURE", "storedFunction");
*_pSession << "CREATE PROCEDURE storedFunction(INOUT param1 INTEGER, INOUT param2 INTEGER) "
@ -358,18 +358,18 @@ void ODBCDB2Test::testStoredFunction()
j = 2;
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assert(1 == j);
assert(2 == i);
assert(3 == result);
assertTrue (1 == j);
assertTrue (2 == i);
assertTrue (3 == result);
Tuple<int, int> params(1, 2);
assert(1 == params.get<0>());
assert(2 == params.get<1>());
assertTrue (1 == params.get<0>());
assertTrue (2 == params.get<1>());
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assert(1 == params.get<1>());
assert(2 == params.get<0>());
assert(3 == result);
assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>());
assertTrue (3 == result);
dropObject("PROCEDURE", "storedFunction");
@ -385,8 +385,8 @@ void ODBCDB2Test::testStoredFunction()
std::string outParam;
int ret;
*_pSession << "{? = call storedFunction(?,?)}", out(ret), in(inParam), out(outParam), now;
assert(inParam == outParam);
assert(ret == inParam.size());
assertTrue (inParam == outParam);
assertTrue (ret == inParam.size());
dropObject("PROCEDURE", "storedFunction");
k += 2;

View File

@ -240,7 +240,7 @@ void ODBCOracleTest::testStoredProcedure()
int i = 0;
*_pSession << "{call storedProcedure(?)}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("PROCEDURE", "storedProcedure");
*_pSession << "CREATE OR REPLACE "
@ -251,7 +251,7 @@ void ODBCOracleTest::testStoredProcedure()
i = 2;
int j = 0;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE OR REPLACE "
@ -261,7 +261,7 @@ void ODBCOracleTest::testStoredProcedure()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
*_pSession << "CREATE OR REPLACE "
@ -271,7 +271,7 @@ void ODBCOracleTest::testStoredProcedure()
DateTime dt(1965, 6, 18, 5, 35, 1);
*_pSession << "{call storedProcedure(?)}", io(dt), now;
assert(19 == dt.day());
assertTrue (19 == dt.day());
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -298,7 +298,7 @@ void ODBCOracleTest::testStoredProcedure()
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
std::string outParam;
*_pSession << "{call storedProcedure(?,?)}", in(inParam), out(outParam), now;
assert(inParam == outParam);
assertTrue (inParam == outParam);
dropObject("PROCEDURE", "storedProcedure");
}
@ -319,7 +319,7 @@ void ODBCOracleTest::testStoredProcedureAny()
"END storedProcedure;" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == AnyCast<int>(j));
assertTrue (4 == AnyCast<int>(j));
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE OR REPLACE "
@ -329,7 +329,7 @@ void ODBCOracleTest::testStoredProcedureAny()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == AnyCast<int>(i));
assertTrue (4 == AnyCast<int>(i));
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -352,7 +352,7 @@ void ODBCOracleTest::testStoredProcedureDynamicAny()
"END storedProcedure;" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE OR REPLACE "
@ -362,7 +362,7 @@ void ODBCOracleTest::testStoredProcedureDynamicAny()
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -400,16 +400,16 @@ void ODBCOracleTest::testCursorStoredProcedure()
*_pSession << "{call storedCursorProcedure(?)}", in(age), into(people), now;
assert (2 == people.size());
assert (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assert (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
Statement stmt = ((*_pSession << "{call storedCursorProcedure(?)}", in(age), now));
RecordSet rs(stmt);
assert (rs["LastName"] == "Simpson");
assert (rs["FirstName"] == "Bart");
assert (rs["Address"] == "Springfield");
assert (rs["Age"] == 12);
assertTrue (rs["LastName"] == "Simpson");
assertTrue (rs["FirstName"] == "Bart");
assertTrue (rs["Address"] == "Springfield");
assertTrue (rs["Age"] == 12);
dropObject("TABLE", "Person");
dropObject("PROCEDURE", "storedCursorProcedure");
@ -435,7 +435,7 @@ void ODBCOracleTest::testStoredFunction()
int i = 0;
*_pSession << "{? = call storedFunction()}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("FUNCTION", "storedFunction");
@ -447,7 +447,7 @@ void ODBCOracleTest::testStoredFunction()
i = 2;
int result = 0;
*_pSession << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == result);
assertTrue (4 == result);
dropObject("FUNCTION", "storedFunction");
*_pSession << "CREATE OR REPLACE "
@ -459,8 +459,8 @@ void ODBCOracleTest::testStoredFunction()
int j = 0;
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now;
assert(4 == j);
assert(j == result);
assertTrue (4 == j);
assertTrue (j == result);
dropObject("FUNCTION", "storedFunction");
*_pSession << "CREATE OR REPLACE "
@ -473,18 +473,18 @@ void ODBCOracleTest::testStoredFunction()
j = 2;
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assert(1 == j);
assert(2 == i);
assert(3 == result);
assertTrue (1 == j);
assertTrue (2 == i);
assertTrue (3 == result);
Tuple<int, int> params(1, 2);
assert(1 == params.get<0>());
assert(2 == params.get<1>());
assertTrue (1 == params.get<0>());
assertTrue (2 == params.get<1>());
result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assert(1 == params.get<1>());
assert(2 == params.get<0>());
assert(3 == result);
assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>());
assertTrue (3 == result);
dropObject("FUNCTION", "storedFunction");
k += 2;
@ -501,9 +501,9 @@ void ODBCOracleTest::testStoredFunction()
std::string outParam;
std::string ret;
*_pSession << "{? = call storedFunction(?,?)}", out(ret), in(inParam), out(outParam), now;
assert("123" == inParam);
assert(inParam == outParam);
assert(ret == outParam);
assertTrue ("123" == inParam);
assertTrue (inParam == outParam);
assertTrue (ret == outParam);
dropObject("PROCEDURE", "storedFunction");
}
@ -540,16 +540,16 @@ void ODBCOracleTest::testCursorStoredFunction()
*_pSession << "{call storedCursorFunction(?)}", in(age), into(people), now;
assert (2 == people.size());
assert (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assert (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
Statement stmt = ((*_pSession << "{call storedCursorFunction(?)}", in(age), now));
RecordSet rs(stmt);
assert (rs["LastName"] == "Simpson");
assert (rs["FirstName"] == "Bart");
assert (rs["Address"] == "Springfield");
assert (rs["Age"] == 12);
assertTrue (rs["LastName"] == "Simpson");
assertTrue (rs["FirstName"] == "Bart");
assertTrue (rs["Address"] == "Springfield");
assertTrue (rs["Age"] == 12);
dropObject("TABLE", "Person");
dropObject("FUNCTION", "storedCursorFunction");
@ -598,17 +598,17 @@ void ODBCOracleTest::testAutoTransaction()
session().setFeature("autoCommit", true);
session() << "INSERT INTO Strings VALUES (1)", now;
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (1 == count);
assertTrue (1 == count);
session() << "INSERT INTO Strings VALUES (2)", now;
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (2 == count);
assertTrue (2 == count);
session() << "INSERT INTO Strings VALUES (3)", now;
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (3 == count);
assertTrue (3 == count);
session() << "DELETE FROM Strings", now;
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (0 == count);
assertTrue (0 == count);
session().setFeature("autoCommit", false);
@ -621,7 +621,7 @@ void ODBCOracleTest::testAutoTransaction()
} catch (Poco::Exception&) {}
session() << "SELECT count(*) FROM Strings", into(count), now;
assert (0 == count);
assertTrue (0 == count);
AutoTransaction at(session());
@ -630,12 +630,12 @@ void ODBCOracleTest::testAutoTransaction()
session() << "INSERT INTO Strings VALUES (3)", now;
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (0 == count);
assertTrue (0 == count);
at.commit();
localSession << "SELECT count(*) FROM Strings", into(count), now;
assert (3 == count);
assertTrue (3 == count);
session().setFeature("autoCommit", ac);
}

View File

@ -220,7 +220,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
int i = 0;
session() << "{? = call storedFunction()}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("FUNCTION", "storedFunction()");
try
@ -237,7 +237,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
i = 2;
int result = 0;
session() << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == result);
assertTrue (4 == result);
dropObject("FUNCTION", "storedFunction(INTEGER)");
dropObject("FUNCTION", "storedFunction(TIMESTAMP)");
@ -255,7 +255,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
DateTime dtIn(1965, 6, 18, 5, 35, 1);
DateTime dtOut;
session() << "{? = call storedFunction(?)}", out(dtOut), in(dtIn), now;
assert(dtOut == dtIn);
assertTrue (dtOut == dtIn);
dropObject("FUNCTION", "storedFunction(TIMESTAMP)");
dropObject("FUNCTION", "storedFunction(TEXT, TEXT)");
@ -280,7 +280,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (func); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (func); }
assert(ret == "Hello, world!");
assertTrue (ret == "Hello, world!");
dropObject("FUNCTION", "storedFunction(TEXT, TEXT)");
k += 2;
@ -304,7 +304,7 @@ void ODBCPostgreSQLTest::testStoredFunctionAny()
Any i = 2;
Any result = 0;
session() << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == AnyCast<int>(result));
assertTrue (4 == AnyCast<int>(result));
k += 2;
}
@ -329,7 +329,7 @@ void ODBCPostgreSQLTest::testStoredFunctionDynamicAny()
DynamicAny i = 2;
DynamicAny result = 0;
session() << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == result);
assertTrue (4 == result);
k += 2;
}

View File

@ -257,7 +257,7 @@ void ODBCSQLServerTest::testStoredProcedure()
int i = 0;
session() << "{call storedProcedure(?)}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("PROCEDURE", "storedProcedure");
session() << "CREATE PROCEDURE storedProcedure(@inParam int, @outParam int OUTPUT) AS "
@ -269,7 +269,7 @@ void ODBCSQLServerTest::testStoredProcedure()
i = 2;
int j = 0;
session() << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
dropObject("PROCEDURE", "storedProcedure");
session() << "CREATE PROCEDURE storedProcedure(@ioParam int OUTPUT) AS "
@ -280,7 +280,7 @@ void ODBCSQLServerTest::testStoredProcedure()
i = 2;
session() << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
session() << "CREATE PROCEDURE storedProcedure(@ioParam DATETIME OUTPUT) AS "
@ -290,7 +290,7 @@ void ODBCSQLServerTest::testStoredProcedure()
DateTime dt(1965, 6, 18, 5, 35, 1);
session() << "{call storedProcedure(?)}", io(dt), now;
assert(19 == dt.day());
assertTrue (19 == dt.day());
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -313,7 +313,7 @@ Deprecated types are not supported as output parameters. Use current large obje
try{
session() << "{call storedProcedure(?, ?)}", in(inParam), out(outParam), now;
}catch(StatementException& ex){std::cout << ex.toString();}
assert(outParam == inParam);
assertTrue (outParam == inParam);
dropObject("PROCEDURE", "storedProcedure");
*/
}
@ -349,16 +349,16 @@ void ODBCSQLServerTest::testCursorStoredProcedure()
session() << "{call storedCursorProcedure(?)}", in(age), into(people), now;
assert (2 == people.size());
assert (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assert (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
Statement stmt = ((session() << "{call storedCursorProcedure(?)}", in(age), now));
RecordSet rs(stmt);
assert (rs["LastName"] == "Simpson");
assert (rs["FirstName"] == "Bart");
assert (rs["Address"] == "Springfield");
assert (rs["Age"] == 12);
assertTrue (rs["LastName"] == "Simpson");
assertTrue (rs["FirstName"] == "Bart");
assertTrue (rs["Address"] == "Springfield");
assertTrue (rs["Age"] == 12);
dropObject("TABLE", "Person");
dropObject("PROCEDURE", "storedCursorProcedure");
@ -385,7 +385,7 @@ void ODBCSQLServerTest::testStoredProcedureAny()
, now;
session() << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == AnyCast<int>(j));
assertTrue (4 == AnyCast<int>(j));
session() << "DROP PROCEDURE storedProcedure;", now;
session() << "CREATE PROCEDURE storedProcedure(@ioParam int OUTPUT) AS "
@ -396,7 +396,7 @@ void ODBCSQLServerTest::testStoredProcedureAny()
i = 2;
session() << "{call storedProcedure(?)}", io(i), now;
assert(4 == AnyCast<int>(i));
assertTrue (4 == AnyCast<int>(i));
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -420,7 +420,7 @@ void ODBCSQLServerTest::testStoredProcedureDynamicAny()
, now;
session() << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
assertTrue (4 == j);
session() << "DROP PROCEDURE storedProcedure;", now;
session() << "CREATE PROCEDURE storedProcedure(@ioParam int OUTPUT) AS "
@ -431,7 +431,7 @@ void ODBCSQLServerTest::testStoredProcedureDynamicAny()
i = 2;
session() << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
assertTrue (4 == i);
dropObject("PROCEDURE", "storedProcedure");
k += 2;
@ -457,7 +457,7 @@ void ODBCSQLServerTest::testStoredFunction()
int i = 0;
session() << "{? = call storedFunction}", out(i), now;
assert(-1 == i);
assertTrue (-1 == i);
dropObject("PROCEDURE", "storedFunction");
@ -470,7 +470,7 @@ void ODBCSQLServerTest::testStoredFunction()
i = 2;
int result = 0;
session() << "{? = call storedFunction(?)}", out(result), in(i), now;
assert(4 == result);
assertTrue (4 == result);
dropObject("PROCEDURE", "storedFunction");
@ -485,8 +485,8 @@ void ODBCSQLServerTest::testStoredFunction()
int j = 0;
result = 0;
session() << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now;
assert(4 == j);
assert(j == result);
assertTrue (4 == j);
assertTrue (j == result);
dropObject("PROCEDURE", "storedFunction");
@ -504,18 +504,18 @@ void ODBCSQLServerTest::testStoredFunction()
j = 2;
result = 0;
session() << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assert(1 == j);
assert(2 == i);
assert(3 == result);
assertTrue (1 == j);
assertTrue (2 == i);
assertTrue (3 == result);
Tuple<int, int> params(1, 2);
assert(1 == params.get<0>());
assert(2 == params.get<1>());
assertTrue (1 == params.get<0>());
assertTrue (2 == params.get<1>());
result = 0;
session() << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assert(1 == params.get<1>());
assert(2 == params.get<0>());
assert(3 == result);
assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>());
assertTrue (3 == result);
dropObject("PROCEDURE", "storedFunction");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -49,25 +49,25 @@ void SessionPoolTest::testSessionPool()
SessionPool pool("test", "cs", 1, 4, 2);
pool.setFeature("f1", true);
assert (pool.getFeature("f1"));
assertTrue (pool.getFeature("f1"));
try { pool.getFeature("g1"); fail ("must fail"); }
catch ( Poco::NotFoundException& ) { }
pool.setProperty("p1", 1);
assert (1 == Poco::AnyCast<int>(pool.getProperty("p1")));
assertTrue (1 == Poco::AnyCast<int>(pool.getProperty("p1")));
try { pool.getProperty("r1"); fail ("must fail"); }
catch ( Poco::NotFoundException& ) { }
assert (pool.capacity() == 4);
assert (pool.allocated() == 0);
assert (pool.idle() == 0);
assert (pool.available() == 4);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 0);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 4);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Session s1(pool.get());
assert (s1.getFeature("f1"));
assert (1 == Poco::AnyCast<int>(s1.getProperty("p1")));
assertTrue (s1.getFeature("f1"));
assertTrue (1 == Poco::AnyCast<int>(s1.getProperty("p1")));
try { pool.setFeature("f1", true); fail ("must fail"); }
catch ( Poco::InvalidAccessException& ) { }
@ -75,63 +75,63 @@ void SessionPoolTest::testSessionPool()
try { pool.setProperty("p1", 1); fail ("must fail"); }
catch ( Poco::InvalidAccessException& ) { }
assert (pool.capacity() == 4);
assert (pool.allocated() == 1);
assert (pool.idle() == 0);
assert (pool.available() == 3);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 1);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 3);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Session s2(pool.get("f1", false));
assert (!s2.getFeature("f1"));
assert (1 == Poco::AnyCast<int>(s2.getProperty("p1")));
assertTrue (!s2.getFeature("f1"));
assertTrue (1 == Poco::AnyCast<int>(s2.getProperty("p1")));
assert (pool.capacity() == 4);
assert (pool.allocated() == 2);
assert (pool.idle() == 0);
assert (pool.available() == 2);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 2);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 2);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
{
Session s3(pool.get("p1", 2));
assert (s3.getFeature("f1"));
assert (2 == Poco::AnyCast<int>(s3.getProperty("p1")));
assertTrue (s3.getFeature("f1"));
assertTrue (2 == Poco::AnyCast<int>(s3.getProperty("p1")));
assert (pool.capacity() == 4);
assert (pool.allocated() == 3);
assert (pool.idle() == 0);
assert (pool.available() == 1);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 3);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 1);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
}
assert (pool.capacity() == 4);
assert (pool.allocated() == 3);
assert (pool.idle() == 1);
assert (pool.available() == 2);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 3);
assertTrue (pool.idle() == 1);
assertTrue (pool.available() == 2);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Session s4(pool.get());
assert (s4.getFeature("f1"));
assert (1 == Poco::AnyCast<int>(s4.getProperty("p1")));
assertTrue (s4.getFeature("f1"));
assertTrue (1 == Poco::AnyCast<int>(s4.getProperty("p1")));
assert (pool.capacity() == 4);
assert (pool.allocated() == 3);
assert (pool.idle() == 0);
assert (pool.available() == 1);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 3);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 1);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Session s5(pool.get());
assert (pool.capacity() == 4);
assert (pool.allocated() == 4);
assert (pool.idle() == 0);
assert (pool.available() == 0);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 4);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 0);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
try
{
@ -141,12 +141,12 @@ void SessionPoolTest::testSessionPool()
catch (SessionPoolExhaustedException&) { }
s5.close();
assert (pool.capacity() == 4);
assert (pool.allocated() == 4);
assert (pool.idle() == 1);
assert (pool.available() == 1);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 4);
assertTrue (pool.idle() == 1);
assertTrue (pool.available() == 1);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
try
{
@ -156,45 +156,45 @@ void SessionPoolTest::testSessionPool()
catch (SessionUnavailableException&) { }
s4.close();
assert (pool.capacity() == 4);
assert (pool.allocated() == 4);
assert (pool.idle() == 2);
assert (pool.available() == 2);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 4);
assertTrue (pool.idle() == 2);
assertTrue (pool.available() == 2);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Thread::sleep(5000); // time to clean up idle sessions
assert (pool.capacity() == 4);
assert (pool.allocated() == 2);
assert (pool.idle() == 0);
assert (pool.available() == 2);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 2);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 2);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
Session s6(pool.get());
assert (pool.capacity() == 4);
assert (pool.allocated() == 3);
assert (pool.idle() == 0);
assert (pool.available() == 1);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 3);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 1);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
s6.setFeature("connected", false);
assert (pool.dead() == 1);
assertTrue (pool.dead() == 1);
s6.close();
assert (pool.capacity() == 4);
assert (pool.allocated() == 2);
assert (pool.idle() == 0);
assert (pool.available() == 2);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 2);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 2);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
assert (pool.isActive());
assertTrue (pool.isActive());
pool.shutdown();
assert (!pool.isActive());
assertTrue (!pool.isActive());
try
{
Session s7(pool.get());
@ -202,12 +202,12 @@ void SessionPoolTest::testSessionPool()
}
catch (InvalidAccessException&) { }
assert (pool.capacity() == 4);
assert (pool.allocated() == 0);
assert (pool.idle() == 0);
assert (pool.available() == 0);
assert (pool.dead() == 0);
assert (pool.allocated() == pool.used() + pool.idle());
assertTrue (pool.capacity() == 4);
assertTrue (pool.allocated() == 0);
assertTrue (pool.idle() == 0);
assertTrue (pool.available() == 0);
assertTrue (pool.dead() == 0);
assertTrue (pool.allocated() == pool.used() + pool.idle());
}
@ -216,36 +216,36 @@ void SessionPoolTest::testSessionPoolContainer()
SessionPoolContainer spc;
AutoPtr<SessionPool> pPool = new SessionPool("TeSt", "Cs");
spc.add(pPool);
assert (pPool->isActive());
assert (spc.isActive("test", "cs"));
assert (spc.isActive("test:///cs"));
assert (spc.has("test:///cs"));
assert (1 == spc.count());
assertTrue (pPool->isActive());
assertTrue (spc.isActive("test", "cs"));
assertTrue (spc.isActive("test:///cs"));
assertTrue (spc.has("test:///cs"));
assertTrue (1 == spc.count());
Poco::Data::Session sess = spc.get("test:///cs");
assert ("test" == sess.impl()->connectorName());
assert ("Cs" == sess.impl()->connectionString());
assert ("test:///Cs" == sess.uri());
assertTrue ("test" == sess.impl()->connectorName());
assertTrue ("Cs" == sess.impl()->connectionString());
assertTrue ("test:///Cs" == sess.uri());
try { spc.add(pPool); fail ("must fail"); }
catch (SessionPoolExistsException&) { }
pPool->shutdown();
assert (!pPool->isActive());
assert (!spc.isActive("test", "cs"));
assert (!spc.isActive("test:///cs"));
assertTrue (!pPool->isActive());
assertTrue (!spc.isActive("test", "cs"));
assertTrue (!spc.isActive("test:///cs"));
spc.remove(pPool->name());
assert (!spc.has("test:///cs"));
assert (!spc.isActive("test", "cs"));
assert (!spc.isActive("test:///cs"));
assert (0 == spc.count());
assertTrue (!spc.has("test:///cs"));
assertTrue (!spc.isActive("test", "cs"));
assertTrue (!spc.isActive("test:///cs"));
assertTrue (0 == spc.count());
try { spc.get("test"); fail ("must fail"); }
catch (NotFoundException&) { }
spc.add("tEsT", "cs");
spc.add("TeSt", "cs");//duplicate request, must be silently ignored
assert (1 == spc.count());
assertTrue (1 == spc.count());
spc.remove("TesT:///cs");
assert (0 == spc.count());
assertTrue (0 == spc.count());
try { spc.get("test"); fail ("must fail"); }
catch (NotFoundException&) { }
}

View File

@ -29,18 +29,18 @@ void DoubleByteEncodingTest::testSingleByte()
{
Poco::ISO8859_4Encoding enc;
assert (std::string(enc.canonicalName()) == "ISO-8859-4");
assert (enc.isA("Latin4"));
assertTrue (std::string(enc.canonicalName()) == "ISO-8859-4");
assertTrue (enc.isA("Latin4"));
unsigned char seq1[] = { 0xF8 }; // 0x00F8 LATIN SMALL LETTER O WITH STROKE
assert (enc.convert(seq1) == 0x00F8);
assert (enc.queryConvert(seq1, 1) == 0x00F8);
assert (enc.sequenceLength(seq1, 1) == 1);
assertTrue (enc.convert(seq1) == 0x00F8);
assertTrue (enc.queryConvert(seq1, 1) == 0x00F8);
assertTrue (enc.sequenceLength(seq1, 1) == 1);
unsigned char seq2[] = { 0xF9 }; // 0x0173 LATIN SMALL LETTER U WITH OGONEK
assert (enc.convert(seq2) == 0x0173);
assert (enc.queryConvert(seq2, 1) == 0x0173);
assert (enc.sequenceLength(seq2, 1) == 1);
assertTrue (enc.convert(seq2) == 0x0173);
assertTrue (enc.queryConvert(seq2, 1) == 0x0173);
assertTrue (enc.sequenceLength(seq2, 1) == 1);
}
@ -50,13 +50,13 @@ void DoubleByteEncodingTest::testSingleByteReverse()
unsigned char seq[2];
assert (enc.convert(0x00F8, seq, 2) == 1);
assert (seq[0] == 0xF8);
assertTrue (enc.convert(0x00F8, seq, 2) == 1);
assertTrue (seq[0] == 0xF8);
assert (enc.convert(0x0173, seq, 2) == 1);
assert (seq[0] == 0xF9);
assertTrue (enc.convert(0x0173, seq, 2) == 1);
assertTrue (seq[0] == 0xF9);
assert (enc.convert(0x3000, seq, 2) == 0);
assertTrue (enc.convert(0x3000, seq, 2) == 0);
}
@ -64,26 +64,26 @@ void DoubleByteEncodingTest::testDoubleByte()
{
Poco::Windows950Encoding enc;
assert (std::string(enc.canonicalName()) == "windows-950");
assert (enc.isA("Windows-950"));
assert (enc.isA("cp950"));
assertTrue (std::string(enc.canonicalName()) == "windows-950");
assertTrue (enc.isA("Windows-950"));
assertTrue (enc.isA("cp950"));
unsigned char seq1[] = { 0x41 }; // 0x0041 LATIN CAPITAL LETTER A
assert (enc.convert(seq1) == 0x0041);
assert (enc.queryConvert(seq1, 1) == 0x0041);
assert (enc.sequenceLength(seq1, 1) == 1);
assertTrue (enc.convert(seq1) == 0x0041);
assertTrue (enc.queryConvert(seq1, 1) == 0x0041);
assertTrue (enc.sequenceLength(seq1, 1) == 1);
unsigned char seq2[] = { 0xA1, 0x40 }; // 0x3000 IDEOGRAPHIC SPACE
assert (enc.convert(seq2) == 0x3000);
assert (enc.queryConvert(seq2, 1) == -2);
assert (enc.queryConvert(seq2, 2) == 0x3000);
assert (enc.sequenceLength(seq2, 1) == 2);
assert (enc.sequenceLength(seq2, 2) == 2);
assertTrue (enc.convert(seq2) == 0x3000);
assertTrue (enc.queryConvert(seq2, 1) == -2);
assertTrue (enc.queryConvert(seq2, 2) == 0x3000);
assertTrue (enc.sequenceLength(seq2, 1) == 2);
assertTrue (enc.sequenceLength(seq2, 2) == 2);
unsigned char seq3[] = { 0x92 }; // invalid
assert (enc.convert(seq3) == -1);
assert (enc.queryConvert(seq3, 1) == -1);
assert (enc.sequenceLength(seq3, 1) == -1);
assertTrue (enc.convert(seq3) == -1);
assertTrue (enc.queryConvert(seq3, 1) == -1);
assertTrue (enc.sequenceLength(seq3, 1) == -1);
}
@ -93,14 +93,14 @@ void DoubleByteEncodingTest::testDoubleByteReverse()
unsigned char seq[2];
assert (enc.convert(0x0041, seq, 2) == 1);
assert (seq[0] == 0x41);
assertTrue (enc.convert(0x0041, seq, 2) == 1);
assertTrue (seq[0] == 0x41);
assert (enc.convert(0x3000, seq, 2) == 2);
assert (seq[0] == 0xA1);
assert (seq[1] == 0x40);
assertTrue (enc.convert(0x3000, seq, 2) == 2);
assertTrue (seq[0] == 0xA1);
assertTrue (seq[1] == 0x40);
assert (enc.convert(0x3004, seq, 2) == 0);
assertTrue (enc.convert(0x3004, seq, 2) == 0);
}

View File

@ -1,8 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2015
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "Foundation_vs140.vcxproj", "{B01196CC-B693-4548-8464-2FF60499E73F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs140.vcxproj", "{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs140.vcxproj", "{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
ProjectSection(ProjectDependencies) = postProject
{B01196CC-B693-4548-8464-2FF60499E73F} = {B01196CC-B693-4548-8464-2FF60499E73F}
EndProjectSection
@ -10,49 +12,49 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32
debug_static_mt|Win32 = debug_static_mt|Win32
release_static_mt|Win32 = release_static_mt|Win32
debug_static_md|Win32 = debug_static_md|Win32
debug_static_mt|Win32 = debug_static_mt|Win32
release_shared|Win32 = release_shared|Win32
release_static_md|Win32 = release_static_md|Win32
release_static_mt|Win32 = release_static_mt|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_shared|Win32.Build.0 = debug_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.ActiveCfg = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.Build.0 = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.Deploy.0 = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.ActiveCfg = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.Build.0 = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_shared|Win32.Deploy.0 = release_shared|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_md|Win32.Build.0 = release_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_shared|Win32.Build.0 = debug_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_shared|Win32.ActiveCfg = release_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_shared|Win32.Build.0 = release_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_shared|Win32.Deploy.0 = release_shared|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_md|Win32.Build.0 = release_static_md|Win32
{C812E0B9-69A9-4FA1-A1D4-161CF677BD10}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{B01196CC-B693-4548-8464-2FF60499E73F}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.Build.0 = debug_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.ActiveCfg = release_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.Build.0 = release_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.Deploy.0 = release_shared|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_md|Win32.Build.0 = release_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -102,12 +102,12 @@ void ActiveDispatcherTest::testWait()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assertTrue (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -115,7 +115,7 @@ void ActiveDispatcherTest::testWaitInterval()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assertTrue (!result.available());
try
{
result.wait(100);
@ -126,9 +126,9 @@ void ActiveDispatcherTest::testWaitInterval()
}
activeObj.cont();
result.wait(10000);
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -136,13 +136,13 @@ void ActiveDispatcherTest::testTryWait()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assert (!result.tryWait(200));
assertTrue (!result.available());
assertTrue (!result.tryWait(200));
activeObj.cont();
assert (result.tryWait(10000));
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.tryWait(10000));
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -151,10 +151,10 @@ void ActiveDispatcherTest::testFailure()
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(100);
result.wait();
assert (result.available());
assert (result.failed());
assertTrue (result.available());
assertTrue (result.failed());
std::string msg = result.error();
assert (msg == "n == 100");
assertTrue (msg == "n == 100");
}
@ -162,11 +162,11 @@ void ActiveDispatcherTest::testVoid()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoid(123);
assert (!result.available());
assertTrue (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assertTrue (result.available());
assertTrue (!result.failed());
}
@ -174,11 +174,11 @@ void ActiveDispatcherTest::testVoidInOut()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoidInOut();
assert (!result.available());
assertTrue (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assertTrue (result.available());
assertTrue (!result.failed());
}
@ -186,12 +186,12 @@ void ActiveDispatcherTest::testVoidIn()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testVoidIn();
assert (!result.available());
assertTrue (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assert (result.data() == 123);
assertTrue (result.available());
assertTrue (!result.failed());
assertTrue (result.data() == 123);
}

View File

@ -104,12 +104,12 @@ void ActiveMethodTest::testWait()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assertTrue (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -119,37 +119,37 @@ void ActiveMethodTest::testCopy()
ActiveObject::IntIntType ii = activeObj.testMethod;
ActiveResult<int> rii = ii(123);
assert (!rii.available());
assertTrue (!rii.available());
activeObj.cont();
rii.wait();
assert (rii.available());
assert (rii.data() == 123);
assert (!rii.failed());
assertTrue (rii.available());
assertTrue (rii.data() == 123);
assertTrue (!rii.failed());
ActiveObject::VoidIntType vi = activeObj.testVoid;
ActiveResult<void> rvi = vi(123);
assert (!rvi.available());
assertTrue (!rvi.available());
activeObj.cont();
rvi.wait();
assert (rvi.available());
assert (!rvi.failed());
assertTrue (rvi.available());
assertTrue (!rvi.failed());
ActiveObject::VoidVoidType vv = activeObj.testVoidInOut;
ActiveResult<void> rvv = vv();
assert (!rvv.available());
assertTrue (!rvv.available());
activeObj.cont();
rvv.wait();
assert (rvv.available());
assert (!rvv.failed());
assertTrue (rvv.available());
assertTrue (!rvv.failed());
ActiveObject::IntVoidType iv = activeObj.testVoidIn;
ActiveResult<int> riv = iv();
assert (!riv.available());
assertTrue (!riv.available());
activeObj.cont();
riv.wait();
assert (riv.available());
assert (riv.data() == 123);
assert (!riv.failed());
assertTrue (riv.available());
assertTrue (riv.data() == 123);
assertTrue (!riv.failed());
}
@ -157,7 +157,7 @@ void ActiveMethodTest::testWaitInterval()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assertTrue (!result.available());
try
{
result.wait(100);
@ -168,9 +168,9 @@ void ActiveMethodTest::testWaitInterval()
}
activeObj.cont();
result.wait(10000);
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -178,13 +178,13 @@ void ActiveMethodTest::testTryWait()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(123);
assert (!result.available());
assert (!result.tryWait(200));
assertTrue (!result.available());
assertTrue (!result.tryWait(200));
activeObj.cont();
assert (result.tryWait(10000));
assert (result.available());
assert (result.data() == 123);
assert (!result.failed());
assertTrue (result.tryWait(10000));
assertTrue (result.available());
assertTrue (result.data() == 123);
assertTrue (!result.failed());
}
@ -193,10 +193,10 @@ void ActiveMethodTest::testFailure()
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testMethod(100);
result.wait();
assert (result.available());
assert (result.failed());
assertTrue (result.available());
assertTrue (result.failed());
std::string msg = result.error();
assert (msg == "n == 100");
assertTrue (msg == "n == 100");
}
@ -206,8 +206,8 @@ void ActiveMethodTest::testVoidOut()
ActiveResult<void> result = activeObj.testVoid(101);
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assertTrue (result.available());
assertTrue (!result.failed());
}
@ -217,8 +217,8 @@ void ActiveMethodTest::testVoidInOut()
ActiveResult<void> result = activeObj.testVoidInOut();
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assertTrue (result.available());
assertTrue (!result.failed());
}
@ -228,9 +228,9 @@ void ActiveMethodTest::testVoidIn()
ActiveResult<int> result = activeObj.testVoidIn();
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assert (result.data() == 123);
assertTrue (result.available());
assertTrue (!result.failed());
assertTrue (result.data() == 123);
}

View File

@ -71,14 +71,14 @@ ActivityTest::~ActivityTest()
void ActivityTest::testActivity()
{
ActiveObject activeObj;
assert (activeObj.activity().isStopped());
assertTrue (activeObj.activity().isStopped());
activeObj.activity().start();
assert (!activeObj.activity().isStopped());
assertTrue (!activeObj.activity().isStopped());
Thread::sleep(1000);
assert (activeObj.activity().isRunning());
assertTrue (activeObj.activity().isRunning());
activeObj.activity().stop();
activeObj.activity().wait();
assert (activeObj.count() > 0);
assertTrue (activeObj.count() > 0);
}

View File

@ -54,9 +54,9 @@ void AnyTest::testDefaultCtor()
{
const Any value;
assert (value.empty());
assert (0 == AnyCast<int>(&value));
assert (value.type() == typeid(void));
assertTrue (value.empty());
assertTrue (0 == AnyCast<int>(&value));
assertTrue (value.type() == typeid(void));
}
@ -65,12 +65,12 @@ void AnyTest::testConvertingCtor()
std::string text = "test message";
Any value = text;
assert (!value.empty());
assert (value.type() == typeid(std::string));
assert (0 == AnyCast<int>(&value));
assert (0 != AnyCast<std::string>(&value));
assert (AnyCast<std::string>(value) == text);
assert (AnyCast<std::string>(&value) != &text);
assertTrue (!value.empty());
assertTrue (value.type() == typeid(std::string));
assertTrue (0 == AnyCast<int>(&value));
assertTrue (0 != AnyCast<std::string>(&value));
assertTrue (AnyCast<std::string>(value) == text);
assertTrue (AnyCast<std::string>(&value) != &text);
}
@ -79,11 +79,11 @@ void AnyTest::testCopyCtor()
std::string text = "test message";
Any original = text, copy = original;
assert (!copy.empty());
assert (original.type() == copy.type());
assert (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assert (text == AnyCast<std::string>(copy));
assert (AnyCast<std::string>(&original) != AnyCast<std::string>(&copy));
assertTrue (!copy.empty());
assertTrue (original.type() == copy.type());
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assertTrue (text == AnyCast<std::string>(copy));
assertTrue (AnyCast<std::string>(&original) != AnyCast<std::string>(&copy));
}
@ -93,19 +93,19 @@ void AnyTest::testCopyAssign()
Any original = text, copy;
Any* assignResult = &(copy = original);
assert (!copy.empty());
assert (original.type() == copy.type());
assert (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assert (text == AnyCast<std::string>(copy));
assert (AnyCast<std::string>(&original) != AnyCast<std::string>(&copy));
assert (assignResult == &copy);
assertTrue (!copy.empty());
assertTrue (original.type() == copy.type());
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assertTrue (text == AnyCast<std::string>(copy));
assertTrue (AnyCast<std::string>(&original) != AnyCast<std::string>(&copy));
assertTrue (assignResult == &copy);
// test self assignment
Any& ref = original;
original = ref;
assert (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
original = original;
assert (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
assertTrue (AnyCast<std::string>(original) == AnyCast<std::string>(copy));
}
@ -115,13 +115,13 @@ void AnyTest::testConvertingAssign()
Any value;
Any* assignResult = &(value = text);
assert (!value.empty());
assert (value.type() == typeid(std::string));
assert (0 == AnyCast<int>(&value));
assert (0 != AnyCast<std::string>(&value));
assert (AnyCast<std::string>(value) == text);
assert (AnyCast<std::string>(&value) != &text);
assert (assignResult == &value);
assertTrue (!value.empty());
assertTrue (value.type() == typeid(std::string));
assertTrue (0 == AnyCast<int>(&value));
assertTrue (0 != AnyCast<std::string>(&value));
assertTrue (AnyCast<std::string>(value) == text);
assertTrue (AnyCast<std::string>(&value) != &text);
assertTrue (assignResult == &value);
}
@ -136,17 +136,17 @@ void AnyTest::testCastToReference()
int const volatile& ra_cv = AnyCast<int const volatile&>(a);
// cv references to same obj
assert (&ra == &ra_c && &ra == &ra_v && &ra == &ra_cv);
assertTrue (&ra == &ra_c && &ra == &ra_v && &ra == &ra_cv);
int const & rb_c = AnyCast<int const &>(b);
int const volatile & rb_cv = AnyCast<int const volatile &>(b);
assert (&rb_c == &rb_cv); // cv references to copied const obj
assert (&ra != &rb_c); // copies hold different objects
assertTrue (&rb_c == &rb_cv); // cv references to copied const obj
assertTrue (&ra != &rb_c); // copies hold different objects
++ra;
int incremented = AnyCast<int>(a);
assert (incremented == 138); // increment by reference changes value
assertTrue (incremented == 138); // increment by reference changes value
try
{
@ -185,15 +185,15 @@ void AnyTest::testSwap()
std::string* originalPtr = AnyCast<std::string>(&original);
Any* swapResult = &original.swap(swapped);
assert (original.empty());
assert (!swapped.empty());
assert (swapped.type() == typeid(std::string));
assert (text == AnyCast<std::string>(swapped));
assert (0 != originalPtr);
assertTrue (original.empty());
assertTrue (!swapped.empty());
assertTrue (swapped.type() == typeid(std::string));
assertTrue (text == AnyCast<std::string>(swapped));
assertTrue (0 != originalPtr);
#ifdef POCO_NO_SOO // pointers only match when heap-allocated
assert (originalPtr == AnyCast<std::string>(&swapped));
assertTrue (originalPtr == AnyCast<std::string>(&swapped));
#endif
assert (swapResult == &original);
assertTrue (swapResult == &original);
}
@ -203,29 +203,29 @@ void AnyTest::testEmptyCopy()
Any copied = null, assigned;
assigned = null;
assert (null.empty());
assert (copied.empty());
assert (assigned.empty());
assertTrue (null.empty());
assertTrue (copied.empty());
assertTrue (assigned.empty());
}
void AnyTest::testInt()
{
Any e;
assert (e.empty());
assertTrue (e.empty());
Any a = 13;
assert (a.type() == typeid(int));
assertTrue (a.type() == typeid(int));
int* i = AnyCast<int>(&a);
assert (*i == 13);
assertTrue (*i == 13);
Any b = a;
assert (b.type() == typeid(int));
assertTrue (b.type() == typeid(int));
int *cpyI = AnyCast<int>(&b);
assert (*cpyI == *i);
assertTrue (*cpyI == *i);
*cpyI = 20;
assert (*cpyI != *i);
assertTrue (*cpyI != *i);
std::string* s = AnyCast<std::string>(&a);
assert (s == NULL);
assertTrue (s == NULL);
int POCO_UNUSED tmp = AnyCast<int>(a);
const Any c = a;
@ -238,14 +238,14 @@ void AnyTest::testComplexType()
SomeClass str(13,std::string("hello"));
Any a = str;
Any b = a;
assert (a.type() == typeid(SomeClass));
assert (b.type() == typeid(SomeClass));
assertTrue (a.type() == typeid(SomeClass));
assertTrue (b.type() == typeid(SomeClass));
SomeClass str2 = AnyCast<SomeClass>(a);
assert (str == str2);
assertTrue (str == str2);
const SomeClass& strCRef = RefAnyCast<SomeClass>(a);
assert (str == strCRef);
assertTrue (str == strCRef);
SomeClass& strRef = RefAnyCast<SomeClass>(a);
assert (str == strRef);
assertTrue (str == strRef);
}
@ -256,17 +256,17 @@ void AnyTest::testVector()
tmp.push_back(2);
tmp.push_back(3);
Any a = tmp;
assert (a.type() == typeid(std::vector<int>));
assertTrue (a.type() == typeid(std::vector<int>));
std::vector<int> tmp2 = AnyCast<std::vector<int> >(a);
assert (tmp2.size() == 3);
assertTrue (tmp2.size() == 3);
const std::vector<int>& vecCRef = RefAnyCast<std::vector<int> >(a);
std::vector<int>& vecRef = RefAnyCast<std::vector<int> >(a);
assert (vecRef[0] == 1);
assert (vecRef[1] == 2);
assert (vecRef[2] == 3);
assertTrue (vecRef[0] == 1);
assertTrue (vecRef[1] == 2);
assertTrue (vecRef[2] == 3);
vecRef[0] = 0;
assert (vecRef[0] == vecCRef[0]);
assertTrue (vecRef[0] == vecCRef[0]);
}

View File

@ -45,7 +45,7 @@ void ArrayTest::testConstruction()
FloatArray b(a);
FloatArray c;
c = a;
assert (a==b && a==c);
assertTrue (a==b && a==c);
typedef Poco::Array<double,6> DArray;
typedef Poco::Array<int,6> IArray;
@ -63,7 +63,7 @@ void ArrayTest::testConstruction()
}
for (unsigned i=0; i<g.size(); ++i) {
assert(g[i]._data == i);
assertTrue (g[i]._data == i);
}
@ -76,30 +76,30 @@ void ArrayTest::testOperations()
Array a = { { 1 } };
// use some common STL container operations
assert(a.size() == SIZE);
assert(a.max_size() == SIZE);
assert(a.empty() == false);
assert(a.front() == a[0]);
assert(a.back() == a[a.size()-1]);
//assert(a.data() == &a[0]);
assertTrue (a.size() == SIZE);
assertTrue (a.max_size() == SIZE);
assertTrue (a.empty() == false);
assertTrue (a.front() == a[0]);
assertTrue (a.back() == a[a.size()-1]);
//assertTrue (a.data() == &a[0]);
// assign
a.assign(100);
for(int i = 0; i<a.size(); i++){
assert(a[i] == 100);
assertTrue (a[i] == 100);
}
// swap
Array b;
b.assign(10);
for(int i=0; i<SIZE; i++){
assert(a[i] == 100);
assert(b[i] == 10);
assertTrue (a[i] == 100);
assertTrue (b[i] == 10);
}
a.swap(b);
for(int i=0; i<SIZE; i++){
assert(a[i] == 10);
assert(b[i] == 100);
assertTrue (a[i] == 10);
assertTrue (b[i] == 100);
}
}
@ -109,18 +109,18 @@ void ArrayTest::testContainer()
const int SIZE = 2;
typedef Poco::Array<int,SIZE> Array;
Array a = {{1, 2}};
assert(a[0] == 1);
assert(a[1] == 2);
assertTrue (a[0] == 1);
assertTrue (a[1] == 2);
typedef std::vector<Array> ArrayVec;
ArrayVec container;
container.push_back(a);
container.push_back(a);
assert(container[0][0] == 1);
assert(container[0][1] == 2);
assert(container[1][0] == 1);
assert(container[1][1] == 2);
assertTrue (container[0][0] == 1);
assertTrue (container[0][1] == 2);
assertTrue (container[1][0] == 1);
assertTrue (container[1][1] == 2);
}
void ArrayTest::testIterator()
@ -164,14 +164,14 @@ void ArrayTest::testAlgorithm()
}
for (unsigned i=0; i<a.size(); ++i) {
assert(a[i] == b[i]);
assertTrue (a[i] == b[i]);
}
// change order using an STL algorithm
std::reverse(a.begin(),a.end());
for (unsigned i=0; i<a.size(); ++i) {
assert(a[SIZE-i-1] == b[i]);
assertTrue (a[SIZE-i-1] == b[i]);
}
std::reverse(a.begin(),a.end());
@ -182,7 +182,7 @@ void ArrayTest::testAlgorithm()
std::negate<int>()); // operation
for (unsigned i=0; i<a.size(); ++i) {
assert(a[i] == -b[i]);
assertTrue (a[i] == -b[i]);
}
}
@ -200,10 +200,10 @@ void ArrayTest::testMultiLevelArray()
a[1][1] = 4;
MultiArray b = a;
assert(b[0][0] == 1);
assert(b[0][1] == 2);
assert(b[1][0] == 3);
assert(b[1][1] == 4);
assertTrue (b[0][0] == 1);
assertTrue (b[0][1] == 2);
assertTrue (b[1][0] == 3);
assertTrue (b[1][1] == 4);
}
void ArrayTest::setUp()

View File

@ -79,21 +79,21 @@ void AutoPtrTest::testAutoPtr()
{
{
AutoPtr<TestObj> ptr = new TestObj;
assert (ptr->rc() == 1);
assertTrue (ptr->rc() == 1);
AutoPtr<TestObj> ptr2 = ptr;
assert (ptr->rc() == 2);
assertTrue (ptr->rc() == 2);
ptr2 = new TestObj;
assert (ptr->rc() == 1);
assertTrue (ptr->rc() == 1);
AutoPtr<TestObj> ptr3;
ptr3 = ptr2;
assert (ptr2->rc() == 2);
assertTrue (ptr2->rc() == 2);
ptr3 = new TestObj;
assert (ptr2->rc() == 1);
assertTrue (ptr2->rc() == 1);
ptr3 = ptr2;
assert (ptr2->rc() == 2);
assert (TestObj::count() > 0);
assertTrue (ptr2->rc() == 2);
assertTrue (TestObj::count() > 0);
}
assert (TestObj::count() == 0);
assertTrue (TestObj::count() == 0);
}
@ -109,59 +109,59 @@ void AutoPtrTest::testOps()
pTO1 = pTO2;
pTO2 = pTmp;
}
assert (pTO1 < pTO2);
assertTrue (pTO1 < pTO2);
ptr1 = pTO1;
AutoPtr<TestObj> ptr2 = pTO2;
AutoPtr<TestObj> ptr3 = ptr1;
AutoPtr<TestObj> ptr4;
assert (ptr1.get() == pTO1);
assert (ptr1 == pTO1);
assert (ptr2.get() == pTO2);
assert (ptr2 == pTO2);
assert (ptr3.get() == pTO1);
assert (ptr3 == pTO1);
assertTrue (ptr1.get() == pTO1);
assertTrue (ptr1 == pTO1);
assertTrue (ptr2.get() == pTO2);
assertTrue (ptr2 == pTO2);
assertTrue (ptr3.get() == pTO1);
assertTrue (ptr3 == pTO1);
assert (ptr1 == pTO1);
assert (ptr1 != pTO2);
assert (ptr1 < pTO2);
assert (ptr1 <= pTO2);
assert (ptr2 > pTO1);
assert (ptr2 >= pTO1);
assertTrue (ptr1 == pTO1);
assertTrue (ptr1 != pTO2);
assertTrue (ptr1 < pTO2);
assertTrue (ptr1 <= pTO2);
assertTrue (ptr2 > pTO1);
assertTrue (ptr2 >= pTO1);
assert (ptr1 == ptr3);
assert (ptr1 != ptr2);
assert (ptr1 < ptr2);
assert (ptr1 <= ptr2);
assert (ptr2 > ptr1);
assert (ptr2 >= ptr1);
assertTrue (ptr1 == ptr3);
assertTrue (ptr1 != ptr2);
assertTrue (ptr1 < ptr2);
assertTrue (ptr1 <= ptr2);
assertTrue (ptr2 > ptr1);
assertTrue (ptr2 >= ptr1);
ptr1 = pTO1;
ptr2 = pTO2;
ptr1.swap(ptr2);
assert (ptr2.get() == pTO1);
assert (ptr1.get() == pTO2);
assertTrue (ptr2.get() == pTO1);
assertTrue (ptr1.get() == pTO2);
try
{
assert (ptr4->rc() > 0);
assertTrue (ptr4->rc() > 0);
fail ("must throw NullPointerException");
}
catch (NullPointerException&)
{
}
assert (!(ptr4 == ptr1));
assert (!(ptr4 == ptr2));
assert (ptr4 != ptr1);
assert (ptr4 != ptr2);
assertTrue (!(ptr4 == ptr1));
assertTrue (!(ptr4 == ptr2));
assertTrue (ptr4 != ptr1);
assertTrue (ptr4 != ptr2);
ptr4 = ptr2;
assert (ptr4 == ptr2);
assert (!(ptr4 != ptr2));
assertTrue (ptr4 == ptr2);
assertTrue (!(ptr4 != ptr2));
assert (!(!ptr1));
assertTrue (!(!ptr1));
ptr1 = 0;
assert (!ptr1);
assertTrue (!ptr1);
}

View File

@ -78,9 +78,9 @@ void AutoReleasePoolTest::testAutoReleasePool()
AutoReleasePool<TestObj> arp;
arp.add(new TestObj);
arp.add(new TestObj);
assert (TestObj::count() == 2);
assertTrue (TestObj::count() == 2);
arp.release();
assert (TestObj::count() == 0);
assertTrue (TestObj::count() == 0);
}

View File

@ -39,35 +39,35 @@ void Base32Test::testEncoder()
Base32Encoder encoder(str);
encoder << std::string("\00\01\02\03\04\05", 6);
encoder.close();
assert (str.str() == "AAAQEAYEAU======");
assertTrue (str.str() == "AAAQEAYEAU======");
}
{
std::ostringstream str;
Base32Encoder encoder(str);
encoder << std::string("\00\01\02\03", 4);
encoder.close();
assert (str.str() == "AAAQEAY=");
assertTrue (str.str() == "AAAQEAY=");
}
{
std::ostringstream str;
Base32Encoder encoder(str, false);
encoder << "ABCDEF";
encoder.close();
assert (str.str() == "IFBEGRCFIY");
assertTrue (str.str() == "IFBEGRCFIY");
}
{
std::ostringstream str;
Base32Encoder encoder(str);
encoder << "ABCDEF";
encoder.close();
assert (str.str() == "IFBEGRCFIY======");
assertTrue (str.str() == "IFBEGRCFIY======");
}
{
std::ostringstream str;
Base32Encoder encoder(str);
encoder << "ABCDE";
encoder.close();
assert (str.str() == "IFBEGRCF");
assertTrue (str.str() == "IFBEGRCF");
}
}
@ -77,41 +77,41 @@ void Base32Test::testDecoder()
{
std::istringstream istr("AAAQEAYEAU======");
Base32Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == 5);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == 5);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAAQEAYE");
Base32Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAAQEAY=");
Base32Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("IFBEGRCFIY======");
Base32Decoder decoder(istr);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "ABCDEF");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("QUJD#REVG");
@ -120,12 +120,12 @@ void Base32Test::testDecoder()
try
{
decoder >> s;
assert (decoder.bad());
assertTrue (decoder.bad());
}
catch (DataFormatException&)
{
}
assert (!decoder.eof());
assertTrue (!decoder.eof());
}
}
@ -142,7 +142,7 @@ void Base32Test::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == "The quick brown fox jumped over the lazy dog.");
assertTrue (s == "The quick brown fox jumped over the lazy dog.");
}
{
std::string src;
@ -155,7 +155,7 @@ void Base32Test::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == src);
assertTrue (s == src);
}
}

View File

@ -39,28 +39,28 @@ void Base64Test::testEncoder()
Base64Encoder encoder(str);
encoder << std::string("\00\01\02\03\04\05", 6);
encoder.close();
assert (str.str() == "AAECAwQF");
assertTrue (str.str() == "AAECAwQF");
}
{
std::ostringstream str;
Base64Encoder encoder(str);
encoder << std::string("\00\01\02\03", 4);
encoder.close();
assert (str.str() == "AAECAw==");
assertTrue (str.str() == "AAECAw==");
}
{
std::ostringstream str;
Base64Encoder encoder(str);
encoder << "ABCDEF";
encoder.close();
assert (str.str() == "QUJDREVG");
assertTrue (str.str() == "QUJDREVG");
}
{
std::ostringstream str;
Base64Encoder encoder(str);
encoder << "!@#$%^&*()_~<>";
encoder.close();
assert (str.str() == "IUAjJCVeJiooKV9+PD4=");
assertTrue (str.str() == "IUAjJCVeJiooKV9+PD4=");
}
}
@ -72,28 +72,28 @@ void Base64Test::testEncoderURL()
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING);
encoder << std::string("\00\01\02\03\04\05", 6);
encoder.close();
assert (str.str() == "AAECAwQF");
assertTrue (str.str() == "AAECAwQF");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING);
encoder << std::string("\00\01\02\03", 4);
encoder.close();
assert (str.str() == "AAECAw==");
assertTrue (str.str() == "AAECAw==");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING);
encoder << "ABCDEF";
encoder.close();
assert (str.str() == "QUJDREVG");
assertTrue (str.str() == "QUJDREVG");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING);
encoder << "!@#$%^&*()_~<>";
encoder.close();
assert (str.str() == "IUAjJCVeJiooKV9-PD4=");
assertTrue (str.str() == "IUAjJCVeJiooKV9-PD4=");
}
}
@ -105,28 +105,28 @@ void Base64Test::testEncoderNoPadding()
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING | Poco::BASE64_NO_PADDING);
encoder << std::string("\00\01\02\03\04\05", 6);
encoder.close();
assert (str.str() == "AAECAwQF");
assertTrue (str.str() == "AAECAwQF");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING | Poco::BASE64_NO_PADDING);
encoder << std::string("\00\01\02\03", 4);
encoder.close();
assert (str.str() == "AAECAw");
assertTrue (str.str() == "AAECAw");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING | Poco::BASE64_NO_PADDING);
encoder << "ABCDEF";
encoder.close();
assert (str.str() == "QUJDREVG");
assertTrue (str.str() == "QUJDREVG");
}
{
std::ostringstream str;
Base64Encoder encoder(str, Poco::BASE64_URL_ENCODING | Poco::BASE64_NO_PADDING);
encoder << "!@#$%^&*()_~<>";
encoder.close();
assert (str.str() == "IUAjJCVeJiooKV9-PD4");
assertTrue (str.str() == "IUAjJCVeJiooKV9-PD4");
}
}
@ -136,50 +136,50 @@ void Base64Test::testDecoder()
{
std::istringstream istr("AAECAwQF");
Base64Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == 5);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == 5);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAwQ=");
Base64Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAw==");
Base64Decoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("QUJDREVG");
Base64Decoder decoder(istr);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "ABCDEF");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("QUJ\r\nDRE\r\nVG");
Base64Decoder decoder(istr);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "ABCDEF");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("QUJD#REVG");
@ -188,12 +188,12 @@ void Base64Test::testDecoder()
try
{
decoder >> s;
assert (decoder.bad());
assertTrue (decoder.bad());
}
catch (DataFormatException&)
{
}
assert (!decoder.eof());
assertTrue (!decoder.eof());
}
}
@ -203,41 +203,41 @@ void Base64Test::testDecoderURL()
{
std::istringstream istr("AAECAwQF");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == 5);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == 5);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAwQ=");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAw==");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("QUJDREVG");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "ABCDEF");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("QUJ\r\nDRE\r\nVG");
@ -246,7 +246,7 @@ void Base64Test::testDecoderURL()
{
std::string s;
decoder >> s;
assert (decoder.bad());
assertTrue (decoder.bad());
}
catch (DataFormatException&)
{
@ -259,21 +259,21 @@ void Base64Test::testDecoderURL()
try
{
decoder >> s;
assert (decoder.bad());
assertTrue (decoder.bad());
}
catch (DataFormatException&)
{
}
assert (!decoder.eof());
assertTrue (!decoder.eof());
}
{
std::istringstream istr("IUAjJCVeJiooKV9-PD4=");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
std::string s;
decoder >> s;
assert (s == "!@#$%^&*()_~<>");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "!@#$%^&*()_~<>");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
}
@ -283,32 +283,32 @@ void Base64Test::testDecoderNoPadding()
{
std::istringstream istr("AAECAwQF");
Base64Decoder decoder(istr, Poco::BASE64_NO_PADDING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == 5);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == 5);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAwQ");
Base64Decoder decoder(istr, Poco::BASE64_NO_PADDING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAw");
Base64Decoder decoder(istr, Poco::BASE64_NO_PADDING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == -1);
}
}
@ -325,7 +325,7 @@ void Base64Test::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == "The quick brown fox jumped over the lazy dog.");
assertTrue (s == "The quick brown fox jumped over the lazy dog.");
}
{
std::string src;
@ -338,7 +338,7 @@ void Base64Test::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == src);
assertTrue (s == src);
}
}

View File

@ -39,61 +39,61 @@ void BasicEventTest::testNoDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assert (Void.empty());
assertTrue (_count == 0);
assertTrue (Void.empty());
Void.notify(this);
assert (_count == 0);
assertTrue (_count == 0);
Void += delegate(this, &BasicEventTest::onVoid);
assert (!Void.empty());
assertTrue (!Void.empty());
Void -= delegate(this, &BasicEventTest::onVoid);
assert (Void.empty());
assertTrue (Void.empty());
Void.notify(this);
assert (_count == 0);
assert (Simple.empty());
assertTrue (_count == 0);
assertTrue (Simple.empty());
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple);
assert (!Simple.empty());
assertTrue (!Simple.empty());
Simple -= delegate(this, &BasicEventTest::onSimple);
assert (Simple.empty());
assertTrue (Simple.empty());
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimpleNoSender);
Simple -= delegate(this, &BasicEventTest::onSimpleNoSender);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
ConstSimple -= delegate(this, &BasicEventTest::onConstSimple);
ConstSimple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
//Note: passing &args will not work due to &
EventArgs* pArgs = &args;
Complex += delegate(this, &BasicEventTest::onComplex);
Complex -= delegate(this, &BasicEventTest::onComplex);
Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
Complex2 += delegate(this, &BasicEventTest::onComplex2);
Complex2 -= delegate(this, &BasicEventTest::onComplex2);
Complex2.notify(this, args);
assert (_count == 0);
assertTrue (_count == 0);
const EventArgs* pCArgs = &args;
ConstComplex += delegate(this, &BasicEventTest::onConstComplex);
ConstComplex -= delegate(this, &BasicEventTest::onConstComplex);
ConstComplex.notify(this, pCArgs);
assert (_count == 0);
assertTrue (_count == 0);
Const2Complex += delegate(this, &BasicEventTest::onConst2Complex);
Const2Complex -= delegate(this, &BasicEventTest::onConst2Complex);
Const2Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(&BasicEventTest::onStaticSimple);
Simple += delegate(&BasicEventTest::onStaticSimple);
@ -101,14 +101,14 @@ void BasicEventTest::testNoDelegate()
Simple += delegate(&BasicEventTest::onStaticSimple3);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Simple -= delegate(BasicEventTest::onStaticSimple);
Void += delegate(&BasicEventTest::onStaticVoid);
Void += delegate(&BasicEventTest::onStaticVoid);
Void.notify(this);
assert (_count == 5);
assertTrue (_count == 5);
Void -= delegate(BasicEventTest::onStaticVoid);
}
@ -117,40 +117,40 @@ void BasicEventTest::testSingleDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assertTrue (_count == 0);
Void += delegate(this, &BasicEventTest::onVoid);
Void.notify(this);
assert (_count == 1);
assertTrue (_count == 1);
Simple += delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
ConstSimple += delegate(this, &BasicEventTest::onConstSimple);
ConstSimple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
EventArgs* pArgs = &args;
Complex += delegate(this, &BasicEventTest::onComplex);
Complex.notify(this, pArgs);
assert (_count == 4);
assertTrue (_count == 4);
Complex2 += delegate(this, &BasicEventTest::onComplex2);
Complex2.notify(this, args);
assert (_count == 5);
assertTrue (_count == 5);
const EventArgs* pCArgs = &args;
ConstComplex += delegate(this, &BasicEventTest::onConstComplex);
ConstComplex.notify(this, pCArgs);
assert (_count == 6);
assertTrue (_count == 6);
Const2Complex += delegate(this, &BasicEventTest::onConst2Complex);
Const2Complex.notify(this, pArgs);
assert (_count == 7);
assertTrue (_count == 7);
// check if 2nd notify also works
Const2Complex.notify(this, pArgs);
assert (_count == 8);
assertTrue (_count == 8);
}
@ -158,15 +158,15 @@ void BasicEventTest::testDuplicateRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple);
Simple += delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
Simple -= delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
@ -175,15 +175,15 @@ void BasicEventTest::testNullMutex()
Poco::BasicEvent<int, NullMutex> ev;
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
ev += delegate(this, &BasicEventTest::onSimple);
ev += delegate(this, &BasicEventTest::onSimple);
ev.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
ev -= delegate(this, &BasicEventTest::onSimple);
ev.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
@ -192,91 +192,91 @@ void BasicEventTest::testDuplicateUnregister()
// duplicate unregister shouldn't give an error,
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple -= delegate(this, &BasicEventTest::onSimple); // should work
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= delegate(this, &BasicEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
void BasicEventTest::testDisabling()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple);
Simple.disable();
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
// unregister should also work with disabled event
Simple.disable();
Simple -= delegate(this, &BasicEventTest::onSimple);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
void BasicEventTest::testExpire()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(700);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple += delegate(&BasicEventTest::onStaticSimple, 400);
Simple += delegate(&BasicEventTest::onStaticSimple, 400);
Simple += delegate(&BasicEventTest::onStaticSimple2, 400);
Simple += delegate(&BasicEventTest::onStaticSimple3, 400);
Simple.notify(this, tmp);
assert (_count == 4);
assertTrue (_count == 4);
Poco::Thread::sleep(700);
Simple.notify(this, tmp);
assert (_count == 4);
assertTrue (_count == 4);
}
void BasicEventTest::testExpireReRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &BasicEventTest::onSimple, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(200);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
// renew registration
Simple += delegate(this, &BasicEventTest::onSimple, 600);
Poco::Thread::sleep(400);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Poco::Thread::sleep(300);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
void BasicEventTest::testReturnParams()
@ -286,7 +286,7 @@ void BasicEventTest::testReturnParams()
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 1);
assertTrue (tmp == 1);
}
void BasicEventTest::testOverwriteDelegate()
@ -297,22 +297,22 @@ void BasicEventTest::testOverwriteDelegate()
int tmp = 0; // onsimple requires 0 as input
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
}
void BasicEventTest::testAsyncNotify()
{
Poco::BasicEvent<int>* pSimple= new Poco::BasicEvent<int>();
(*pSimple) += delegate(this, &BasicEventTest::onAsync);
assert (_count == 0);
assertTrue (_count == 0);
int tmp = 0;
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
delete pSimple; // must work even when the event got deleted!
pSimple = NULL;
assert (_count == 0);
assertTrue (_count == 0);
retArg.wait();
assert (retArg.data() == tmp);
assert (_count == LARGEINC);
assertTrue (retArg.data() == tmp);
assertTrue (_count == LARGEINC);
}
void BasicEventTest::onStaticVoid(const void* pSender)

View File

@ -53,11 +53,11 @@ void BinaryReaderWriterTest::testBigEndian()
std::stringstream sstream;
BinaryWriter writer(sstream, BinaryWriter::BIG_ENDIAN_BYTE_ORDER);
BinaryReader reader(sstream, BinaryReader::UNSPECIFIED_BYTE_ORDER);
assert (writer.byteOrder() == BinaryWriter::BIG_ENDIAN_BYTE_ORDER);
assertTrue (writer.byteOrder() == BinaryWriter::BIG_ENDIAN_BYTE_ORDER);
writer.writeBOM();
write(writer);
reader.readBOM();
assert (reader.byteOrder() == BinaryReader::BIG_ENDIAN_BYTE_ORDER);
assertTrue (reader.byteOrder() == BinaryReader::BIG_ENDIAN_BYTE_ORDER);
read(reader);
}
@ -67,11 +67,11 @@ void BinaryReaderWriterTest::testLittleEndian()
std::stringstream sstream;
BinaryWriter writer(sstream, BinaryWriter::LITTLE_ENDIAN_BYTE_ORDER);
BinaryReader reader(sstream, BinaryReader::UNSPECIFIED_BYTE_ORDER);
assert (writer.byteOrder() == BinaryWriter::LITTLE_ENDIAN_BYTE_ORDER);
assertTrue (writer.byteOrder() == BinaryWriter::LITTLE_ENDIAN_BYTE_ORDER);
writer.writeBOM();
write(writer);
reader.readBOM();
assert (reader.byteOrder() == BinaryReader::LITTLE_ENDIAN_BYTE_ORDER);
assertTrue (reader.byteOrder() == BinaryReader::LITTLE_ENDIAN_BYTE_ORDER);
read(reader);
}
@ -130,100 +130,100 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
{
bool b;
reader >> b;
assert (b);
assertTrue (b);
reader >> b;
assert (!b);
assertTrue (!b);
char c;
reader >> c;
assert (c == 'a');
assertTrue (c == 'a');
short shortv;
reader >> shortv;
assert (shortv == -100);
assertTrue (shortv == -100);
unsigned short ushortv;
reader >> ushortv;
assert (ushortv == 50000);
assertTrue (ushortv == 50000);
int intv;
reader >> intv;
assert (intv == -123456);
assertTrue (intv == -123456);
unsigned uintv;
reader >> uintv;
assert (uintv == 123456);
assertTrue (uintv == 123456);
long longv;
reader >> longv;
assert (longv == -1234567890);
assertTrue (longv == -1234567890);
unsigned long ulongv;
reader >> ulongv;
assert (ulongv == 1234567890);
assertTrue (ulongv == 1234567890);
#if defined(POCO_HAVE_INT64)
Int64 int64v;
reader >> int64v;
assert (int64v == -1234567890);
assertTrue (int64v == -1234567890);
UInt64 uint64v;
reader >> uint64v;
assert (uint64v == 1234567890);
assertTrue (uint64v == 1234567890);
#endif
float floatv;
reader >> floatv;
assert (floatv == 1.5);
assertTrue (floatv == 1.5);
double doublev;
reader >> doublev;
assert (doublev == -1.5);
assertTrue (doublev == -1.5);
std::string str;
reader >> str;
assert (str == "foo");
assertTrue (str == "foo");
reader >> str;
assert (str == "");
assertTrue (str == "");
reader >> str;
assert (str == "bar");
assertTrue (str == "bar");
reader >> str;
assert (str == "");
assertTrue (str == "");
UInt32 uint32v;
reader.read7BitEncoded(uint32v);
assert (uint32v == 100);
assertTrue (uint32v == 100);
reader.read7BitEncoded(uint32v);
assert (uint32v == 1000);
assertTrue (uint32v == 1000);
reader.read7BitEncoded(uint32v);
assert (uint32v == 10000);
assertTrue (uint32v == 10000);
reader.read7BitEncoded(uint32v);
assert (uint32v == 100000);
assertTrue (uint32v == 100000);
reader.read7BitEncoded(uint32v);
assert (uint32v == 1000000);
assertTrue (uint32v == 1000000);
#if defined(POCO_HAVE_INT64)
reader.read7BitEncoded(uint64v);
assert (uint64v == 100);
assertTrue (uint64v == 100);
reader.read7BitEncoded(uint64v);
assert (uint64v == 1000);
assertTrue (uint64v == 1000);
reader.read7BitEncoded(uint64v);
assert (uint64v == 10000);
assertTrue (uint64v == 10000);
reader.read7BitEncoded(uint64v);
assert (uint64v == 100000);
assertTrue (uint64v == 100000);
reader.read7BitEncoded(uint64v);
assert (uint64v == 1000000);
assertTrue (uint64v == 1000000);
#endif
std::vector<int> vec;
reader >> vec;
assert (vec.size() == 3);
assert (vec[0] == 1);
assert (vec[1] == 2);
assert (vec[2] == 3);
assertTrue (vec.size() == 3);
assertTrue (vec[0] == 1);
assertTrue (vec[1] == 2);
assertTrue (vec[2] == 3);
reader.readRaw(3, str);
assert (str == "RAW");
assertTrue (str == "RAW");
}
@ -240,14 +240,14 @@ void BinaryReaderWriterTest::testWrappers()
writer << -1;
MemoryBinaryReader reader(writer.data());
reader >> b; assert (b);
reader >> b; assert (!b);
reader >> c; assert ('a' == c);
assert(reader.available() == sizeof(i) * 2);
reader >> i; assert (1 == i);
assert(reader.available() == sizeof(i));
reader >> i; assert (-1 == i);
assert(reader.available() == 0);
reader >> b; assertTrue (b);
reader >> b; assertTrue (!b);
reader >> c; assertTrue ('a' == c);
assertTrue (reader.available() == sizeof(i) * 2);
reader >> i; assertTrue (1 == i);
assertTrue (reader.available() == sizeof(i));
reader >> i; assertTrue (-1 == i);
assertTrue (reader.available() == 0);
reader.setExceptions(std::istream::eofbit);
try

View File

@ -40,45 +40,45 @@ void ByteOrderTest::testByteOrderFlip()
{
Int16 norm = (Int16) 0xAABB;
Int16 flip = ByteOrder::flipBytes(norm);
assert (UInt16(flip) == 0xBBAA);
assertTrue (UInt16(flip) == 0xBBAA);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
{
UInt16 norm = (UInt16) 0xAABB;
UInt16 flip = ByteOrder::flipBytes(norm);
assert (flip == 0xBBAA);
assertTrue (flip == 0xBBAA);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
{
Int32 norm = 0xAABBCCDD;
Int32 flip = ByteOrder::flipBytes(norm);
assert (UInt32(flip) == 0xDDCCBBAA);
assertTrue (UInt32(flip) == 0xDDCCBBAA);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
{
UInt32 norm = 0xAABBCCDD;
UInt32 flip = ByteOrder::flipBytes(norm);
assert (flip == 0xDDCCBBAA);
assertTrue (flip == 0xDDCCBBAA);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = (Int64(0x8899AABB) << 32) + 0xCCDDEEFF;
Int64 flip = ByteOrder::flipBytes(norm);
assert (flip == (Int64(0xFFEEDDCC) << 32) + 0xBBAA9988);
assertTrue (flip == (Int64(0xFFEEDDCC) << 32) + 0xBBAA9988);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
{
UInt64 norm = (UInt64(0x8899AABB) << 32) + 0xCCDDEEFF;
UInt64 flip = ByteOrder::flipBytes(norm);
assert (flip == (UInt64(0xFFEEDDCC) << 32) + 0xBBAA9988);
assertTrue (flip == (UInt64(0xFFEEDDCC) << 32) + 0xBBAA9988);
flip = ByteOrder::flipBytes(flip);
assert (flip == norm);
assertTrue (flip == norm);
}
#endif
}
@ -93,66 +93,66 @@ void ByteOrderTest::testByteOrderBigEndian()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::fromBigEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#else
@ -162,90 +162,90 @@ void ByteOrderTest::testByteOrderBigEndian()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::fromBigEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#endif
@ -261,66 +261,66 @@ void ByteOrderTest::testByteOrderLittleEndian()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toLittleEndian(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#else
@ -330,90 +330,90 @@ void ByteOrderTest::testByteOrderLittleEndian()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::fromLittleEndian(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#endif
@ -429,66 +429,66 @@ void ByteOrderTest::testByteOrderNetwork()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::fromNetwork(norm);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#else
@ -498,90 +498,90 @@ void ByteOrderTest::testByteOrderNetwork()
{
Int16 norm = 4;
Int16 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::toNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
{
Int16 norm = 4;
Int16 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt16 norm = 4;
UInt16 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
Int32 norm = 4;
Int32 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt32 norm = 4;
UInt32 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#if defined(POCO_HAVE_INT64)
{
Int64 norm = 4;
Int64 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
{
UInt64 norm = 4;
UInt64 flip = ByteOrder::fromNetwork(norm);
assert (norm != flip);
assertTrue (norm != flip);
flip = ByteOrder::flipBytes(flip);
assert (norm == flip);
assertTrue (norm == flip);
}
#endif
#endif

View File

@ -63,7 +63,7 @@ void ChannelTest::testSplitter()
pSplitter->addChannel(pChannel.get());
Message msg;
pSplitter->log(msg);
assert (pChannel->list().size() == 2);
assertTrue (pChannel->list().size() == 2);
}
@ -76,7 +76,7 @@ void ChannelTest::testAsync()
pAsync->log(msg);
pAsync->log(msg);
pAsync->close();
assert (pChannel->list().size() == 2);
assertTrue (pChannel->list().size() == 2);
}
@ -87,8 +87,8 @@ void ChannelTest::testFormatting()
AutoPtr<FormattingChannel> pFormatterChannel = new FormattingChannel(pFormatter, pChannel.get());
Message msg("Source", "Text", Message::PRIO_INFORMATION);
pFormatterChannel->log(msg);
assert (pChannel->list().size() == 1);
assert (pChannel->list().begin()->getText() == "Source: Text");
assertTrue (pChannel->list().size() == 1);
assertTrue (pChannel->list().begin()->getText() == "Source: Text");
}
@ -110,7 +110,7 @@ void ChannelTest::testStream()
AutoPtr<FormattingChannel> pFormatterChannel = new FormattingChannel(pFormatter, pChannel.get());
Message msg("Source", "Text", Message::PRIO_INFORMATION);
pFormatterChannel->log(msg);
assert (str.str().find("Source: Text") == 0);
assertTrue (str.str().find("Source: Text") == 0);
}

View File

@ -42,11 +42,11 @@ void ClassLoaderTest::testClassLoader1()
ClassLoader<TestPlugin> cl;
assert (cl.begin() == cl.end());
assertTrue (cl.begin() == cl.end());
assertNullPtr (cl.findClass("PluginA"));
assertNullPtr (cl.findManifest(path));
assert (!cl.isLibraryLoaded(path));
assertTrue (!cl.isLibraryLoaded(path));
try
{
@ -84,41 +84,41 @@ void ClassLoaderTest::testClassLoader2()
ClassLoader<TestPlugin> cl;
cl.loadLibrary(path);
assert (cl.begin() != cl.end());
assertTrue (cl.begin() != cl.end());
assertNotNullPtr (cl.findClass("PluginA"));
assertNotNullPtr (cl.findClass("PluginB"));
assertNotNullPtr (cl.findClass("PluginC"));
assertNotNullPtr (cl.findManifest(path));
assert (cl.isLibraryLoaded(path));
assert (cl.manifestFor(path).size() == 3);
assertTrue (cl.isLibraryLoaded(path));
assertTrue (cl.manifestFor(path).size() == 3);
ClassLoader<TestPlugin>::Iterator it = cl.begin();
assert (it != cl.end());
assert (it->first == path);
assert (it->second->size() == 3);
assertTrue (it != cl.end());
assertTrue (it->first == path);
assertTrue (it->second->size() == 3);
++it;
assert (it == cl.end());
assertTrue (it == cl.end());
TestPlugin* pPluginA = cl.classFor("PluginA").create();
assert (pPluginA->name() == "PluginA");
assert (!cl.classFor("PluginA").isAutoDelete(pPluginA));
assertTrue (pPluginA->name() == "PluginA");
assertTrue (!cl.classFor("PluginA").isAutoDelete(pPluginA));
delete pPluginA;
TestPlugin* pPluginB = cl.classFor("PluginB").create();
assert (pPluginB->name() == "PluginB");
assertTrue (pPluginB->name() == "PluginB");
delete pPluginB;
pPluginB = cl.create("PluginB");
assert (pPluginB->name() == "PluginB");
assertTrue (pPluginB->name() == "PluginB");
delete pPluginB;
assert (cl.canCreate("PluginA"));
assert (cl.canCreate("PluginB"));
assert (!cl.canCreate("PluginC"));
assertTrue (cl.canCreate("PluginA"));
assertTrue (cl.canCreate("PluginB"));
assertTrue (!cl.canCreate("PluginC"));
TestPlugin& pluginC = cl.instance("PluginC");
assert (pluginC.name() == "PluginC");
assertTrue (pluginC.name() == "PluginC");
try
{
@ -149,7 +149,7 @@ void ClassLoaderTest::testClassLoader2()
}
const AbstractMetaObject<TestPlugin>& meta1 = cl.classFor("PluginC");
assert (meta1.isAutoDelete(&(meta1.instance())));
assertTrue (meta1.isAutoDelete(&(meta1.instance())));
// the following must not produce memory leaks
const AbstractMetaObject<TestPlugin>& meta2 = cl.classFor("PluginA");
@ -158,9 +158,9 @@ void ClassLoaderTest::testClassLoader2()
TestPlugin* pPlugin = meta2.create();
meta2.autoDelete(pPlugin);
assert (meta2.isAutoDelete(pPlugin));
assertTrue (meta2.isAutoDelete(pPlugin));
meta2.destroy(pPlugin);
assert (!meta2.isAutoDelete(pPlugin));
assertTrue (!meta2.isAutoDelete(pPlugin));
cl.unloadLibrary(path);
}
@ -176,14 +176,14 @@ void ClassLoaderTest::testClassLoader3()
cl.loadLibrary(path);
cl.unloadLibrary(path);
assert (cl.manifestFor(path).size() == 3);
assertTrue (cl.manifestFor(path).size() == 3);
ClassLoader<TestPlugin>::Iterator it = cl.begin();
assert (it != cl.end());
assert (it->first == path);
assert (it->second->size() == 3);
assertTrue (it != cl.end());
assertTrue (it->first == path);
assertTrue (it->second->size() == 3);
++it;
assert (it == cl.end());
assertTrue (it == cl.end());
cl.unloadLibrary(path);
assertNullPtr (cl.findManifest(path));

View File

@ -36,32 +36,32 @@ void ClockTest::testClock()
Thread::sleep(200);
Clock t2;
Clock t3 = t2;
assert (t1 != t2);
assert (!(t1 == t2));
assert (t2 > t1);
assert (t2 >= t1);
assert (!(t1 > t2));
assert (!(t1 >= t2));
assert (t2 == t3);
assert (!(t2 != t3));
assert (t2 >= t3);
assert (t2 <= t3);
assertTrue (t1 != t2);
assertTrue (!(t1 == t2));
assertTrue (t2 > t1);
assertTrue (t2 >= t1);
assertTrue (!(t1 > t2));
assertTrue (!(t1 >= t2));
assertTrue (t2 == t3);
assertTrue (!(t2 != t3));
assertTrue (t2 >= t3);
assertTrue (t2 <= t3);
Clock::ClockDiff d = (t2 - t1);
assert (d >= 180000 && d <= 300000);
assertTrue (d >= 180000 && d <= 300000);
Clock::ClockDiff acc = Clock::accuracy();
assert (acc > 0 && acc < Clock::resolution());
assertTrue (acc > 0 && acc < Clock::resolution());
std::cout << "Clock accuracy: " << acc << std::endl;
t1.swap(t2);
assert (t1 > t2);
assertTrue (t1 > t2);
t2.swap(t1);
Clock now;
Thread::sleep(201);
assert (now.elapsed() >= 200000);
assert (now.isElapsed(200000));
assert (!now.isElapsed(2000000));
assertTrue (now.elapsed() >= 200000);
assertTrue (now.isElapsed(200000));
assertTrue (!now.isElapsed(2000000));
}

View File

@ -114,21 +114,21 @@ void ConditionTest::testSignal()
Thread::sleep(200);
t2.start(r2);
assert (!r1.ran());
assert (!r2.ran());
assertTrue (!r1.ran());
assertTrue (!r2.ran());
cond.signal();
t1.join();
assert (r1.ran());
assertTrue (r1.ran());
assert (!t2.tryJoin(200));
assertTrue (!t2.tryJoin(200));
cond.signal();
t2.join();
assert (r2.ran());
assertTrue (r2.ran());
}
@ -150,24 +150,24 @@ void ConditionTest::testBroadcast()
Thread::sleep(200);
t3.start(r3);
assert (!r1.ran());
assert (!r2.ran());
assert (!r3.ran());
assertTrue (!r1.ran());
assertTrue (!r2.ran());
assertTrue (!r3.ran());
cond.signal();
t1.join();
assert (r1.ran());
assert (!t2.tryJoin(500));
assert (!t3.tryJoin(500));
assertTrue (r1.ran());
assertTrue (!t2.tryJoin(500));
assertTrue (!t3.tryJoin(500));
cond.broadcast();
t2.join();
t3.join();
assert (r2.ran());
assert (r3.ran());
assertTrue (r2.ran());
assertTrue (r3.ran());
}

File diff suppressed because it is too large Load Diff

View File

@ -35,23 +35,23 @@ void CountingStreamTest::testInput()
std::istringstream istr1("foo");
CountingInputStream ci1(istr1);
while (ci1.good()) ci1.get(c);
assert (ci1.lines() == 1);
assert (ci1.chars() == 3);
assert (ci1.pos() == 3);
assertTrue (ci1.lines() == 1);
assertTrue (ci1.chars() == 3);
assertTrue (ci1.pos() == 3);
std::istringstream istr2("foo\nbar");
CountingInputStream ci2(istr2);
while (ci2.good()) ci2.get(c);
assert (ci2.lines() == 2);
assert (ci2.chars() == 7);
assert (ci2.pos() == 3);
assertTrue (ci2.lines() == 2);
assertTrue (ci2.chars() == 7);
assertTrue (ci2.pos() == 3);
std::istringstream istr3("foo\nbar\n");
CountingInputStream ci3(istr3);
while (ci3.good()) ci3.get(c);
assert (ci3.lines() == 2);
assert (ci3.chars() == 8);
assert (ci3.pos() == 0);
assertTrue (ci3.lines() == 2);
assertTrue (ci3.chars() == 8);
assertTrue (ci3.pos() == 0);
std::istringstream istr4("foo");
CountingInputStream ci4(istr4);
@ -59,9 +59,9 @@ void CountingStreamTest::testInput()
ci4.addChars(10);
ci4.addLines(2);
ci4.addPos(3);
assert (ci4.lines() == 1 + 2);
assert (ci4.chars() == 3 + 10);
assert (ci4.pos() == 3 + 3);
assertTrue (ci4.lines() == 1 + 2);
assertTrue (ci4.chars() == 3 + 10);
assertTrue (ci4.pos() == 3 + 3);
}
@ -70,24 +70,24 @@ void CountingStreamTest::testOutput()
std::ostringstream ostr1;
CountingOutputStream co1(ostr1);
co1 << "foo";
assert (ostr1.str() == "foo");
assert (co1.lines() == 1);
assert (co1.chars() == 3);
assert (co1.pos() == 3);
assertTrue (ostr1.str() == "foo");
assertTrue (co1.lines() == 1);
assertTrue (co1.chars() == 3);
assertTrue (co1.pos() == 3);
std::ostringstream ostr2;
CountingOutputStream co2(ostr2);
co2 << "foo\nbar";
assert (ostr2.str() == "foo\nbar");
assert (co2.lines() == 2);
assert (co2.chars() == 7);
assert (co2.pos() == 3);
assertTrue (ostr2.str() == "foo\nbar");
assertTrue (co2.lines() == 2);
assertTrue (co2.chars() == 7);
assertTrue (co2.pos() == 3);
CountingOutputStream co3;
co3 << "foo\nbar\n";
assert (co3.lines() == 2);
assert (co3.chars() == 8);
assert (co3.pos() == 0);
assertTrue (co3.lines() == 2);
assertTrue (co3.chars() == 8);
assertTrue (co3.pos() == 0);
std::ostringstream ostr4;
CountingOutputStream co4(ostr4);
@ -95,9 +95,9 @@ void CountingStreamTest::testOutput()
co4.addChars(10);
co4.addLines(2);
co4.addPos(3);
assert (co4.lines() == 1 + 2);
assert (co4.chars() == 3 + 10);
assert (co4.pos() == 3 + 3);
assertTrue (co4.lines() == 1 + 2);
assertTrue (co4.chars() == 3 + 10);
assertTrue (co4.pos() == 3 + 3);
}

View File

@ -43,13 +43,13 @@ void DateTimeFormatterTest::testISO8601()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT);
assert (str == "2005-01-08T12:30:00Z");
assertTrue (str == "2005-01-08T12:30:00Z");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT, 3600);
assert (str == "2005-01-08T12:30:00+01:00");
assertTrue (str == "2005-01-08T12:30:00+01:00");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT, -3600);
assert (str == "2005-01-08T12:30:00-01:00");
assertTrue (str == "2005-01-08T12:30:00-01:00");
}
@ -58,13 +58,13 @@ void DateTimeFormatterTest::testISO8601Frac()
DateTime dt(2005, 1, 8, 12, 30, 00, 12, 34);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT);
assert(str == "2005-01-08T12:30:00.012034Z");
assertTrue (str == "2005-01-08T12:30:00.012034Z");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT, 3600);
assert(str == "2005-01-08T12:30:00.012034+01:00");
assertTrue (str == "2005-01-08T12:30:00.012034+01:00");
str = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT, -3600);
assert(str == "2005-01-08T12:30:00.012034-01:00");
assertTrue (str == "2005-01-08T12:30:00.012034-01:00");
}
@ -73,13 +73,13 @@ void DateTimeFormatterTest::testRFC822()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::RFC822_FORMAT);
assert (str == "Sat, 8 Jan 05 12:30:00 GMT");
assertTrue (str == "Sat, 8 Jan 05 12:30:00 GMT");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC822_FORMAT, 3600);
assert (str == "Sat, 8 Jan 05 12:30:00 +0100");
assertTrue (str == "Sat, 8 Jan 05 12:30:00 +0100");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC822_FORMAT, -3600);
assert (str == "Sat, 8 Jan 05 12:30:00 -0100");
assertTrue (str == "Sat, 8 Jan 05 12:30:00 -0100");
}
@ -88,13 +88,13 @@ void DateTimeFormatterTest::testRFC1123()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1123_FORMAT);
assert (str == "Sat, 8 Jan 2005 12:30:00 GMT");
assertTrue (str == "Sat, 8 Jan 2005 12:30:00 GMT");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1123_FORMAT, 3600);
assert (str == "Sat, 8 Jan 2005 12:30:00 +0100");
assertTrue (str == "Sat, 8 Jan 2005 12:30:00 +0100");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1123_FORMAT, -3600);
assert (str == "Sat, 8 Jan 2005 12:30:00 -0100");
assertTrue (str == "Sat, 8 Jan 2005 12:30:00 -0100");
}
@ -103,13 +103,13 @@ void DateTimeFormatterTest::testHTTP()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT);
assert (str == "Sat, 08 Jan 2005 12:30:00 GMT");
assertTrue (str == "Sat, 08 Jan 2005 12:30:00 GMT");
str = DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT, 3600);
assert (str == "Sat, 08 Jan 2005 12:30:00 +0100");
assertTrue (str == "Sat, 08 Jan 2005 12:30:00 +0100");
str = DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT, -3600);
assert (str == "Sat, 08 Jan 2005 12:30:00 -0100");
assertTrue (str == "Sat, 08 Jan 2005 12:30:00 -0100");
}
@ -118,13 +118,13 @@ void DateTimeFormatterTest::testRFC850()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::RFC850_FORMAT);
assert (str == "Saturday, 8-Jan-05 12:30:00 GMT");
assertTrue (str == "Saturday, 8-Jan-05 12:30:00 GMT");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC850_FORMAT, 3600);
assert (str == "Saturday, 8-Jan-05 12:30:00 +0100");
assertTrue (str == "Saturday, 8-Jan-05 12:30:00 +0100");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC850_FORMAT, -3600);
assert (str == "Saturday, 8-Jan-05 12:30:00 -0100");
assertTrue (str == "Saturday, 8-Jan-05 12:30:00 -0100");
}
@ -133,13 +133,13 @@ void DateTimeFormatterTest::testRFC1036()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1036_FORMAT);
assert (str == "Saturday, 8 Jan 05 12:30:00 GMT");
assertTrue (str == "Saturday, 8 Jan 05 12:30:00 GMT");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1036_FORMAT, 3600);
assert (str == "Saturday, 8 Jan 05 12:30:00 +0100");
assertTrue (str == "Saturday, 8 Jan 05 12:30:00 +0100");
str = DateTimeFormatter::format(dt, DateTimeFormat::RFC1036_FORMAT, -3600);
assert (str == "Saturday, 8 Jan 05 12:30:00 -0100");
assertTrue (str == "Saturday, 8 Jan 05 12:30:00 -0100");
}
@ -148,7 +148,7 @@ void DateTimeFormatterTest::testASCTIME()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::ASCTIME_FORMAT);
assert (str == "Sat Jan 8 12:30:00 2005");
assertTrue (str == "Sat Jan 8 12:30:00 2005");
}
@ -157,7 +157,7 @@ void DateTimeFormatterTest::testSORTABLE()
DateTime dt(2005, 1, 8, 12, 30, 00);
std::string str = DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT);
assert (str == "2005-01-08 12:30:00");
assertTrue (str == "2005-01-08 12:30:00");
}
@ -166,7 +166,7 @@ void DateTimeFormatterTest::testCustom()
DateTime dt(2005, 1, 8, 12, 30, 00, 250);
std::string str = DateTimeFormatter::format(dt, "%w/%W/%b/%B/%d/%e/%f/%m/%n/%o/%y/%Y/%H/%h/%a/%A/%M/%S/%i/%c/%z/%Z/%%");
assert (str == "Sat/Saturday/Jan/January/08/8/ 8/01/1/ 1/05/2005/12/12/pm/PM/30/00/250/2/Z/GMT/%");
assertTrue (str == "Sat/Saturday/Jan/January/08/8/ 8/01/1/ 1/05/2005/12/12/pm/PM/30/00/250/2/Z/GMT/%");
}
@ -174,27 +174,27 @@ void DateTimeFormatterTest::testTimespan()
{
Timespan ts(1, 1, 1, 1, 1000);
std::string str = DateTimeFormatter::format(ts);
assert (str == "1d 01:01:01.001");
assertTrue (str == "1d 01:01:01.001");
Timespan ts1(1, 24, 1, 1, 1000);
str = DateTimeFormatter::format(ts1);
assert (str == "2d 00:01:01.001");
assertTrue (str == "2d 00:01:01.001");
Timespan ts2(1, 25, 1, 1, 1000);
str = DateTimeFormatter::format(ts2);
assert (str == "2d 01:01:01.001");
assertTrue (str == "2d 01:01:01.001");
Timespan ts3(5, 4, 3, 2, 1000);
str = DateTimeFormatter::format(ts3, "%i.%S:%M:%H d%d %%");
assert (str == "001.02:03:04 d5 %");
assertTrue (str == "001.02:03:04 d5 %");
Timespan ts4(0, 24, 60, 60, 1001000);
str = DateTimeFormatter::format(ts4);
assert (str == "1d 01:01:01.001");
assertTrue (str == "1d 01:01:01.001");
Timespan ts5(2, 11, 30, 20, 0);
str = DateTimeFormatter::format(ts5, "%h %m %s");
assert (str == "59 3570 214220");
assertTrue (str == "59 3570 214220");
}

File diff suppressed because it is too large Load Diff

View File

@ -37,28 +37,28 @@ void DateTimeTest::testTimestamp()
{
Timestamp ts(0); // Unix epoch 1970-01-01 00:00:00 Thursday
DateTime dt(ts);
assert (dt.year() == 1970);
assert (dt.month() == 1);
assert (dt.day() == 1);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assert (dt.julianDay() == 2440587.5);
assert (dt.timestamp() == 0);
assertTrue (dt.year() == 1970);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 1);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 4);
assertTrue (dt.julianDay() == 2440587.5);
assertTrue (dt.timestamp() == 0);
ts = Timestamp::fromEpochTime(1000000000);
dt = ts; // 2001-09-09 01:46:40 Sunday
assert (dt.year() == 2001);
assert (dt.month() == 9);
assert (dt.day() == 9);
assert (dt.hour() == 1);
assert (dt.minute() == 46);
assert (dt.second() == 40);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 0);
assert (dt.timestamp().epochTime() == 1000000000);
assertTrue (dt.year() == 2001);
assertTrue (dt.month() == 9);
assertTrue (dt.day() == 9);
assertTrue (dt.hour() == 1);
assertTrue (dt.minute() == 46);
assertTrue (dt.second() == 40);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 0);
assertTrue (dt.timestamp().epochTime() == 1000000000);
assertEqualDelta (dt.julianDay(), 2452161.574074, 0.000001);
}
@ -66,77 +66,77 @@ void DateTimeTest::testTimestamp()
void DateTimeTest::testJulian()
{
DateTime dt(2440587.5); // unix epoch as Julian day
assert (dt.year() == 1970);
assert (dt.month() == 1);
assert (dt.day() == 1);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assert (dt.julianDay() == 2440587.5);
assert (dt.timestamp() == 0);
assertTrue (dt.year() == 1970);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 1);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 4);
assertTrue (dt.julianDay() == 2440587.5);
assertTrue (dt.timestamp() == 0);
dt = 2299160.5; // 1582-10-15 00:00:00 (first day of Gregorian reform, UTC base)
assert (dt.year() == 1582);
assert (dt.month() == 10);
assert (dt.day() == 15);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 5);
assert (dt.julianDay() == 2299160.5);
assertTrue (dt.year() == 1582);
assertTrue (dt.month() == 10);
assertTrue (dt.day() == 15);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 5);
assertTrue (dt.julianDay() == 2299160.5);
dt = 0.0; // -4713-11-24 12:00:00 (Gregorian date of Julian day reference)
assert (dt.year() == -4713);
assert (dt.month() == 11);
assert (dt.day() == 24);
assert (dt.hour() == 12);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 1);
assert (dt.julianDay() == 0);
assertTrue (dt.year() == -4713);
assertTrue (dt.month() == 11);
assertTrue (dt.day() == 24);
assertTrue (dt.hour() == 12);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 1);
assertTrue (dt.julianDay() == 0);
// Test that we can represent down to the microsecond.
dt = DateTime(2010, 1, 31, 17, 30, 15, 800, 3);
assert (dt.year() == 2010);
assert (dt.month() == 1);
assert (dt.day() == 31);
assert (dt.hour() == 17);
assert (dt.minute() == 30);
assert (dt.second() == 15);
assert (dt.millisecond() == 800);
assert (dt.microsecond() == 3);
assertTrue (dt.year() == 2010);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 31);
assertTrue (dt.hour() == 17);
assertTrue (dt.minute() == 30);
assertTrue (dt.second() == 15);
assertTrue (dt.millisecond() == 800);
assertTrue (dt.microsecond() == 3);
}
void DateTimeTest::testGregorian()
{
DateTime dt(1970, 1, 1);
assert (dt.year() == 1970);
assert (dt.month() == 1);
assert (dt.day() == 1);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assert (dt.julianDay() == 2440587.5);
assert (dt.timestamp() == 0);
assertTrue (dt.year() == 1970);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 1);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 4);
assertTrue (dt.julianDay() == 2440587.5);
assertTrue (dt.timestamp() == 0);
dt.assign(2001, 9, 9, 1, 46, 40);
assert (dt.year() == 2001);
assert (dt.month() == 9);
assert (dt.day() == 9);
assert (dt.hour() == 1);
assert (dt.minute() == 46);
assert (dt.second() == 40);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 0);
assert (dt.timestamp().epochTime() == 1000000000);
assertTrue (dt.year() == 2001);
assertTrue (dt.month() == 9);
assertTrue (dt.day() == 9);
assertTrue (dt.hour() == 1);
assertTrue (dt.minute() == 46);
assertTrue (dt.second() == 40);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 0);
assertTrue (dt.timestamp().epochTime() == 1000000000);
assertEqualDelta (dt.julianDay(), 2452161.574074, 0.000001);
}
@ -153,167 +153,167 @@ void DateTimeTest::testConversions()
DateTime dt4(dt2);
Timestamp ts4 = dt4.timestamp();
assert (ts1 == ts2);
assert (ts2 == ts3);
assert (ts3 == ts4);
assertTrue (ts1 == ts2);
assertTrue (ts2 == ts3);
assertTrue (ts3 == ts4);
assert (dt2.year() == 2005);
assert (dt2.month() == 1);
assert (dt2.day() == 28);
assert (dt2.hour() == 14);
assert (dt2.minute() == 24);
assert (dt2.second() == 44);
assert (dt2.millisecond() == 234);
assert (dt2.dayOfWeek() == 5);
assertTrue (dt2.year() == 2005);
assertTrue (dt2.month() == 1);
assertTrue (dt2.day() == 28);
assertTrue (dt2.hour() == 14);
assertTrue (dt2.minute() == 24);
assertTrue (dt2.second() == 44);
assertTrue (dt2.millisecond() == 234);
assertTrue (dt2.dayOfWeek() == 5);
}
void DateTimeTest::testStatics()
{
assert (DateTime::isLeapYear(1984));
assert (DateTime::isLeapYear(1988));
assert (DateTime::isLeapYear(1992));
assert (DateTime::isLeapYear(1996));
assert (DateTime::isLeapYear(2000));
assert (DateTime::isLeapYear(2400));
assert (!DateTime::isLeapYear(1995));
assert (!DateTime::isLeapYear(1998));
assert (!DateTime::isLeapYear(2001));
assert (!DateTime::isLeapYear(1800));
assert (!DateTime::isLeapYear(1900));
assertTrue (DateTime::isLeapYear(1984));
assertTrue (DateTime::isLeapYear(1988));
assertTrue (DateTime::isLeapYear(1992));
assertTrue (DateTime::isLeapYear(1996));
assertTrue (DateTime::isLeapYear(2000));
assertTrue (DateTime::isLeapYear(2400));
assertTrue (!DateTime::isLeapYear(1995));
assertTrue (!DateTime::isLeapYear(1998));
assertTrue (!DateTime::isLeapYear(2001));
assertTrue (!DateTime::isLeapYear(1800));
assertTrue (!DateTime::isLeapYear(1900));
assert (DateTime::daysOfMonth(2000, 1) == 31);
assert (DateTime::daysOfMonth(2000, 2) == 29);
assert (DateTime::daysOfMonth(1999, 2) == 28);
assertTrue (DateTime::daysOfMonth(2000, 1) == 31);
assertTrue (DateTime::daysOfMonth(2000, 2) == 29);
assertTrue (DateTime::daysOfMonth(1999, 2) == 28);
}
void DateTimeTest::testCalcs()
{
DateTime dt1(2005, 1, 1);
assert (dt1.dayOfYear() == 1);
assert (dt1.week(DateTime::MONDAY) == 0);
assertTrue (dt1.dayOfYear() == 1);
assertTrue (dt1.week(DateTime::MONDAY) == 0);
dt1.assign(2005, 1, 3);
assert (dt1.dayOfYear() == 3);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.dayOfYear() == 3);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2005, 1, 9);
assert (dt1.dayOfYear() == 9);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.dayOfYear() == 9);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2005, 1, 10);
assert (dt1.dayOfYear() == 10);
assert (dt1.week(DateTime::MONDAY) == 2);
assertTrue (dt1.dayOfYear() == 10);
assertTrue (dt1.week(DateTime::MONDAY) == 2);
dt1.assign(2005, 2, 1);
assert (dt1.dayOfYear() == 32);
assert (dt1.week(DateTime::MONDAY) == 5);
assertTrue (dt1.dayOfYear() == 32);
assertTrue (dt1.week(DateTime::MONDAY) == 5);
dt1.assign(2005, 12, 31);
assert (dt1.week(DateTime::MONDAY) == 52);
assertTrue (dt1.week(DateTime::MONDAY) == 52);
dt1.assign(2007, 1, 1);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2007, 12, 31);
assert (dt1.week(DateTime::MONDAY) == 53);
assertTrue (dt1.week(DateTime::MONDAY) == 53);
// Jan 1 is Mon
dt1.assign(2001, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2001, 1, 7);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2001, 1, 8);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2001, 1, 21);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2001, 1, 22);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Tue
dt1.assign(2002, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2002, 1, 6);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2002, 1, 7);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2002, 1, 20);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2002, 1, 21);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Wed
dt1.assign(2003, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2003, 1, 5);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2003, 1, 6);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2003, 1, 19);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2003, 1, 20);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Thu
dt1.assign(2004, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2004, 1, 4);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2004, 1, 5);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2004, 1, 18);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2004, 1, 19);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Fri
dt1.assign(1999, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1999, 1, 3);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1999, 1, 4);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1999, 1, 17);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(1999, 1, 18);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
// Jan 1 is Sat
dt1.assign(2000, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(2000, 1, 2);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(2000, 1, 3);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2000, 1, 16);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2000, 1, 17);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
// Jan 1 is Sun
dt1.assign(1995, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1995, 1, 2);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1995, 1, 3);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1995, 1, 15);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(1995, 1, 16);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
}
void DateTimeTest::testAMPM()
{
DateTime dt1(2005, 1, 1, 0, 15, 30);
assert (dt1.isAM());
assert (!dt1.isPM());
assert (dt1.hourAMPM() == 12);
assertTrue (dt1.isAM());
assertTrue (!dt1.isPM());
assertTrue (dt1.hourAMPM() == 12);
dt1.assign(2005, 1, 1, 12, 15, 30);
assert (!dt1.isAM());
assert (dt1.isPM());
assert (dt1.hourAMPM() == 12);
assertTrue (!dt1.isAM());
assertTrue (dt1.isPM());
assertTrue (dt1.hourAMPM() == 12);
dt1.assign(2005, 1, 1, 13, 15, 30);
assert (!dt1.isAM());
assert (dt1.isPM());
assert (dt1.hourAMPM() == 1);
assertTrue (!dt1.isAM());
assertTrue (dt1.isPM());
assertTrue (dt1.hourAMPM() == 1);
}
@ -323,19 +323,19 @@ void DateTimeTest::testRelational()
DateTime dt2(2005, 1, 2, 0, 15, 30);
DateTime dt3(dt1);
assert (dt1 < dt2);
assert (dt1 <= dt2);
assert (dt2 > dt1);
assert (dt2 >= dt1);
assert (dt1 != dt2);
assert (!(dt1 == dt2));
assertTrue (dt1 < dt2);
assertTrue (dt1 <= dt2);
assertTrue (dt2 > dt1);
assertTrue (dt2 >= dt1);
assertTrue (dt1 != dt2);
assertTrue (!(dt1 == dt2));
assert (dt1 == dt3);
assert (!(dt1 != dt3));
assert (dt1 >= dt3);
assert (dt1 <= dt3);
assert (!(dt1 > dt3));
assert (!(dt1 < dt3));
assertTrue (dt1 == dt3);
assertTrue (!(dt1 != dt3));
assertTrue (dt1 >= dt3);
assertTrue (dt1 <= dt3);
assertTrue (!(dt1 > dt3));
assertTrue (!(dt1 < dt3));
static const struct
{
@ -372,10 +372,10 @@ void DateTimeTest::testRelational()
const DateTime& U = u;
u.assign(values[j].year, values[j].month, values[j].day);
loop_2_assert(i, j, (j < i) == (U < V));
loop_2_assert(i, j, (j <= i) == (U <= V));
loop_2_assert(i, j, (j >= i) == (U >= V));
loop_2_assert(i, j, (j > i) == (U > V));
loop_2_assert (i, j, (j < i) == (U < V));
loop_2_assert (i, j, (j <= i) == (U <= V));
loop_2_assert (i, j, (j >= i) == (U >= V));
loop_2_assert (i, j, (j > i) == (U > V));
}
}
}
@ -387,15 +387,15 @@ void DateTimeTest::testArithmetics()
DateTime dt2(2005, 1, 2, 0, 15, 30);
Timespan s = dt2 - dt1;
assert (s.days() == 1);
assertTrue (s.days() == 1);
DateTime dt3 = dt1 + s;
assert (dt3 == dt2);
assertTrue (dt3 == dt2);
dt3 -= s;
assert (dt3 == dt1);
assertTrue (dt3 == dt1);
dt1 += s;
assert (dt1 == dt2);
assertTrue (dt1 == dt2);
static const struct
{
@ -436,32 +436,32 @@ void DateTimeTest::testArithmetics()
DateTime x = DateTime(data[di].year1, data[di].month1, data[di].day1);
const DateTime& X = x;
x += Timespan(num_days, 0, 0, 0, 0);
loop_1_assert(line, data[di].year2 == X.year());
loop_1_assert(line, data[di].month2 == X.month());
loop_1_assert(line, data[di].day2 == X.day());
loop_1_assert (line, data[di].year2 == X.year());
loop_1_assert (line, data[di].month2 == X.month());
loop_1_assert (line, data[di].day2 == X.day());
}
DateTime edgeTime(2014, 9, 16, 0, 0, 0, 0, 10);
edgeTime -= Poco::Timespan(11);
assert (edgeTime.year() == 2014);
assert (edgeTime.month() == 9);
assert (edgeTime.day() == 15);
assert (edgeTime.hour() == 23);
assert (edgeTime.minute() == 59);
assert (edgeTime.second() == 59);
assert (edgeTime.millisecond() == 999);
assert (edgeTime.microsecond() == 999);
assertTrue (edgeTime.year() == 2014);
assertTrue (edgeTime.month() == 9);
assertTrue (edgeTime.day() == 15);
assertTrue (edgeTime.hour() == 23);
assertTrue (edgeTime.minute() == 59);
assertTrue (edgeTime.second() == 59);
assertTrue (edgeTime.millisecond() == 999);
assertTrue (edgeTime.microsecond() == 999);
edgeTime.assign(2014, 9, 15, 23, 59, 59, 999, 968);
edgeTime += Poco::Timespan(11);
assert (edgeTime.year() == 2014);
assert (edgeTime.month() == 9);
assert (edgeTime.day() == 15);
assert (edgeTime.hour() == 23);
assert (edgeTime.minute() == 59);
assert (edgeTime.second() == 59);
assert (edgeTime.millisecond() == 999);
assert (edgeTime.microsecond() == 979);
assertTrue (edgeTime.year() == 2014);
assertTrue (edgeTime.month() == 9);
assertTrue (edgeTime.day() == 15);
assertTrue (edgeTime.hour() == 23);
assertTrue (edgeTime.minute() == 59);
assertTrue (edgeTime.second() == 59);
assertTrue (edgeTime.millisecond() == 999);
assertTrue (edgeTime.microsecond() == 979);
}
void DateTimeTest::testIncrementDecrement()
@ -516,13 +516,13 @@ void DateTimeTest::testIncrementDecrement()
x = x + Timespan(1,0,0,0,0);
DateTime y = x; const DateTime& Y = y;
loop_1_assert(line, data[di].year2 == X.year());
loop_1_assert(line, data[di].month2 == X.month());
loop_1_assert(line, data[di].day2 == X.day());
loop_1_assert (line, data[di].year2 == X.year());
loop_1_assert (line, data[di].month2 == X.month());
loop_1_assert (line, data[di].day2 == X.day());
loop_1_assert(line, data[di].year2 == Y.year());
loop_1_assert(line, data[di].month2 == Y.month());
loop_1_assert(line, data[di].day2 == Y.day());
loop_1_assert (line, data[di].year2 == Y.year());
loop_1_assert (line, data[di].month2 == Y.month());
loop_1_assert (line, data[di].day2 == Y.day());
}
for (di = 0; di < num_data; ++di)
@ -537,12 +537,12 @@ void DateTimeTest::testIncrementDecrement()
const DateTime& X = x;
x = x + Timespan(1,0,0,0,0);
loop_1_assert(line, data[di].year2 == X.year());
loop_1_assert(line, data[di].month2 == X.month());
loop_1_assert(line, data[di].day2 == X.day());
loop_1_assert(line, data[di].year1 == Y.year());
loop_1_assert(line, data[di].month1 == Y.month());
loop_1_assert(line, data[di].day1 == Y.day());
loop_1_assert (line, data[di].year2 == X.year());
loop_1_assert (line, data[di].month2 == X.month());
loop_1_assert (line, data[di].day2 == X.day());
loop_1_assert (line, data[di].year1 == Y.year());
loop_1_assert (line, data[di].month1 == Y.month());
loop_1_assert (line, data[di].day1 == Y.day());
}
for (di = 0; di < num_data; ++di)
@ -553,13 +553,13 @@ void DateTimeTest::testIncrementDecrement()
x = x - Timespan(1,0,0,0,0);
DateTime y = x; DateTime Y = y;
loop_1_assert(line, data[di].year1 == X.year());
loop_1_assert(line, data[di].month1 == X.month());
loop_1_assert(line, data[di].day1 == X.day());
loop_1_assert (line, data[di].year1 == X.year());
loop_1_assert (line, data[di].month1 == X.month());
loop_1_assert (line, data[di].day1 == X.day());
loop_1_assert(line, data[di].year1 == Y.year());
loop_1_assert(line, data[di].month1 == Y.month());
loop_1_assert(line, data[di].day1 == Y.day());
loop_1_assert (line, data[di].year1 == Y.year());
loop_1_assert (line, data[di].month1 == Y.month());
loop_1_assert (line, data[di].day1 == Y.day());
}
for (di = 0; di < num_data; ++di)
@ -572,13 +572,13 @@ void DateTimeTest::testIncrementDecrement()
// would post-decrement x here.
x = x - Timespan(1,0,0,0,0);
loop_1_assert(line, data[di].year1 == X.year());
loop_1_assert(line, data[di].month1 == X.month());
loop_1_assert(line, data[di].day1 == X.day());
loop_1_assert (line, data[di].year1 == X.year());
loop_1_assert (line, data[di].month1 == X.month());
loop_1_assert (line, data[di].day1 == X.day());
loop_1_assert(line, data[di].year2 == Y.year());
loop_1_assert(line, data[di].month2 == Y.month());
loop_1_assert(line, data[di].day2 == Y.day());
loop_1_assert (line, data[di].year2 == Y.year());
loop_1_assert (line, data[di].month2 == Y.month());
loop_1_assert (line, data[di].day2 == Y.day());
}
}
@ -591,26 +591,26 @@ void DateTimeTest::testSwap()
DateTime dt4(2005, 1, 2, 0, 15, 30);
dt1.swap(dt2);
assert (dt2 == dt3);
assert (dt1 == dt4);
assertTrue (dt2 == dt3);
assertTrue (dt1 == dt4);
}
void DateTimeTest::testUsage()
{
DateTime dt1(1776, 7, 4);
assert (dt1.year() == 1776);
assert (dt1.month() == 7);
assert (dt1.day() == 4);
assertTrue (dt1.year() == 1776);
assertTrue (dt1.month() == 7);
assertTrue (dt1.day() == 4);
DateTime dt2(dt1);
dt2 += Timespan(6, 0, 0, 0, 0);
assert (dt2.year() == 1776);
assert (dt2.month() == 7);
assert (dt2.day() == 10);
assertTrue (dt2.year() == 1776);
assertTrue (dt2.month() == 7);
assertTrue (dt2.day() == 10);
Timespan span = dt2 - dt1;
assert (span.days() == 6);
assertTrue (span.days() == 6);
// TODO - When adding months and years we need to be
// able to specify the end-end convention.
@ -662,8 +662,8 @@ void DateTimeTest::testSetYearDay()
// TODO - need to be able to assert with the loop counter
// but cppUnit is not able to do this.
assert (r == x);
assert (day == X.dayOfYear());
assertTrue (r == x);
assertTrue (day == X.dayOfYear());
#endif
}
@ -771,7 +771,7 @@ void DateTimeTest::testIsValid()
const bool exp = data[di].d_exp;
bool isValid = DateTime::isValid(year, month, day);
loop_1_assert(line, exp == isValid);
loop_1_assert (line, exp == isValid);
}
}
@ -828,7 +828,7 @@ void DateTimeTest::testDayOfWeek()
const int line = data[di].d_lineNum;
DateTime x = DateTime(data[di].d_year, data[di].d_month, data[di].d_day);
const DateTime& X = x;
loop_1_assert(line, data[di].d_expDay == X.dayOfWeek());
loop_1_assert (line, data[di].d_expDay == X.dayOfWeek());
}
}
@ -837,11 +837,11 @@ void DateTimeTest::testUTC()
{
DateTime dt(2007, 3, 5, 12, 30, 00);
assert (dt.hour() == 12);
assertTrue (dt.hour() == 12);
dt.makeUTC(3600);
assert (dt.hour() == 11);
assertTrue (dt.hour() == 11);
dt.makeLocal(3600);
assert (dt.hour() == 12);
assertTrue (dt.hour() == 12);
}
@ -850,7 +850,7 @@ void DateTimeTest::testLeapSeconds()
DateTime dt1(2015, 6, 30, 23, 59, 60);
DateTime dt2(2015, 7, 1, 0, 0, 0);
assert (dt1 == dt2);
assertTrue (dt1 == dt2);
}

View File

@ -40,8 +40,8 @@ void DigestStreamTest::testInputStream()
DigestInputStream ds(md5, istr);
std::string s;
ds >> s;
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assert (s == "abcdefghijklmnopqrstuvwxyz");
assertTrue (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assertTrue (s == "abcdefghijklmnopqrstuvwxyz");
}
@ -51,12 +51,12 @@ void DigestStreamTest::testOutputStream1()
DigestOutputStream ds(md5);
ds << "abcdefghijklmnopqrstuvwxyz";
ds.close();
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assertTrue (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
ds << "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ds << "abcdefghijklmnopqrstuvwxyz0123456789";
ds.close();
assert (DigestEngine::digestToHex(md5.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
assertTrue (DigestEngine::digestToHex(md5.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
}
@ -67,8 +67,8 @@ void DigestStreamTest::testOutputStream2()
DigestOutputStream ds(md5, ostr);
ds << "abcdefghijklmnopqrstuvwxyz";
ds.close();
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assert (ostr.str() == "abcdefghijklmnopqrstuvwxyz");
assertTrue (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assertTrue (ostr.str() == "abcdefghijklmnopqrstuvwxyz");
}
@ -77,7 +77,7 @@ void DigestStreamTest::testToFromHex()
std::string digest("c3fcd3d76192e4007dfb496cca67e13b");
Poco::DigestEngine::Digest dig = DigestEngine::digestFromHex(digest);
std::string digest2 = DigestEngine::digestToHex(dig);
assert (digest == digest2);
assertTrue (digest == digest2);
}

View File

@ -56,11 +56,11 @@ void DirectoryWatcherTest::testAdded()
Poco::Thread::sleep(2000*dw.scanInterval());
assert (_events.size() >= 1);
assert (_events[0].callback == "onItemAdded");
assert (Poco::Path(_events[0].path).getFileName() == "test.txt");
assert (_events[0].type == DirectoryWatcher::DW_ITEM_ADDED);
assert (!_error);
assertTrue (_events.size() >= 1);
assertTrue (_events[0].callback == "onItemAdded");
assertTrue (Poco::Path(_events[0].path).getFileName() == "test.txt");
assertTrue (_events[0].type == DirectoryWatcher::DW_ITEM_ADDED);
assertTrue (!_error);
}
@ -87,11 +87,11 @@ void DirectoryWatcherTest::testRemoved()
Poco::Thread::sleep(2000*dw.scanInterval());
assert (_events.size() >= 1);
assert (_events[0].callback == "onItemRemoved");
assert (Poco::Path(_events[0].path).getFileName() == "test.txt");
assert (_events[0].type == DirectoryWatcher::DW_ITEM_REMOVED);
assert (!_error);
assertTrue (_events.size() >= 1);
assertTrue (_events[0].callback == "onItemRemoved");
assertTrue (Poco::Path(_events[0].path).getFileName() == "test.txt");
assertTrue (_events[0].type == DirectoryWatcher::DW_ITEM_REMOVED);
assertTrue (!_error);
}
@ -119,11 +119,11 @@ void DirectoryWatcherTest::testModified()
Poco::Thread::sleep(2000*dw.scanInterval());
assert (_events.size() >= 1);
assert (_events[0].callback == "onItemModified");
assert (Poco::Path(_events[0].path).getFileName() == "test.txt");
assert (_events[0].type == DirectoryWatcher::DW_ITEM_MODIFIED);
assert (!_error);
assertTrue (_events.size() >= 1);
assertTrue (_events[0].callback == "onItemModified");
assertTrue (Poco::Path(_events[0].path).getFileName() == "test.txt");
assertTrue (_events[0].type == DirectoryWatcher::DW_ITEM_MODIFIED);
assertTrue (!_error);
}
@ -154,37 +154,37 @@ void DirectoryWatcherTest::testMoved()
if (dw.supportsMoveEvents())
{
assert (_events.size() >= 2);
assert (
assertTrue (_events.size() >= 2);
assertTrue (
(_events[0].callback == "onItemMovedFrom" && _events[1].callback == "onItemMovedTo") ||
(_events[1].callback == "onItemMovedFrom" && _events[0].callback == "onItemMovedTo")
);
assert (
assertTrue (
(Poco::Path(_events[0].path).getFileName() == "test.txt" && Poco::Path(_events[1].path).getFileName() == "test2.txt") ||
(Poco::Path(_events[1].path).getFileName() == "test.txt" && Poco::Path(_events[0].path).getFileName() == "test2.txt")
);
assert (
assertTrue (
(_events[0].type == DirectoryWatcher::DW_ITEM_MOVED_FROM && _events[1].type == DirectoryWatcher::DW_ITEM_MOVED_TO) ||
(_events[1].type == DirectoryWatcher::DW_ITEM_MOVED_FROM && _events[0].type == DirectoryWatcher::DW_ITEM_MOVED_TO)
);
}
else
{
assert (_events.size() >= 2);
assert (
assertTrue (_events.size() >= 2);
assertTrue (
(_events[0].callback == "onItemAdded" && _events[1].callback == "onItemRemoved") ||
(_events[1].callback == "onItemAdded" && _events[0].callback == "onItemRemoved")
);
assert (
assertTrue (
(Poco::Path(_events[0].path).getFileName() == "test.txt" && Poco::Path(_events[1].path).getFileName() == "test2.txt") ||
(Poco::Path(_events[1].path).getFileName() == "test.txt" && Poco::Path(_events[0].path).getFileName() == "test2.txt")
);
assert (
assertTrue (
(_events[0].type == DirectoryWatcher::DW_ITEM_ADDED && _events[1].type == DirectoryWatcher::DW_ITEM_REMOVED) ||
(_events[1].type == DirectoryWatcher::DW_ITEM_ADDED && _events[0].type == DirectoryWatcher::DW_ITEM_REMOVED)
);
}
assert (!_error);
assertTrue (!_error);
}

View File

@ -61,10 +61,10 @@ void DynamicFactoryTest::testDynamicFactory()
dynFactory.registerClass<A>("A");
dynFactory.registerClass<B>("B");
assert (dynFactory.isClass("A"));
assert (dynFactory.isClass("B"));
assertTrue (dynFactory.isClass("A"));
assertTrue (dynFactory.isClass("B"));
assert (!dynFactory.isClass("C"));
assertTrue (!dynFactory.isClass("C"));
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<A> a(dynamic_cast<A*>(dynFactory.createInstance("A")));
@ -87,8 +87,8 @@ void DynamicFactoryTest::testDynamicFactory()
}
dynFactory.unregisterClass("B");
assert (dynFactory.isClass("A"));
assert (!dynFactory.isClass("B"));
assertTrue (dynFactory.isClass("A"));
assertTrue (!dynFactory.isClass("B"));
try
{

View File

@ -42,16 +42,16 @@ void ExpireCacheTest::testClear()
aCache.add(1, 2);
aCache.add(3, 4);
aCache.add(5, 6);
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(1) == 2);
assert (*aCache.get(3) == 4);
assert (*aCache.get(5) == 6);
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(1) == 2);
assertTrue (*aCache.get(3) == 4);
assertTrue (*aCache.get(5) == 6);
aCache.clear();
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (!aCache.has(5));
assertTrue (!aCache.has(1));
assertTrue (!aCache.has(3));
assertTrue (!aCache.has(5));
}
@ -74,51 +74,51 @@ void ExpireCacheTest::testExpireN()
// 3-1|5 -> 5 gets removed
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assertTrue (aCache.has(1));
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
assert (aCache.size() == 1);
assertTrue (!tmp.isNull());
assertTrue (*tmp == 2);
assertTrue (aCache.size() == 1);
Thread::sleep(DURWAIT);
assert (aCache.size() == 0);
assert (!aCache.has(1));
assertTrue (aCache.size() == 0);
assertTrue (!aCache.has(1));
// tmp must still be valid, access it
assert (*tmp == 2);
assertTrue (*tmp == 2);
tmp = aCache.get(1);
assert (!tmp);
assertTrue (!tmp);
aCache.add(1, 2); // 1
Thread::sleep(DURHALFSLEEP);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
tmp = aCache.get(1);
SharedPtr<int> tmp2 = aCache.get(3);
assert (*tmp == 2);
assert (*tmp2 == 4);
assertTrue (*tmp == 2);
assertTrue (*tmp2 == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (*tmp == 2); // 1-3
assert (*tmp2 == 4); // 3-1
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*tmp == 2); // 1-3
assertTrue (*tmp2 == 4); // 3-1
tmp2 = aCache.get(3);
assert (*tmp2 == 4);
assertTrue (*tmp2 == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(3));
assert (*tmp2 == 4);
assertTrue (!aCache.has(3));
assertTrue (*tmp2 == 4);
tmp = aCache.get(1);
tmp2 = aCache.get(3);
assert (!tmp);
assert (!tmp2);
assertTrue (!tmp);
assertTrue (!tmp2);
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -126,11 +126,11 @@ void ExpireCacheTest::testDuplicateAdd()
{
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(1, 3);
assert (aCache.has(1));
assert (*aCache.get(1) == 3);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 3);
}
@ -141,37 +141,37 @@ void ExpireCacheTest::testAccessExpireN()
// 3-1|5 -> 5 gets removed
AccessExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assertTrue (aCache.has(1));
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
assert (aCache.size() == 1);
assertTrue (!tmp.isNull());
assertTrue (*tmp == 2);
assertTrue (aCache.size() == 1);
Thread::sleep(DURWAIT);
assert (aCache.size() == 0);
assert (!aCache.has(1));
assertTrue (aCache.size() == 0);
assertTrue (!aCache.has(1));
// tmp must still be valid, access it
assert (*tmp == 2);
assertTrue (*tmp == 2);
tmp = aCache.get(1);
assert (!tmp);
assertTrue (!tmp);
aCache.add(1, 2); // 1
Thread::sleep(DURHALFSLEEP);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
Thread::sleep(DURHALFSLEEP+50); //3|1
assert (!aCache.has(1));
assert (*aCache.get(3) == 4);
assertTrue (!aCache.has(1));
assertTrue (*aCache.get(3) == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (*aCache.get(3) == 4);
assertTrue (*aCache.get(3) == 4);
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -181,9 +181,9 @@ void ExpireCacheTest::testExpireWithHas()
// 3-1|5 -> 5 gets removed
ExpireCache<int, int> aCache(DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assertTrue (aCache.has(1));
Thread::sleep(DURWAIT);
assert (!aCache.has(1));
assertTrue (!aCache.has(1));
}

View File

@ -42,16 +42,16 @@ void ExpireLRUCacheTest::testClear()
aCache.add(1, 2);
aCache.add(3, 4);
aCache.add(5, 6);
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(1) == 2);
assert (*aCache.get(3) == 4);
assert (*aCache.get(5) == 6);
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(1) == 2);
assertTrue (*aCache.get(3) == 4);
assertTrue (*aCache.get(5) == 6);
aCache.clear();
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (!aCache.has(5));
assertTrue (!aCache.has(1));
assertTrue (!aCache.has(3));
assertTrue (!aCache.has(5));
}
@ -74,49 +74,49 @@ void ExpireLRUCacheTest::testExpireN()
// 3-1|5 -> 5 gets removed
ExpireLRUCache<int, int> aCache(3, DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assertTrue (aCache.has(1));
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
assertTrue (!tmp.isNull());
assertTrue (*tmp == 2);
Thread::sleep(DURWAIT);
assert (!aCache.has(1));
assertTrue (!aCache.has(1));
// tmp must still be valid, access it
assert (*tmp == 2);
assertTrue (*tmp == 2);
tmp = aCache.get(1);
assert (!tmp);
assertTrue (!tmp);
aCache.add(1, 2); // 1
Thread::sleep(DURHALFSLEEP);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
tmp = aCache.get(1);
SharedPtr<int> tmp2 = aCache.get(3);
assert (*tmp == 2);
assert (*tmp2 == 4);
assertTrue (*tmp == 2);
assertTrue (*tmp2 == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (*tmp == 2); // 1-3
assert (*tmp2 == 4); // 3-1
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*tmp == 2); // 1-3
assertTrue (*tmp2 == 4); // 3-1
tmp2 = aCache.get(3);
assert (*tmp2 == 4);
assertTrue (*tmp2 == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (!aCache.has(3));
assert (*tmp2 == 4);
assertTrue (!aCache.has(3));
assertTrue (*tmp2 == 4);
tmp = aCache.get(1);
tmp2 = aCache.get(3);
assert (!tmp);
assert (!tmp2);
assertTrue (!tmp);
assertTrue (!tmp2);
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -126,37 +126,37 @@ void ExpireLRUCacheTest::testAccessExpireN()
// 3-1|5 -> 5 gets removed
AccessExpireLRUCache<int, int> aCache(3, DURSLEEP);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assertTrue (aCache.has(1));
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
assert (aCache.size() == 1);
assertTrue (!tmp.isNull());
assertTrue (*tmp == 2);
assertTrue (aCache.size() == 1);
Thread::sleep(DURWAIT);
assert (aCache.size() == 0);
assert (!aCache.has(1));
assertTrue (aCache.size() == 0);
assertTrue (!aCache.has(1));
// tmp must still be valid, access it
assert (*tmp == 2);
assertTrue (*tmp == 2);
tmp = aCache.get(1);
assert (!tmp);
assertTrue (!tmp);
aCache.add(1, 2); // 1
Thread::sleep(DURHALFSLEEP);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
Thread::sleep(DURHALFSLEEP+50); //3|1
assert (!aCache.has(1));
assert (*aCache.get(3) == 4);
assertTrue (!aCache.has(1));
assertTrue (*aCache.get(3) == 4);
Thread::sleep(DURHALFSLEEP+25); //3|1
assert (*aCache.get(3) == 4);
assertTrue (*aCache.get(3) == 4);
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -178,22 +178,22 @@ void ExpireLRUCacheTest::testCacheSize1()
{
ExpireLRUCache<int, int> aCache(1);
aCache.add(1, 2);
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // replaces 1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(3) == 4);
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(3) == 4);
aCache.add(5, 6);
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6);
assertTrue (!aCache.has(1));
assertTrue (!aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6);
aCache.remove(5);
assert (!aCache.has(5));
assertTrue (!aCache.has(5));
// removing illegal entries should work too
aCache.remove(666);
@ -206,37 +206,37 @@ void ExpireLRUCacheTest::testCacheSize2()
// 3-1|5 -> 5 gets removed
ExpireLRUCache<int, int> aCache(2);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(1) == 2); // 1-3
assert (*aCache.get(3) == 4); // 3-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(1) == 2); // 1-3
assertTrue (*aCache.get(3) == 4); // 3-1
aCache.add(5, 6); // 5-3|1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-3
assert (*aCache.get(3) == 4); // 3-5
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-3
assertTrue (*aCache.get(3) == 4); // 3-5
// test remove from the end and the beginning of the list
aCache.remove(5); // 3
assert (!aCache.has(5));
assert (*aCache.get(3) == 4); // 3
assertTrue (!aCache.has(5));
assertTrue (*aCache.get(3) == 4); // 3
aCache.add(5, 6); // 5-3
assert (*aCache.get(3) == 4); // 3-5
assertTrue (*aCache.get(3) == 4); // 3-5
aCache.remove(3); // 5
assert (!aCache.has(3));
assert (*aCache.get(5) == 6); // 5
assertTrue (!aCache.has(3));
assertTrue (*aCache.get(5) == 6); // 5
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assertTrue (!aCache.has(5));
}
@ -246,48 +246,48 @@ void ExpireLRUCacheTest::testCacheSizeN()
// 3-1|5 -> 5 gets removed
ExpireLRUCache<int, int> aCache(3);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(1) == 2); // 1-3
assert (*aCache.get(3) == 4); // 3-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(1) == 2); // 1-3
assertTrue (*aCache.get(3) == 4); // 3-1
aCache.add(5, 6); // 5-3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-3-1
assert (*aCache.get(3) == 4); // 3-5-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-3-1
assertTrue (*aCache.get(3) == 4); // 3-5-1
aCache.add(7, 8); // 7-5-3|1
assert (!aCache.has(1));
assert (aCache.has(7));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-7-3
assert (*aCache.get(3) == 4); // 3-5-7
assert (*aCache.get(7) == 8); // 7-3-5
assertTrue (!aCache.has(1));
assertTrue (aCache.has(7));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-7-3
assertTrue (*aCache.get(3) == 4); // 3-5-7
assertTrue (*aCache.get(7) == 8); // 7-3-5
// test remove from the end and the beginning of the list
aCache.remove(5); // 7-3
assert (!aCache.has(5));
assert (*aCache.get(3) == 4); // 3-7
assertTrue (!aCache.has(5));
assertTrue (*aCache.get(3) == 4); // 3-7
aCache.add(5, 6); // 5-3-7
assert (*aCache.get(7) == 8); // 7-5-3
assertTrue (*aCache.get(7) == 8); // 7-5-3
aCache.remove(7); // 5-3
assert (!aCache.has(7));
assert (aCache.has(3));
assert (*aCache.get(5) == 6); // 5-3
assertTrue (!aCache.has(7));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(5) == 6); // 5-3
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -295,11 +295,11 @@ void ExpireLRUCacheTest::testDuplicateAdd()
{
ExpireLRUCache<int, int> aCache(3);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(1, 3);
assert (aCache.has(1));
assert (*aCache.get(1) == 3);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 3);
}

View File

@ -36,41 +36,41 @@ void FIFOBufferStreamTest::testInput()
const char* data = "This is a test";
FIFOBuffer fb1(data, 14);
FIFOBufferStream str1(fb1);
assert (str1.rdbuf()->fifoBuffer().isFull());
assertTrue (str1.rdbuf()->fifoBuffer().isFull());
int c = str1.get();
assert (c == 'T');
assertTrue (c == 'T');
c = str1.get();
assert (c == 'h');
assertTrue (c == 'h');
std::string str;
str1 >> str;
assert (str == "is");
assertTrue (str == "is");
char buffer[32];
str1.read(buffer, sizeof(buffer));
assert (str1.gcount() == 10);
assertTrue (str1.gcount() == 10);
buffer[str1.gcount()] = 0;
assert (std::string(" is a test") == buffer);
assertTrue (std::string(" is a test") == buffer);
const char* data2 = "123";
FIFOBufferStream str2(data2, 3);
c = str2.get();
assert (c == '1');
assert (str2.good());
assertTrue (c == '1');
assertTrue (str2.good());
c = str2.get();
assert (c == '2');
assertTrue (c == '2');
str2.unget();
c = str2.get();
assert (c == '2');
assert (str2.good());
assertTrue (c == '2');
assertTrue (str2.good());
c = str2.get();
assert (c == '3');
assert (str2.good());
assertTrue (c == '3');
assertTrue (str2.good());
c = str2.get();
assert (c == -1);
assert (str2.eof());
assertTrue (c == -1);
assertTrue (str2.eof());
}
@ -79,7 +79,7 @@ void FIFOBufferStreamTest::testOutput()
char output[64];
FIFOBufferStream iostr1(output, 64);
iostr1 << "This is a test " << 42 << std::ends << std::flush;
assert (std::string("This is a test 42") == output);
assertTrue (std::string("This is a test 42") == output);
}
@ -87,75 +87,75 @@ void FIFOBufferStreamTest::testNotify()
{
FIFOBuffer fb(18);
FIFOBufferStream iostr(fb);
assert (iostr.rdbuf()->fifoBuffer().isEmpty());
assertTrue (iostr.rdbuf()->fifoBuffer().isEmpty());
assert (0 == _readableToNot);
assert (0 == _notToReadable);
assert (0 == _writableToNot);
assert (0 == _notToWritable);
assertTrue (0 == _readableToNot);
assertTrue (0 == _notToReadable);
assertTrue (0 == _writableToNot);
assertTrue (0 == _notToWritable);
iostr.readable += delegate(this, &FIFOBufferStreamTest::onReadable);
iostr.writable += delegate(this, &FIFOBufferStreamTest::onWritable);
iostr << "This is a test " << 42 << std::ends << std::flush;
assert (iostr.rdbuf()->fifoBuffer().isFull());
assertTrue (iostr.rdbuf()->fifoBuffer().isFull());
assert (0 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (0 == _notToWritable);
assertTrue (0 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (0 == _notToWritable);
char input[64];
iostr >> input;
assert (std::string("This") == input);
assert (iostr.rdbuf()->fifoBuffer().isEmpty());
assertTrue (std::string("This") == input);
assertTrue (iostr.rdbuf()->fifoBuffer().isEmpty());
assert (1 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr >> input;
assert (std::string("is") == input);
assertTrue (std::string("is") == input);
assert (1 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr >> input;
assert (std::string("a") == input);
assertTrue (std::string("a") == input);
assert (1 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr >> input;
assert (std::string("test") == input);
assertTrue (std::string("test") == input);
assert (1 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr >> input;
assert (std::string("42") == input);
assertTrue (std::string("42") == input);
assert (1 == _readableToNot);
assert (1 == _notToReadable);
assert (1 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (1 == _notToReadable);
assertTrue (1 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr.clear();
assert (iostr.good());
assertTrue (iostr.good());
iostr << "This is a test " << 42 << std::ends << std::flush;
assert (iostr.rdbuf()->fifoBuffer().isFull());
assertTrue (iostr.rdbuf()->fifoBuffer().isFull());
assert (1 == _readableToNot);
assert (2 == _notToReadable);
assert (2 == _writableToNot);
assert (1 == _notToWritable);
assertTrue (1 == _readableToNot);
assertTrue (2 == _notToReadable);
assertTrue (2 == _writableToNot);
assertTrue (1 == _notToWritable);
iostr.readable -= delegate(this, &FIFOBufferStreamTest::onReadable);
iostr.writable -= delegate(this, &FIFOBufferStreamTest::onWritable);

View File

@ -38,50 +38,50 @@ void FIFOEventTest::testNoDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assertTrue (_count == 0);
Void.notify(this);
assert (_count == 0);
assertTrue (_count == 0);
Void += delegate(this, &FIFOEventTest::onVoid);
Void -= delegate(this, &FIFOEventTest::onVoid);
Void.notify(this);
assert (_count == 0);
assertTrue (_count == 0);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple -= delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
ConstSimple -= delegate(this, &FIFOEventTest::onConstSimple);
ConstSimple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
//Note: passing &args will not work due to &
EventArgs* pArgs = &args;
Complex += delegate(this, &FIFOEventTest::onComplex);
Complex -= delegate(this, &FIFOEventTest::onComplex);
Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
Complex2 += delegate(this, &FIFOEventTest::onComplex2);
Complex2 -= delegate(this, &FIFOEventTest::onComplex2);
Complex2.notify(this, args);
assert (_count == 0);
assertTrue (_count == 0);
const EventArgs* pCArgs = &args;
ConstComplex += delegate(this, &FIFOEventTest::onConstComplex);
ConstComplex -= delegate(this, &FIFOEventTest::onConstComplex);
ConstComplex.notify(this, pCArgs);
assert (_count == 0);
assertTrue (_count == 0);
Const2Complex += delegate(this, &FIFOEventTest::onConst2Complex);
Const2Complex -= delegate(this, &FIFOEventTest::onConst2Complex);
Const2Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
}
void FIFOEventTest::testSingleDelegate()
@ -89,40 +89,40 @@ void FIFOEventTest::testSingleDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assertTrue (_count == 0);
Void += delegate(this, &FIFOEventTest::onVoid);
Void.notify(this);
assert (_count == 1);
assertTrue (_count == 1);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
ConstSimple += delegate(this, &FIFOEventTest::onConstSimple);
ConstSimple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
EventArgs* pArgs = &args;
Complex += delegate(this, &FIFOEventTest::onComplex);
Complex.notify(this, pArgs);
assert (_count == 4);
assertTrue (_count == 4);
Complex2 += delegate(this, &FIFOEventTest::onComplex2);
Complex2.notify(this, args);
assert (_count == 5);
assertTrue (_count == 5);
const EventArgs* pCArgs = &args;
ConstComplex += delegate(this, &FIFOEventTest::onConstComplex);
ConstComplex.notify(this, pCArgs);
assert (_count == 6);
assertTrue (_count == 6);
Const2Complex += delegate(this, &FIFOEventTest::onConst2Complex);
Const2Complex.notify(this, pArgs);
assert (_count == 7);
assertTrue (_count == 7);
// check if 2nd notify also works
Const2Complex.notify(this, pArgs);
assert (_count == 8);
assertTrue (_count == 8);
}
@ -130,15 +130,15 @@ void FIFOEventTest::testDuplicateRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
Simple -= delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
void FIFOEventTest::testDuplicateUnregister()
@ -146,23 +146,23 @@ void FIFOEventTest::testDuplicateUnregister()
// duplicate unregister shouldn't give an error,
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple -= delegate(this, &FIFOEventTest::onSimple); // should work
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= delegate(this, &FIFOEventTest::onSimple);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
@ -170,22 +170,22 @@ void FIFOEventTest::testDisabling()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple);
Simple.disable();
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
// unregister should also work with disabled event
Simple.disable();
Simple -= delegate(this, &FIFOEventTest::onSimple);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
void FIFOEventTest::testFIFOOrder()
@ -193,13 +193,13 @@ void FIFOEventTest::testFIFOOrder()
DummyDelegate o1;
DummyDelegate o2;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(&o1, &DummyDelegate::onSimple);
Simple += delegate(&o2, &DummyDelegate::onSimple2);
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
Simple -= delegate(&o1, &DummyDelegate::onSimple);
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
@ -225,32 +225,32 @@ void FIFOEventTest::testFIFOOrderExpire()
DummyDelegate o1;
DummyDelegate o2;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(&o1, &DummyDelegate::onSimple, 5000);
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// both ways of unregistering should work
Simple -= delegate(&o1, &DummyDelegate::onSimple, 6000);
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// now start mixing of expire and non expire
tmp = 0;
Simple += delegate(&o1, &DummyDelegate::onSimple);
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
Simple -= delegate(&o2, &DummyDelegate::onSimple2);
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
Simple -= delegate(&o1, &DummyDelegate::onSimple, 6000);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// now try with the wrong order
Simple += delegate(&o2, &DummyDelegate::onSimple2, 5000);
@ -273,14 +273,14 @@ void FIFOEventTest::testExpire()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(700);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
@ -288,22 +288,22 @@ void FIFOEventTest::testExpireReRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += delegate(this, &FIFOEventTest::onSimple, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(200);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
// renew registration
Simple += delegate(this, &FIFOEventTest::onSimple, 600);
Poco::Thread::sleep(400);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Poco::Thread::sleep(300);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
@ -314,7 +314,7 @@ void FIFOEventTest::testReturnParams()
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 1);
assertTrue (tmp == 1);
}
void FIFOEventTest::testOverwriteDelegate()
@ -325,22 +325,22 @@ void FIFOEventTest::testOverwriteDelegate()
int tmp = 0; // onsimple requires 0 as input
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
}
void FIFOEventTest::testAsyncNotify()
{
Poco::FIFOEvent<int >* pSimple= new Poco::FIFOEvent<int>();
(*pSimple) += delegate(this, &FIFOEventTest::onAsync);
assert (_count == 0);
assertTrue (_count == 0);
int tmp = 0;
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
delete pSimple; // must work even when the event got deleted!
pSimple = NULL;
assert (_count == 0);
assertTrue (_count == 0);
retArg.wait();
assert (retArg.data() == tmp);
assert (_count == LARGEINC);
assertTrue (retArg.data() == tmp);
assertTrue (_count == LARGEINC);
}
void FIFOEventTest::onVoid(const void* pSender)

View File

@ -35,10 +35,10 @@ void FPETest::testClassify()
float nan = a/b;
float inf = 1.0f/b;
assert (FPE::isNaN(nan));
assert (!FPE::isNaN(a));
assert (FPE::isInfinite(inf));
assert (!FPE::isInfinite(a));
assertTrue (FPE::isNaN(nan));
assertTrue (!FPE::isNaN(a));
assertTrue (FPE::isInfinite(inf));
assertTrue (!FPE::isInfinite(a));
}
{
double a = 0;
@ -46,10 +46,10 @@ void FPETest::testClassify()
double nan = a/b;
double inf = 1.0/b;
assert (FPE::isNaN(nan));
assert (!FPE::isNaN(a));
assert (FPE::isInfinite(inf));
assert (!FPE::isInfinite(a));
assertTrue (FPE::isNaN(nan));
assertTrue (!FPE::isNaN(a));
assertTrue (FPE::isInfinite(inf));
assertTrue (!FPE::isInfinite(a));
}
}
@ -87,16 +87,16 @@ void FPETest::testFlags()
volatile double c = div(a, b);
#if !defined(POCO_NO_FPENVIRONMENT)
assert (FPE::isFlag(FPE::FP_DIVIDE_BY_ZERO));
assertTrue (FPE::isFlag(FPE::FP_DIVIDE_BY_ZERO));
#endif
assert (FPE::isInfinite(c));
assertTrue (FPE::isInfinite(c));
FPE::clearFlags();
a = 1.23456789e210;
b = 9.87654321e210;
c = mult(a, b);
#if !defined(POCO_NO_FPENVIRONMENT)
assert (FPE::isFlag(FPE::FP_OVERFLOW));
assertTrue (FPE::isFlag(FPE::FP_OVERFLOW));
#endif
assertEqualDelta(c, c, 0);
@ -105,7 +105,7 @@ void FPETest::testFlags()
b = 9.87654321e210;
c = div(a, b);
#if !defined(POCO_NO_FPENVIRONMENT)
assert (FPE::isFlag(FPE::FP_UNDERFLOW));
assertTrue (FPE::isFlag(FPE::FP_UNDERFLOW));
#endif
assertEqualDelta(c, c, 0);
}
@ -124,12 +124,12 @@ void FPETest::testRound()
{
#if !defined(__osf__) && !defined(__VMS) && !defined(POCO_NO_FPENVIRONMENT)
FPE::setRoundingMode(FPE::FP_ROUND_TONEAREST);
assert (FPE::getRoundingMode() == FPE::FP_ROUND_TONEAREST);
assertTrue (FPE::getRoundingMode() == FPE::FP_ROUND_TONEAREST);
{
FPE env(FPE::FP_ROUND_TOWARDZERO);
assert (FPE::getRoundingMode() == FPE::FP_ROUND_TOWARDZERO);
assertTrue (FPE::getRoundingMode() == FPE::FP_ROUND_TOWARDZERO);
}
assert (FPE::getRoundingMode() == FPE::FP_ROUND_TONEAREST);
assertTrue (FPE::getRoundingMode() == FPE::FP_ROUND_TONEAREST);
#endif
}

View File

@ -70,11 +70,11 @@ void FileChannelTest::testRotateBySize()
pChannel->log(msg);
}
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
f = name + ".1";
assert (f.exists());
assertTrue (f.exists());
f = name + ".2";
assert (!f.exists());
assertTrue (!f.exists());
}
catch (...)
{
@ -100,9 +100,9 @@ void FileChannelTest::testRotateByAge()
Thread::sleep(300);
}
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
f = name + ".1";
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -131,7 +131,7 @@ void FileChannelTest::testRotateAtTimeDayUTC()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -160,7 +160,7 @@ void FileChannelTest::testRotateAtTimeDayLocal()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -189,7 +189,7 @@ void FileChannelTest::testRotateAtTimeHourUTC()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -218,7 +218,7 @@ void FileChannelTest::testRotateAtTimeHourLocal()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -247,7 +247,7 @@ void FileChannelTest::testRotateAtTimeMinUTC()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -276,7 +276,7 @@ void FileChannelTest::testRotateAtTimeMinLocal()
}
pChannel->log(msg);
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -302,7 +302,7 @@ void FileChannelTest::testArchive()
pChannel->log(msg);
}
File f(name + ".0");
assert (f.exists());
assertTrue (f.exists());
}
catch (...)
{
@ -330,9 +330,9 @@ void FileChannelTest::testCompress()
}
Thread::sleep(3000); // allow time for background compression
File f0(name + ".0.gz");
assert (f0.exists());
assertTrue (f0.exists());
File f1(name + ".1.gz");
assert (f1.exists());
assertTrue (f1.exists());
}
catch (...)
{
@ -359,11 +359,11 @@ void FileChannelTest::purgeAge(const std::string& pa)
pChannel->log(msg);
}
File f0(name + ".0");
assert(f0.exists());
assertTrue (f0.exists());
File f1(name + ".1");
assert(f1.exists());
assertTrue (f1.exists());
File f2(name + ".2");
assert(f2.exists());
assertTrue (f2.exists());
Thread::sleep(5000);
for (int i = 0; i < 50; ++i)
@ -371,7 +371,7 @@ void FileChannelTest::purgeAge(const std::string& pa)
pChannel->log(msg);
}
assert(!f2.exists());
assertTrue (!f2.exists());
}
catch (...)
{
@ -399,11 +399,11 @@ void FileChannelTest::noPurgeAge(const std::string& npa)
pChannel->log(msg);
}
File f0(name + ".0");
assert(f0.exists());
assertTrue (f0.exists());
File f1(name + ".1");
assert(f1.exists());
assertTrue (f1.exists());
File f2(name + ".2");
assert(f2.exists());
assertTrue (f2.exists());
Thread::sleep(5000);
for (int i = 0; i < 50; ++i)
@ -411,7 +411,7 @@ void FileChannelTest::noPurgeAge(const std::string& npa)
pChannel->log(msg);
}
assert(f2.exists());
assertTrue (f2.exists());
}
catch (...)
{
@ -455,11 +455,11 @@ void FileChannelTest::purgeCount(const std::string& pc)
Thread::sleep(50);
}
File f0(name + ".0");
assert(f0.exists());
assertTrue (f0.exists());
File f1(name + ".1");
assert(f1.exists());
assertTrue (f1.exists());
File f2(name + ".2");
assert(!f2.exists());
assertTrue (!f2.exists());
} catch (...)
{
remove(name);
@ -486,11 +486,11 @@ void FileChannelTest::noPurgeCount(const std::string& npc)
Thread::sleep(50);
}
File f0(name + ".0");
assert(f0.exists());
assertTrue (f0.exists());
File f1(name + ".1");
assert(f1.exists());
assertTrue (f1.exists());
File f2(name + ".2");
assert(f2.exists());
assertTrue (f2.exists());
} catch (...)
{
remove(name);
@ -528,7 +528,7 @@ void FileChannelTest::testWrongPurgeOption()
fail("must fail");
} catch (InvalidArgumentException)
{
assert(pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
assertTrue (pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
}
try
@ -537,7 +537,7 @@ void FileChannelTest::testWrongPurgeOption()
fail("must fail");
} catch (InvalidArgumentException)
{
assert(pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
assertTrue (pChannel->getProperty(FileChannel::PROP_PURGEAGE) == "5 seconds");
}
remove(name);

View File

@ -48,10 +48,10 @@ void FileStreamTest::testRead()
fos.close();
Poco::FileInputStream fis(file);
assert (fis.good());
assertTrue (fis.good());
std::string read;
fis >> read;
assert (!read.empty());
assertTrue (!read.empty());
}
@ -72,15 +72,15 @@ void FileStreamTest::testWrite()
Poco::TemporaryFile::registerForDeletion(file);
Poco::FileOutputStream fos(file);
assert (fos.good());
assertTrue (fos.good());
fos << "hiho";
fos.close();
Poco::FileInputStream fis(file);
assert (fis.good());
assertTrue (fis.good());
std::string read;
fis >> read;
assert (read == "hiho");
assertTrue (read == "hiho");
}
@ -99,12 +99,12 @@ void FileStreamTest::testReadWrite()
Poco::TemporaryFile::registerForDeletion(file);
Poco::FileStream fos(file);
assert (fos.good());
assertTrue (fos.good());
fos << "hiho";
fos.seekg(0, std::ios::beg);
std::string read;
fos >> read;
assert (read == "hiho");
assertTrue (read == "hiho");
}
@ -112,7 +112,7 @@ void FileStreamTest::testOpen()
{
Poco::FileOutputStream ostr;
ostr.open("test.txt", std::ios::out);
assert (ostr.good());
assertTrue (ostr.good());
ostr.close();
}
@ -134,7 +134,7 @@ void FileStreamTest::testOpenModeIn()
f.createFile();
Poco::FileInputStream istr("nonexistent.txt");
assert (istr.good());
assertTrue (istr.good());
}
@ -148,20 +148,20 @@ void FileStreamTest::testOpenModeOut()
ostr1 << "Hello, world!";
ostr1.close();
assert (f.exists());
assert (f.getSize() != 0);
assertTrue (f.exists());
assertTrue (f.getSize() != 0);
Poco::FileStream str1("test.txt");
str1.close();
assert (f.exists());
assert (f.getSize() != 0);
assertTrue (f.exists());
assertTrue (f.getSize() != 0);
Poco::FileOutputStream ostr2("test.txt");
ostr2.close();
assert (f.exists());
assert (f.getSize() == 0);
assertTrue (f.exists());
assertTrue (f.getSize() == 0);
f.remove();
}
@ -177,14 +177,14 @@ void FileStreamTest::testOpenModeTrunc()
ostr1 << "Hello, world!";
ostr1.close();
assert (f.exists());
assert (f.getSize() != 0);
assertTrue (f.exists());
assertTrue (f.getSize() != 0);
Poco::FileStream str1("test.txt", std::ios::trunc);
str1.close();
assert (f.exists());
assert (f.getSize() == 0);
assertTrue (f.exists());
assertTrue (f.getSize() == 0);
f.remove();
}
@ -198,12 +198,12 @@ void FileStreamTest::testOpenModeAte()
Poco::FileStream str1("test.txt", std::ios::ate);
int c = str1.get();
assert (str1.eof());
assertTrue (str1.eof());
str1.clear();
str1.seekg(0);
c = str1.get();
assert (c == '0');
assertTrue (c == '0');
str1.close();
@ -212,7 +212,7 @@ void FileStreamTest::testOpenModeAte()
str2.seekg(0);
std::string s;
str2 >> s;
assert (s == "0123456789abcdef");
assertTrue (s == "0123456789abcdef");
str2.close();
}
@ -236,7 +236,7 @@ void FileStreamTest::testOpenModeApp()
Poco::FileInputStream istr("test.txt");
std::string s;
istr >> s;
assert (s == "0123456789abcdef");
assertTrue (s == "0123456789abcdef");
istr.close();
}
@ -248,37 +248,37 @@ void FileStreamTest::testSeek()
str.seekg(0);
int c = str.get();
assert (c == '0');
assertTrue (c == '0');
str.seekg(10);
assert (str.tellg() == std::streampos(10));
assertTrue (str.tellg() == std::streampos(10));
c = str.get();
assert (c == 'a');
assert (str.tellg() == std::streampos(11));
assertTrue (c == 'a');
assertTrue (str.tellg() == std::streampos(11));
str.seekg(-1, std::ios::end);
assert (str.tellg() == std::streampos(15));
assertTrue (str.tellg() == std::streampos(15));
c = str.get();
assert (c == 'f');
assert (str.tellg() == std::streampos(16));
assertTrue (c == 'f');
assertTrue (str.tellg() == std::streampos(16));
str.seekg(-1, std::ios::cur);
assert (str.tellg() == std::streampos(15));
assertTrue (str.tellg() == std::streampos(15));
c = str.get();
assert (c == 'f');
assert (str.tellg() == std::streampos(16));
assertTrue (c == 'f');
assertTrue (str.tellg() == std::streampos(16));
str.seekg(-4, std::ios::cur);
assert (str.tellg() == std::streampos(12));
assertTrue (str.tellg() == std::streampos(12));
c = str.get();
assert (c == 'c');
assert (str.tellg() == std::streampos(13));
assertTrue (c == 'c');
assertTrue (str.tellg() == std::streampos(13));
str.seekg(1, std::ios::cur);
assert (str.tellg() == std::streampos(14));
assertTrue (str.tellg() == std::streampos(14));
c = str.get();
assert (c == 'e');
assert (str.tellg() == std::streampos(15));
assertTrue (c == 'e');
assertTrue (str.tellg() == std::streampos(15));
}
@ -293,12 +293,12 @@ void FileStreamTest::testMultiOpen()
std::string s;
str.open("test.txt", std::ios::in);
std::getline(str, s);
assert (s == "0123456789");
assertTrue (s == "0123456789");
str.close();
str.open("test.txt", std::ios::in);
std::getline(str, s);
assert (s == "0123456789");
assertTrue (s == "0123456789");
str.close();
}

View File

@ -41,7 +41,7 @@ FileTest::~FileTest()
void FileTest::testFileAttributes1()
{
File f("testfile.dat");
assert (!f.exists());
assertTrue (!f.exists());
try
{
@ -185,10 +185,10 @@ void FileTest::testCreateFile()
{
File f("testfile.dat");
bool created = f.createFile();
assert (created);
assert (!f.isHidden());
assertTrue (created);
assertTrue (!f.isHidden());
created = f.createFile();
assert (!created);
assertTrue (!created);
}
@ -197,29 +197,29 @@ void FileTest::testFileAttributes2()
TemporaryFile f;
bool created = f.createFile();
Timestamp ts;
assert (created);
assertTrue (created);
assert (f.exists());
assert (f.canRead());
assert (f.canWrite());
assert (f.isFile());
assert (!f.isDirectory());
assertTrue (f.exists());
assertTrue (f.canRead());
assertTrue (f.canWrite());
assertTrue (f.isFile());
assertTrue (!f.isDirectory());
Timestamp tsc = f.created();
Timestamp tsm = f.getLastModified();
assert (tsc - ts >= -2000000 && tsc - ts <= 2000000);
assert (tsm - ts >= -2000000 && tsm - ts <= 2000000);
assertTrue (tsc - ts >= -2000000 && tsc - ts <= 2000000);
assertTrue (tsm - ts >= -2000000 && tsm - ts <= 2000000);
f.setWriteable(false);
assert (!f.canWrite());
assert (f.canRead());
assertTrue (!f.canWrite());
assertTrue (f.canRead());
f.setReadOnly(false);
assert (f.canWrite());
assert (f.canRead());
assertTrue (f.canWrite());
assertTrue (f.canRead());
ts = Timestamp::fromEpochTime(1000000);
f.setLastModified(ts);
assert (f.getLastModified() == ts);
assertTrue (f.getLastModified() == ts);
}
@ -236,9 +236,9 @@ void FileTest::testFileAttributes3()
#endif
#if !defined(_WIN32_WCE)
assert (f.isDevice());
assert (!f.isFile());
assert (!f.isDirectory());
assertTrue (f.isDevice());
assertTrue (!f.isFile());
assertTrue (!f.isDirectory());
#endif
}
@ -249,22 +249,22 @@ void FileTest::testCompare()
File f2("def.txt");
File f3("abc.txt");
assert (f1 == f3);
assert (!(f1 == f2));
assert (f1 != f2);
assert (!(f1 != f3));
assert (!(f1 == f2));
assert (f1 < f2);
assert (f1 <= f2);
assert (!(f2 < f1));
assert (!(f2 <= f1));
assert (f2 > f1);
assert (f2 >= f1);
assert (!(f1 > f2));
assert (!(f1 >= f2));
assertTrue (f1 == f3);
assertTrue (!(f1 == f2));
assertTrue (f1 != f2);
assertTrue (!(f1 != f3));
assertTrue (!(f1 == f2));
assertTrue (f1 < f2);
assertTrue (f1 <= f2);
assertTrue (!(f2 < f1));
assertTrue (!(f2 <= f1));
assertTrue (f2 > f1);
assertTrue (f2 >= f1);
assertTrue (!(f1 > f2));
assertTrue (!(f1 >= f2));
assert (f1 <= f3);
assert (f1 >= f3);
assertTrue (f1 <= f3);
assertTrue (f1 >= f3);
}
@ -274,21 +274,21 @@ void FileTest::testRootDir()
#if defined(_WIN32_WCE)
File f1("\\");
File f2("/");
assert (f1.exists());
assert (f2.exists());
assertTrue (f1.exists());
assertTrue (f2.exists());
#else
File f1("/");
File f2("c:/");
File f3("c:\\");
File f4("\\");
assert (f1.exists());
assert (f2.exists());
assert (f3.exists());
assert (f4.exists());
assertTrue (f1.exists());
assertTrue (f2.exists());
assertTrue (f3.exists());
assertTrue (f4.exists());
#endif
#else
File f1("/");
assert (f1.exists());
assertTrue (f1.exists());
#endif
}
@ -298,8 +298,8 @@ void FileTest::testSwap()
File f1("abc.txt");
File f2("def.txt");
f1.swap(f2);
assert (f1.path() == "def.txt");
assert (f2.path() == "abc.txt");
assertTrue (f1.path() == "def.txt");
assertTrue (f2.path() == "abc.txt");
}
@ -309,9 +309,9 @@ void FileTest::testSize()
ostr << "Hello, world!" << std::endl;
ostr.close();
File f("testfile.dat");
assert (f.getSize() > 0);
assertTrue (f.getSize() > 0);
f.setSize(0);
assert (f.getSize() == 0);
assertTrue (f.getSize() == 0);
}
@ -328,12 +328,12 @@ void FileTest::testDirectory()
TemporaryFile::registerForDeletion("testdir");
bool created = d.createDirectory();
assert (created);
assert (d.isDirectory());
assert (!d.isFile());
assertTrue (created);
assertTrue (d.isDirectory());
assertTrue (!d.isFile());
std::vector<std::string> files;
d.list(files);
assert (files.empty());
assertTrue (files.empty());
File f = Path("testdir/file1", Path::PATH_UNIX);
f.createFile();
@ -343,23 +343,23 @@ void FileTest::testDirectory()
f.createFile();
d.list(files);
assert (files.size() == 3);
assertTrue (files.size() == 3);
std::set<std::string> fs;
fs.insert(files.begin(), files.end());
assert (fs.find("file1") != fs.end());
assert (fs.find("file2") != fs.end());
assert (fs.find("file3") != fs.end());
assertTrue (fs.find("file1") != fs.end());
assertTrue (fs.find("file2") != fs.end());
assertTrue (fs.find("file3") != fs.end());
File dd(Path("testdir/testdir2/testdir3", Path::PATH_UNIX));
dd.createDirectories();
assert (dd.exists());
assert (dd.isDirectory());
assertTrue (dd.exists());
assertTrue (dd.isDirectory());
File ddd(Path("testdir/testdirB/testdirC/testdirD", Path::PATH_UNIX));
ddd.createDirectories();
assert (ddd.exists());
assert (ddd.isDirectory());
assertTrue (ddd.exists());
assertTrue (ddd.isDirectory());
d.remove(true);
}
@ -374,9 +374,9 @@ void FileTest::testCopy()
File f1("testfile.dat");
TemporaryFile f2;
f1.setReadOnly().copyTo(f2.path());
assert (f2.exists());
assert (!f2.canWrite());
assert (f1.getSize() == f2.getSize());
assertTrue (f2.exists());
assertTrue (!f2.canWrite());
assertTrue (f1.getSize() == f2.getSize());
f1.setWriteable().remove();
}
@ -391,10 +391,10 @@ void FileTest::testMove()
File::FileSize sz = f1.getSize();
TemporaryFile f2;
f1.moveTo(f2.path());
assert (f2.exists());
assert (f2.getSize() == sz);
assert (f1.exists());
assert (f1 == f2);
assertTrue (f2.exists());
assertTrue (f2.getSize() == sz);
assertTrue (f1.exists());
assertTrue (f1 == f2);
}
@ -440,28 +440,28 @@ void FileTest::testCopyDirectory()
Path pd1t("testdir2");
File fd1t(pd1t);
assert (fd1t.exists());
assert (fd1t.isDirectory());
assertTrue (fd1t.exists());
assertTrue (fd1t.isDirectory());
Path pd2t(pd1t, "subdir");
File fd2t(pd2t);
assert (fd2t.exists());
assert (fd2t.isDirectory());
assertTrue (fd2t.exists());
assertTrue (fd2t.isDirectory());
Path pf1t(pd1t, "testfile1.dat");
File ff1t(pf1t);
assert (ff1t.exists());
assert (ff1t.isFile());
assertTrue (ff1t.exists());
assertTrue (ff1t.isFile());
Path pf2t(pd1t, "testfile2.dat");
File ff2t(pf2t);
assert (ff2t.exists());
assert (ff2t.isFile());
assertTrue (ff2t.exists());
assertTrue (ff2t.isFile());
Path pf3t(pd2t, "testfile3.dat");
File ff3t(pf3t);
assert (ff3t.exists());
assert (ff3t.isFile());
assertTrue (ff3t.exists());
assertTrue (ff3t.isFile());
fd1.remove(true);
fd3.remove(true);
@ -478,9 +478,9 @@ void FileTest::testRename()
File f2("testfile2.dat");
f1.renameTo(f2.path());
assert (f2.exists());
assert (f1.exists());
assert (f1 == f2);
assertTrue (f2.exists());
assertTrue (f1.exists());
assertTrue (f1 == f2);
f2.remove();
}
@ -501,8 +501,8 @@ void FileTest::testLongPath()
Poco::File d(longpath);
d.createDirectories();
assert (d.exists());
assert (d.isDirectory());
assertTrue (d.exists());
assertTrue (d.isDirectory());
Poco::File f(p.toString());
f.remove(true);

View File

@ -36,14 +36,14 @@ void FormatTest::testChar()
{
char c = 'a';
std::string s(format("%c", c));
assert(s == "a");
assertTrue (s == "a");
s = format("%2c", c);
assert(s == " a");
assertTrue (s == " a");
s = format("%-2c", c);
assert(s == "a ");
assertTrue (s == "a ");
s = format("%c", std::string("foo"));
assert(s == "[ERRFMT]");
assertTrue (s == "[ERRFMT]");
}
@ -51,119 +51,119 @@ void FormatTest::testInt()
{
int i = 42;
std::string s(format("%d", i));
assert (s == "42");
assertTrue (s == "42");
s = format("%4d", i);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04d", i);
assert (s == "0042");
assertTrue (s == "0042");
short h = 42;
s = format("%hd", h);
assert (s == "42");
assertTrue (s == "42");
s = format("%4hd", h);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04hd", h);
assert (s == "0042");
assertTrue (s == "0042");
unsigned short hu = 42;
s = format("%hu", hu);
assert (s == "42");
assertTrue (s == "42");
s = format("%4hu", hu);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04hu", hu);
assert (s == "0042");
assertTrue (s == "0042");
unsigned x = 0x42;
s = format("%x", x);
assert (s == "42");
assertTrue (s == "42");
s = format("%4x", x);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04x", x);
assert (s == "0042");
assertTrue (s == "0042");
unsigned o = 042;
s = format("%o", o);
assert (s == "42");
assertTrue (s == "42");
s = format("%4o", o);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04o", o);
assert (s == "0042");
assertTrue (s == "0042");
unsigned u = 42;
s = format("%u", u);
assert (s == "42");
assertTrue (s == "42");
s = format("%4u", u);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04u", u);
assert (s == "0042");
assertTrue (s == "0042");
long l = 42;
s = format("%ld", l);
assert (s == "42");
assertTrue (s == "42");
s = format("%4ld", l);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04ld", l);
assert (s == "0042");
assertTrue (s == "0042");
unsigned long ul = 42;
s = format("%lu", ul);
assert (s == "42");
assertTrue (s == "42");
s = format("%4lu", ul);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04lu", ul);
assert (s == "0042");
assertTrue (s == "0042");
unsigned long xl = 0x42;
s = format("%lx", xl);
assert (s == "42");
assertTrue (s == "42");
s = format("%4lx", xl);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04lx", xl);
assert (s == "0042");
assertTrue (s == "0042");
Int64 i64 = 42;
s = format("%Ld", i64);
assert (s == "42");
assertTrue (s == "42");
s = format("%4Ld", i64);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04Ld", i64);
assert (s == "0042");
assertTrue (s == "0042");
UInt64 ui64 = 42;
s = format("%Lu", ui64);
assert (s == "42");
assertTrue (s == "42");
s = format("%4Lu", ui64);
assert (s == " 42");
assertTrue (s == " 42");
s = format("%04Lu", ui64);
assert (s == "0042");
assertTrue (s == "0042");
x = 0xaa;
s = format("%x", x);
assert (s == "aa");
assertTrue (s == "aa");
s = format("%X", x);
assert (s == "AA");
assertTrue (s == "AA");
i = 42;
s = format("%+d", i);
assert (s == "+42");
assertTrue (s == "+42");
i = -42;
s = format("%+d", i);
assert (s == "-42");
assertTrue (s == "-42");
s = format("%+04d", i);
assert (s == "-042");
assertTrue (s == "-042");
s = format("%d", i);
assert (s == "-42");
assertTrue (s == "-42");
s = format("%d", i);
assert (s == "-42");
assertTrue (s == "-42");
x = 0x42;
s = format("%#x", x);
assert (s == "0x42");
assertTrue (s == "0x42");
s = format("%d", l);
assert (s == "[ERRFMT]");
assertTrue (s == "[ERRFMT]");
}
@ -171,11 +171,11 @@ void FormatTest::testBool()
{
bool b = true;
std::string s = format("%b", b);
assert (s == "1");
assertTrue (s == "1");
b = false;
s = format("%b", b);
assert (s == "0");
assertTrue (s == "0");
std::vector<Poco::Any> bv;
bv.push_back(false);
@ -191,7 +191,7 @@ void FormatTest::testBool()
s.clear();
format(s, "%b%b%b%b%b%b%b%b%b%b", bv);
assert (s == "0101010101");
assertTrue (s == "0101010101");
}
@ -199,59 +199,59 @@ void FormatTest::testAnyInt()
{
char c = 42;
std::string s(format("%?i", c));
assert (s == "42");
assertTrue (s == "42");
bool b = true;
s = format("%?i", b);
assert (s == "1");
assertTrue (s == "1");
signed char sc = -42;
s = format("%?i", sc);
assert (s == "-42");
assertTrue (s == "-42");
unsigned char uc = 65;
s = format("%?i", uc);
assert (s == "65");
assertTrue (s == "65");
short ss = -134;
s = format("%?i", ss);
assert (s == "-134");
assertTrue (s == "-134");
unsigned short us = 200;
s = format("%?i", us);
assert (s == "200");
assertTrue (s == "200");
int i = -12345;
s = format("%?i", i);
assert (s == "-12345");
assertTrue (s == "-12345");
unsigned ui = 12345;
s = format("%?i", ui);
assert (s == "12345");
assertTrue (s == "12345");
long l = -54321;
s = format("%?i", l);
assert (s == "-54321");
assertTrue (s == "-54321");
unsigned long ul = 54321;
s = format("%?i", ul);
assert (s == "54321");
assertTrue (s == "54321");
Int64 i64 = -12345678;
s = format("%?i", i64);
assert (s == "-12345678");
assertTrue (s == "-12345678");
UInt64 ui64 = 12345678;
s = format("%?i", ui64);
assert (s == "12345678");
assertTrue (s == "12345678");
ss = 0x42;
s = format("%?x", ss);
assert (s == "42");
assertTrue (s == "42");
ss = 042;
s = format("%?o", ss);
assert (s == "42");
assertTrue (s == "42");
}
@ -259,22 +259,22 @@ void FormatTest::testFloatFix()
{
double d = 1.5;
std::string s(format("%f", d));
assert (s.find("1.50") == 0);
assertTrue (s.find("1.50") == 0);
s = format("%10f", d);
assert (s.find(" 1.50") != std::string::npos);
assertTrue (s.find(" 1.50") != std::string::npos);
s = format("%6.2f", d);
assert (s == " 1.50");
assertTrue (s == " 1.50");
s = format("%-6.2f", d);
assert (s == "1.50 ");
assertTrue (s == "1.50 ");
float f = 1.5;
s = format("%hf", f);
assert (s.find("1.50") == 0);
assertTrue (s.find("1.50") == 0);
s = format("%.0f", 1.0);
assert (s == "1");
assertTrue (s == "1");
}
@ -282,19 +282,19 @@ void FormatTest::testFloatSci()
{
double d = 1.5;
std::string s(format("%e", d));
assert (s.find("1.50") == 0);
assert (s.find("0e+0") != std::string::npos);
assertTrue (s.find("1.50") == 0);
assertTrue (s.find("0e+0") != std::string::npos);
s = format("%20e", d);
assert (s.find(" 1.50") != std::string::npos);
assert (s.find("0e+0") != std::string::npos);
assertTrue (s.find(" 1.50") != std::string::npos);
assertTrue (s.find("0e+0") != std::string::npos);
s = format("%10.2e", d);
assert (s == " 1.50e+000" || s == " 1.50e+00");
assertTrue (s == " 1.50e+000" || s == " 1.50e+00");
s = format("%-10.2e", d);
assert (s == "1.50e+000 " || s == "1.50e+00 ");
assertTrue (s == "1.50e+000 " || s == "1.50e+00 ");
s = format("%-10.2E", d);
assert (s == "1.50E+000 " || s == "1.50E+00 ");
assertTrue (s == "1.50E+000 " || s == "1.50E+00 ");
}
@ -302,54 +302,54 @@ void FormatTest::testString()
{
std::string foo("foo");
std::string s(format("%s", foo));
assert (s == "foo");
assertTrue (s == "foo");
s = format("%5s", foo);
assert (s == " foo");
assertTrue (s == " foo");
s = format("%-5s", foo);
assert (s == "foo ");
assertTrue (s == "foo ");
s = format("%s%%a", foo);
assert (s == "foo%a");
assertTrue (s == "foo%a");
s = format("'%s%%''%s%%'", foo, foo);
assert (s == "'foo%''foo%'");
assertTrue (s == "'foo%''foo%'");
}
void FormatTest::testMultiple()
{
std::string s(format("aaa%dbbb%4dccc", 1, 2));
assert (s == "aaa1bbb 2ccc");
assertTrue (s == "aaa1bbb 2ccc");
s = format("%%%d%%%d%%%d", 1, 2, 3);
assert (s == "%1%2%3");
assertTrue (s == "%1%2%3");
s = format("%d%d%d%d", 1, 2, 3, 4);
assert (s == "1234");
assertTrue (s == "1234");
s = format("%d%d%d%d%d", 1, 2, 3, 4, 5);
assert (s == "12345");
assertTrue (s == "12345");
s = format("%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6);
assert (s == "123456");
assertTrue (s == "123456");
}
void FormatTest::testIndex()
{
std::string s(format("%[1]d%[0]d", 1, 2));
assert(s == "21");
assertTrue (s == "21");
s = format("%[5]d%[4]d%[3]d%[2]d%[1]d%[0]d", 1, 2, 3, 4, 5, 6);
assert(s == "654321");
assertTrue (s == "654321");
s = format("%%%[1]d%%%[2]d%%%d", 1, 2, 3);
assert(s == "%2%3%1");
assertTrue (s == "%2%3%1");
s = format("%%%d%%%d%%%[0]d", 1, 2);
assert(s == "%1%2%1");
assertTrue (s == "%1%2%1");
}

View File

@ -35,343 +35,343 @@ GlobTest::~GlobTest()
void GlobTest::testMatchChars()
{
Glob g1("a");
assert (g1.match("a"));
assert (!g1.match("b"));
assert (!g1.match("aa"));
assert (!g1.match(""));
assertTrue (g1.match("a"));
assertTrue (!g1.match("b"));
assertTrue (!g1.match("aa"));
assertTrue (!g1.match(""));
Glob g2("ab");
assert (g2.match("ab"));
assert (!g2.match("aab"));
assert (!g2.match("abab"));
assertTrue (g2.match("ab"));
assertTrue (!g2.match("aab"));
assertTrue (!g2.match("abab"));
}
void GlobTest::testMatchQM()
{
Glob g1("?");
assert (g1.match("a"));
assert (g1.match("b"));
assert (!g1.match("aa"));
assert (g1.match("."));
assertTrue (g1.match("a"));
assertTrue (g1.match("b"));
assertTrue (!g1.match("aa"));
assertTrue (g1.match("."));
Glob g2("\\?");
assert (g2.match("?"));
assert (!g2.match("a"));
assert (!g2.match("ab"));
assertTrue (g2.match("?"));
assertTrue (!g2.match("a"));
assertTrue (!g2.match("ab"));
Glob g3("a?");
assert (g3.match("aa"));
assert (g3.match("az"));
assert (!g3.match("a"));
assert (!g3.match("aaa"));
assertTrue (g3.match("aa"));
assertTrue (g3.match("az"));
assertTrue (!g3.match("a"));
assertTrue (!g3.match("aaa"));
Glob g4("??");
assert (g4.match("aa"));
assert (g4.match("ab"));
assert (!g4.match("a"));
assert (!g4.match("abc"));
assertTrue (g4.match("aa"));
assertTrue (g4.match("ab"));
assertTrue (!g4.match("a"));
assertTrue (!g4.match("abc"));
Glob g5("?a?");
assert (g5.match("aaa"));
assert (g5.match("bac"));
assert (!g5.match("bbc"));
assert (!g5.match("ba"));
assert (!g5.match("ab"));
assertTrue (g5.match("aaa"));
assertTrue (g5.match("bac"));
assertTrue (!g5.match("bbc"));
assertTrue (!g5.match("ba"));
assertTrue (!g5.match("ab"));
Glob g6("a\\?");
assert (g6.match("a?"));
assert (!g6.match("az"));
assert (!g6.match("a"));
assertTrue (g6.match("a?"));
assertTrue (!g6.match("az"));
assertTrue (!g6.match("a"));
Glob g7("?", Glob::GLOB_DOT_SPECIAL);
assert (g7.match("a"));
assert (g7.match("b"));
assert (!g7.match("aa"));
assert (!g7.match("."));
assertTrue (g7.match("a"));
assertTrue (g7.match("b"));
assertTrue (!g7.match("aa"));
assertTrue (!g7.match("."));
}
void GlobTest::testMatchAsterisk()
{
Glob g1("*");
assert (g1.match(""));
assert (g1.match("a"));
assert (g1.match("ab"));
assert (g1.match("abc"));
assert (g1.match("."));
assertTrue (g1.match(""));
assertTrue (g1.match("a"));
assertTrue (g1.match("ab"));
assertTrue (g1.match("abc"));
assertTrue (g1.match("."));
Glob g2("a*");
assert (g2.match("a"));
assert (g2.match("aa"));
assert (g2.match("abc"));
assert (!g2.match("b"));
assert (!g2.match("ba"));
assertTrue (g2.match("a"));
assertTrue (g2.match("aa"));
assertTrue (g2.match("abc"));
assertTrue (!g2.match("b"));
assertTrue (!g2.match("ba"));
Glob g3("ab*");
assert (g3.match("ab"));
assert (g3.match("abc"));
assert (g3.match("abab"));
assert (!g3.match("ac"));
assert (!g3.match("baab"));
assertTrue (g3.match("ab"));
assertTrue (g3.match("abc"));
assertTrue (g3.match("abab"));
assertTrue (!g3.match("ac"));
assertTrue (!g3.match("baab"));
Glob g4("*a");
assert (g4.match("a"));
assert (g4.match("ba"));
assert (g4.match("aa"));
assert (g4.match("aaaaaa"));
assert (g4.match("bbbbba"));
assert (!g4.match("b"));
assert (!g4.match("ab"));
assert (!g4.match("aaab"));
assertTrue (g4.match("a"));
assertTrue (g4.match("ba"));
assertTrue (g4.match("aa"));
assertTrue (g4.match("aaaaaa"));
assertTrue (g4.match("bbbbba"));
assertTrue (!g4.match("b"));
assertTrue (!g4.match("ab"));
assertTrue (!g4.match("aaab"));
Glob g5("a*a");
assert (g5.match("aa"));
assert (g5.match("aba"));
assert (g5.match("abba"));
assert (!g5.match("aab"));
assert (!g5.match("aaab"));
assert (!g5.match("baaaa"));
assertTrue (g5.match("aa"));
assertTrue (g5.match("aba"));
assertTrue (g5.match("abba"));
assertTrue (!g5.match("aab"));
assertTrue (!g5.match("aaab"));
assertTrue (!g5.match("baaaa"));
Glob g6("a*b*c");
assert (g6.match("abc"));
assert (g6.match("aabbcc"));
assert (g6.match("abcbbc"));
assert (g6.match("aaaabbbbcccc"));
assert (!g6.match("aaaabbbcb"));
assertTrue (g6.match("abc"));
assertTrue (g6.match("aabbcc"));
assertTrue (g6.match("abcbbc"));
assertTrue (g6.match("aaaabbbbcccc"));
assertTrue (!g6.match("aaaabbbcb"));
Glob g7("a*b*");
assert (g7.match("aaabbb"));
assert (g7.match("abababab"));
assert (g7.match("ab"));
assert (g7.match("aaaaab"));
assert (!g7.match("a"));
assert (!g7.match("aa"));
assert (!g7.match("aaa"));
assertTrue (g7.match("aaabbb"));
assertTrue (g7.match("abababab"));
assertTrue (g7.match("ab"));
assertTrue (g7.match("aaaaab"));
assertTrue (!g7.match("a"));
assertTrue (!g7.match("aa"));
assertTrue (!g7.match("aaa"));
Glob g8("**");
assert (g1.match(""));
assert (g1.match("a"));
assert (g1.match("ab"));
assert (g1.match("abc"));
assertTrue (g1.match(""));
assertTrue (g1.match("a"));
assertTrue (g1.match("ab"));
assertTrue (g1.match("abc"));
Glob g9("a\\*");
assert (g9.match("a*"));
assert (!g9.match("aa"));
assert (!g9.match("a"));
assertTrue (g9.match("a*"));
assertTrue (!g9.match("aa"));
assertTrue (!g9.match("a"));
Glob g10("a*\\*");
assert (g10.match("a*"));
assert (g10.match("aaa*"));
assert (!g10.match("a"));
assert (!g10.match("aa"));
assertTrue (g10.match("a*"));
assertTrue (g10.match("aaa*"));
assertTrue (!g10.match("a"));
assertTrue (!g10.match("aa"));
Glob g11("*", Glob::GLOB_DOT_SPECIAL);
assert (g11.match(""));
assert (g11.match("a"));
assert (g11.match("ab"));
assert (g11.match("abc"));
assert (!g11.match("."));
assertTrue (g11.match(""));
assertTrue (g11.match("a"));
assertTrue (g11.match("ab"));
assertTrue (g11.match("abc"));
assertTrue (!g11.match("."));
}
void GlobTest::testMatchRange()
{
Glob g1("[a]");
assert (g1.match("a"));
assert (!g1.match("b"));
assert (!g1.match("aa"));
assertTrue (g1.match("a"));
assertTrue (!g1.match("b"));
assertTrue (!g1.match("aa"));
Glob g2("[ab]");
assert (g2.match("a"));
assert (g2.match("b"));
assert (!g2.match("c"));
assert (!g2.match("ab"));
assertTrue (g2.match("a"));
assertTrue (g2.match("b"));
assertTrue (!g2.match("c"));
assertTrue (!g2.match("ab"));
Glob g3("[abc]");
assert (g3.match("a"));
assert (g3.match("b"));
assert (g3.match("c"));
assert (!g3.match("ab"));
assertTrue (g3.match("a"));
assertTrue (g3.match("b"));
assertTrue (g3.match("c"));
assertTrue (!g3.match("ab"));
Glob g4("[a-z]");
assert (g4.match("a"));
assert (g4.match("z"));
assert (!g4.match("A"));
assertTrue (g4.match("a"));
assertTrue (g4.match("z"));
assertTrue (!g4.match("A"));
Glob g5("[!a]");
assert (g5.match("b"));
assert (g5.match("c"));
assert (!g5.match("a"));
assert (!g5.match("bb"));
assertTrue (g5.match("b"));
assertTrue (g5.match("c"));
assertTrue (!g5.match("a"));
assertTrue (!g5.match("bb"));
Glob g6("[!a-z]");
assert (g6.match("A"));
assert (!g6.match("a"));
assert (!g6.match("z"));
assertTrue (g6.match("A"));
assertTrue (!g6.match("a"));
assertTrue (!g6.match("z"));
Glob g7("[0-9a-zA-Z_]");
assert (g7.match("0"));
assert (g7.match("1"));
assert (g7.match("8"));
assert (g7.match("9"));
assert (g7.match("a"));
assert (g7.match("b"));
assert (g7.match("z"));
assert (g7.match("A"));
assert (g7.match("Z"));
assert (g7.match("_"));
assert (!g7.match("-"));
assertTrue (g7.match("0"));
assertTrue (g7.match("1"));
assertTrue (g7.match("8"));
assertTrue (g7.match("9"));
assertTrue (g7.match("a"));
assertTrue (g7.match("b"));
assertTrue (g7.match("z"));
assertTrue (g7.match("A"));
assertTrue (g7.match("Z"));
assertTrue (g7.match("_"));
assertTrue (!g7.match("-"));
Glob g8("[1-3]");
assert (g8.match("1"));
assert (g8.match("2"));
assert (g8.match("3"));
assert (!g8.match("0"));
assert (!g8.match("4"));
assertTrue (g8.match("1"));
assertTrue (g8.match("2"));
assertTrue (g8.match("3"));
assertTrue (!g8.match("0"));
assertTrue (!g8.match("4"));
Glob g9("[!1-3]");
assert (g9.match("0"));
assert (g9.match("4"));
assert (!g9.match("1"));
assert (!g9.match("2"));
assert (!g9.match("3"));
assertTrue (g9.match("0"));
assertTrue (g9.match("4"));
assertTrue (!g9.match("1"));
assertTrue (!g9.match("2"));
assertTrue (!g9.match("3"));
Glob g10("[\\!a]");
assert (g10.match("!"));
assert (g10.match("a"));
assert (!g10.match("x"));
assertTrue (g10.match("!"));
assertTrue (g10.match("a"));
assertTrue (!g10.match("x"));
Glob g11("[a\\-c]");
assert (g11.match("a"));
assert (g11.match("c"));
assert (g11.match("-"));
assert (!g11.match("b"));
assertTrue (g11.match("a"));
assertTrue (g11.match("c"));
assertTrue (g11.match("-"));
assertTrue (!g11.match("b"));
Glob g12("[\\]]");
assert (g12.match("]"));
assert (!g12.match("["));
assertTrue (g12.match("]"));
assertTrue (!g12.match("["));
Glob g13("[[\\]]");
assert (g13.match("["));
assert (g13.match("]"));
assert (!g13.match("x"));
assertTrue (g13.match("["));
assertTrue (g13.match("]"));
assertTrue (!g13.match("x"));
Glob g14("\\[]");
assert (g14.match("[]"));
assert (!g14.match("[["));
assertTrue (g14.match("[]"));
assertTrue (!g14.match("[["));
Glob g15("a[bc]");
assert (g15.match("ab"));
assert (g15.match("ac"));
assert (!g15.match("a"));
assert (!g15.match("aa"));
assertTrue (g15.match("ab"));
assertTrue (g15.match("ac"));
assertTrue (!g15.match("a"));
assertTrue (!g15.match("aa"));
Glob g16("[ab]c");
assert (g16.match("ac"));
assert (g16.match("bc"));
assert (!g16.match("a"));
assert (!g16.match("b"));
assert (!g16.match("c"));
assert (!g16.match("aa"));
assertTrue (g16.match("ac"));
assertTrue (g16.match("bc"));
assertTrue (!g16.match("a"));
assertTrue (!g16.match("b"));
assertTrue (!g16.match("c"));
assertTrue (!g16.match("aa"));
}
void GlobTest::testMisc()
{
Glob g1("*.cpp");
assert (g1.match("Glob.cpp"));
assert (!g1.match("Glob.h"));
assertTrue (g1.match("Glob.cpp"));
assertTrue (!g1.match("Glob.h"));
Glob g2("*.[hc]");
assert (g2.match("foo.c"));
assert (g2.match("foo.h"));
assert (!g2.match("foo.i"));
assertTrue (g2.match("foo.c"));
assertTrue (g2.match("foo.h"));
assertTrue (!g2.match("foo.i"));
Glob g3("*.*");
assert (g3.match("foo.cpp"));
assert (g3.match("foo.h"));
assert (g3.match("foo."));
assert (!g3.match("foo"));
assertTrue (g3.match("foo.cpp"));
assertTrue (g3.match("foo.h"));
assertTrue (g3.match("foo."));
assertTrue (!g3.match("foo"));
Glob g4("File*.?pp");
assert (g4.match("File.hpp"));
assert (g4.match("File.cpp"));
assert (g4.match("Filesystem.hpp"));
assert (!g4.match("File.h"));
assertTrue (g4.match("File.hpp"));
assertTrue (g4.match("File.cpp"));
assertTrue (g4.match("Filesystem.hpp"));
assertTrue (!g4.match("File.h"));
Glob g5("File*.[ch]*");
assert (g5.match("File.hpp"));
assert (g5.match("File.cpp"));
assert (g5.match("Filesystem.hpp"));
assert (g5.match("File.h"));
assert (g5.match("Filesystem.cp"));
assertTrue (g5.match("File.hpp"));
assertTrue (g5.match("File.cpp"));
assertTrue (g5.match("Filesystem.hpp"));
assertTrue (g5.match("File.h"));
assertTrue (g5.match("Filesystem.cp"));
}
void GlobTest::testCaseless()
{
Glob g1("*.cpp", Glob::GLOB_CASELESS);
assert (g1.match("Glob.cpp"));
assert (!g1.match("Glob.h"));
assert (g1.match("Glob.CPP"));
assert (!g1.match("Glob.H"));
assertTrue (g1.match("Glob.cpp"));
assertTrue (!g1.match("Glob.h"));
assertTrue (g1.match("Glob.CPP"));
assertTrue (!g1.match("Glob.H"));
Glob g2("*.[hc]", Glob::GLOB_CASELESS);
assert (g2.match("foo.c"));
assert (g2.match("foo.h"));
assert (!g2.match("foo.i"));
assert (g2.match("foo.C"));
assert (g2.match("foo.H"));
assert (!g2.match("foo.I"));
assertTrue (g2.match("foo.c"));
assertTrue (g2.match("foo.h"));
assertTrue (!g2.match("foo.i"));
assertTrue (g2.match("foo.C"));
assertTrue (g2.match("foo.H"));
assertTrue (!g2.match("foo.I"));
Glob g4("File*.?pp", Glob::GLOB_CASELESS);
assert (g4.match("file.hpp"));
assert (g4.match("FILE.CPP"));
assert (g4.match("filesystem.hpp"));
assert (g4.match("FILESYSTEM.HPP"));
assert (!g4.match("FILE.H"));
assert (!g4.match("file.h"));
assertTrue (g4.match("file.hpp"));
assertTrue (g4.match("FILE.CPP"));
assertTrue (g4.match("filesystem.hpp"));
assertTrue (g4.match("FILESYSTEM.HPP"));
assertTrue (!g4.match("FILE.H"));
assertTrue (!g4.match("file.h"));
Glob g5("File*.[ch]*", Glob::GLOB_CASELESS);
assert (g5.match("file.hpp"));
assert (g5.match("FILE.HPP"));
assert (g5.match("file.cpp"));
assert (g5.match("FILE.CPP"));
assert (g5.match("filesystem.hpp"));
assert (g5.match("FILESYSTEM.HPP"));
assert (g5.match("file.h"));
assert (g5.match("FILE.H"));
assert (g5.match("filesystem.cp"));
assert (g5.match("FILESYSTEM.CP"));
assertTrue (g5.match("file.hpp"));
assertTrue (g5.match("FILE.HPP"));
assertTrue (g5.match("file.cpp"));
assertTrue (g5.match("FILE.CPP"));
assertTrue (g5.match("filesystem.hpp"));
assertTrue (g5.match("FILESYSTEM.HPP"));
assertTrue (g5.match("file.h"));
assertTrue (g5.match("FILE.H"));
assertTrue (g5.match("filesystem.cp"));
assertTrue (g5.match("FILESYSTEM.CP"));
Glob g6("[abc]", Glob::GLOB_CASELESS);
assert (g6.match("a"));
assert (g6.match("b"));
assert (g6.match("c"));
assert (g6.match("A"));
assert (g6.match("B"));
assert (g6.match("C"));
assertTrue (g6.match("a"));
assertTrue (g6.match("b"));
assertTrue (g6.match("c"));
assertTrue (g6.match("A"));
assertTrue (g6.match("B"));
assertTrue (g6.match("C"));
Glob g7("[a-f]", Glob::GLOB_CASELESS);
assert (g7.match("a"));
assert (g7.match("b"));
assert (g7.match("f"));
assert (!g7.match("g"));
assert (g7.match("A"));
assert (g7.match("B"));
assert (g7.match("F"));
assert (!g7.match("G"));
assertTrue (g7.match("a"));
assertTrue (g7.match("b"));
assertTrue (g7.match("f"));
assertTrue (!g7.match("g"));
assertTrue (g7.match("A"));
assertTrue (g7.match("B"));
assertTrue (g7.match("F"));
assertTrue (!g7.match("G"));
Glob g8("[A-F]", Glob::GLOB_CASELESS);
assert (g8.match("a"));
assert (g8.match("b"));
assert (g8.match("f"));
assert (!g8.match("g"));
assert (g8.match("A"));
assert (g8.match("B"));
assert (g8.match("F"));
assert (!g8.match("G"));
assertTrue (g8.match("a"));
assertTrue (g8.match("b"));
assertTrue (g8.match("f"));
assertTrue (!g8.match("g"));
assertTrue (g8.match("A"));
assertTrue (g8.match("B"));
assertTrue (g8.match("F"));
assertTrue (!g8.match("G"));
}
@ -391,77 +391,77 @@ void GlobTest::testGlob()
std::set<std::string> files;
Glob::glob("globtest/*", files);
translatePaths(files);
assert (files.size() == 5);
assert (files.find("globtest/Makefile") != files.end());
assert (files.find("globtest/.hidden") != files.end());
assert (files.find("globtest/include/") != files.end());
assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end());
assertTrue (files.size() == 5);
assertTrue (files.find("globtest/Makefile") != files.end());
assertTrue (files.find("globtest/.hidden") != files.end());
assertTrue (files.find("globtest/include/") != files.end());
assertTrue (files.find("globtest/src/") != files.end());
assertTrue (files.find("globtest/testsuite/") != files.end());
files.clear();
Glob::glob("GlobTest/*", files, Glob::GLOB_CASELESS);
translatePaths(files);
assert (files.size() == 5);
assert (files.find("globtest/Makefile") != files.end());
assert (files.find("globtest/.hidden") != files.end());
assert (files.find("globtest/include/") != files.end());
assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end());
assertTrue (files.size() == 5);
assertTrue (files.find("globtest/Makefile") != files.end());
assertTrue (files.find("globtest/.hidden") != files.end());
assertTrue (files.find("globtest/include/") != files.end());
assertTrue (files.find("globtest/src/") != files.end());
assertTrue (files.find("globtest/testsuite/") != files.end());
files.clear();
Glob::glob("globtest/*/*.[hc]", files);
translatePaths(files);
assert (files.size() == 5);
assert (files.find("globtest/include/one.h") != files.end());
assert (files.find("globtest/include/two.h") != files.end());
assert (files.find("globtest/src/one.c") != files.end());
assert (files.find("globtest/src/one.c") != files.end());
assert (files.find("globtest/src/main.c") != files.end());
assertTrue (files.size() == 5);
assertTrue (files.find("globtest/include/one.h") != files.end());
assertTrue (files.find("globtest/include/two.h") != files.end());
assertTrue (files.find("globtest/src/one.c") != files.end());
assertTrue (files.find("globtest/src/one.c") != files.end());
assertTrue (files.find("globtest/src/main.c") != files.end());
files.clear();
Glob::glob("gl?bt?st/*/*/*.c", files);
translatePaths(files);
assert (files.size() == 2);
assert (files.find("globtest/testsuite/src/test.c") != files.end());
assert (files.find("globtest/testsuite/src/main.c") != files.end());
assertTrue (files.size() == 2);
assertTrue (files.find("globtest/testsuite/src/test.c") != files.end());
assertTrue (files.find("globtest/testsuite/src/main.c") != files.end());
files.clear();
Glob::glob("Gl?bT?st/*/*/*.C", files, Glob::GLOB_CASELESS);
translatePaths(files);
assert (files.size() == 2);
assert (files.find("globtest/testsuite/src/test.c") != files.end());
assert (files.find("globtest/testsuite/src/main.c") != files.end());
assertTrue (files.size() == 2);
assertTrue (files.find("globtest/testsuite/src/test.c") != files.end());
assertTrue (files.find("globtest/testsuite/src/main.c") != files.end());
files.clear();
Glob::glob("globtest/*/src/*", files);
translatePaths(files);
assert (files.size() == 3);
assert (files.find("globtest/testsuite/src/test.h") != files.end());
assert (files.find("globtest/testsuite/src/test.c") != files.end());
assert (files.find("globtest/testsuite/src/main.c") != files.end());
assertTrue (files.size() == 3);
assertTrue (files.find("globtest/testsuite/src/test.h") != files.end());
assertTrue (files.find("globtest/testsuite/src/test.c") != files.end());
assertTrue (files.find("globtest/testsuite/src/main.c") != files.end());
files.clear();
Glob::glob("globtest/*/", files);
translatePaths(files);
assert (files.size() == 3);
assert (files.find("globtest/include/") != files.end());
assert (files.find("globtest/src/") != files.end());
assert (files.find("globtest/testsuite/") != files.end());
assertTrue (files.size() == 3);
assertTrue (files.find("globtest/include/") != files.end());
assertTrue (files.find("globtest/src/") != files.end());
assertTrue (files.find("globtest/testsuite/") != files.end());
files.clear();
Glob::glob("globtest/testsuite/src/*", "globtest/testsuite/", files);
translatePaths(files);
assert (files.size() == 3);
assert (files.find("globtest/testsuite/src/test.h") != files.end());
assert (files.find("globtest/testsuite/src/test.c") != files.end());
assert (files.find("globtest/testsuite/src/main.c") != files.end());
assertTrue (files.size() == 3);
assertTrue (files.find("globtest/testsuite/src/test.h") != files.end());
assertTrue (files.find("globtest/testsuite/src/test.c") != files.end());
assertTrue (files.find("globtest/testsuite/src/main.c") != files.end());
#if !defined(_WIN32_WCE)
// won't work if current directory is root dir
files.clear();
Glob::glob("globtest/../*/testsuite/*/", files);
translatePaths(files);
assert (files.size() == 1);
assertTrue (files.size() == 1);
#endif
File dir("globtest");
@ -474,14 +474,14 @@ void GlobTest::testMatchEmptyPattern()
// Run the empty pattern against a number of subjects with all different match options
const std::string empty;
assert (!Glob(empty, Glob::GLOB_DEFAULT).match("subject"));
assert (Glob(empty, Glob::GLOB_DEFAULT).match(empty));
assertTrue (!Glob(empty, Glob::GLOB_DEFAULT).match("subject"));
assertTrue (Glob(empty, Glob::GLOB_DEFAULT).match(empty));
assert (!Glob(empty, Glob::GLOB_DOT_SPECIAL).match("subject"));
assert (Glob(empty, Glob::GLOB_DOT_SPECIAL).match(empty));
assertTrue (!Glob(empty, Glob::GLOB_DOT_SPECIAL).match("subject"));
assertTrue (Glob(empty, Glob::GLOB_DOT_SPECIAL).match(empty));
assert (!Glob(empty, Glob::GLOB_CASELESS).match("subject"));
assert (Glob(empty, Glob::GLOB_CASELESS).match(empty));
assertTrue (!Glob(empty, Glob::GLOB_CASELESS).match("subject"));
assertTrue (Glob(empty, Glob::GLOB_CASELESS).match(empty));
}

View File

@ -39,21 +39,21 @@ void HMACEngineTest::testHMAC()
HMACEngine<MD5Engine> hmac1(key);
hmac1.update(data);
std::string digest = DigestEngine::digestToHex(hmac1.digest());
assert (digest == "9294727a3638bb1c13f48ef8158bfc9d");
assertTrue (digest == "9294727a3638bb1c13f48ef8158bfc9d");
key = "Jefe";
data = "what do ya want for nothing?";
HMACEngine<MD5Engine> hmac2(key);
hmac2.update(data);
digest = DigestEngine::digestToHex(hmac2.digest());
assert (digest == "750c783e6ab0b503eaa86e310a5db738");
assertTrue (digest == "750c783e6ab0b503eaa86e310a5db738");
key = std::string(16, 0xaa);
data = std::string(50, 0xdd);
HMACEngine<MD5Engine> hmac3(key);
hmac3.update(data);
digest = DigestEngine::digestToHex(hmac3.digest());
assert (digest == "56be34521d144c88dbb8c733f0e8b3f6");
assertTrue (digest == "56be34521d144c88dbb8c733f0e8b3f6");
}

View File

@ -36,38 +36,38 @@ void HashMapTest::testInsert()
typedef HashMap<int, int> IntMap;
IntMap hm;
assert (hm.empty());
assertTrue (hm.empty());
for (int i = 0; i < N; ++i)
{
std::pair<IntMap::Iterator, bool> res = hm.insert(IntMap::ValueType(i, i*2));
assert (res.first->first == i);
assert (res.first->second == i*2);
assert (res.second);
assertTrue (res.first->first == i);
assertTrue (res.first->second == i*2);
assertTrue (res.second);
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assert (hm.count(i) == 1);
assert (hm.size() == i + 1);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
assertTrue (hm.count(i) == 1);
assertTrue (hm.size() == i + 1);
}
assert (!hm.empty());
assertTrue (!hm.empty());
for (int i = 0; i < N; ++i)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
}
for (int i = 0; i < N; ++i)
{
std::pair<IntMap::Iterator, bool> res = hm.insert(IntMap::ValueType(i, 0));
assert (res.first->first == i);
assert (res.first->second == i*2);
assert (!res.second);
assertTrue (res.first->first == i);
assertTrue (res.first->second == i*2);
assertTrue (!res.second);
}
}
@ -83,27 +83,27 @@ void HashMapTest::testErase()
{
hm.insert(IntMap::ValueType(i, i*2));
}
assert (hm.size() == N);
assertTrue (hm.size() == N);
for (int i = 0; i < N; i += 2)
{
hm.erase(i);
IntMap::Iterator it = hm.find(i);
assert (it == hm.end());
assertTrue (it == hm.end());
}
assert (hm.size() == N/2);
assertTrue (hm.size() == N/2);
for (int i = 0; i < N; i += 2)
{
IntMap::Iterator it = hm.find(i);
assert (it == hm.end());
assertTrue (it == hm.end());
}
for (int i = 1; i < N; i += 2)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (*it == i);
assertTrue (it != hm.end());
assertTrue (*it == i);
}
for (int i = 0; i < N; i += 2)
@ -114,9 +114,9 @@ void HashMapTest::testErase()
for (int i = 0; i < N; ++i)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
}
}
@ -138,12 +138,12 @@ void HashMapTest::testIterator()
it = hm.begin();
while (it != hm.end())
{
assert (values.find(it->first) == values.end());
assertTrue (values.find(it->first) == values.end());
values[it->first] = it->second;
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -163,12 +163,12 @@ void HashMapTest::testConstIterator()
IntMap::ConstIterator it = hm.begin();
while (it != hm.end())
{
assert (values.find(it->first) == values.end());
assertTrue (values.find(it->first) == values.end());
values[it->first] = it->second;
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -181,10 +181,10 @@ void HashMapTest::testIndex()
hm[2] = 4;
hm[3] = 6;
assert (hm.size() == 3);
assert (hm[1] == 2);
assert (hm[2] == 4);
assert (hm[3] == 6);
assertTrue (hm.size() == 3);
assertTrue (hm[1] == 2);
assertTrue (hm[2] == 4);
assertTrue (hm[3] == 6);
try
{

View File

@ -35,33 +35,33 @@ void HashSetTest::testInsert()
HashSet<int, Hash<int> > hs;
assert (hs.empty());
assertTrue (hs.empty());
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (res.second);
assertTrue (*res.first == i);
assertTrue (res.second);
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assert (hs.size() == i + 1);
assertTrue (it != hs.end());
assertTrue (*it == i);
assertTrue (hs.size() == i + 1);
}
assert (!hs.empty());
assertTrue (!hs.empty());
for (int i = 0; i < N; ++i)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assertTrue (it != hs.end());
assertTrue (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<HashSet<int, Hash<int> >::Iterator, bool> res = hs.insert(i);
assert (*res.first == i);
assert (!res.second);
assertTrue (*res.first == i);
assertTrue (!res.second);
}
}
@ -76,27 +76,27 @@ void HashSetTest::testErase()
{
hs.insert(i);
}
assert (hs.size() == N);
assertTrue (hs.size() == N);
for (int i = 0; i < N; i += 2)
{
hs.erase(i);
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end());
assertTrue (it == hs.end());
}
assert (hs.size() == N/2);
assertTrue (hs.size() == N/2);
for (int i = 0; i < N; i += 2)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it == hs.end());
assertTrue (it == hs.end());
}
for (int i = 1; i < N; i += 2)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assertTrue (it != hs.end());
assertTrue (*it == i);
}
for (int i = 0; i < N; i += 2)
@ -107,8 +107,8 @@ void HashSetTest::testErase()
for (int i = 0; i < N; ++i)
{
HashSet<int, Hash<int> >::Iterator it = hs.find(i);
assert (it != hs.end());
assert (*it == i);
assertTrue (it != hs.end());
assertTrue (*it == i);
}
}
@ -128,12 +128,12 @@ void HashSetTest::testIterator()
HashSet<int, Hash<int> >::Iterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
assertTrue (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -152,12 +152,12 @@ void HashSetTest::testConstIterator()
HashSet<int, Hash<int> >::ConstIterator it = hs.begin();
while (it != hs.end())
{
assert (values.find(*it) == values.end());
assertTrue (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}

View File

@ -33,14 +33,14 @@ void HashTableTest::testInsert()
std::string s1("str1");
std::string s2("str2");
HashTable<std::string, int> hashTable;
assert (!hashTable.exists(s1));
assertTrue (!hashTable.exists(s1));
hashTable.insert(s1, 13);
assert (hashTable.exists(s1));
assert (hashTable.get(s1) == 13);
assertTrue (hashTable.exists(s1));
assertTrue (hashTable.get(s1) == 13);
int retVal = 0;
assert (hashTable.get(s1, retVal));
assert (retVal == 13);
assertTrue (hashTable.get(s1, retVal));
assertTrue (retVal == 13);
try
{
hashTable.insert(s1, 22);
@ -54,9 +54,9 @@ void HashTableTest::testInsert()
}
catch (Exception&){}
assert (!hashTable.exists(s2));
assertTrue (!hashTable.exists(s2));
hashTable.insert(s2, 13);
assert (hashTable.exists(s2));
assertTrue (hashTable.exists(s2));
}
@ -68,16 +68,16 @@ void HashTableTest::testUpdate()
HashTable<std::string, int> hashTable;
hashTable.insert(s1, 13);
hashTable.update(s1, 14);
assert (hashTable.exists(s1));
assert (hashTable.get(s1) == 14);
assertTrue (hashTable.exists(s1));
assertTrue (hashTable.get(s1) == 14);
int retVal = 0;
assert (hashTable.get(s1, retVal));
assert (retVal == 14);
assertTrue (hashTable.get(s1, retVal));
assertTrue (retVal == 14);
// updating a non existing item must work too
hashTable.update(s2, 15);
assert (hashTable.get(s2) == 15);
assertTrue (hashTable.get(s2) == 15);
}
@ -92,8 +92,8 @@ void HashTableTest::testOverflow()
for (int i = 0; i < 1024; ++i)
{
std::string tmp = Poco::NumberFormatter::format(i);
assert (hashTable.exists(tmp));
assert (hashTable.get(tmp) == i*i);
assertTrue (hashTable.exists(tmp));
assertTrue (hashTable.get(tmp) == i*i);
}
}
@ -101,29 +101,29 @@ void HashTableTest::testOverflow()
void HashTableTest::testSize()
{
HashTable<std::string, int> hashTable(13);
assert (hashTable.size() == 0);
assertTrue (hashTable.size() == 0);
Poco::UInt32 POCO_UNUSED h1 = hashTable.insert("1", 1);
assert (hashTable.size() == 1);
assertTrue (hashTable.size() == 1);
Poco::UInt32 POCO_UNUSED h2 = hashTable.update("2", 2);
assert (hashTable.size() == 2);
assertTrue (hashTable.size() == 2);
hashTable.remove("1");
assert (hashTable.size() == 1);
assertTrue (hashTable.size() == 1);
hashTable.remove("3");
assert (hashTable.size() == 1);
assertTrue (hashTable.size() == 1);
hashTable.removeRaw("2", h2);
assert (hashTable.size() == 0);
assertTrue (hashTable.size() == 0);
hashTable.insert("1", 1);
hashTable.insert("2", 2);
assert (hashTable.size() == 2);
assertTrue (hashTable.size() == 2);
hashTable.clear();
assert (hashTable.size() == 0);
assertTrue (hashTable.size() == 0);
}
void HashTableTest::testResize()
{
HashTable<std::string, int> hashTable(13);
assert (hashTable.size() == 0);
assertTrue (hashTable.size() == 0);
hashTable.resize(19);
for (int i = 0; i < 1024; ++i)
{
@ -134,8 +134,8 @@ void HashTableTest::testResize()
for (int i = 0; i < 1024; ++i)
{
std::string tmp = Poco::NumberFormatter::format(i);
assert (hashTable.exists(tmp));
assert (hashTable.get(tmp) == i*i);
assertTrue (hashTable.exists(tmp));
assertTrue (hashTable.get(tmp) == i*i);
}
}
@ -144,18 +144,18 @@ void HashTableTest::testStatistic()
{
double relax = 0.001;
HashTable<std::string, int> hashTable(13);
assert (hashTable.size() == 0);
assertTrue (hashTable.size() == 0);
HashStatistic stat1(hashTable.currentState());
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
assert (stat1.maxPositionsOfTable() == 13);
assert (stat1.maxEntriesPerHash() == 0);
assertTrue (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
assertTrue (stat1.maxPositionsOfTable() == 13);
assertTrue (stat1.maxEntriesPerHash() == 0);
hashTable.resize(19);
stat1 = hashTable.currentState(true);
assert (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
assert (stat1.maxPositionsOfTable() == 19);
assert (stat1.maxEntriesPerHash() == 0);
assert (stat1.detailedEntriesPerHash().size() == 19);
assertTrue (stat1.avgEntriesPerHash() < relax && stat1.avgEntriesPerHash() > -relax);
assertTrue (stat1.maxPositionsOfTable() == 19);
assertTrue (stat1.maxEntriesPerHash() == 0);
assertTrue (stat1.detailedEntriesPerHash().size() == 19);
for (int i = 0; i < 1024; ++i)
{
@ -163,17 +163,17 @@ void HashTableTest::testStatistic()
}
stat1 = hashTable.currentState(true);
double expAvg = 1024.0/ 19;
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
assert (stat1.maxPositionsOfTable() == 19);
assert (stat1.maxEntriesPerHash() > expAvg);
assertTrue (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
assertTrue (stat1.maxPositionsOfTable() == 19);
assertTrue (stat1.maxEntriesPerHash() > expAvg);
hashTable.resize(1009);
stat1 = hashTable.currentState(true);
expAvg = 1024.0/ 1009;
assert (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
assert (stat1.maxPositionsOfTable() == 1009);
assert (stat1.maxEntriesPerHash() > expAvg);
assertTrue (stat1.avgEntriesPerHash() < (expAvg + relax) && stat1.avgEntriesPerHash() > (expAvg - relax));
assertTrue (stat1.maxPositionsOfTable() == 1009);
assertTrue (stat1.maxEntriesPerHash() > expAvg);
}

View File

@ -39,14 +39,14 @@ void HexBinaryTest::testEncoder()
HexBinaryEncoder encoder(str);
encoder << std::string("\00\01\02\03\04\05", 6);
encoder.close();
assert (str.str() == "000102030405");
assertTrue (str.str() == "000102030405");
}
{
std::ostringstream str;
HexBinaryEncoder encoder(str);
encoder << std::string("\00\01\02\03", 4);
encoder.close();
assert (str.str() == "00010203");
assertTrue (str.str() == "00010203");
}
{
std::ostringstream str;
@ -54,7 +54,7 @@ void HexBinaryTest::testEncoder()
encoder << "ABCDEF";
encoder << char(0xaa) << char(0xbb);
encoder.close();
assert (str.str() == "414243444546aabb");
assertTrue (str.str() == "414243444546aabb");
}
{
std::ostringstream str;
@ -63,7 +63,7 @@ void HexBinaryTest::testEncoder()
encoder << "ABCDEF";
encoder << char(0xaa) << char(0xbb);
encoder.close();
assert (str.str() == "414243444546AABB");
assertTrue (str.str() == "414243444546AABB");
}
}
@ -73,68 +73,68 @@ void HexBinaryTest::testDecoder()
{
std::istringstream istr("000102030405");
HexBinaryDecoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == 5);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == 5);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("0001020304");
HexBinaryDecoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == 4);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == 4);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("0a0bcdef");
HexBinaryDecoder decoder(istr);
assert (decoder.good() && decoder.get() == 0x0a);
assert (decoder.good() && decoder.get() == 0x0b);
assert (decoder.good() && decoder.get() == 0xcd);
assert (decoder.good() && decoder.get() == 0xef);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0x0a);
assertTrue (decoder.good() && decoder.get() == 0x0b);
assertTrue (decoder.good() && decoder.get() == 0xcd);
assertTrue (decoder.good() && decoder.get() == 0xef);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("0A0BCDEF");
HexBinaryDecoder decoder(istr);
assert (decoder.good() && decoder.get() == 0x0a);
assert (decoder.good() && decoder.get() == 0x0b);
assert (decoder.good() && decoder.get() == 0xcd);
assert (decoder.good() && decoder.get() == 0xef);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0x0a);
assertTrue (decoder.good() && decoder.get() == 0x0b);
assertTrue (decoder.good() && decoder.get() == 0xcd);
assertTrue (decoder.good() && decoder.get() == 0xef);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("00 01 02 03");
HexBinaryDecoder decoder(istr);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
assert (decoder.good() && decoder.get() == 3);
assert (decoder.good() && decoder.get() == -1);
assertTrue (decoder.good() && decoder.get() == 0);
assertTrue (decoder.good() && decoder.get() == 1);
assertTrue (decoder.good() && decoder.get() == 2);
assertTrue (decoder.good() && decoder.get() == 3);
assertTrue (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("414243444546");
HexBinaryDecoder decoder(istr);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "ABCDEF");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("4041\r\n4243\r\n4445");
HexBinaryDecoder decoder(istr);
std::string s;
decoder >> s;
assert (s == "@ABCDE");
assert (decoder.eof());
assert (!decoder.fail());
assertTrue (s == "@ABCDE");
assertTrue (decoder.eof());
assertTrue (!decoder.fail());
}
{
std::istringstream istr("AABB#CCDD");
@ -143,12 +143,12 @@ void HexBinaryTest::testDecoder()
try
{
decoder >> s;
assert (decoder.bad());
assertTrue (decoder.bad());
}
catch (DataFormatException&)
{
}
assert (!decoder.eof());
assertTrue (!decoder.eof());
}
}
@ -165,7 +165,7 @@ void HexBinaryTest::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == "The quick brown fox jumped over the lazy dog.");
assertTrue (s == "The quick brown fox jumped over the lazy dog.");
}
{
std::string src;
@ -178,7 +178,7 @@ void HexBinaryTest::testEncodeDecode()
std::string s;
int c = decoder.get();
while (c != -1) { s += char(c); c = decoder.get(); }
assert (s == src);
assertTrue (s == src);
}
}

View File

@ -33,23 +33,23 @@ LRUCacheTest::~LRUCacheTest()
void LRUCacheTest::testClear()
{
LRUCache<int, int> aCache(3);
assert (aCache.size() == 0);
assert (aCache.getAllKeys().size() == 0);
assertTrue (aCache.size() == 0);
assertTrue (aCache.getAllKeys().size() == 0);
aCache.add(1, 2);
aCache.add(3, 4);
aCache.add(5, 6);
assert (aCache.size() == 3);
assert (aCache.getAllKeys().size() == 3);
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(1) == 2);
assert (*aCache.get(3) == 4);
assert (*aCache.get(5) == 6);
assertTrue (aCache.size() == 3);
assertTrue (aCache.getAllKeys().size() == 3);
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(1) == 2);
assertTrue (*aCache.get(3) == 4);
assertTrue (*aCache.get(5) == 6);
aCache.clear();
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (!aCache.has(5));
assertTrue (!aCache.has(1));
assertTrue (!aCache.has(3));
assertTrue (!aCache.has(5));
}
@ -71,22 +71,22 @@ void LRUCacheTest::testCacheSize1()
{
LRUCache<int, int> aCache(1);
aCache.add(1, 2);
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // replaces 1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(3) == 4);
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(3) == 4);
aCache.add(5, 6);
assert (!aCache.has(1));
assert (!aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6);
assertTrue (!aCache.has(1));
assertTrue (!aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6);
aCache.remove(5);
assert (!aCache.has(5));
assertTrue (!aCache.has(5));
// removing illegal entries should work too
aCache.remove(666);
@ -99,37 +99,37 @@ void LRUCacheTest::testCacheSize2()
// 3-1|5 -> 5 gets removed
LRUCache<int, int> aCache(2);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(1) == 2); // 1-3
assert (*aCache.get(3) == 4); // 3-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(1) == 2); // 1-3
assertTrue (*aCache.get(3) == 4); // 3-1
aCache.add(5, 6); // 5-3|1
assert (!aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-3
assert (*aCache.get(3) == 4); // 3-5
assertTrue (!aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-3
assertTrue (*aCache.get(3) == 4); // 3-5
// test remove from the end and the beginning of the list
aCache.remove(5); // 3
assert (!aCache.has(5));
assert (*aCache.get(3) == 4); // 3
assertTrue (!aCache.has(5));
assertTrue (*aCache.get(3) == 4); // 3
aCache.add(5, 6); // 5-3
assert (*aCache.get(3) == 4); // 3-5
assertTrue (*aCache.get(3) == 4); // 3-5
aCache.remove(3); // 5
assert (!aCache.has(3));
assert (*aCache.get(5) == 6); // 5
assertTrue (!aCache.has(3));
assertTrue (*aCache.get(5) == 6); // 5
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assertTrue (!aCache.has(5));
}
@ -139,48 +139,48 @@ void LRUCacheTest::testCacheSizeN()
// 3-1|5 -> 5 gets removed
LRUCache<int, int> aCache(3);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(3, 4); // 3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (*aCache.get(1) == 2); // 1-3
assert (*aCache.get(3) == 4); // 3-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(1) == 2); // 1-3
assertTrue (*aCache.get(3) == 4); // 3-1
aCache.add(5, 6); // 5-3-1
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-3-1
assert (*aCache.get(3) == 4); // 3-5-1
assertTrue (aCache.has(1));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-3-1
assertTrue (*aCache.get(3) == 4); // 3-5-1
aCache.add(7, 8); // 7-5-3|1
assert (!aCache.has(1));
assert (aCache.has(7));
assert (aCache.has(3));
assert (aCache.has(5));
assert (*aCache.get(5) == 6); // 5-7-3
assert (*aCache.get(3) == 4); // 3-5-7
assert (*aCache.get(7) == 8); // 7-3-5
assertTrue (!aCache.has(1));
assertTrue (aCache.has(7));
assertTrue (aCache.has(3));
assertTrue (aCache.has(5));
assertTrue (*aCache.get(5) == 6); // 5-7-3
assertTrue (*aCache.get(3) == 4); // 3-5-7
assertTrue (*aCache.get(7) == 8); // 7-3-5
// test remove from the end and the beginning of the list
aCache.remove(5); // 7-3
assert (!aCache.has(5));
assert (*aCache.get(3) == 4); // 3-7
assertTrue (!aCache.has(5));
assertTrue (*aCache.get(3) == 4); // 3-7
aCache.add(5, 6); // 5-3-7
assert (*aCache.get(7) == 8); // 7-5-3
assertTrue (*aCache.get(7) == 8); // 7-5-3
aCache.remove(7); // 5-3
assert (!aCache.has(7));
assert (aCache.has(3));
assert (*aCache.get(5) == 6); // 5-3
assertTrue (!aCache.has(7));
assertTrue (aCache.has(3));
assertTrue (*aCache.get(5) == 6); // 5-3
// removing illegal entries should work too
aCache.remove(666);
aCache.clear();
assert (!aCache.has(5));
assert (!aCache.has(3));
assertTrue (!aCache.has(5));
assertTrue (!aCache.has(3));
}
@ -188,11 +188,11 @@ void LRUCacheTest::testDuplicateAdd()
{
LRUCache<int, int> aCache(3);
aCache.add(1, 2); // 1
assert (aCache.has(1));
assert (*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.add(1, 3);
assert (aCache.has(1));
assert (*aCache.get(1) == 3);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 3);
}
@ -206,18 +206,18 @@ void LRUCacheTest::testUpdate()
aCache.Remove += delegate(this, &LRUCacheTest::onRemove);
aCache.Update += delegate(this, &LRUCacheTest::onUpdate);
aCache.add(1, 2); // 1 ,one add event
assert(addCnt == 1);
assert(updateCnt == 0);
assert(removeCnt == 0);
assertTrue (addCnt == 1);
assertTrue (updateCnt == 0);
assertTrue (removeCnt == 0);
assert(aCache.has(1));
assert(*aCache.get(1) == 2);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 2);
aCache.update(1, 3); // one update event only!
assert(addCnt == 1);
assert(updateCnt == 1);
assert(removeCnt == 0);
assert(aCache.has(1));
assert(*aCache.get(1) == 3);
assertTrue (addCnt == 1);
assertTrue (updateCnt == 1);
assertTrue (removeCnt == 0);
assertTrue (aCache.has(1));
assertTrue (*aCache.get(1) == 3);
}

View File

@ -39,7 +39,7 @@ void LineEndingConverterTest::testInputDosToUnix()
InputLineEndingConverter conv(input, LineEnding::NEWLINE_LF);
StreamCopier::copyStream(conv, output);
std::string result = output.str();
assert (result == "line1\nline2\nline3\n");
assertTrue (result == "line1\nline2\nline3\n");
}
@ -50,7 +50,7 @@ void LineEndingConverterTest::testInputUnixToDos()
InputLineEndingConverter conv(input, LineEnding::NEWLINE_CRLF);
StreamCopier::copyStream(conv, output);
std::string result = output.str();
assert (result == "line1\r\nline2\r\nline3\r\n");
assertTrue (result == "line1\r\nline2\r\nline3\r\n");
}
@ -61,7 +61,7 @@ void LineEndingConverterTest::testInputMacToUnix()
InputLineEndingConverter conv(input, LineEnding::NEWLINE_LF);
StreamCopier::copyStream(conv, output);
std::string result = output.str();
assert (result == "line1\nline2\nline3\n");
assertTrue (result == "line1\nline2\nline3\n");
}
@ -72,7 +72,7 @@ void LineEndingConverterTest::testInputRemove()
InputLineEndingConverter conv(input, "");
StreamCopier::copyStream(conv, output);
std::string result = output.str();
assert (result == "line1line2line3");
assertTrue (result == "line1line2line3");
}
@ -82,7 +82,7 @@ void LineEndingConverterTest::testOutputDosToUnix()
OutputLineEndingConverter conv(output, LineEnding::NEWLINE_LF);
conv << "line1\r\nline2\r\nline3\r\n" << std::flush;
std::string result = output.str();
assert (result == "line1\nline2\nline3\n");
assertTrue (result == "line1\nline2\nline3\n");
}
@ -92,7 +92,7 @@ void LineEndingConverterTest::testOutputUnixToDos()
OutputLineEndingConverter conv(output, LineEnding::NEWLINE_CRLF);
conv << "line1\nline2\nline3\n" << std::flush;
std::string result = output.str();
assert (result == "line1\r\nline2\r\nline3\r\n");
assertTrue (result == "line1\r\nline2\r\nline3\r\n");
}
@ -102,7 +102,7 @@ void LineEndingConverterTest::testOutputMacToUnix()
OutputLineEndingConverter conv(output, LineEnding::NEWLINE_LF);
conv << "line1\rline2\rline3\r" << std::flush;
std::string result = output.str();
assert (result == "line1\nline2\nline3\n");
assertTrue (result == "line1\nline2\nline3\n");
}
@ -112,7 +112,7 @@ void LineEndingConverterTest::testOutputRemove()
OutputLineEndingConverter conv(output, "");
conv << "line1\r\nline2\rline3\n" << std::flush;
std::string result = output.str();
assert (result == "line1line2line3");
assertTrue (result == "line1line2line3");
}

View File

@ -42,36 +42,36 @@ void LinearHashTableTest::testInsert()
LinearHashTable<int, Hash<int> > ht;
assert (ht.empty());
assertTrue (ht.empty());
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (res.second);
assertTrue (*res.first == i);
assertTrue (res.second);
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assert (ht.size() == i + 1);
assertTrue (it != ht.end());
assertTrue (*it == i);
assertTrue (ht.size() == i + 1);
}
assert (ht.buckets() == N + 1);
assertTrue (ht.buckets() == N + 1);
assert (!ht.empty());
assertTrue (!ht.empty());
for (int i = 0; i < N; ++i)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assertTrue (it != ht.end());
assertTrue (*it == i);
}
for (int i = 0; i < N; ++i)
{
std::pair<LinearHashTable<int, Hash<int> >::Iterator, bool> res = ht.insert(i);
assert (*res.first == i);
assert (!res.second);
assert (ht.size() == N);
assert (ht.buckets() == N + 1);
assertTrue (*res.first == i);
assertTrue (!res.second);
assertTrue (ht.size() == N);
assertTrue (ht.buckets() == N + 1);
}
}
@ -86,27 +86,27 @@ void LinearHashTableTest::testErase()
{
ht.insert(i);
}
assert (ht.size() == N);
assertTrue (ht.size() == N);
for (int i = 0; i < N; i += 2)
{
ht.erase(i);
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end());
assertTrue (it == ht.end());
}
assert (ht.size() == N/2);
assertTrue (ht.size() == N/2);
for (int i = 0; i < N; i += 2)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it == ht.end());
assertTrue (it == ht.end());
}
for (int i = 1; i < N; i += 2)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assertTrue (it != ht.end());
assertTrue (*it == i);
}
for (int i = 0; i < N; i += 2)
@ -117,8 +117,8 @@ void LinearHashTableTest::testErase()
for (int i = 0; i < N; ++i)
{
LinearHashTable<int, Hash<int> >::Iterator it = ht.find(i);
assert (it != ht.end());
assert (*it == i);
assertTrue (it != ht.end());
assertTrue (*it == i);
}
}
@ -138,12 +138,12 @@ void LinearHashTableTest::testIterator()
LinearHashTable<int, Hash<int> >::Iterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
assertTrue (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -162,12 +162,12 @@ void LinearHashTableTest::testConstIterator()
LinearHashTable<int, Hash<int> >::ConstIterator it = ht.begin();
while (it != ht.end())
{
assert (values.find(*it) == values.end());
assertTrue (values.find(*it) == values.end());
values.insert(*it);
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
values.clear();
const LinearHashTable<int, Hash<int> > cht(ht);
@ -175,12 +175,12 @@ void LinearHashTableTest::testConstIterator()
LinearHashTable<int, Hash<int> >::ConstIterator cit = cht.begin();
while (cit != cht.end())
{
assert (values.find(*cit) == values.end());
assertTrue (values.find(*cit) == values.end());
values.insert(*cit);
++cit;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}

View File

@ -36,36 +36,36 @@ void ListMapTest::testInsert()
typedef ListMap<int, int> IntMap;
IntMap hm;
assert (hm.empty());
assertTrue (hm.empty());
for (int i = 0; i < N; ++i)
{
IntMap::Iterator res = hm.insert(IntMap::ValueType(i, i*2));
assert (res->first == i);
assert (res->second == i*2);
assertTrue (res->first == i);
assertTrue (res->second == i*2);
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assert (hm.size() == i + 1);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
assertTrue (hm.size() == i + 1);
}
assert (!hm.empty());
assertTrue (!hm.empty());
for (int i = 0; i < N; ++i)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
}
hm.clear();
for (int i = 0; i < N; ++i)
{
IntMap::Iterator res = hm.insert(IntMap::ValueType(i, 0));
assert (res->first == i);
assert (res->second == 0);
assertTrue (res->first == i);
assertTrue (res->second == 0);
}
}
@ -81,27 +81,27 @@ void ListMapTest::testInsertOrder()
lm.insert(StrToIntMap::ValueType("bar", 43));
StrToIntMap::Iterator it = lm.begin();
assert (it != lm.end() && it->first == "foo" && it->second == 42);
assertTrue (it != lm.end() && it->first == "foo" && it->second == 42);
++it;
assert (it != lm.end() && it->first == "bar" && it->second == 43);
assertTrue (it != lm.end() && it->first == "bar" && it->second == 43);
++it;
assert (it == lm.end());
assertTrue (it == lm.end());
lm.insert(StrToIntMap::ValueType("foo", 44));
it = lm.begin();
assert (it != lm.end() && it->first == "foo" && it->second == 42);
assertTrue (it != lm.end() && it->first == "foo" && it->second == 42);
++it;
assert (it != lm.end() && it->first == "foo" && it->second == 44);
assertTrue (it != lm.end() && it->first == "foo" && it->second == 44);
++it;
assert (it != lm.end() && it->first == "bar" && it->second == 43);
assertTrue (it != lm.end() && it->first == "bar" && it->second == 43);
++it;
assert (it == lm.end());
assertTrue (it == lm.end());
}
@ -116,27 +116,27 @@ void ListMapTest::testErase()
{
hm.insert(IntMap::ValueType(i, i*2));
}
assert (hm.size() == N);
assertTrue (hm.size() == N);
for (int i = 0; i < N; i += 2)
{
hm.erase(i);
IntMap::Iterator it = hm.find(i);
assert (it == hm.end());
assertTrue (it == hm.end());
}
assert (hm.size() == N/2);
assertTrue (hm.size() == N/2);
for (int i = 0; i < N; i += 2)
{
IntMap::Iterator it = hm.find(i);
assert (it == hm.end());
assertTrue (it == hm.end());
}
for (int i = 1; i < N; i += 2)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assertTrue (it != hm.end());
assertTrue (it->first == i);
}
for (int i = 0; i < N; i += 2)
@ -147,9 +147,9 @@ void ListMapTest::testErase()
for (int i = 0; i < N; ++i)
{
IntMap::Iterator it = hm.find(i);
assert (it != hm.end());
assert (it->first == i);
assert (it->second == i*2);
assertTrue (it != hm.end());
assertTrue (it->first == i);
assertTrue (it->second == i*2);
}
}
@ -171,12 +171,12 @@ void ListMapTest::testIterator()
it = hm.begin();
while (it != hm.end())
{
assert (values.find(it->first) == values.end());
assertTrue (values.find(it->first) == values.end());
values[it->first] = it->second;
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -196,12 +196,12 @@ void ListMapTest::testConstIterator()
IntMap::ConstIterator it = hm.begin();
while (it != hm.end())
{
assert (values.find(it->first) == values.end());
assertTrue (values.find(it->first) == values.end());
values[it->first] = it->second;
++it;
}
assert (values.size() == N);
assertTrue (values.size() == N);
}
@ -214,10 +214,10 @@ void ListMapTest::testIntIndex()
hm[2] = 4;
hm[3] = 6;
assert (hm.size() == 3);
assert (hm[1] == 2);
assert (hm[2] == 4);
assert (hm[3] == 6);
assertTrue (hm.size() == 3);
assertTrue (hm[1] == 2);
assertTrue (hm[2] == 4);
assertTrue (hm[3] == 6);
try
{
@ -240,10 +240,10 @@ void ListMapTest::testStringIndex()
hm["index2"] = "value4";
hm["index3"] = "value6";
assert (hm.size() == 3);
assert (hm["index1"] == "value2");
assert (hm["Index2"] == "value4");
assert (hm["inDeX3"] == "value6");
assertTrue (hm.size() == 3);
assertTrue (hm["index1"] == "value2");
assertTrue (hm["Index2"] == "value4");
assertTrue (hm["inDeX3"] == "value6");
try
{

View File

@ -47,29 +47,29 @@ LocalDateTimeTest::~LocalDateTimeTest()
void LocalDateTimeTest::testGregorian1()
{
LocalDateTime dt(1970, 1, 1);
assert (dt.year() == 1970);
assert (dt.month() == 1);
assert (dt.day() == 1);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assertTrue (dt.year() == 1970);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 1);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 4);
// REMOVED: this fails when the current DST offset differs from
// the one on 1970-1-1
//assert (dt.tzd() == Timezone::tzd());
assert (dt.julianDay() == 2440587.5);
//assertTrue (dt.tzd() == Timezone::tzd());
assertTrue (dt.julianDay() == 2440587.5);
dt.assign(2001, 9, 9, 1, 46, 40);
assert (dt.year() == 2001);
assert (dt.month() == 9);
assert (dt.day() == 9);
assert (dt.hour() == 1);
assert (dt.minute() == 46);
assert (dt.second() == 40);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 0);
//assert (dt.tzd() == Timezone::tzd());
assertTrue (dt.year() == 2001);
assertTrue (dt.month() == 9);
assertTrue (dt.day() == 9);
assertTrue (dt.hour() == 1);
assertTrue (dt.minute() == 46);
assertTrue (dt.second() == 40);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 0);
//assertTrue (dt.tzd() == Timezone::tzd());
assertEqualDelta (dt.julianDay(), 2452161.574074, 0.000001);
}
@ -77,26 +77,26 @@ void LocalDateTimeTest::testGregorian1()
void LocalDateTimeTest::testGregorian2()
{
LocalDateTime dt(2*3600, 1970, 1, 1, 0, 0, 0, 0, 0);
assert (dt.year() == 1970);
assert (dt.month() == 1);
assert (dt.day() == 1);
assert (dt.hour() == 0);
assert (dt.minute() == 0);
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assert (dt.tzd() == 2*3600);
assertTrue (dt.year() == 1970);
assertTrue (dt.month() == 1);
assertTrue (dt.day() == 1);
assertTrue (dt.hour() == 0);
assertTrue (dt.minute() == 0);
assertTrue (dt.second() == 0);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 4);
assertTrue (dt.tzd() == 2*3600);
dt.assign(-7*3600, 2001, 9, 9, 1, 46, 40, 0, 0);
assert (dt.year() == 2001);
assert (dt.month() == 9);
assert (dt.day() == 9);
assert (dt.hour() == 1);
assert (dt.minute() == 46);
assert (dt.second() == 40);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 0);
assert (dt.tzd() == -7*3600);
assertTrue (dt.year() == 2001);
assertTrue (dt.month() == 9);
assertTrue (dt.day() == 9);
assertTrue (dt.hour() == 1);
assertTrue (dt.minute() == 46);
assertTrue (dt.second() == 40);
assertTrue (dt.millisecond() == 0);
assertTrue (dt.dayOfWeek() == 0);
assertTrue (dt.tzd() == -7*3600);
}
@ -109,163 +109,163 @@ void LocalDateTimeTest::testConversions()
LocalDateTime dt4(dt2);
LocalDateTime dt5(-4*3600, dt1.utc());
assert (dt2.year() == 2005);
assert (dt2.month() == 1);
assert (dt2.day() == 28);
assert (dt2.hour() == 14);
assert (dt2.minute() == 24);
assert (dt2.second() == 44);
assert (dt2.millisecond() == 234);
assert (dt2.dayOfWeek() == 5);
assert (dt2.tzd() == 2*3600);
assertTrue (dt2.year() == 2005);
assertTrue (dt2.month() == 1);
assertTrue (dt2.day() == 28);
assertTrue (dt2.hour() == 14);
assertTrue (dt2.minute() == 24);
assertTrue (dt2.second() == 44);
assertTrue (dt2.millisecond() == 234);
assertTrue (dt2.dayOfWeek() == 5);
assertTrue (dt2.tzd() == 2*3600);
assert (dt5.year() == 2005);
assert (dt5.month() == 1);
assert (dt5.day() == 28);
assert (dt5.hour() == 8);
assert (dt5.minute() == 24);
assert (dt5.second() == 44);
assert (dt5.millisecond() == 234);
assert (dt5.dayOfWeek() == 5);
assert (dt5.tzd() == -4*3600);
assertTrue (dt5.year() == 2005);
assertTrue (dt5.month() == 1);
assertTrue (dt5.day() == 28);
assertTrue (dt5.hour() == 8);
assertTrue (dt5.minute() == 24);
assertTrue (dt5.second() == 44);
assertTrue (dt5.millisecond() == 234);
assertTrue (dt5.dayOfWeek() == 5);
assertTrue (dt5.tzd() == -4*3600);
DateTime dt6(2005, 1, 28, 14, 24, 44, 234, 0);
LocalDateTime dt7(3600, dt6);
LocalDateTime dt8(3600, dt6, false);
LocalDateTime dt9(3600, dt6, true);
assert (dt7.hour() == 15);
assert (dt8.hour() == 14);
assert (dt9.hour() == 15);
assertTrue (dt7.hour() == 15);
assertTrue (dt8.hour() == 14);
assertTrue (dt9.hour() == 15);
}
void LocalDateTimeTest::testCalcs()
{
LocalDateTime dt1(2005, 1, 1);
assert (dt1.dayOfYear() == 1);
assert (dt1.week(DateTime::MONDAY) == 0);
assertTrue (dt1.dayOfYear() == 1);
assertTrue (dt1.week(DateTime::MONDAY) == 0);
dt1.assign(2005, 1, 3);
assert (dt1.dayOfYear() == 3);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.dayOfYear() == 3);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2005, 1, 9);
assert (dt1.dayOfYear() == 9);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.dayOfYear() == 9);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2005, 1, 10);
assert (dt1.dayOfYear() == 10);
assert (dt1.week(DateTime::MONDAY) == 2);
assertTrue (dt1.dayOfYear() == 10);
assertTrue (dt1.week(DateTime::MONDAY) == 2);
dt1.assign(2005, 2, 1);
assert (dt1.dayOfYear() == 32);
assert (dt1.week(DateTime::MONDAY) == 5);
assertTrue (dt1.dayOfYear() == 32);
assertTrue (dt1.week(DateTime::MONDAY) == 5);
dt1.assign(2005, 12, 31);
assert (dt1.week(DateTime::MONDAY) == 52);
assertTrue (dt1.week(DateTime::MONDAY) == 52);
dt1.assign(2007, 1, 1);
assert (dt1.week(DateTime::MONDAY) == 1);
assertTrue (dt1.week(DateTime::MONDAY) == 1);
dt1.assign(2007, 12, 31);
assert (dt1.week(DateTime::MONDAY) == 53);
assertTrue (dt1.week(DateTime::MONDAY) == 53);
// Jan 1 is Mon
dt1.assign(2001, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2001, 1, 7);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2001, 1, 8);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2001, 1, 21);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2001, 1, 22);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Tue
dt1.assign(2002, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2002, 1, 6);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2002, 1, 7);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2002, 1, 20);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2002, 1, 21);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Wed
dt1.assign(2003, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2003, 1, 5);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2003, 1, 6);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2003, 1, 19);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2003, 1, 20);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Thu
dt1.assign(2004, 1, 1);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2004, 1, 4);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2004, 1, 5);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2004, 1, 18);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
dt1.assign(2004, 1, 19);
assert (dt1.week() == 4);
assertTrue (dt1.week() == 4);
// Jan 1 is Fri
dt1.assign(1999, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1999, 1, 3);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1999, 1, 4);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1999, 1, 17);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(1999, 1, 18);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
// Jan 1 is Sat
dt1.assign(2000, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(2000, 1, 2);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(2000, 1, 3);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(2000, 1, 16);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(2000, 1, 17);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
// Jan 1 is Sun
dt1.assign(1995, 1, 1);
assert (dt1.week() == 0);
assertTrue (dt1.week() == 0);
dt1.assign(1995, 1, 2);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1995, 1, 3);
assert (dt1.week() == 1);
assertTrue (dt1.week() == 1);
dt1.assign(1995, 1, 15);
assert (dt1.week() == 2);
assertTrue (dt1.week() == 2);
dt1.assign(1995, 1, 16);
assert (dt1.week() == 3);
assertTrue (dt1.week() == 3);
}
void LocalDateTimeTest::testAMPM()
{
LocalDateTime dt1(2005, 1, 1, 0, 15, 30);
assert (dt1.isAM());
assert (!dt1.isPM());
assert (dt1.hourAMPM() == 12);
assertTrue (dt1.isAM());
assertTrue (!dt1.isPM());
assertTrue (dt1.hourAMPM() == 12);
dt1.assign(2005, 1, 1, 12, 15, 30);
assert (!dt1.isAM());
assert (dt1.isPM());
assert (dt1.hourAMPM() == 12);
assertTrue (!dt1.isAM());
assertTrue (dt1.isPM());
assertTrue (dt1.hourAMPM() == 12);
dt1.assign(2005, 1, 1, 13, 15, 30);
assert (!dt1.isAM());
assert (dt1.isPM());
assert (dt1.hourAMPM() == 1);
assertTrue (!dt1.isAM());
assertTrue (dt1.isPM());
assertTrue (dt1.hourAMPM() == 1);
}
@ -275,19 +275,19 @@ void LocalDateTimeTest::testRelational1()
LocalDateTime dt2(2005, 1, 2, 0, 15, 30);
LocalDateTime dt3(dt1);
assert (dt1 < dt2);
assert (dt1 <= dt2);
assert (dt2 > dt1);
assert (dt2 >= dt1);
assert (dt1 != dt2);
assert (!(dt1 == dt2));
assertTrue (dt1 < dt2);
assertTrue (dt1 <= dt2);
assertTrue (dt2 > dt1);
assertTrue (dt2 >= dt1);
assertTrue (dt1 != dt2);
assertTrue (!(dt1 == dt2));
assert (dt1 == dt3);
assert (!(dt1 != dt3));
assert (dt1 >= dt3);
assert (dt1 <= dt3);
assert (!(dt1 > dt3));
assert (!(dt1 < dt3));
assertTrue (dt1 == dt3);
assertTrue (!(dt1 != dt3));
assertTrue (dt1 >= dt3);
assertTrue (dt1 <= dt3);
assertTrue (!(dt1 > dt3));
assertTrue (!(dt1 < dt3));
}
@ -297,19 +297,19 @@ void LocalDateTimeTest::testRelational2()
LocalDateTime dt2(2*3600, 2005, 1, 1, 17, 30, 0, 0, 0);
LocalDateTime dt3(5*3600, 2005, 1, 1, 18, 30, 0, 0, 0);
assert (dt1 < dt2);
assert (dt1 <= dt2);
assert (dt2 > dt1);
assert (dt2 >= dt1);
assert (dt1 != dt2);
assert (!(dt1 == dt2));
assertTrue (dt1 < dt2);
assertTrue (dt1 <= dt2);
assertTrue (dt2 > dt1);
assertTrue (dt2 >= dt1);
assertTrue (dt1 != dt2);
assertTrue (!(dt1 == dt2));
assert (dt1 == dt3);
assert (!(dt1 != dt3));
assert (dt1 >= dt3);
assert (dt1 <= dt3);
assert (!(dt1 > dt3));
assert (!(dt1 < dt3));
assertTrue (dt1 == dt3);
assertTrue (!(dt1 != dt3));
assertTrue (dt1 >= dt3);
assertTrue (dt1 <= dt3);
assertTrue (!(dt1 > dt3));
assertTrue (!(dt1 < dt3));
}
@ -319,15 +319,15 @@ void LocalDateTimeTest::testArithmetics1()
LocalDateTime dt2(2005, 1, 2, 0, 15, 30);
Timespan s = dt2 - dt1;
assert (s.days() == 1);
assertTrue (s.days() == 1);
LocalDateTime dt3 = dt1 + s;
assert (dt3 == dt2);
assertTrue (dt3 == dt2);
dt3 -= s;
assert (dt3 == dt1);
assertTrue (dt3 == dt1);
dt1 += s;
assert (dt1 == dt2);
assertTrue (dt1 == dt2);
}
@ -337,15 +337,15 @@ void LocalDateTimeTest::testArithmetics2()
LocalDateTime dt2(5*3600, 2005, 1, 2, 18, 30, 0, 0, 0);
Timespan s = dt2 - dt1;
assert (s.days() == 1);
assertTrue (s.days() == 1);
LocalDateTime dt3 = dt1 + s;
assert (dt3 == dt2);
assertTrue (dt3 == dt2);
dt3 -= s;
assert (dt3 == dt1);
assertTrue (dt3 == dt1);
dt1 += s;
assert (dt1 == dt2);
assertTrue (dt1 == dt2);
}
@ -354,9 +354,9 @@ void LocalDateTimeTest::testSwap()
LocalDateTime dt1(2005, 1, 1, 0, 15, 30);
LocalDateTime dt2(2005, 1, 2, 0, 15, 30);
assert (dt1 < dt2);
assertTrue (dt1 < dt2);
dt1.swap(dt2);
assert (dt2 < dt1);
assertTrue (dt2 < dt1);
}
@ -432,7 +432,7 @@ void LocalDateTimeTest::testTimezone()
then.tm_sec,
dt2.millisecond(),
dt2.microsecond()));
assert (dt2 == calcd);
assertTrue (dt2 == calcd);
}
}
}

View File

@ -43,13 +43,13 @@ void LogStreamTest::testLogStream()
LogStream ls(root);
ls << "information" << ' ' << 1 << std::endl;
assert (pChannel->list().begin()->getPriority() == Message::PRIO_INFORMATION);
assert (pChannel->list().begin()->getText() == "information 1");
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_INFORMATION);
assertTrue (pChannel->list().begin()->getText() == "information 1");
pChannel->list().clear();
ls.error() << "error" << std::endl;
assert (pChannel->list().begin()->getPriority() == Message::PRIO_ERROR);
assert (pChannel->list().begin()->getText() == "error");
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_ERROR);
assertTrue (pChannel->list().begin()->getText() == "error");
pChannel->list().clear();
}

View File

@ -37,23 +37,23 @@ void LoggerTest::testLogger()
AutoPtr<TestChannel> pChannel = new TestChannel;
Logger& root = Logger::root();
root.setChannel(pChannel.get());
assert (root.getLevel() == Message::PRIO_INFORMATION);
assert (root.is(Message::PRIO_INFORMATION));
assert (root.fatal());
assert (root.critical());
assert (root.error());
assert (root.warning());
assert (root.notice());
assert (root.information());
assert (!root.debug());
assert (!root.trace());
assertTrue (root.getLevel() == Message::PRIO_INFORMATION);
assertTrue (root.is(Message::PRIO_INFORMATION));
assertTrue (root.fatal());
assertTrue (root.critical());
assertTrue (root.error());
assertTrue (root.warning());
assertTrue (root.notice());
assertTrue (root.information());
assertTrue (!root.debug());
assertTrue (!root.trace());
root.information("Informational message");
assert (pChannel->list().size() == 1);
assertTrue (pChannel->list().size() == 1);
root.warning("Warning message");
assert (pChannel->list().size() == 2);
assertTrue (pChannel->list().size() == 2);
root.debug("Debug message");
assert (pChannel->list().size() == 2);
assertTrue (pChannel->list().size() == 2);
Logger& logger1 = Logger::get("Logger1");
Logger& logger2 = Logger::get("Logger2");
@ -64,91 +64,91 @@ void LoggerTest::testLogger()
std::vector<std::string> loggers;
Logger::names(loggers);
assert (loggers.size() == 7);
assert (loggers[0] == "");
assert (loggers[1] == "Logger1");
assert (loggers[2] == "Logger1.Logger1");
assert (loggers[3] == "Logger1.Logger2");
assert (loggers[4] == "Logger2");
assert (loggers[5] == "Logger2.Logger1");
assert (loggers[6] == "Logger2.Logger2");
assertTrue (loggers.size() == 7);
assertTrue (loggers[0] == "");
assertTrue (loggers[1] == "Logger1");
assertTrue (loggers[2] == "Logger1.Logger1");
assertTrue (loggers[3] == "Logger1.Logger2");
assertTrue (loggers[4] == "Logger2");
assertTrue (loggers[5] == "Logger2.Logger1");
assertTrue (loggers[6] == "Logger2.Logger2");
Logger::setLevel("Logger1", Message::PRIO_DEBUG);
assert (logger1.is(Message::PRIO_DEBUG));
assert (logger11.is(Message::PRIO_DEBUG));
assert (logger12.is(Message::PRIO_DEBUG));
assert (!logger2.is(Message::PRIO_DEBUG));
assert (!logger21.is(Message::PRIO_DEBUG));
assert (!logger22.is(Message::PRIO_DEBUG));
assert (logger11.is(Message::PRIO_INFORMATION));
assert (logger12.is(Message::PRIO_INFORMATION));
assert (logger21.is(Message::PRIO_INFORMATION));
assert (logger22.is(Message::PRIO_INFORMATION));
assertTrue (logger1.is(Message::PRIO_DEBUG));
assertTrue (logger11.is(Message::PRIO_DEBUG));
assertTrue (logger12.is(Message::PRIO_DEBUG));
assertTrue (!logger2.is(Message::PRIO_DEBUG));
assertTrue (!logger21.is(Message::PRIO_DEBUG));
assertTrue (!logger22.is(Message::PRIO_DEBUG));
assertTrue (logger11.is(Message::PRIO_INFORMATION));
assertTrue (logger12.is(Message::PRIO_INFORMATION));
assertTrue (logger21.is(Message::PRIO_INFORMATION));
assertTrue (logger22.is(Message::PRIO_INFORMATION));
Logger::setLevel("Logger2.Logger1", Message::PRIO_ERROR);
assert (logger1.is(Message::PRIO_DEBUG));
assert (logger11.is(Message::PRIO_DEBUG));
assert (logger12.is(Message::PRIO_DEBUG));
assert (!logger21.is(Message::PRIO_DEBUG));
assert (!logger22.is(Message::PRIO_DEBUG));
assert (logger11.is(Message::PRIO_INFORMATION));
assert (logger12.is(Message::PRIO_INFORMATION));
assert (logger21.is(Message::PRIO_ERROR));
assert (logger22.is(Message::PRIO_INFORMATION));
assertTrue (logger1.is(Message::PRIO_DEBUG));
assertTrue (logger11.is(Message::PRIO_DEBUG));
assertTrue (logger12.is(Message::PRIO_DEBUG));
assertTrue (!logger21.is(Message::PRIO_DEBUG));
assertTrue (!logger22.is(Message::PRIO_DEBUG));
assertTrue (logger11.is(Message::PRIO_INFORMATION));
assertTrue (logger12.is(Message::PRIO_INFORMATION));
assertTrue (logger21.is(Message::PRIO_ERROR));
assertTrue (logger22.is(Message::PRIO_INFORMATION));
Logger::setLevel("", Message::PRIO_WARNING);
assert (root.getLevel() == Message::PRIO_WARNING);
assert (logger1.getLevel() == Message::PRIO_WARNING);
assert (logger11.getLevel() == Message::PRIO_WARNING);
assert (logger12.getLevel() == Message::PRIO_WARNING);
assert (logger1.getLevel() == Message::PRIO_WARNING);
assert (logger21.getLevel() == Message::PRIO_WARNING);
assert (logger22.getLevel() == Message::PRIO_WARNING);
assertTrue (root.getLevel() == Message::PRIO_WARNING);
assertTrue (logger1.getLevel() == Message::PRIO_WARNING);
assertTrue (logger11.getLevel() == Message::PRIO_WARNING);
assertTrue (logger12.getLevel() == Message::PRIO_WARNING);
assertTrue (logger1.getLevel() == Message::PRIO_WARNING);
assertTrue (logger21.getLevel() == Message::PRIO_WARNING);
assertTrue (logger22.getLevel() == Message::PRIO_WARNING);
AutoPtr<TestChannel> pChannel2 = new TestChannel;
Logger::setChannel("Logger2", pChannel2.get());
assert (pChannel == root.getChannel());
assert (pChannel == logger1.getChannel());
assert (pChannel == logger11.getChannel());
assert (pChannel == logger12.getChannel());
assert (pChannel2 == logger2.getChannel());
assert (pChannel2 == logger21.getChannel());
assert (pChannel2 == logger22.getChannel());
assertTrue (pChannel == root.getChannel());
assertTrue (pChannel == logger1.getChannel());
assertTrue (pChannel == logger11.getChannel());
assertTrue (pChannel == logger12.getChannel());
assertTrue (pChannel2 == logger2.getChannel());
assertTrue (pChannel2 == logger21.getChannel());
assertTrue (pChannel2 == logger22.getChannel());
root.setLevel(Message::PRIO_TRACE);
pChannel->list().clear();
root.trace("trace");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_TRACE);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_TRACE);
pChannel->list().clear();
root.debug("debug");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_DEBUG);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_DEBUG);
pChannel->list().clear();
root.information("information");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_INFORMATION);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_INFORMATION);
pChannel->list().clear();
root.notice("notice");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_NOTICE);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_NOTICE);
pChannel->list().clear();
root.warning("warning");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_WARNING);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_WARNING);
pChannel->list().clear();
root.error("error");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_ERROR);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_ERROR);
pChannel->list().clear();
root.critical("critical");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_CRITICAL);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_CRITICAL);
pChannel->list().clear();
root.fatal("fatal");
assert (pChannel->list().begin()->getPriority() == Message::PRIO_FATAL);
assertTrue (pChannel->list().begin()->getPriority() == Message::PRIO_FATAL);
root.setLevel("1");
assert (root.getLevel() == Message::PRIO_FATAL);
assertTrue (root.getLevel() == Message::PRIO_FATAL);
root.setLevel("8");
assert (root.getLevel() == Message::PRIO_TRACE);
assertTrue (root.getLevel() == Message::PRIO_TRACE);
try
{
root.setLevel("0");
assert(0);
assertTrue (0);
}
catch(Poco::InvalidArgumentException&)
{
@ -156,7 +156,7 @@ void LoggerTest::testLogger()
try
{
root.setLevel("9");
assert(0);
assertTrue (0);
}
catch(Poco::InvalidArgumentException&)
{
@ -168,23 +168,23 @@ void LoggerTest::testLogger()
void LoggerTest::testFormat()
{
std::string str = Logger::format("$0$1", "foo", "bar");
assert (str == "foobar");
assertTrue (str == "foobar");
str = Logger::format("foo$0", "bar");
assert (str == "foobar");
assertTrue (str == "foobar");
str = Logger::format("the amount is $$ $0", "100");
assert (str == "the amount is $ 100");
assertTrue (str == "the amount is $ 100");
str = Logger::format("$0$1$2", "foo", "bar");
assert (str == "foobar");
assertTrue (str == "foobar");
str = Logger::format("$foo$0", "bar");
assert (str == "$foobar");
assertTrue (str == "$foobar");
str = Logger::format("$0", "1");
assert (str == "1");
assertTrue (str == "1");
str = Logger::format("$0$1", "1", "2");
assert (str == "12");
assertTrue (str == "12");
str = Logger::format("$0$1$2", "1", "2", "3");
assert (str == "123");
assertTrue (str == "123");
str = Logger::format("$0$1$2$3", "1", "2", "3", "4");
assert (str == "1234");
assertTrue (str == "1234");
}
void LoggerTest::testFormatAny()
@ -194,43 +194,43 @@ void LoggerTest::testFormatAny()
root.setChannel(pChannel.get());
root.error("%s%s", std::string("foo"), std::string("bar"));
assert (pChannel->getLastMessage().getText() == "foobar");
assertTrue (pChannel->getLastMessage().getText() == "foobar");
root.error("foo%s", std::string("bar"));
assert (pChannel->getLastMessage().getText() == "foobar");
assertTrue (pChannel->getLastMessage().getText() == "foobar");
root.error("the amount is %% %d", 100);
assert (pChannel->getLastMessage().getText() == "the amount is % 100");
assertTrue (pChannel->getLastMessage().getText() == "the amount is % 100");
root.error("%d", 1);
assert (pChannel->getLastMessage().getText() == "1");
assertTrue (pChannel->getLastMessage().getText() == "1");
root.error("%d%d", 1, 2);
assert (pChannel->getLastMessage().getText() == "12");
assertTrue (pChannel->getLastMessage().getText() == "12");
root.error("%d%d%d", 1, 2, 3);
assert (pChannel->getLastMessage().getText() == "123");
assertTrue (pChannel->getLastMessage().getText() == "123");
root.error("%d%d%d%d", 1, 2, 3, 4);
assert (pChannel->getLastMessage().getText() == "1234");
assertTrue (pChannel->getLastMessage().getText() == "1234");
root.error("%d%d%d%d%d", 1, 2, 3, 4, 5);
assert (pChannel->getLastMessage().getText() == "12345");
assertTrue (pChannel->getLastMessage().getText() == "12345");
root.error("%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6);
assert (pChannel->getLastMessage().getText() == "123456");
assertTrue (pChannel->getLastMessage().getText() == "123456");
root.error("%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7);
assert(pChannel->getLastMessage().getText() == "1234567");
assertTrue (pChannel->getLastMessage().getText() == "1234567");
root.error("%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8);
assert(pChannel->getLastMessage().getText() == "12345678");
assertTrue (pChannel->getLastMessage().getText() == "12345678");
root.error("%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9);
assert(pChannel->getLastMessage().getText() == "123456789");
assertTrue (pChannel->getLastMessage().getText() == "123456789");
root.error("%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
assert(pChannel->getLastMessage().getText() == "12345678910");
assertTrue (pChannel->getLastMessage().getText() == "12345678910");
}
@ -243,13 +243,13 @@ void LoggerTest::testDump()
char buffer1[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
root.dump("test", buffer1, sizeof(buffer1));
assert (pChannel->list().empty());
assertTrue (pChannel->list().empty());
root.setLevel(Message::PRIO_DEBUG);
root.dump("test", buffer1, sizeof(buffer1));
std::string msg = pChannel->list().begin()->getText();
assert (msg == "test\n0000 00 01 02 03 04 05 ......");
assertTrue (msg == "test\n0000 00 01 02 03 04 05 ......");
pChannel->clear();
char buffer2[] = {
@ -258,7 +258,7 @@ void LoggerTest::testDump()
};
root.dump("", buffer2, sizeof(buffer2));
msg = pChannel->list().begin()->getText();
assert (msg == "0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................");
assertTrue (msg == "0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................");
pChannel->clear();
char buffer3[] = {
@ -268,7 +268,7 @@ void LoggerTest::testDump()
};
root.dump("", buffer3, sizeof(buffer3));
msg = pChannel->list().begin()->getText();
assert (msg == "0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................\n"
assertTrue (msg == "0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................\n"
"0010 20 41 42 1F 7F 7E AB..~");
pChannel->clear();
}

View File

@ -75,16 +75,16 @@ void LoggingFactoryTest::testBuiltins()
AutoPtr<Channel> pConsoleChannel = fact.createChannel("ConsoleChannel");
#if defined(_WIN32) && !defined(_WIN32_WCE)
assert (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
assertTrue (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
#else
assert (dynamic_cast<ConsoleChannel*>(pConsoleChannel.get()) != 0);
assertTrue (dynamic_cast<ConsoleChannel*>(pConsoleChannel.get()) != 0);
#endif
AutoPtr<Channel> pFileChannel = fact.createChannel("FileChannel");
assert (dynamic_cast<FileChannel*>(pFileChannel.get()) != 0);
assertTrue (dynamic_cast<FileChannel*>(pFileChannel.get()) != 0);
AutoPtr<Channel> pSplitterChannel = fact.createChannel("SplitterChannel");
assert (dynamic_cast<SplitterChannel*>(pSplitterChannel.get()) != 0);
assertTrue (dynamic_cast<SplitterChannel*>(pSplitterChannel.get()) != 0);
try
{
@ -96,7 +96,7 @@ void LoggingFactoryTest::testBuiltins()
}
AutoPtr<Formatter> pPatternFormatter = fact.createFormatter("PatternFormatter");
assert (dynamic_cast<PatternFormatter*>(pPatternFormatter.get()) != 0);
assertTrue (dynamic_cast<PatternFormatter*>(pPatternFormatter.get()) != 0);
try
{
@ -121,10 +121,10 @@ void LoggingFactoryTest::testCustom()
fact->registerFormatterClass("CustomFormatter", new Instantiator<CustomFormatter, Formatter>);
AutoPtr<Channel> pCustomChannel = fact->createChannel("CustomChannel");
assert (dynamic_cast<CustomChannel*>(pCustomChannel.get()) != 0);
assertTrue (dynamic_cast<CustomChannel*>(pCustomChannel.get()) != 0);
AutoPtr<Formatter> pCustomFormatter = fact->createFormatter("CustomFormatter");
assert (dynamic_cast<CustomFormatter*>(pCustomFormatter.get()) != 0);
assertTrue (dynamic_cast<CustomFormatter*>(pCustomFormatter.get()) != 0);
}

View File

@ -52,14 +52,14 @@ void LoggingRegistryTest::testRegister()
reg.registerFormatter("f2", pF2);
Channel* pC = reg.channelForName("c1");
assert (pC1 == pC);
assertTrue (pC1 == pC);
pC = reg.channelForName("c2");
assert (pC2 == pC);
assertTrue (pC2 == pC);
Formatter* pF = reg.formatterForName("f1");
assert (pF1 == pF);
assertTrue (pF1 == pF);
pF = reg.formatterForName("f2");
assert (pF2 == pF);
assertTrue (pF2 == pF);
try
{
@ -92,15 +92,15 @@ void LoggingRegistryTest::testReregister()
reg.registerChannel("c1", pC1b);
Channel* pC = reg.channelForName("c1");
assert (pC1b == pC);
assertTrue (pC1b == pC);
pC = reg.channelForName("c2");
assert (pC2 == pC);
assertTrue (pC2 == pC);
reg.registerFormatter("f1", pF1b);
Formatter* pF = reg.formatterForName("f1");
assert (pF1b == pF);
assertTrue (pF1b == pF);
pF = reg.formatterForName("f2");
assert (pF2 == pF);
assertTrue (pF2 == pF);
}

View File

@ -35,26 +35,26 @@ void MD4EngineTest::testMD4()
// test vectors from RFC 1320
engine.update("");
assert (DigestEngine::digestToHex(engine.digest()) == "31d6cfe0d16ae931b73c59d7e0c089c0");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "31d6cfe0d16ae931b73c59d7e0c089c0");
engine.update("a");
assert (DigestEngine::digestToHex(engine.digest()) == "bde52cb31de33e46245e05fbdbd6fb24");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "bde52cb31de33e46245e05fbdbd6fb24");
engine.update("abc");
assert (DigestEngine::digestToHex(engine.digest()) == "a448017aaf21d8525fc10ae87aa6729d");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "a448017aaf21d8525fc10ae87aa6729d");
engine.update("message digest");
assert (DigestEngine::digestToHex(engine.digest()) == "d9130a8164549fe818874806e1c7014b");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d9130a8164549fe818874806e1c7014b");
engine.update("abcdefghijklmnopqrstuvwxyz");
assert (DigestEngine::digestToHex(engine.digest()) == "d79e1c308aa5bbcdeea8ed63df412da9");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d79e1c308aa5bbcdeea8ed63df412da9");
engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
engine.update("abcdefghijklmnopqrstuvwxyz0123456789");
assert (DigestEngine::digestToHex(engine.digest()) == "043f8582f241db351ce627e153e7f0e4");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "043f8582f241db351ce627e153e7f0e4");
engine.update("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
assert (DigestEngine::digestToHex(engine.digest()) == "e33b4ddc9c38f2199c3e7b164fcc0536");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "e33b4ddc9c38f2199c3e7b164fcc0536");
}

View File

@ -35,26 +35,26 @@ void MD5EngineTest::testMD5()
// test vectors from RFC 1321
engine.update("");
assert (DigestEngine::digestToHex(engine.digest()) == "d41d8cd98f00b204e9800998ecf8427e");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d41d8cd98f00b204e9800998ecf8427e");
engine.update("a");
assert (DigestEngine::digestToHex(engine.digest()) == "0cc175b9c0f1b6a831c399e269772661");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "0cc175b9c0f1b6a831c399e269772661");
engine.update("abc");
assert (DigestEngine::digestToHex(engine.digest()) == "900150983cd24fb0d6963f7d28e17f72");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "900150983cd24fb0d6963f7d28e17f72");
engine.update("message digest");
assert (DigestEngine::digestToHex(engine.digest()) == "f96b697d7cb7938d525a2f31aaf161d0");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "f96b697d7cb7938d525a2f31aaf161d0");
engine.update("abcdefghijklmnopqrstuvwxyz");
assert (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
engine.update("abcdefghijklmnopqrstuvwxyz0123456789");
assert (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
engine.update("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
assert (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a");
}
@ -64,8 +64,8 @@ void MD5EngineTest::testConstantTimeEquals()
DigestEngine::Digest d2 = DigestEngine::digestFromHex("d41d8cd98f00b204e9800998ecf8427e");
DigestEngine::Digest d3 = DigestEngine::digestFromHex("0cc175b9c0f1b6a831c399e269772661");
assert (DigestEngine::constantTimeEquals(d1, d2));
assert (!DigestEngine::constantTimeEquals(d1, d3));
assertTrue (DigestEngine::constantTimeEquals(d1, d2));
assertTrue (!DigestEngine::constantTimeEquals(d1, d3));
}

View File

@ -43,54 +43,54 @@ ManifestTest::~ManifestTest()
void ManifestTest::testManifest()
{
Manifest<MfTestBase> manifest;
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject1")));
assert (!manifest.empty());
assert (manifest.size() == 1);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject2")));
assertTrue (manifest.empty());
assertTrue (manifest.size() == 0);
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject1")));
assertTrue (!manifest.empty());
assertTrue (manifest.size() == 1);
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject2")));
MetaObject<MfTestObject, MfTestBase>* pMeta = new MetaObject<MfTestObject, MfTestBase>("MfTestObject2");
assert (!manifest.insert(pMeta));
assertTrue (!manifest.insert(pMeta));
delete pMeta;
assert (!manifest.empty());
assert (manifest.size() == 2);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject3")));
assert (manifest.size() == 3);
assertTrue (!manifest.empty());
assertTrue (manifest.size() == 2);
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject3")));
assertTrue (manifest.size() == 3);
assert (manifest.find("MfTestObject1") != manifest.end());
assert (manifest.find("MfTestObject2") != manifest.end());
assert (manifest.find("MfTestObject3") != manifest.end());
assert (manifest.find("MfTestObject4") == manifest.end());
assertTrue (manifest.find("MfTestObject1") != manifest.end());
assertTrue (manifest.find("MfTestObject2") != manifest.end());
assertTrue (manifest.find("MfTestObject3") != manifest.end());
assertTrue (manifest.find("MfTestObject4") == manifest.end());
std::set<std::string> classes;
Manifest<MfTestBase>::Iterator it = manifest.begin();
assert (it != manifest.end());
assertTrue (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
assertTrue (it != manifest.end());
classes.insert(it->name());
++it;
assert (it != manifest.end());
assertTrue (it != manifest.end());
classes.insert(it->name());
it++;
assert (it == manifest.end());
assertTrue (it == manifest.end());
assert (classes.find("MfTestObject1") != classes.end());
assert (classes.find("MfTestObject2") != classes.end());
assert (classes.find("MfTestObject3") != classes.end());
assertTrue (classes.find("MfTestObject1") != classes.end());
assertTrue (classes.find("MfTestObject2") != classes.end());
assertTrue (classes.find("MfTestObject3") != classes.end());
manifest.clear();
assert (manifest.empty());
assert (manifest.size() == 0);
assert (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject4")));
assert (!manifest.empty());
assert (manifest.size() == 1);
assertTrue (manifest.empty());
assertTrue (manifest.size() == 0);
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject4")));
assertTrue (!manifest.empty());
assertTrue (manifest.size() == 1);
it = manifest.begin();
assert (it != manifest.end());
assert (std::string(it->name()) == "MfTestObject4");
assertTrue (it != manifest.end());
assertTrue (std::string(it->name()) == "MfTestObject4");
++it;
assert (it == manifest.end());
assertTrue (it == manifest.end());
}

View File

@ -32,16 +32,16 @@ void MemoryPoolTest::testMemoryPool()
{
MemoryPool pool1(100, 0, 10);
assert (pool1.blockSize() == 100);
assert (pool1.allocated() == 0);
assert (pool1.available() == 0);
assertTrue (pool1.blockSize() == 100);
assertTrue (pool1.allocated() == 0);
assertTrue (pool1.available() == 0);
std::vector<void*> ptrs;
for (int i = 0; i < 10; ++i)
{
ptrs.push_back(pool1.get());
assert (pool1.allocated() == i + 1);
assert (pool1.available() == 0);
assertTrue (pool1.allocated() == i + 1);
assertTrue (pool1.available() == 0);
}
try
@ -58,13 +58,13 @@ void MemoryPoolTest::testMemoryPool()
{
pool1.release(*it);
++av;
assert (pool1.available() == av);
assertTrue (pool1.available() == av);
}
MemoryPool pool2(32, 5, 10);
assert (pool2.available() == 5);
assert (pool2.blockSize() == 32);
assert (pool2.allocated() == 5);
assertTrue (pool2.available() == 5);
assertTrue (pool2.blockSize() == 32);
assertTrue (pool2.allocated() == 5);
}

View File

@ -36,37 +36,37 @@ void MemoryStreamTest::testInput()
MemoryInputStream istr1(data, 14);
int c = istr1.get();
assert (c == 'T');
assertTrue (c == 'T');
c = istr1.get();
assert (c == 'h');
assertTrue (c == 'h');
std::string str;
istr1 >> str;
assert (str == "is");
assertTrue (str == "is");
char buffer[32];
istr1.read(buffer, sizeof(buffer));
assert (istr1.gcount() == 10);
assertTrue (istr1.gcount() == 10);
buffer[istr1.gcount()] = 0;
assert (std::string(" is a test") == buffer);
assertTrue (std::string(" is a test") == buffer);
const char* data2 = "123";
MemoryInputStream istr2(data2, 3);
c = istr2.get();
assert (c == '1');
assert (istr2.good());
assertTrue (c == '1');
assertTrue (istr2.good());
c = istr2.get();
assert (c == '2');
assertTrue (c == '2');
istr2.unget();
c = istr2.get();
assert (c == '2');
assert (istr2.good());
assertTrue (c == '2');
assertTrue (istr2.good());
c = istr2.get();
assert (c == '3');
assert (istr2.good());
assertTrue (c == '3');
assertTrue (istr2.good());
c = istr2.get();
assert (c == -1);
assert (istr2.eof());
assertTrue (c == -1);
assertTrue (istr2.eof());
}
@ -75,15 +75,15 @@ void MemoryStreamTest::testOutput()
char output[64];
MemoryOutputStream ostr1(output, 64);
ostr1 << "This is a test " << 42 << std::ends;
assert (ostr1.charsWritten() == 18);
assert (std::string("This is a test 42") == output);
assertTrue (ostr1.charsWritten() == 18);
assertTrue (std::string("This is a test 42") == output);
char output2[4];
MemoryOutputStream ostr2(output2, 4);
ostr2 << "test";
assert (ostr2.good());
assertTrue (ostr2.good());
ostr2 << 'x';
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
void MemoryStreamTest::testTell()
@ -92,22 +92,22 @@ void MemoryStreamTest::testTell()
Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size());
ostr << 'H' << 'e' << 'l' << 'l' << 'o' << '\0';
std::streamoff np = ostr.tellp();
assert (np == 6);
assertTrue (np == 6);
Poco::MemoryInputStream istr(buffer.begin(), buffer.size());
char c;
istr >> c;
assert (c == 'H');
assertTrue (c == 'H');
istr >> c;
assert (c == 'e');
assertTrue (c == 'e');
istr >> c;
assert (c == 'l');
assertTrue (c == 'l');
std::streamoff ng = istr.tellg();
assert (ng == 3);
assertTrue (ng == 3);
}
@ -121,27 +121,27 @@ void MemoryStreamTest::testInputSeek()
char c;
istr >> c;
assert (c == '1');
assertTrue (c == '1');
istr.seekg(3, std::ios_base::beg); // 3 from beginning
istr >> c; // now that makes 4
assert (4 == istr.tellg());
assert (c == '4');
assertTrue (4 == istr.tellg());
assertTrue (c == '4');
istr.seekg(2, std::ios_base::cur); // now that makes 6
istr >> c; // now that makes 7
assert (7 == istr.tellg());
assert (c == '7');
assertTrue (7 == istr.tellg());
assertTrue (c == '7');
istr.seekg(-7, std::ios_base::end); // so that puts us at 9-7=2
istr >> c; // now 3
assert (3 == istr.tellg());
assert (c == '3');
assertTrue (3 == istr.tellg());
assertTrue (c == '3');
istr.seekg(9, std::ios_base::beg);
assert (istr.good());
assert (9 == istr.tellg());
assertTrue (istr.good());
assertTrue (9 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -149,16 +149,16 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(0));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(0));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(-9, std::ios_base::end);
assert (istr.good());
assert (0 == istr.tellg());
assertTrue (istr.good());
assertTrue (0 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -166,16 +166,16 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(0));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(0));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(0, std::ios_base::beg);
assert (istr.good());
assert (0 == istr.tellg());
assertTrue (istr.good());
assertTrue (0 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -183,16 +183,16 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(0));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(0));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(0, std::ios_base::end);
assert (istr.good());
assert (9 == istr.tellg());
assertTrue (istr.good());
assertTrue (9 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -200,19 +200,19 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(0));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(0));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(3, std::ios_base::beg);
assert (istr.good());
assert (3 == istr.tellg());
assertTrue (istr.good());
assertTrue (3 == istr.tellg());
istr.seekg(6, std::ios_base::cur);
assert (istr.good());
assert (9 == istr.tellg());
assertTrue (istr.good());
assertTrue (9 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -221,19 +221,19 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(4));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(4));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(-4, std::ios_base::end);
assert (istr.good());
assert (5 == istr.tellg());
assertTrue (istr.good());
assertTrue (5 == istr.tellg());
istr.seekg(4, std::ios_base::cur);
assert (istr.good());
assert (9 == istr.tellg());
assertTrue (istr.good());
assertTrue (9 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -242,19 +242,19 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(5));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(5));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
istr.seekg(4, std::ios_base::beg);
assert (istr.good());
assert (4 == istr.tellg());
assertTrue (istr.good());
assertTrue (4 == istr.tellg());
istr.seekg(-4, std::ios_base::cur);
assert (istr.good());
assert (0 == istr.tellg());
assertTrue (istr.good());
assertTrue (0 == istr.tellg());
{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
@ -263,9 +263,9 @@ void MemoryStreamTest::testInputSeek()
#ifdef __APPLE__
// workaround for clang libstdc++, which does not
// set failbit if seek returns -1
assert (istr2.fail() || istr2.tellg() == std::streampos(4));
assertTrue (istr2.fail() || istr2.tellg() == std::streampos(4));
#else
assert (istr2.fail());
assertTrue (istr2.fail());
#endif
}
}
@ -286,28 +286,28 @@ void MemoryStreamTest::testInputSeekVsStringStream()
sss >> x;
mis >> y;
assert (x == y);
assertTrue (x == y);
sss.seekg(3, std::ios_base::beg);
mis.seekg(3, std::ios_base::beg);
sss >> x;
mis >> y;
assert (x == y);
assert (sss.tellg() == mis.tellg());
assertTrue (x == y);
assertTrue (sss.tellg() == mis.tellg());
sss.seekg(2, std::ios_base::cur);
mis.seekg(2, std::ios_base::cur);
sss >> x;
mis >> y;
assert (x == y);
assert (sss.tellg() == mis.tellg());
assertTrue (x == y);
assertTrue (sss.tellg() == mis.tellg());
sss.seekg(-7, std::ios_base::end);
mis.seekg(-7, std::ios_base::end);
sss >> x;
mis >> y;
assert (x == y);
assert (sss.tellg() == mis.tellg());
assertTrue (x == y);
assertTrue (sss.tellg() == mis.tellg());
}
@ -319,106 +319,106 @@ void MemoryStreamTest::testOutputSeek()
ostr.seekp(4, std::ios_base::beg); // 4 from beginning
ostr << 'a'; // and that makes 5 (zero index 4)
assert (5 == ostr.tellp());
assert (buffer[4] == 'a');
assertTrue (5 == ostr.tellp());
assertTrue (buffer[4] == 'a');
ostr.seekp(2, std::ios_base::cur); // and this makes 7
ostr << 'b'; // and this makes 8 (zero index 7)
assert (8 == ostr.tellp());
assert (buffer[7] == 'b');
assertTrue (8 == ostr.tellp());
assertTrue (buffer[7] == 'b');
ostr.seekp(-3, std::ios_base::end); // 9-3=6 from the beginning
ostr << 'c'; // and this makes 7 (zero index 6)
assert (7 == ostr.tellp());
assert (buffer[6] == 'c');
assertTrue (7 == ostr.tellp());
assertTrue (buffer[6] == 'c');
ostr.seekp(9, std::ios_base::beg);
assert (ostr.good());
assert (9 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (9 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(10, std::ios_base::beg);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(-9, std::ios_base::end);
assert (ostr.good());
assert (0 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (0 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(-10, std::ios_base::end);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(0, std::ios_base::beg);
assert (ostr.good());
assert (0 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (0 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(-1, std::ios_base::beg);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(0, std::ios_base::end);
assert (ostr.good());
assert (9 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (9 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(1, std::ios_base::end);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(3, std::ios_base::beg);
assert (ostr.good());
assert (3 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (3 == ostr.tellp());
ostr.seekp(6, std::ios_base::cur);
assert (ostr.good());
assert (9 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (9 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(4, std::ios_base::beg);
ostr2.seekp(6, std::ios_base::cur);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(-4, std::ios_base::end);
assert (ostr.good());
assert (5 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (5 == ostr.tellp());
ostr.seekp(4, std::ios_base::cur);
assert (ostr.good());
assert (9 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (9 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(-4, std::ios_base::end);
ostr2.seekp(5, std::ios_base::cur);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
ostr.seekp(4, std::ios_base::beg);
assert (ostr.good());
assert (4 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (4 == ostr.tellp());
ostr.seekp(-4, std::ios_base::cur);
assert (ostr.good());
assert (0 == ostr.tellp());
assertTrue (ostr.good());
assertTrue (0 == ostr.tellp());
{
Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size());
ostr2.seekp(4, std::ios_base::beg);
ostr2.seekp(-5, std::ios_base::cur);
assert (ostr2.fail());
assertTrue (ostr2.fail());
}
}
@ -436,33 +436,33 @@ void MemoryStreamTest::testOutputSeekVsStringStream()
oss.seekp(4, std::ios_base::beg);
mos << 'a';
oss << 'a';
assert (oss.str()[4] == 'a');
assert (buffer[4] == oss.str()[4]);
assert (oss.tellp() == mos.tellp());
assertTrue (oss.str()[4] == 'a');
assertTrue (buffer[4] == oss.str()[4]);
assertTrue (oss.tellp() == mos.tellp());
mos.seekp(2, std::ios_base::cur);
oss.seekp(2, std::ios_base::cur);
mos << 'b';
oss << 'b';
assert (oss.str()[7] == 'b');
assert (buffer[7] == oss.str()[7]);
assert (oss.tellp() == mos.tellp());
assertTrue (oss.str()[7] == 'b');
assertTrue (buffer[7] == oss.str()[7]);
assertTrue (oss.tellp() == mos.tellp());
mos.seekp(-3, std::ios_base::end);
oss.seekp(-3, std::ios_base::end);
mos << 'c';
oss << 'c';
assert (oss.str()[6] == 'c');
assert (buffer[6] == oss.str()[6]);
assert (oss.tellp() == mos.tellp());
assertTrue (oss.str()[6] == 'c');
assertTrue (buffer[6] == oss.str()[6]);
assertTrue (oss.tellp() == mos.tellp());
mos.seekp(-2, std::ios_base::cur);
oss.seekp(-2, std::ios_base::cur);
mos << 'd';
oss << 'd';
assert (oss.str()[5] == 'd');
assert (buffer[5] == oss.str()[5]);
assert (oss.tellp() == mos.tellp());
assertTrue (oss.str()[5] == 'd');
assertTrue (buffer[5] == oss.str()[5]);
assertTrue (oss.tellp() == mos.tellp());
}

View File

@ -31,36 +31,36 @@ NDCTest::~NDCTest()
void NDCTest::testNDC()
{
NDC ndc;
assert (ndc.depth() == 0);
assertTrue (ndc.depth() == 0);
ndc.push("item1");
assert (ndc.toString() == "item1");
assert (ndc.depth() == 1);
assertTrue (ndc.toString() == "item1");
assertTrue (ndc.depth() == 1);
ndc.push("item2");
assert (ndc.toString() == "item1:item2");
assert (ndc.depth() == 2);
assertTrue (ndc.toString() == "item1:item2");
assertTrue (ndc.depth() == 2);
ndc.pop();
assert (ndc.depth() == 1);
assert (ndc.toString() == "item1");
assertTrue (ndc.depth() == 1);
assertTrue (ndc.toString() == "item1");
ndc.pop();
assert (ndc.depth() == 0);
assertTrue (ndc.depth() == 0);
}
void NDCTest::testNDCScope()
{
poco_ndc("item1");
assert (NDC::current().depth() == 1);
assertTrue (NDC::current().depth() == 1);
{
poco_ndc("item2");
assert (NDC::current().depth() == 2);
assertTrue (NDC::current().depth() == 2);
{
poco_ndc("item3");
assert (NDC::current().depth() == 3);
assertTrue (NDC::current().depth() == 3);
NDC::current().dump(std::cout);
}
assert (NDC::current().depth() == 2);
assertTrue (NDC::current().depth() == 2);
}
assert (NDC::current().depth() == 1);
assertTrue (NDC::current().depth() == 1);
}

View File

@ -78,7 +78,7 @@ void NamedEventTest::testNamedEvent()
}
thr1.join();
#if POCO_OS != POCO_OS_ANDROID
assert (te.timestamp() > now);
assertTrue (te.timestamp() > now);
#endif
Thread thr2;
thr2.start(te);
@ -96,7 +96,7 @@ void NamedEventTest::testNamedEvent()
}
thr2.join();
#if POCO_OS != POCO_OS_ANDROID
assert (te.timestamp() > now);
assertTrue (te.timestamp() > now);
#endif
}

View File

@ -97,7 +97,7 @@ void NamedMutexTest::testLock()
Thread::sleep(2000);
testMutex.unlock();
thr.join();
assert (tl.timestamp() > now);
assertTrue (tl.timestamp() > now);
}
catch(Poco::NotImplementedException e)
{
@ -115,7 +115,7 @@ void NamedMutexTest::testTryLock()
thr1.start(ttl1);
thr1.join();
#if POCO_OS != POCO_OS_ANDROID
assert (ttl1.locked());
assertTrue (ttl1.locked());
#endif
try
{
@ -125,7 +125,7 @@ void NamedMutexTest::testTryLock()
thr2.start(ttl2);
thr2.join();
testMutex.unlock();
assert (!ttl2.locked());
assertTrue (!ttl2.locked());
}
catch(Poco::NotImplementedException e)
{

File diff suppressed because it is too large Load Diff

View File

@ -51,16 +51,16 @@ void NotificationCenterTest::test2()
NotificationCenter nc;
Observer<NotificationCenterTest, Notification> o(*this, &NotificationCenterTest::handle1);
nc.addObserver(o);
assert (nc.hasObserver(o));
assert (nc.hasObservers());
assert (nc.countObservers() == 1);
assertTrue (nc.hasObserver(o));
assertTrue (nc.hasObservers());
assertTrue (nc.countObservers() == 1);
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end());
assertTrue (_set.size() == 1);
assertTrue (_set.find("handle1") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (!nc.hasObserver(o));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
assertTrue (!nc.hasObserver(o));
assertTrue (!nc.hasObservers());
assertTrue (nc.countObservers() == 0);
}
@ -70,21 +70,21 @@ void NotificationCenterTest::test3()
Observer<NotificationCenterTest, Notification> o1(*this, &NotificationCenterTest::handle1);
Observer<NotificationCenterTest, Notification> o2(*this, &NotificationCenterTest::handle2);
nc.addObserver(o1);
assert (nc.hasObserver(o1));
assertTrue (nc.hasObserver(o1));
nc.addObserver(o2);
assert (nc.hasObserver(o2));
assert (nc.hasObservers());
assert (nc.countObservers() == 2);
assertTrue (nc.hasObserver(o2));
assertTrue (nc.hasObservers());
assertTrue (nc.countObservers() == 2);
nc.postNotification(new Notification);
assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end());
assert (_set.find("handle2") != _set.end());
assertTrue (_set.size() == 2);
assertTrue (_set.find("handle1") != _set.end());
assertTrue (_set.find("handle2") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (!nc.hasObserver(o1));
assertTrue (!nc.hasObserver(o1));
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (!nc.hasObserver(o2));
assert (!nc.hasObservers());
assert (nc.countObservers() == 0);
assertTrue (!nc.hasObserver(o2));
assertTrue (!nc.hasObservers());
assertTrue (nc.countObservers() == 0);
}
@ -94,28 +94,28 @@ void NotificationCenterTest::test4()
Observer<NotificationCenterTest, Notification> o1(*this, &NotificationCenterTest::handle1);
Observer<NotificationCenterTest, Notification> o2(*this, &NotificationCenterTest::handle2);
nc.addObserver(o1);
assert (nc.hasObserver(o1));
assertTrue (nc.hasObserver(o1));
nc.addObserver(o2);
assert (nc.hasObserver(o2));
assertTrue (nc.hasObserver(o2));
nc.postNotification(new Notification);
assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end());
assert (_set.find("handle2") != _set.end());
assertTrue (_set.size() == 2);
assertTrue (_set.find("handle1") != _set.end());
assertTrue (_set.find("handle2") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
assert (!nc.hasObserver(o1));
assertTrue (!nc.hasObserver(o1));
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
assert (!nc.hasObserver(o2));
assertTrue (!nc.hasObserver(o2));
_set.clear();
nc.postNotification(new Notification);
assert (_set.empty());
assertTrue (_set.empty());
Observer<NotificationCenterTest, Notification> o3(*this, &NotificationCenterTest::handle3);
nc.addObserver(o3);
assert (nc.hasObserver(o3));
assertTrue (nc.hasObserver(o3));
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle3") != _set.end());
assertTrue (_set.size() == 1);
assertTrue (_set.find("handle3") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle3));
assert (!nc.hasObserver(o3));
assertTrue (!nc.hasObserver(o3));
}
@ -125,13 +125,13 @@ void NotificationCenterTest::test5()
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.addObserver(Observer<NotificationCenterTest, TestNotification>(*this, &NotificationCenterTest::handleTest));
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end());
assertTrue (_set.size() == 1);
assertTrue (_set.find("handle1") != _set.end());
_set.clear();
nc.postNotification(new TestNotification);
assert (_set.size() == 2);
assert (_set.find("handle1") != _set.end());
assert (_set.find("handleTest") != _set.end());
assertTrue (_set.size() == 2);
assertTrue (_set.find("handle1") != _set.end());
assertTrue (_set.find("handleTest") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.removeObserver(Observer<NotificationCenterTest, TestNotification>(*this, &NotificationCenterTest::handleTest));
}
@ -142,8 +142,8 @@ void NotificationCenterTest::testAuto()
NotificationCenter nc;
nc.addObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handleAuto") != _set.end());
assertTrue (_set.size() == 1);
assertTrue (_set.find("handleAuto") != _set.end());
nc.removeObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
}
@ -153,8 +153,8 @@ void NotificationCenterTest::testDefaultCenter()
NotificationCenter& nc = NotificationCenter::defaultCenter();
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
nc.postNotification(new Notification);
assert (_set.size() == 1);
assert (_set.find("handle1") != _set.end());
assertTrue (_set.size() == 1);
assertTrue (_set.find("handle1") != _set.end());
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
}

View File

@ -60,35 +60,35 @@ NotificationQueueTest::~NotificationQueueTest()
void NotificationQueueTest::testQueueDequeue()
{
NotificationQueue queue;
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
Notification* pNf = queue.dequeueNotification();
assertNullPtr(pNf);
queue.enqueueNotification(new Notification);
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pNf = queue.dequeueNotification();
assertNotNullPtr(pNf);
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
pNf->release();
queue.enqueueNotification(new QTestNotification("first"));
queue.enqueueNotification(new QTestNotification("second"));
assert (!queue.empty());
assert (queue.size() == 2);
assertTrue (!queue.empty());
assertTrue (queue.size() == 2);
QTestNotification* pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "first");
assertTrue (pTNf->data() == "first");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "second");
assertTrue (pTNf->data() == "second");
pTNf->release();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
pNf = queue.dequeueNotification();
assertNullPtr(pNf);
@ -101,25 +101,25 @@ void NotificationQueueTest::testQueueDequeueUrgent()
queue.enqueueNotification(new QTestNotification("first"));
queue.enqueueNotification(new QTestNotification("second"));
queue.enqueueUrgentNotification(new QTestNotification("third"));
assert (!queue.empty());
assert (queue.size() == 3);
assertTrue (!queue.empty());
assertTrue (queue.size() == 3);
QTestNotification* pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "third");
assertTrue (pTNf->data() == "third");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 2);
assertTrue (!queue.empty());
assertTrue (queue.size() == 2);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assert (pTNf->data() == "first");
assertTrue (pTNf->data() == "first");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "second");
assertTrue (pTNf->data() == "second");
pTNf->release();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
Notification* pNf = queue.dequeueNotification();
assertNullPtr(pNf);
@ -131,20 +131,20 @@ void NotificationQueueTest::testWaitDequeue()
NotificationQueue queue;
queue.enqueueNotification(new QTestNotification("third"));
queue.enqueueNotification(new QTestNotification("fourth"));
assert (!queue.empty());
assert (queue.size() == 2);
assertTrue (!queue.empty());
assertTrue (queue.size() == 2);
QTestNotification* pTNf = dynamic_cast<QTestNotification*>(queue.waitDequeueNotification(10));
assertNotNullPtr(pTNf);
assert (pTNf->data() == "third");
assertTrue (pTNf->data() == "third");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pTNf = dynamic_cast<QTestNotification*>(queue.waitDequeueNotification(10));
assertNotNullPtr(pTNf);
assert (pTNf->data() == "fourth");
assertTrue (pTNf->data() == "fourth");
pTNf->release();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
Notification* pNf = queue.waitDequeueNotification(10);
assertNullPtr(pNf);
@ -173,18 +173,18 @@ void NotificationQueueTest::testThreads()
t1.join();
t2.join();
t3.join();
assert (_handled.size() == NOTIFICATION_COUNT);
assert (_handled.count("thread1") > 0);
assert (_handled.count("thread2") > 0);
assert (_handled.count("thread3") > 0);
assertTrue (_handled.size() == NOTIFICATION_COUNT);
assertTrue (_handled.count("thread1") > 0);
assertTrue (_handled.count("thread2") > 0);
assertTrue (_handled.count("thread3") > 0);
}
void NotificationQueueTest::testDefaultQueue()
{
NotificationQueue& queue = NotificationQueue::defaultQueue();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
}

View File

@ -31,20 +31,20 @@ NullStreamTest::~NullStreamTest()
void NullStreamTest::testInput()
{
NullInputStream istr;
assert (istr.good());
assert (!istr.eof());
assertTrue (istr.good());
assertTrue (!istr.eof());
int c = istr.get();
assert (c == -1);
assert (istr.eof());
assertTrue (c == -1);
assertTrue (istr.eof());
}
void NullStreamTest::testOutput()
{
NullOutputStream ostr;
assert (ostr.good());
assertTrue (ostr.good());
ostr << "Hello, world!";
assert (ostr.good());
assertTrue (ostr.good());
}

View File

@ -32,69 +32,69 @@ NumberFormatterTest::~NumberFormatterTest()
void NumberFormatterTest::testFormat()
{
assert (NumberFormatter::format(123) == "123");
assert (NumberFormatter::format(-123) == "-123");
assert (NumberFormatter::format(-123, 5) == " -123");
assertTrue (NumberFormatter::format(123) == "123");
assertTrue (NumberFormatter::format(-123) == "-123");
assertTrue (NumberFormatter::format(-123, 5) == " -123");
assert (NumberFormatter::format((unsigned) 123) == "123");
assert (NumberFormatter::format((unsigned) 123, 5) == " 123");
assert (NumberFormatter::format0((unsigned) 123, 5) == "00123");
assertTrue (NumberFormatter::format((unsigned) 123) == "123");
assertTrue (NumberFormatter::format((unsigned) 123, 5) == " 123");
assertTrue (NumberFormatter::format0((unsigned) 123, 5) == "00123");
assert (NumberFormatter::format((long) 123) == "123");
assert (NumberFormatter::format((long) -123) == "-123");
assert (NumberFormatter::format((long) -123, 5) == " -123");
assertTrue (NumberFormatter::format((long) 123) == "123");
assertTrue (NumberFormatter::format((long) -123) == "-123");
assertTrue (NumberFormatter::format((long) -123, 5) == " -123");
assert (NumberFormatter::format((unsigned long) 123) == "123");
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
assertTrue (NumberFormatter::format((unsigned long) 123) == "123");
assertTrue (NumberFormatter::format((unsigned long) 123, 5) == " 123");
assert (NumberFormatter::format(123) == "123");
assert (NumberFormatter::format(-123) == "-123");
assert (NumberFormatter::format(-123, 5) == " -123");
assertTrue (NumberFormatter::format(123) == "123");
assertTrue (NumberFormatter::format(-123) == "-123");
assertTrue (NumberFormatter::format(-123, 5) == " -123");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::format((Int64) 123) == "123");
assert (NumberFormatter::format((Int64) -123) == "-123");
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
assertTrue (NumberFormatter::format((Int64) 123) == "123");
assertTrue (NumberFormatter::format((Int64) -123) == "-123");
assertTrue (NumberFormatter::format((Int64) -123, 5) == " -123");
assert (NumberFormatter::format((UInt64) 123) == "123");
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
assertTrue (NumberFormatter::format((UInt64) 123) == "123");
assertTrue (NumberFormatter::format((UInt64) 123, 5) == " 123");
#if defined(POCO_LONG_IS_64_BIT)
assert (NumberFormatter::format((long long) 123) == "123");
assert (NumberFormatter::format((long long) -123) == "-123");
assert (NumberFormatter::format((long long) -123, 5) == " -123");
assertTrue (NumberFormatter::format((long long) 123) == "123");
assertTrue (NumberFormatter::format((long long) -123) == "-123");
assertTrue (NumberFormatter::format((long long) -123, 5) == " -123");
assert (NumberFormatter::format((unsigned long long) 123) == "123");
assert (NumberFormatter::format((unsigned long long) 123, 5) == " 123");
assertTrue (NumberFormatter::format((unsigned long long) 123) == "123");
assertTrue (NumberFormatter::format((unsigned long long) 123, 5) == " 123");
#endif
#endif
if (sizeof(void*) == 4)
{
assert (NumberFormatter::format((void*) 0x12345678) == "12345678");
assertTrue (NumberFormatter::format((void*) 0x12345678) == "12345678");
}
else
{
assert (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
assertTrue (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
}
}
void NumberFormatterTest::testFormat0()
{
assert (NumberFormatter::format0(123, 5) == "00123");
assert (NumberFormatter::format0(-123, 5) == "-0123");
assert (NumberFormatter::format0((long) 123, 5) == "00123");
assert (NumberFormatter::format0((long) -123, 5) == "-0123");
assert (NumberFormatter::format0((unsigned long) 123, 5) == "00123");
assertTrue (NumberFormatter::format0(123, 5) == "00123");
assertTrue (NumberFormatter::format0(-123, 5) == "-0123");
assertTrue (NumberFormatter::format0((long) 123, 5) == "00123");
assertTrue (NumberFormatter::format0((long) -123, 5) == "-0123");
assertTrue (NumberFormatter::format0((unsigned long) 123, 5) == "00123");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
assertTrue (NumberFormatter::format0((Int64) 123, 5) == "00123");
assertTrue (NumberFormatter::format0((Int64) -123, 5) == "-0123");
assertTrue (NumberFormatter::format0((UInt64) 123, 5) == "00123");
#if defined(POCO_LONG_IS_64_BIT)
assert (NumberFormatter::format0((long long) 123, 5) == "00123");
assert (NumberFormatter::format0((long long) -123, 5) == "-0123");
assert (NumberFormatter::format0((unsigned long long) 123, 5) == "00123");
assertTrue (NumberFormatter::format0((long long) 123, 5) == "00123");
assertTrue (NumberFormatter::format0((long long) -123, 5) == "-0123");
assertTrue (NumberFormatter::format0((unsigned long long) 123, 5) == "00123");
#endif
#endif
}
@ -102,116 +102,116 @@ void NumberFormatterTest::testFormat0()
void NumberFormatterTest::testFormatBool()
{
assert(NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
assert(NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
assert(NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
assert(NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
assert(NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
assert(NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
assertTrue (NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
assertTrue (NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
assertTrue (NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
assertTrue (NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
assertTrue (NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
assertTrue (NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
}
void NumberFormatterTest::testFormatHex()
{
assert (NumberFormatter::formatHex(0x12) == "12");
assert (NumberFormatter::formatHex(0xab) == "AB");
assert (NumberFormatter::formatHex(0x12, 4) == "0012");
assert (NumberFormatter::formatHex(0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex(0x12) == "12");
assertTrue (NumberFormatter::formatHex(0xab) == "AB");
assertTrue (NumberFormatter::formatHex(0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex(0xab, 4) == "00AB");
assert (NumberFormatter::formatHex((unsigned) 0x12) == "12");
assert (NumberFormatter::formatHex((unsigned) 0xab) == "AB");
assert (NumberFormatter::formatHex((unsigned) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((unsigned) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((unsigned) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((unsigned) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4) == "00AB");
assert (NumberFormatter::formatHex((long) 0x12) == "12");
assert (NumberFormatter::formatHex((long) 0xab) == "AB");
assert (NumberFormatter::formatHex((long) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((long) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((long) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((long) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((long) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((long) 0xab, 4) == "00AB");
assert (NumberFormatter::formatHex((unsigned long) 0x12) == "12");
assert (NumberFormatter::formatHex((unsigned long) 0xab) == "AB");
assert (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::formatHex((Int64) 0x12) == "12");
assert (NumberFormatter::formatHex((Int64) 0xab) == "AB");
assert (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((Int64) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((Int64) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((Int64) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4) == "00AB");
assert (NumberFormatter::formatHex((UInt64) 0x12) == "12");
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((UInt64) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
#if defined(POCO_LONG_IS_64_BIT)
assert (NumberFormatter::formatHex((long long) 0x12) == "12");
assert (NumberFormatter::formatHex((long long) 0xab) == "AB");
assert (NumberFormatter::formatHex((long long) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((long long) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((long long) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((long long) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((long long) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4) == "00AB");
assert (NumberFormatter::formatHex((unsigned long long) 0x12) == "12");
assert (NumberFormatter::formatHex((unsigned long long) 0xab) == "AB");
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 4) == "0012");
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 4) == "00AB");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12) == "12");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab) == "AB");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 4) == "0012");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4) == "00AB");
#endif
#endif
assert (NumberFormatter::formatHex(0x12, true) == "0x12");
assert (NumberFormatter::formatHex(0xab, true) == "0xAB");
assert (NumberFormatter::formatHex(0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex(0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex(0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex(0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex(0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex(0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex(0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex(0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex(0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex(0xab, 6, true) == "0x00AB");
assert (NumberFormatter::formatHex((unsigned) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((unsigned) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 6, true) == "0x00AB");
assert (NumberFormatter::formatHex((long) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((long) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((long) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((long) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((long) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((long) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((long) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((long) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((long) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((long) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((long) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((long) 0xab, 6, true) == "0x00AB");
assert (NumberFormatter::formatHex((unsigned long) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned long) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned long) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned long) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned long) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((unsigned long) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 6, true) == "0x00AB");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::formatHex((Int64) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((Int64) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((Int64) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((Int64) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((Int64) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((Int64) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((Int64) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((Int64) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 6, true) == "0x00AB");
assert (NumberFormatter::formatHex((UInt64) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((UInt64) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((UInt64) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
#if defined(POCO_LONG_IS_64_BIT)
assert (NumberFormatter::formatHex((long long) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((long long) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((long long) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((long long) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((long long) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((long long) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((long long) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((long long) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((long long) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((long long) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((long long) 0xab, 6, true) == "0x00AB");
assert (NumberFormatter::formatHex((unsigned long long) 0x12, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned long long) 0xab, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 4, true) == "0x12");
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 4, true) == "0xAB");
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 6, true) == "0x0012");
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 6, true) == "0x00AB");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 4, true) == "0x12");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4, true) == "0xAB");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 6, true) == "0x0012");
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 6, true) == "0x00AB");
#endif
#endif
}
@ -219,50 +219,50 @@ void NumberFormatterTest::testFormatHex()
void NumberFormatterTest::testFormatFloat()
{
assert (NumberFormatter::format(1.0f) == "1");
assert (NumberFormatter::format(1.23f) == "1.23");
assert (NumberFormatter::format(-1.23f) == "-1.23");
assert (NumberFormatter::format(0.1f) == "0.1");
assert (NumberFormatter::format(-0.1f) == "-0.1");
assert (NumberFormatter::format(1.23) == "1.23");
assert (NumberFormatter::format(-1.23) == "-1.23");
assert (NumberFormatter::format(1.0) == "1");
assert (NumberFormatter::format(-1.0) == "-1");
assert (NumberFormatter::format(0.1) == "0.1");
assert (NumberFormatter::format(-0.1) == "-0.1");
assertTrue (NumberFormatter::format(1.0f) == "1");
assertTrue (NumberFormatter::format(1.23f) == "1.23");
assertTrue (NumberFormatter::format(-1.23f) == "-1.23");
assertTrue (NumberFormatter::format(0.1f) == "0.1");
assertTrue (NumberFormatter::format(-0.1f) == "-0.1");
assertTrue (NumberFormatter::format(1.23) == "1.23");
assertTrue (NumberFormatter::format(-1.23) == "-1.23");
assertTrue (NumberFormatter::format(1.0) == "1");
assertTrue (NumberFormatter::format(-1.0) == "-1");
assertTrue (NumberFormatter::format(0.1) == "0.1");
assertTrue (NumberFormatter::format(-0.1) == "-0.1");
int decDigits = std::numeric_limits<double>::digits10;
std::ostringstream ostr;
ostr << "0." << std::string(decDigits - 1, '0') << '1';
assert(NumberFormatter::format(1 / std::pow(10., decDigits)) == ostr.str());
assertTrue (NumberFormatter::format(1 / std::pow(10., decDigits)) == ostr.str());
ostr.str("");
ostr << "1e-" << decDigits + 1;
std::string str (ostr.str());
std::string str1 (NumberFormatter::format(1 / std::pow(10., decDigits + 1)));
assert(NumberFormatter::format(1 / std::pow(10., decDigits + 1)) == ostr.str());
assertTrue (NumberFormatter::format(1 / std::pow(10., decDigits + 1)) == ostr.str());
assert(NumberFormatter::format(12.25) == "12.25");
assert(NumberFormatter::format(12.25, 4) == "12.2500");
assert(NumberFormatter::format(12.25, 8, 4) == " 12.2500");
assertTrue (NumberFormatter::format(12.25) == "12.25");
assertTrue (NumberFormatter::format(12.25, 4) == "12.2500");
assertTrue (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
assert (NumberFormatter::format(12.45f, 2) == "12.45");
assertTrue (NumberFormatter::format(12.45f, 2) == "12.45");
assert(NumberFormatter::format(-12.25) == "-12.25");
assert(NumberFormatter::format(-12.25, 4) == "-12.2500");
assert(NumberFormatter::format(-12.25, 10, 4) == " -12.2500");
assert(NumberFormatter::format(-12.25, 10, 2) == " -12.25");
assert(NumberFormatter::format(-12.25, 10, 1) == " -12.3");
assertTrue (NumberFormatter::format(-12.25) == "-12.25");
assertTrue (NumberFormatter::format(-12.25, 4) == "-12.2500");
assertTrue (NumberFormatter::format(-12.25, 10, 4) == " -12.2500");
assertTrue (NumberFormatter::format(-12.25, 10, 2) == " -12.25");
assertTrue (NumberFormatter::format(-12.25, 10, 1) == " -12.3");
assert (NumberFormatter::format(50.0, 3) == "50.000");
assert (NumberFormatter::format(50.0f, 3) == "50.000");
assert (NumberFormatter::format(50.123, 3) == "50.123");
assert (NumberFormatter::format(50.123f, 3) == "50.123");
assert (NumberFormatter::format(50.123, 0) == "50");
assert (NumberFormatter::format(50.123f, 0) == "50");
assert (NumberFormatter::format(50.546, 0) == "51");
assert (NumberFormatter::format(50.546f, 0) == "51");
assert (NumberFormatter::format(50.546f, 2) == "50.55");
assertTrue (NumberFormatter::format(50.0, 3) == "50.000");
assertTrue (NumberFormatter::format(50.0f, 3) == "50.000");
assertTrue (NumberFormatter::format(50.123, 3) == "50.123");
assertTrue (NumberFormatter::format(50.123f, 3) == "50.123");
assertTrue (NumberFormatter::format(50.123, 0) == "50");
assertTrue (NumberFormatter::format(50.123f, 0) == "50");
assertTrue (NumberFormatter::format(50.546, 0) == "51");
assertTrue (NumberFormatter::format(50.546f, 0) == "51");
assertTrue (NumberFormatter::format(50.546f, 2) == "50.55");
}
@ -270,48 +270,48 @@ void NumberFormatterTest::testAppend()
{
std::string s;
NumberFormatter::append(s, 123);
assert (s == "123");
assertTrue (s == "123");
s.erase();
NumberFormatter::append(s, 123, 4);
assert (s == " 123");
assertTrue (s == " 123");
s.erase();
NumberFormatter::append0(s, 123, 5);
assert (s == "00123");
assertTrue (s == "00123");
s.erase();
NumberFormatter::appendHex(s, 0xDEAD);
assert (s == "DEAD");
assertTrue (s == "DEAD");
s.erase();
NumberFormatter::appendHex(s, 0xDEAD, 6);
assert (s == "00DEAD");
assertTrue (s == "00DEAD");
s.erase();
NumberFormatter::append(s, 123u);
assert (s == "123");
assertTrue (s == "123");
s.erase();
NumberFormatter::append(s, 123u, 4);
assert (s == " 123");
assertTrue (s == " 123");
s.erase();
NumberFormatter::append0(s, 123u, 5);
assert (s == "00123");
assertTrue (s == "00123");
s.erase();
NumberFormatter::append(s, 123.4);
assert (s == "123.4");
assertTrue (s == "123.4");
s.erase();
NumberFormatter::append(s, 123.4567, 2);
assert (s == "123.46");
assertTrue (s == "123.46");
s.erase();
NumberFormatter::append(s, 123.4567, 10, 5);
assert (s == " 123.45670");
assertTrue (s == " 123.45670");
s.erase();
NumberFormatter::append(s, 123., 2);
assert (s == "123.00");
assertTrue (s == "123.00");
s.erase();
NumberFormatter::append(s, static_cast<double>(1234567), 2);
assert (s == "1234567.00");
assertTrue (s == "1234567.00");
s.erase();
NumberFormatter::append(s, 1234567.0, 10, 1);
assert (s == " 1234567.0");
assertTrue (s == " 1234567.0");
}

View File

@ -58,44 +58,44 @@ void NumberParserTest::testParse()
{
char ts = sep[i];
assert(NumberParser::parse("123") == 123);
assert(NumberParser::parse(format("123%c456", ts), ts) == 123456);
assert(NumberParser::parse(format("1%c234%c567", ts, ts), ts) == 1234567);
assertTrue (NumberParser::parse("123") == 123);
assertTrue (NumberParser::parse(format("123%c456", ts), ts) == 123456);
assertTrue (NumberParser::parse(format("1%c234%c567", ts, ts), ts) == 1234567);
}
assert(NumberParser::parse("+123") == 123);
assert(NumberParser::parse("-123") == -123);
assert(NumberParser::parse("0") == 0);
assert(NumberParser::parse("000") == 0);
assert(NumberParser::parse("0123") == 123);
assert(NumberParser::parse("+0123") == 123);
assert(NumberParser::parse("-0123") == -123);
assert(NumberParser::parseUnsigned("123") == 123);
assert(NumberParser::parseHex("12AB") == 0x12ab);
assert(NumberParser::parseHex("0x12AB") == 0x12ab);
assert(NumberParser::parseHex("0X12AB") == 0x12ab);
assert(NumberParser::parseHex("00") == 0);
assert(NumberParser::parseOct("123") == 0123);
assert(NumberParser::parseOct("0123") == 0123);
assert(NumberParser::parseOct("0") == 0);
assert(NumberParser::parseOct("000") == 0);
assertTrue (NumberParser::parse("+123") == 123);
assertTrue (NumberParser::parse("-123") == -123);
assertTrue (NumberParser::parse("0") == 0);
assertTrue (NumberParser::parse("000") == 0);
assertTrue (NumberParser::parse("0123") == 123);
assertTrue (NumberParser::parse("+0123") == 123);
assertTrue (NumberParser::parse("-0123") == -123);
assertTrue (NumberParser::parseUnsigned("123") == 123);
assertTrue (NumberParser::parseHex("12AB") == 0x12ab);
assertTrue (NumberParser::parseHex("0x12AB") == 0x12ab);
assertTrue (NumberParser::parseHex("0X12AB") == 0x12ab);
assertTrue (NumberParser::parseHex("00") == 0);
assertTrue (NumberParser::parseOct("123") == 0123);
assertTrue (NumberParser::parseOct("0123") == 0123);
assertTrue (NumberParser::parseOct("0") == 0);
assertTrue (NumberParser::parseOct("000") == 0);
assert(NumberParser::parseBool("0") == false);
assert(NumberParser::parseBool("FALSE") == false);
assert(NumberParser::parseBool("no") == false);
assert(NumberParser::parseBool("1") == true);
assert(NumberParser::parseBool("True") == true);
assert(NumberParser::parseBool("YeS") == true);
assertTrue (NumberParser::parseBool("0") == false);
assertTrue (NumberParser::parseBool("FALSE") == false);
assertTrue (NumberParser::parseBool("no") == false);
assertTrue (NumberParser::parseBool("1") == true);
assertTrue (NumberParser::parseBool("True") == true);
assertTrue (NumberParser::parseBool("YeS") == true);
#if defined(POCO_HAVE_INT64)
assert(NumberParser::parse64("123") == 123);
assert(NumberParser::parse64("-123") == -123);
assert(NumberParser::parse64("0123") == 123);
assert(NumberParser::parse64("-0123") == -123);
assert(NumberParser::parseUnsigned64("123") == 123);
assert(NumberParser::parseHex64("12AB") == 0x12ab);
assert(NumberParser::parseOct64("123") == 0123);
assert(NumberParser::parseOct64("0123") == 0123);
assertTrue (NumberParser::parse64("123") == 123);
assertTrue (NumberParser::parse64("-123") == -123);
assertTrue (NumberParser::parse64("0123") == 123);
assertTrue (NumberParser::parse64("-0123") == -123);
assertTrue (NumberParser::parseUnsigned64("123") == 123);
assertTrue (NumberParser::parseHex64("12AB") == 0x12ab);
assertTrue (NumberParser::parseOct64("123") == 0123);
assertTrue (NumberParser::parseOct64("0123") == 0123);
#endif
#ifndef POCO_NO_FPENVIRONMENT
@ -173,20 +173,20 @@ void NumberParserTest::testParse()
void NumberParserTest::testLimits()
{
assert(testUpperLimit<Int8>());
assert(testLowerLimit<Int8>());
assert(testUpperLimit<UInt8>());
assert(testUpperLimit<Int16>());
assert(testLowerLimit<Int16>());
assert(testUpperLimit<UInt16>());
assert(testUpperLimit<Int32>());
assert(testLowerLimit<Int32>());
assert(testUpperLimit<UInt32>());
assertTrue (testUpperLimit<Int8>());
assertTrue (testLowerLimit<Int8>());
assertTrue (testUpperLimit<UInt8>());
assertTrue (testUpperLimit<Int16>());
assertTrue (testLowerLimit<Int16>());
assertTrue (testUpperLimit<UInt16>());
assertTrue (testUpperLimit<Int32>());
assertTrue (testLowerLimit<Int32>());
assertTrue (testUpperLimit<UInt32>());
#if defined(POCO_HAVE_INT64)
assert(testUpperLimit64<Int64>());
assert(testLowerLimit64<Int64>());
assert(testUpperLimit64<UInt64>());
assertTrue (testUpperLimit64<Int64>());
assertTrue (testLowerLimit64<Int64>());
assertTrue (testUpperLimit64<UInt64>());
#endif
}
@ -197,7 +197,7 @@ void NumberParserTest::testParseError()
if (dp == 0) dp = '.';
char ts = thousandSeparator();
if (ts == 0) ts = ',';
assert (dp != ts);
assertTrue (dp != ts);
try
{

View File

@ -32,59 +32,59 @@ void ObjectPoolTest::testObjectPool()
{
ObjectPool<std::string, Poco::SharedPtr<std::string> > pool(3, 4);
assert (pool.capacity() == 3);
assert (pool.peakCapacity() == 4);
assert (pool.size() == 0);
assert (pool.available() == 4);
assertTrue (pool.capacity() == 3);
assertTrue (pool.peakCapacity() == 4);
assertTrue (pool.size() == 0);
assertTrue (pool.available() == 4);
Poco::SharedPtr<std::string> pStr1 = pool.borrowObject();
pStr1->assign("first");
assert (pool.size() == 1);
assert (pool.available() == 3);
assertTrue (pool.size() == 1);
assertTrue (pool.available() == 3);
Poco::SharedPtr<std::string> pStr2 = pool.borrowObject();
pStr2->assign("second");
assert (pool.size() == 2);
assert (pool.available() == 2);
assertTrue (pool.size() == 2);
assertTrue (pool.available() == 2);
Poco::SharedPtr<std::string> pStr3 = pool.borrowObject();
pStr3->assign("third");
assert (pool.size() == 3);
assert (pool.available() == 1);
assertTrue (pool.size() == 3);
assertTrue (pool.available() == 1);
Poco::SharedPtr<std::string> pStr4 = pool.borrowObject();
pStr4->assign("fourth");
assert (pool.size() == 4);
assert (pool.available() == 0);
assertTrue (pool.size() == 4);
assertTrue (pool.available() == 0);
Poco::SharedPtr<std::string> pStr5 = pool.borrowObject();
assert (pStr5.isNull());
assertTrue (pStr5.isNull());
pool.returnObject(pStr4);
assert (pool.size() == 4);
assert (pool.available() == 1);
assertTrue (pool.size() == 4);
assertTrue (pool.available() == 1);
pool.returnObject(pStr3);
assert (pool.size() == 4);
assert (pool.available() == 2);
assertTrue (pool.size() == 4);
assertTrue (pool.available() == 2);
pStr3 = pool.borrowObject();
assert (*pStr3 == "third");
assert (pool.available() == 1);
assertTrue (*pStr3 == "third");
assertTrue (pool.available() == 1);
pool.returnObject(pStr3);
pool.returnObject(pStr2);
pool.returnObject(pStr1);
assert (pool.size() == 3);
assert (pool.available() == 4);
assertTrue (pool.size() == 3);
assertTrue (pool.available() == 4);
pStr1 = pool.borrowObject();
assert (*pStr1 == "second");
assert (pool.available() == 3);
assertTrue (*pStr1 == "second");
assertTrue (pool.available() == 3);
pool.returnObject(pStr1);
assert (pool.available() == 4);
assertTrue (pool.available() == 4);
}

View File

@ -41,7 +41,7 @@ void PBKDF2EngineTest::testPBKDF2a()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 1, 20);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "0c60c80f961f0e71f3a9b524af6012062fe037a6");
assertTrue (dk == "0c60c80f961f0e71f3a9b524af6012062fe037a6");
}
@ -54,7 +54,7 @@ void PBKDF2EngineTest::testPBKDF2b()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 2, 20);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957");
assertTrue (dk == "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957");
}
@ -67,7 +67,7 @@ void PBKDF2EngineTest::testPBKDF2c()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 4096, 20);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "4b007901b765489abead49d926f721d065a429c1");
assertTrue (dk == "4b007901b765489abead49d926f721d065a429c1");
}
@ -80,7 +80,7 @@ void PBKDF2EngineTest::testPBKDF2d()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 16777216, 20);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984");
assertTrue (dk == "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984");
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
}
@ -94,7 +94,7 @@ void PBKDF2EngineTest::testPBKDF2e()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 4096, 25);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038");
assertTrue (dk == "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038");
}
@ -107,7 +107,7 @@ void PBKDF2EngineTest::testPBKDF2f()
PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(s, 4096, 16);
pbkdf2.update(p);
std::string dk = DigestEngine::digestToHex(pbkdf2.digest());
assert (dk == "56fa6aa75548099dcc37d7f03425e0c3");
assertTrue (dk == "56fa6aa75548099dcc37d7f03425e0c3");
}

File diff suppressed because it is too large Load Diff

View File

@ -47,50 +47,50 @@ void PatternFormatterTest::testPatternFormatter()
std::string result;
fmt.setProperty("pattern", "%Y-%m-%dT%H:%M:%S [%s] %p: %t");
fmt.format(msg, result);
assert (result == "2005-01-01T14:30:15 [TestSource] Error: Test message text");
assertTrue (result == "2005-01-01T14:30:15 [TestSource] Error: Test message text");
result.clear();
fmt.setProperty("pattern", "%w, %e %b %y %H:%M:%S.%i [%s:%I:%T] %q: %t");
fmt.format(msg, result);
assert (result == "Sat, 1 Jan 05 14:30:15.500 [TestSource:1:TestThread] E: Test message text");
assertTrue (result == "Sat, 1 Jan 05 14:30:15.500 [TestSource:1:TestThread] E: Test message text");
result.clear();
fmt.setProperty("pattern", "%Y-%m-%d %H:%M:%S [%N:%P:%s]%l-%t");
fmt.format(msg, result);
assert (result.find("2005-01-01 14:30:15 [") == 0);
assert (result.find(":TestSource]3-Test message text") != std::string::npos);
assertTrue (result.find("2005-01-01 14:30:15 [") == 0);
assertTrue (result.find(":TestSource]3-Test message text") != std::string::npos);
result.clear();
assert (fmt.getProperty("times") == "UTC");
assertTrue (fmt.getProperty("times") == "UTC");
fmt.setProperty("times", "local");
fmt.format(msg, result);
assert (result.find("2005-01-01 ") == 0);
assert (result.find(":TestSource]3-Test message text") != std::string::npos);
assertTrue (result.find("2005-01-01 ") == 0);
assertTrue (result.find(":TestSource]3-Test message text") != std::string::npos);
result.clear();
fmt.setProperty("pattern", "%[testParam]");
fmt.format(msg, result);
assert (result == "Test Parameter");
assertTrue (result == "Test Parameter");
result.clear();
fmt.setProperty("pattern", "%[testParam] %p");
fmt.format(msg, result);
assert (result == "Test Parameter Error");
assertTrue (result == "Test Parameter Error");
result.clear();
fmt.setProperty("pattern", "start %v[10] end");
fmt.format(msg, result);
assert (result == "start TestSource end");
assertTrue (result == "start TestSource end");
result.clear();
fmt.setProperty("pattern", "start %v[12] end");
fmt.format(msg, result);
assert (result == "start TestSource end");
assertTrue (result == "start TestSource end");
result.clear();
fmt.setProperty("pattern", "start %v[8] end");
fmt.format(msg, result);
assert (result == "start stSource end");
assertTrue (result == "start stSource end");
}

View File

@ -38,55 +38,55 @@ void PriorityEventTest::testNoDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assertTrue (_count == 0);
Void.notify(this);
assert (_count == 0);
assertTrue (_count == 0);
Void += priorityDelegate(this, &PriorityEventTest::onVoid, 0);
Void -= priorityDelegate(this, &PriorityEventTest::onVoid, 0);
Void.notify(this);
assert (_count == 0);
assertTrue (_count == 0);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimpleNoSender, 0);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimpleNoSender, 0);
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
ConstSimple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
//Note: passing &args will not work due to &
EventArgs* pArgs = &args;
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
Complex -= priorityDelegate(this, &PriorityEventTest::onComplex, 0);
Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
Complex2 += priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
Complex2 -= priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
Complex2.notify(this, args);
assert (_count == 0);
assertTrue (_count == 0);
const EventArgs* pCArgs = &args;
ConstComplex += priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
ConstComplex -= priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
ConstComplex.notify(this, pCArgs);
assert (_count == 0);
assertTrue (_count == 0);
Const2Complex += priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
Const2Complex -= priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
Const2Complex.notify(this, pArgs);
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 0);
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 0);
@ -95,7 +95,7 @@ void PriorityEventTest::testNoDelegate()
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple3, 3);
Simple.notify(this, tmp);
assert (_count == 4);
assertTrue (_count == 4);
Simple -= priorityDelegate(PriorityEventTest::onStaticSimple, 0);
@ -104,7 +104,7 @@ void PriorityEventTest::testNoDelegate()
Void += priorityDelegate(&PriorityEventTest::onStaticVoid, 1);
Void.notify(this);
assert (_count == 7);
assertTrue (_count == 7);
Void -= priorityDelegate(PriorityEventTest::onStaticVoid, 0);
}
@ -113,49 +113,49 @@ void PriorityEventTest::testSingleDelegate()
int tmp = 0;
EventArgs args;
assert (_count == 0);
assertTrue (_count == 0);
Void += priorityDelegate(this, &PriorityEventTest::onVoid, 0);
// unregistering with a different priority --> different observer, is ignored
Void -= priorityDelegate(this, &PriorityEventTest::onVoid, 3);
Void.notify(this);
assert (_count == 1);
assertTrue (_count == 1);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
// unregistering with a different priority --> different observer, is ignored
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 3);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
ConstSimple += priorityDelegate(this, &PriorityEventTest::onConstSimple, 0);
ConstSimple -= priorityDelegate(this, &PriorityEventTest::onConstSimple, 3);
ConstSimple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
EventArgs* pArgs = &args;
Complex += priorityDelegate(this, &PriorityEventTest::onComplex, 0);
Complex -= priorityDelegate(this, &PriorityEventTest::onComplex, 3);
Complex.notify(this, pArgs);
assert (_count == 4);
assertTrue (_count == 4);
Complex2 += priorityDelegate(this, &PriorityEventTest::onComplex2, 0);
Complex2 -= priorityDelegate(this, &PriorityEventTest::onComplex2, 3);
Complex2.notify(this, args);
assert (_count == 5);
assertTrue (_count == 5);
const EventArgs* pCArgs = &args;
ConstComplex += priorityDelegate(this, &PriorityEventTest::onConstComplex, 0);
ConstComplex -= priorityDelegate(this, &PriorityEventTest::onConstComplex, 3);
ConstComplex.notify(this, pCArgs);
assert (_count == 6);
assertTrue (_count == 6);
Const2Complex += priorityDelegate(this, &PriorityEventTest::onConst2Complex, 0);
Const2Complex -= priorityDelegate(this, &PriorityEventTest::onConst2Complex, 3);
Const2Complex.notify(this, pArgs);
assert (_count == 7);
assertTrue (_count == 7);
// check if 2nd notify also works
Const2Complex.notify(this, pArgs);
assert (_count == 8);
assertTrue (_count == 8);
}
@ -163,22 +163,22 @@ void PriorityEventTest::testDuplicateRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Simple += priorityDelegate(this, &PriorityEventTest::onSimpleOther, 1);
Simple.notify(this, tmp);
assert (_count == 4 + LARGEINC);
assertTrue (_count == 4 + LARGEINC);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimpleOther, 1);
Simple.notify(this, tmp);
assert (_count == 5 + LARGEINC);
assertTrue (_count == 5 + LARGEINC);
}
void PriorityEventTest::testDuplicateUnregister()
@ -186,23 +186,23 @@ void PriorityEventTest::testDuplicateUnregister()
// duplicate unregister shouldn't give an error,
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0); // should work
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
@ -210,22 +210,22 @@ void PriorityEventTest::testDisabling()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.disable();
Simple.notify(this, tmp);
assert (_count == 0);
assertTrue (_count == 0);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
// unregister should also work with disabled event
Simple.disable();
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 0);
Simple.enable();
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
}
void PriorityEventTest::testPriorityOrder()
@ -233,14 +233,14 @@ void PriorityEventTest::testPriorityOrder()
DummyDelegate o1;
DummyDelegate o2;
assert (_count == 0);
assertTrue (_count == 0);
Simple += PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
Simple += PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
Simple -= PriorityDelegate<DummyDelegate, int>(&o1, &DummyDelegate::onSimple, 0);
Simple -= PriorityDelegate<DummyDelegate, int>(&o2, &DummyDelegate::onSimple2, 1);
@ -269,19 +269,19 @@ void PriorityEventTest::testPriorityOrderExpire()
DummyDelegate o1;
DummyDelegate o2;
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 1, 500000);
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 500000);
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// both ways of unregistering should work
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 500000);
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 1);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// now start mixing of expire and non expire
tmp = 0;
@ -289,13 +289,13 @@ void PriorityEventTest::testPriorityOrderExpire()
Simple += priorityDelegate(&o1, &DummyDelegate::onSimple, 0);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
Simple -= priorityDelegate(&o2, &DummyDelegate::onSimple2, 1);
// it is not forbidden to unregister a non expiring event with an expire decorator (it is just stupid ;-))
Simple -= priorityDelegate(&o1, &DummyDelegate::onSimple, 0, 500000);
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
// now try with the wrong order
Simple += priorityDelegate(&o2, &DummyDelegate::onSimple2, 0, 500000);
@ -320,24 +320,24 @@ void PriorityEventTest::testExpire()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(700);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Simple -= priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple, 1, 500);
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple2, 1, 500);
Simple += priorityDelegate(&PriorityEventTest::onStaticSimple3, 1, 500);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Poco::Thread::sleep(700);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
@ -345,22 +345,22 @@ void PriorityEventTest::testExpireReRegister()
{
int tmp = 0;
assert (_count == 0);
assertTrue (_count == 0);
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 500);
Simple.notify(this, tmp);
assert (_count == 1);
assertTrue (_count == 1);
Poco::Thread::sleep(200);
Simple.notify(this, tmp);
assert (_count == 2);
assertTrue (_count == 2);
// renew registration
Simple += priorityDelegate(this, &PriorityEventTest::onSimple, 1, 600);
Poco::Thread::sleep(400);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
Poco::Thread::sleep(300);
Simple.notify(this, tmp);
assert (_count == 3);
assertTrue (_count == 3);
}
@ -371,7 +371,7 @@ void PriorityEventTest::testReturnParams()
int tmp = 0;
Simple.notify(this, tmp);
assert (tmp == 1);
assertTrue (tmp == 1);
}
void PriorityEventTest::testOverwriteDelegate()
@ -382,22 +382,22 @@ void PriorityEventTest::testOverwriteDelegate()
int tmp = 0; // onsimple requires 0 as input
Simple.notify(this, tmp);
assert (tmp == 2);
assertTrue (tmp == 2);
}
void PriorityEventTest::testAsyncNotify()
{
Poco::PriorityEvent<int >* pSimple= new Poco::PriorityEvent<int>();
(*pSimple) += priorityDelegate(this, &PriorityEventTest::onAsync, 0);
assert (_count == 0);
assertTrue (_count == 0);
int tmp = 0;
Poco::ActiveResult<int>retArg = pSimple->notifyAsync(this, tmp);
delete pSimple; // must work even when the event got deleted!
pSimple = NULL;
assert (_count == 0);
assertTrue (_count == 0);
retArg.wait();
assert (retArg.data() == tmp);
assert (_count == LARGEINC);
assertTrue (retArg.data() == tmp);
assertTrue (_count == LARGEINC);
}

View File

@ -60,49 +60,49 @@ PriorityNotificationQueueTest::~PriorityNotificationQueueTest()
void PriorityNotificationQueueTest::testQueueDequeue()
{
PriorityNotificationQueue queue;
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
Notification* pNf = queue.dequeueNotification();
assertNullPtr(pNf);
queue.enqueueNotification(new Notification, 1);
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pNf = queue.dequeueNotification();
assertNotNullPtr(pNf);
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
pNf->release();
queue.enqueueNotification(new QTestNotification("first"), 1);
queue.enqueueNotification(new QTestNotification("fourth"), 4);
queue.enqueueNotification(new QTestNotification("third"), 3);
queue.enqueueNotification(new QTestNotification("second"), 2);
assert (!queue.empty());
assert (queue.size() == 4);
assertTrue (!queue.empty());
assertTrue (queue.size() == 4);
QTestNotification* pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "first");
assertTrue (pTNf->data() == "first");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 3);
assertTrue (!queue.empty());
assertTrue (queue.size() == 3);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "second");
assertTrue (pTNf->data() == "second");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 2);
assertTrue (!queue.empty());
assertTrue (queue.size() == 2);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "third");
assertTrue (pTNf->data() == "third");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pTNf = dynamic_cast<QTestNotification*>(queue.dequeueNotification());
assertNotNullPtr(pTNf);
assert (pTNf->data() == "fourth");
assertTrue (pTNf->data() == "fourth");
pTNf->release();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
pNf = queue.dequeueNotification();
assertNullPtr(pNf);
@ -114,20 +114,20 @@ void PriorityNotificationQueueTest::testWaitDequeue()
PriorityNotificationQueue queue;
queue.enqueueNotification(new QTestNotification("third"), 3);
queue.enqueueNotification(new QTestNotification("fourth"), 4);
assert (!queue.empty());
assert (queue.size() == 2);
assertTrue (!queue.empty());
assertTrue (queue.size() == 2);
QTestNotification* pTNf = dynamic_cast<QTestNotification*>(queue.waitDequeueNotification(10));
assertNotNullPtr(pTNf);
assert (pTNf->data() == "third");
assertTrue (pTNf->data() == "third");
pTNf->release();
assert (!queue.empty());
assert (queue.size() == 1);
assertTrue (!queue.empty());
assertTrue (queue.size() == 1);
pTNf = dynamic_cast<QTestNotification*>(queue.waitDequeueNotification(10));
assertNotNullPtr(pTNf);
assert (pTNf->data() == "fourth");
assertTrue (pTNf->data() == "fourth");
pTNf->release();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
Notification* pNf = queue.waitDequeueNotification(10);
assertNullPtr(pNf);
@ -156,18 +156,18 @@ void PriorityNotificationQueueTest::testThreads()
t1.join();
t2.join();
t3.join();
assert (_handled.size() == NOTIFICATION_COUNT);
assert (_handled.count("thread1") > 0);
assert (_handled.count("thread2") > 0);
assert (_handled.count("thread3") > 0);
assertTrue (_handled.size() == NOTIFICATION_COUNT);
assertTrue (_handled.count("thread1") > 0);
assertTrue (_handled.count("thread2") > 0);
assertTrue (_handled.count("thread3") > 0);
}
void PriorityNotificationQueueTest::testDefaultQueue()
{
PriorityNotificationQueue& queue = PriorityNotificationQueue::defaultQueue();
assert (queue.empty());
assert (queue.size() == 0);
assertTrue (queue.empty());
assertTrue (queue.size() == 0);
}

View File

@ -58,7 +58,7 @@ void ProcessTest::testLaunch()
args.push_back("arg3");
ProcessHandle ph = Process::launch(cmd, args);
int rc = ph.wait();
assert (rc == 3);
assertTrue (rc == 3);
}
@ -86,7 +86,7 @@ void ProcessTest::testLaunchRedirectIn()
ostr << std::string(100, 'x');
ostr.close();
int rc = ph.wait();
assert (rc == 100);
assertTrue (rc == 100);
#endif // !defined(_WIN32_WCE)
}
@ -115,9 +115,9 @@ void ProcessTest::testLaunchRedirectOut()
std::string s;
int c = istr.get();
while (c != -1) { s += (char) c; c = istr.get(); }
assert (s == "Hello, world!");
assertTrue (s == "Hello, world!");
int rc = ph.wait();
assert (rc == 1);
assertTrue (rc == 1);
#endif // !defined(_WIN32_WCE)
}
@ -148,9 +148,9 @@ void ProcessTest::testLaunchEnv()
std::string s;
int c = istr.get();
while (c != -1) { s += (char) c; c = istr.get(); }
assert (s == "test");
assertTrue (s == "test");
int rc = ph.wait();
assert (rc == 0);
assertTrue (rc == 0);
#endif // !defined(_WIN32_WCE)
}
@ -186,12 +186,12 @@ void ProcessTest::testLaunchArgs()
{
if ('\n' == c)
{
assert(argNumber < args.size());
assertTrue (argNumber < args.size());
std::string expectedArg = args[argNumber];
if (expectedArg.npos != expectedArg.find("already quoted")) {
expectedArg = "already quoted \" \\";
}
assert(receivedArg == expectedArg);
assertTrue (receivedArg == expectedArg);
++argNumber;
receivedArg = "";
}
@ -201,9 +201,9 @@ void ProcessTest::testLaunchArgs()
}
c = istr.get();
}
assert(argNumber == args.size());
assertTrue (argNumber == args.size());
int rc = ph.wait();
assert(rc == args.size());
assertTrue (rc == args.size());
#endif // !defined(_WIN32_WCE)
}
@ -229,14 +229,14 @@ void ProcessTest::testIsRunning()
Pipe inPipe;
ProcessHandle ph = Process::launch(cmd, args, &inPipe, 0, 0);
Process::PID id = ph.id();
assert (Process::isRunning(ph));
assert (Process::isRunning(id));
assertTrue (Process::isRunning(ph));
assertTrue (Process::isRunning(id));
PipeOutputStream ostr(inPipe);
ostr << std::string(100, 'x');
ostr.close();
int POCO_UNUSED rc = ph.wait();
assert (!Process::isRunning(ph));
assert (!Process::isRunning(id));
assertTrue (!Process::isRunning(ph));
assertTrue (!Process::isRunning(id));
#endif // !defined(_WIN32_WCE)
}

View File

@ -154,12 +154,12 @@ void RWLockTest::testLock()
t3.join();
t4.join();
t5.join();
assert (counter == 50000);
assert (r1.ok());
assert (r2.ok());
assert (r3.ok());
assert (r4.ok());
assert (r5.ok());
assertTrue (counter == 50000);
assertTrue (r1.ok());
assertTrue (r2.ok());
assertTrue (r3.ok());
assertTrue (r4.ok());
assertTrue (r5.ok());
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
}
@ -189,12 +189,12 @@ void RWLockTest::testTryLock()
t3.join();
t4.join();
t5.join();
assert (counter == 50000);
assert (r1.ok());
assert (r2.ok());
assert (r3.ok());
assert (r4.ok());
assert (r5.ok());
assertTrue (counter == 50000);
assertTrue (r1.ok());
assertTrue (r2.ok());
assertTrue (r3.ok());
assertTrue (r4.ok());
assertTrue (r5.ok());
#endif // defined(ENABLE_LONG_RUNNING_TESTS)
}

View File

@ -50,8 +50,8 @@ void RandomStreamTest::testStream()
var /= n;
int sd = int(std::sqrt((double) var));
assert (110 < avg && avg < 140);
assert (sd < 20);
assertTrue (110 < avg && avg < 140);
assertTrue (sd < 20);
}

View File

@ -37,7 +37,7 @@ void RandomTest::testSequence1()
rnd2.seed(12345);
for (int i = 0; i < 100; ++i)
{
assert (rnd1.next() == rnd2.next());
assertTrue (rnd1.next() == rnd2.next());
}
}
@ -58,7 +58,7 @@ void RandomTest::testSequence2()
break;
}
}
assert (!equals);
assertTrue (!equals);
}
@ -75,7 +75,7 @@ void RandomTest::testDistribution1()
int sum = 0;
for (int k = 0; k < n; ++k) sum += d[k];
assert (sum == n);
assertTrue (sum == n);
}
@ -97,8 +97,8 @@ void RandomTest::testDistribution2()
var /= n;
int sd = int(std::sqrt((double) var));
assert (95 < avg && avg < 105);
assert (sd < 15);
assertTrue (95 < avg && avg < 105);
assertTrue (sd < 15);
}
@ -120,8 +120,8 @@ void RandomTest::testDistribution3()
var /= n;
int sd = int(std::sqrt((double) var));
assert (95 < avg && avg < 105);
assert (sd < 15);
assertTrue (95 < avg && avg < 105);
assertTrue (sd < 15);
}

View File

@ -33,18 +33,18 @@ void RegularExpressionTest::testIndex()
{
RegularExpression re("[0-9]+");
RegularExpression::Match match;
assert (re.match("", 0, match) == 0);
assert (re.match("123", 3, match) == 0);
assertTrue (re.match("", 0, match) == 0);
assertTrue (re.match("123", 3, match) == 0);
}
void RegularExpressionTest::testMatch1()
{
RegularExpression re("[0-9]+");
assert (re.match("123"));
assert (!re.match("123cd"));
assert (!re.match("abcde"));
assert (re.match("ab123", 2));
assertTrue (re.match("123"));
assertTrue (!re.match("123cd"));
assertTrue (!re.match("abcde"));
assertTrue (re.match("ab123", 2));
}
@ -52,21 +52,21 @@ void RegularExpressionTest::testMatch2()
{
RegularExpression re("[0-9]+");
RegularExpression::Match match;
assert (re.match("123", 0, match) == 1);
assert (match.offset == 0);
assert (match.length == 3);
assertTrue (re.match("123", 0, match) == 1);
assertTrue (match.offset == 0);
assertTrue (match.length == 3);
assert (re.match("abc123def", 0, match) == 1);
assert (match.offset == 3);
assert (match.length == 3);
assertTrue (re.match("abc123def", 0, match) == 1);
assertTrue (match.offset == 3);
assertTrue (match.length == 3);
assert (re.match("abcdef", 0, match) == 0);
assert (match.offset == std::string::npos);
assert (match.length == 0);
assertTrue (re.match("abcdef", 0, match) == 0);
assertTrue (match.offset == std::string::npos);
assertTrue (match.length == 0);
assert (re.match("abc123def", 3, match) == 1);
assert (match.offset == 3);
assert (match.length == 3);
assertTrue (re.match("abc123def", 3, match) == 1);
assertTrue (match.offset == 3);
assertTrue (match.length == 3);
}
@ -74,23 +74,23 @@ void RegularExpressionTest::testMatch3()
{
RegularExpression re("[0-9]+");
RegularExpression::MatchVec match;
assert (re.match("123", 0, match) == 1);
assert (match.size() == 1);
assert (match[0].offset == 0);
assert (match[0].length == 3);
assertTrue (re.match("123", 0, match) == 1);
assertTrue (match.size() == 1);
assertTrue (match[0].offset == 0);
assertTrue (match[0].length == 3);
assert (re.match("abc123def", 0, match) == 1);
assert (match.size() == 1);
assert (match[0].offset == 3);
assert (match[0].length == 3);
assertTrue (re.match("abc123def", 0, match) == 1);
assertTrue (match.size() == 1);
assertTrue (match[0].offset == 3);
assertTrue (match[0].length == 3);
assert (re.match("abcdef", 0, match) == 0);
assert (match.size() == 0);
assertTrue (re.match("abcdef", 0, match) == 0);
assertTrue (match.size() == 0);
assert (re.match("abc123def", 3, match) == 1);
assert (match.size() == 1);
assert (match[0].offset == 3);
assert (match[0].length == 3);
assertTrue (re.match("abc123def", 3, match) == 1);
assertTrue (match.size() == 1);
assertTrue (match[0].offset == 3);
assertTrue (match[0].length == 3);
}
@ -98,41 +98,41 @@ void RegularExpressionTest::testMatch4()
{
RegularExpression re("([0-9]+) ([0-9]+)");
RegularExpression::MatchVec matches;
assert (re.match("123 456", 0, matches) == 3);
assert (matches.size() == 3);
assert (matches[0].offset == 0);
assert (matches[0].length == 7);
assert (matches[1].offset == 0);
assert (matches[1].length == 3);
assert (matches[2].offset == 4);
assert (matches[2].length == 3);
assertTrue (re.match("123 456", 0, matches) == 3);
assertTrue (matches.size() == 3);
assertTrue (matches[0].offset == 0);
assertTrue (matches[0].length == 7);
assertTrue (matches[1].offset == 0);
assertTrue (matches[1].length == 3);
assertTrue (matches[2].offset == 4);
assertTrue (matches[2].length == 3);
assert (re.match("abc123 456def", 0, matches) == 3);
assert (matches.size() == 3);
assert (matches[0].offset == 3);
assert (matches[0].length == 7);
assert (matches[1].offset == 3);
assert (matches[1].length == 3);
assert (matches[2].offset == 7);
assert (matches[2].length == 3);
assertTrue (re.match("abc123 456def", 0, matches) == 3);
assertTrue (matches.size() == 3);
assertTrue (matches[0].offset == 3);
assertTrue (matches[0].length == 7);
assertTrue (matches[1].offset == 3);
assertTrue (matches[1].length == 3);
assertTrue (matches[2].offset == 7);
assertTrue (matches[2].length == 3);
}
void RegularExpressionTest::testMatch5()
{
std::string digits = "0123";
assert (RegularExpression::match(digits, "[0-9]+"));
assertTrue (RegularExpression::match(digits, "[0-9]+"));
std::string alphas = "abcd";
assert (!RegularExpression::match(alphas, "[0-9]+"));
assertTrue (!RegularExpression::match(alphas, "[0-9]+"));
}
void RegularExpressionTest::testMatch6()
{
RegularExpression expr("^([a-z]*)?$");
assert (expr.match("", 0, 0));
assert (expr.match("abcde", 0, 0));
assert (!expr.match("123", 0, 0));
assertTrue (expr.match("", 0, 0));
assertTrue (expr.match("abcde", 0, 0));
assertTrue (!expr.match("123", 0, 0));
}
@ -140,17 +140,17 @@ void RegularExpressionTest::testExtract()
{
RegularExpression re("[0-9]+");
std::string str;
assert (re.extract("123", str) == 1);
assert (str == "123");
assertTrue (re.extract("123", str) == 1);
assertTrue (str == "123");
assert (re.extract("abc123def", 0, str) == 1);
assert (str == "123");
assertTrue (re.extract("abc123def", 0, str) == 1);
assertTrue (str == "123");
assert (re.extract("abcdef", 0, str) == 0);
assert (str == "");
assertTrue (re.extract("abcdef", 0, str) == 0);
assertTrue (str == "");
assert (re.extract("abc123def", 3, str) == 1);
assert (str == "123");
assertTrue (re.extract("abc123def", 3, str) == 1);
assertTrue (str == "123");
}
@ -158,20 +158,20 @@ void RegularExpressionTest::testSplit1()
{
RegularExpression re("[0-9]+");
std::vector<std::string> strings;
assert (re.split("123", 0, strings) == 1);
assert (strings.size() == 1);
assert (strings[0] == "123");
assertTrue (re.split("123", 0, strings) == 1);
assertTrue (strings.size() == 1);
assertTrue (strings[0] == "123");
assert (re.split("abc123def", 0, strings) == 1);
assert (strings.size() == 1);
assert (strings[0] == "123");
assertTrue (re.split("abc123def", 0, strings) == 1);
assertTrue (strings.size() == 1);
assertTrue (strings[0] == "123");
assert (re.split("abcdef", 0, strings) == 0);
assert (strings.empty());
assertTrue (re.split("abcdef", 0, strings) == 0);
assertTrue (strings.empty());
assert (re.split("abc123def", 3, strings) == 1);
assert (strings.size() == 1);
assert (strings[0] == "123");
assertTrue (re.split("abc123def", 3, strings) == 1);
assertTrue (strings.size() == 1);
assertTrue (strings[0] == "123");
}
@ -179,17 +179,17 @@ void RegularExpressionTest::testSplit2()
{
RegularExpression re("([0-9]+) ([0-9]+)");
std::vector<std::string> strings;
assert (re.split("123 456", 0, strings) == 3);
assert (strings.size() == 3);
assert (strings[0] == "123 456");
assert (strings[1] == "123");
assert (strings[2] == "456");
assertTrue (re.split("123 456", 0, strings) == 3);
assertTrue (strings.size() == 3);
assertTrue (strings[0] == "123 456");
assertTrue (strings[1] == "123");
assertTrue (strings[2] == "456");
assert (re.split("abc123 456def", 0, strings) == 3);
assert (strings.size() == 3);
assert (strings[0] == "123 456");
assert (strings[1] == "123");
assert (strings[2] == "456");
assertTrue (re.split("abc123 456def", 0, strings) == 3);
assertTrue (strings.size() == 3);
assertTrue (strings[0] == "123 456");
assertTrue (strings[1] == "123");
assertTrue (strings[2] == "456");
}
@ -197,29 +197,29 @@ void RegularExpressionTest::testSubst1()
{
RegularExpression re("[0-9]+");
std::string s = "123";
assert (re.subst(s, "ABC") == 1);
assert (s == "ABC");
assert (re.subst(s, "123") == 0);
assertTrue (re.subst(s, "ABC") == 1);
assertTrue (s == "ABC");
assertTrue (re.subst(s, "123") == 0);
s = "123";
assert (re.subst(s, "AB$0CD") == 1);
assert (s == "AB123CD");
assertTrue (re.subst(s, "AB$0CD") == 1);
assertTrue (s == "AB123CD");
s = "123";
assert (re.subst(s, "AB$1CD") == 1);
assert (s == "ABCD");
assertTrue (re.subst(s, "AB$1CD") == 1);
assertTrue (s == "ABCD");
s = "123";
assert (re.subst(s, "AB$2CD") == 1);
assert (s == "ABCD");
assertTrue (re.subst(s, "AB$2CD") == 1);
assertTrue (s == "ABCD");
s = "123";
assert (re.subst(s, "AB$$CD") == 1);
assert (s == "AB$$CD");
assertTrue (re.subst(s, "AB$$CD") == 1);
assertTrue (s == "AB$$CD");
s = "123";
assert (re.subst(s, "AB$0CD", RegularExpression::RE_NO_VARS) == 1);
assert (s == "AB$0CD");
assertTrue (re.subst(s, "AB$0CD", RegularExpression::RE_NO_VARS) == 1);
assertTrue (s == "AB$0CD");
}
@ -227,8 +227,8 @@ void RegularExpressionTest::testSubst2()
{
RegularExpression re("([0-9]+) ([0-9]+)");
std::string s = "123 456";
assert (re.subst(s, "$2-$1") == 1);
assert (s == "456-123");
assertTrue (re.subst(s, "$2-$1") == 1);
assertTrue (s == "456-123");
}
@ -236,8 +236,8 @@ void RegularExpressionTest::testSubst3()
{
RegularExpression re("[0-9]+");
std::string s = "123 456 789";
assert (re.subst(s, "n", RegularExpression::RE_GLOBAL) == 3);
assert (s == "n n n");
assertTrue (re.subst(s, "n", RegularExpression::RE_GLOBAL) == 3);
assertTrue (s == "n n n");
}
@ -245,8 +245,8 @@ void RegularExpressionTest::testSubst4()
{
RegularExpression re("[0-9]+");
std::string s = "ABC 123 456 789 DEF";
assert (re.subst(s, "n", RegularExpression::RE_GLOBAL) == 3);
assert (s == "ABC n n n DEF");
assertTrue (re.subst(s, "n", RegularExpression::RE_GLOBAL) == 3);
assertTrue (s == "ABC n n n DEF");
}

View File

@ -35,14 +35,14 @@ void SHA1EngineTest::testSHA1()
// test vectors from FIPS 180-1
engine.update("abc");
assert (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
engine.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
assert (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
for (int i = 0; i < 1000000; ++i)
engine.update('a');
assert (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
}

View File

@ -80,7 +80,7 @@ SemaphoreTest::~SemaphoreTest()
void SemaphoreTest::testInitZero()
{
SemaRunnable r(0, 3);
assert (!r.tryWait(10));
assertTrue (!r.tryWait(10));
r.set();
r.wait();
try
@ -97,18 +97,18 @@ void SemaphoreTest::testInitZero()
}
r.set();
r.set();
assert (r.tryWait(0));
assertTrue (r.tryWait(0));
r.wait();
assert (!r.tryWait(10));
assertTrue (!r.tryWait(10));
Thread t;
t.start(r);
Thread::sleep(100);
assert (!r.ran());
assertTrue (!r.ran());
r.set();
t.join();
assert (r.ran());
assert (!r.tryWait(10));
assertTrue (r.ran());
assertTrue (!r.tryWait(10));
}
@ -116,11 +116,11 @@ void SemaphoreTest::testInitNonZero()
{
SemaRunnable r(2, 2);
r.wait();
assert (r.tryWait(10));
assert (!r.tryWait(10));
assertTrue (r.tryWait(10));
assertTrue (!r.tryWait(10));
r.set();
assert (r.tryWait(10));
assert (!r.tryWait(10));
assertTrue (r.tryWait(10));
assertTrue (!r.tryWait(10));
}

View File

@ -39,15 +39,15 @@ void SharedLibraryTest::testSharedLibrary1()
std::string path = "TestLibrary";
path.append(SharedLibrary::suffix());
SharedLibrary sl;
assert (!sl.isLoaded());
assertTrue (!sl.isLoaded());
sl.load(path);
assert (sl.getPath() == path);
assert (sl.isLoaded());
assert (sl.hasSymbol("pocoBuildManifest"));
assert (sl.hasSymbol("pocoInitializeLibrary"));
assert (sl.hasSymbol("pocoUninitializeLibrary"));
assert (sl.hasSymbol("gimmeFive"));
assert (!sl.hasSymbol("fooBar123"));
assertTrue (sl.getPath() == path);
assertTrue (sl.isLoaded());
assertTrue (sl.hasSymbol("pocoBuildManifest"));
assertTrue (sl.hasSymbol("pocoInitializeLibrary"));
assertTrue (sl.hasSymbol("pocoUninitializeLibrary"));
assertTrue (sl.hasSymbol("gimmeFive"));
assertTrue (!sl.hasSymbol("fooBar123"));
void* p1 = sl.getSymbol("pocoBuildManifest");
assertNotNullPtr(p1);
@ -64,7 +64,7 @@ void SharedLibraryTest::testSharedLibrary1()
failmsg("wrong exception");
}
sl.unload();
assert (!sl.isLoaded());
assertTrue (!sl.isLoaded());
}
@ -73,14 +73,14 @@ void SharedLibraryTest::testSharedLibrary2()
std::string path = "TestLibrary";
path.append(SharedLibrary::suffix());
SharedLibrary sl(path);
assert (sl.getPath() == path);
assert (sl.isLoaded());
assertTrue (sl.getPath() == path);
assertTrue (sl.isLoaded());
GimmeFiveFunc gimmeFive = (GimmeFiveFunc) sl.getSymbol("gimmeFive");
assert (gimmeFive() == 5);
assertTrue (gimmeFive() == 5);
sl.unload();
assert (!sl.isLoaded());
assertTrue (!sl.isLoaded());
}
@ -101,12 +101,12 @@ void SharedLibraryTest::testSharedLibrary3()
{
failmsg("wrong exception");
}
assert (!sl.isLoaded());
assertTrue (!sl.isLoaded());
path = "TestLibrary";
path.append(SharedLibrary::suffix());
sl.load(path);
assert (sl.isLoaded());
assertTrue (sl.isLoaded());
try
{
@ -120,10 +120,10 @@ void SharedLibraryTest::testSharedLibrary3()
{
failmsg("wrong exception");
}
assert (sl.isLoaded());
assertTrue (sl.isLoaded());
sl.unload();
assert (!sl.isLoaded());
assertTrue (!sl.isLoaded());
}

View File

@ -32,7 +32,7 @@ SharedMemoryTest::~SharedMemoryTest()
void SharedMemoryTest::testCreate()
{
SharedMemory mem("hi", 4096, SharedMemory::AM_WRITE);
assert (mem.end()- mem.begin() == 4096);
assertTrue (mem.end()- mem.begin() == 4096);
mem.begin()[0] = 'A';
mem.end()[-1] = 'Z';
}
@ -42,12 +42,12 @@ void SharedMemoryTest::testCreateFromFile()
{
Poco::Path p = findDataFile("testdata.txt");
Poco::File f(p);
assert (f.exists() && f.isFile());
assertTrue (f.exists() && f.isFile());
SharedMemory mem(f, SharedMemory::AM_READ);
assert (mem.end() > mem.begin()); // valid?
assert (mem.end() - mem.begin() == f.getSize());
assert (mem.begin()[0] == 'A');
assert (mem.end()[-5] == 'Z');
assertTrue (mem.end() > mem.begin()); // valid?
assertTrue (mem.end() - mem.begin() == f.getSize());
assertTrue (mem.begin()[0] == 'A');
assertTrue (mem.end()[-5] == 'Z');
}

Some files were not shown because too many files have changed in this diff Show More