diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/charset/main.cpp | 4 | ||||
-rw-r--r-- | tests/encoding/main.cpp | 6 | ||||
-rw-r--r-- | tests/mailbox/main.cpp | 18 | ||||
-rw-r--r-- | tests/parser/headerTest.cpp | 127 |
4 files changed, 29 insertions, 126 deletions
diff --git a/tests/charset/main.cpp b/tests/charset/main.cpp index 5bf3a647..b7a91495 100644 --- a/tests/charset/main.cpp +++ b/tests/charset/main.cpp @@ -33,8 +33,8 @@ int main(int argc, char* argv[]) const vmime::string from(argv[1]); const vmime::string to(argv[2]); - vmime::inputStreamAdapter in(std::cin); - vmime::outputStreamAdapter out(std::cout); + vmime::utility::inputStreamAdapter in(std::cin); + vmime::utility::outputStreamAdapter out(std::cout); vmime::charset::convert(in, out, from, to); } diff --git a/tests/encoding/main.cpp b/tests/encoding/main.cpp index 78664f8a..597ef248 100644 --- a/tests/encoding/main.cpp +++ b/tests/encoding/main.cpp @@ -35,10 +35,10 @@ int main(int argc, char* argv[]) vmime::encoder* p = vmime::encoderFactory::getInstance()->create(encoding); - p->properties()["maxlinelength"] = 76; + p->getProperties()["maxlinelength"] = 76; - vmime::inputStreamAdapter in(std::cin); - vmime::outputStreamAdapter out(std::cout); + vmime::utility::inputStreamAdapter in(std::cin); + vmime::utility::outputStreamAdapter out(std::cout); if (mode == "e") p->encode(in, out); diff --git a/tests/mailbox/main.cpp b/tests/mailbox/main.cpp index 9f1de6ac..cd59d900 100644 --- a/tests/mailbox/main.cpp +++ b/tests/mailbox/main.cpp @@ -32,14 +32,14 @@ std::ostream& operator<<(std::ostream& os, const vmime::text& txt) { os << "["; - for (int i = 0 ; i < txt.size() ; ++i) + for (int i = 0 ; i < txt.getWordCount() ; ++i) { - const vmime::word& w = txt[i]; + const vmime::word& w = *txt.getWordAt(i); if (i != 0) os << ","; - os << "[" << w.charset().name() << "," << w.buffer() << "]"; + os << "[" << w.getCharset().getName() << "," << w.getBuffer() << "]"; } os << "]"; @@ -50,7 +50,7 @@ std::ostream& operator<<(std::ostream& os, const vmime::text& txt) std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) { - std::cout << "MAILBOX[name=" << mbox.name() << ",email=" << mbox.email() << "]" << std::endl; + std::cout << "MAILBOX[name=" << mbox.getName() << ",email=" << mbox.getEmail() << "]" << std::endl; return (os); } @@ -58,11 +58,11 @@ std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group) { - std::cout << "GROUP[name=" << group.name() << "]" << std::endl; + std::cout << "GROUP[name=" << group.getName() << "]" << std::endl; - for (int i = 0 ; i < group.size() ; ++i) + for (int i = 0 ; i < group.getMailboxCount() ; ++i) { - std::cout << "* " << group[i]; + std::cout << "* " << *group.getMailboxAt(i); } return (os); @@ -97,9 +97,9 @@ int main(int argc, char* argv[]) vmime::addressList list; list.parse(data.str()); - for (int i = 0 ; i < list.size() ; ++i) + for (int i = 0 ; i < list.getAddressCount() ; ++i) { - const vmime::address& addr = list[i]; + const vmime::address& addr = *list.getAddressAt(i); if (addr.isGroup()) { diff --git a/tests/parser/headerTest.cpp b/tests/parser/headerTest.cpp index 90905c3e..13a8f03e 100644 --- a/tests/parser/headerTest.cpp +++ b/tests/parser/headerTest.cpp @@ -21,125 +21,40 @@ namespace return (oss.str()); } - // has function tests - void testHas1(/*By type*/) - { - vmime::header hdr; - hdr.parse("From: x\r\nTo: y\r\nSubject: test\r\n"); - - bool res = hdr.fields.has(vmime::headerField::To); - - assert_eq("Value", true, res); - } - - void testHas2(/*By type*/) - { - vmime::header hdr; - hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n"); - - bool res = hdr.fields.has(vmime::headerField::Subject); - - assert_eq("Value", false, res); - } - - void testHas3(/*By name*/) - { - vmime::header hdr; - hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n"); - - bool res = hdr.fields.has("Z"); - - assert_eq("Value", false, res); - } - - void testHas4(/*By name*/) - { - vmime::header hdr; - hdr.parse("X: x\r\nTo: y\r\nTo: z\r\n"); - - bool res = hdr.fields.has("To"); - - assert_eq("Value", true, res); - } - - // find function tests - void testFind1(/*By type*/) - { - vmime::header hdr; - hdr.parse("From: a\r\nTo: b\r\nTo: c\r\nFrom: d\r\n"); - - vmime::headerField& res = hdr.fields.find(vmime::headerField::To); - - assert_eq("Value", "To: b", getFieldValue(res)); - } - - void testFind2(/*By name*/) - { - vmime::header hdr; - hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n"); - - vmime::headerField& res = hdr.fields.find("B"); - - assert_eq("Value", "B: b", getFieldValue(res)); - } - - // findAllByType function tests - void testFindAllByType1() - { - vmime::header hdr; - hdr.parse("To: a\r\nFrom: b\r\n"); - - std::vector <vmime::headerField*> res = hdr.fields.findAllByType(vmime::headerField::Subject); - - assert_eq("Count", (unsigned int) 0, res.size()); - } - - void testFindAllByType2() - { - vmime::header hdr; - hdr.parse("To: b\r\nTo : a\r\nFrom: c\r\n"); - - std::vector <vmime::headerField*> res = hdr.fields.findAllByType(vmime::headerField::To); - - assert_eq("Count", (unsigned int) 2, res.size()); - assert_eq("First value", "To: b", getFieldValue(*res[0])); - assert_eq("First value", "To: a", getFieldValue(*res[1])); - } - - // findAllByName function tests - void testFindAllByName1() + // getAllByName function tests + void testFindAllFields1() { vmime::header hdr; hdr.parse("A: a1\nC: c1\n"); - std::vector <vmime::headerField*> res = hdr.fields.findAllByName("B"); + std::vector <vmime::headerField*> res = hdr.findAllFields("B"); assert_eq("Count", (unsigned int) 0, res.size()); } - void testFindAllByName2() + void testFindAllFields2() { vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n"); - std::vector <vmime::headerField*> res = hdr.fields.findAllByName("B"); + std::vector <vmime::headerField*> res = hdr.findAllFields("B"); assert_eq("Count", (unsigned int) 2, res.size()); - assert_eq("First value", "B: b1", getFieldValue(*res[0])); - assert_eq("Second value", "B: b2", getFieldValue(*res[1])); + assert_eq("First value", "B: b1", headerTest::getFieldValue(*res[0])); + assert_eq("Second value", "B: b2", headerTest::getFieldValue(*res[1])); } - void testFindAllByName3() + void testFindAllFields3() { vmime::header hdr; hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n"); - std::vector <vmime::headerField*> res = hdr.fields.findAllByName("C"); + std::vector <vmime::headerField*> res = hdr.findAllFields("C"); assert_eq("Count", (unsigned int) 3, res.size()); - assert_eq("First value", "C: c1", getFieldValue(*res[0])); - assert_eq("Second value", "C: c3", getFieldValue(*res[1])); - assert_eq("Second value", "C: c2", getFieldValue(*res[2])); + assert_eq("First value", "C: c1", headerTest::getFieldValue(*res[0])); + assert_eq("Second value", "C: c3", headerTest::getFieldValue(*res[1])); + assert_eq("Second value", "C: c2", headerTest::getFieldValue(*res[2])); } public: @@ -149,21 +64,9 @@ namespace // VMime initialization vmime::platformDependant::setHandler<my_handler>(); - add("Has", testcase(this, "Has1", &headerTest::testHas1)); - add("Has", testcase(this, "Has2", &headerTest::testHas2)); - add("Has", testcase(this, "Has3", &headerTest::testHas3)); - add("Has", testcase(this, "Has4", &headerTest::testHas4)); - - add("Find", testcase(this, "Find1", &headerTest::testFind1)); - add("Find", testcase(this, "Find2", &headerTest::testFind2)); - - add("FindAllByType", testcase(this, "FindAllByType1", &headerTest::testFindAllByType1)); - add("FindAllByType", testcase(this, "FindAllByType2", &headerTest::testFindAllByType2)); - - add("FindAllByName", testcase(this, "FindAllByName1", &headerTest::testFindAllByName1)); - add("FindAllByName", testcase(this, "FindAllByName2", &headerTest::testFindAllByName2)); - add("FindAllByName", testcase(this, "FindAllByName3", &headerTest::testFindAllByName3)); - + add("FindAllFields", testcase(this, "FindAllFields1", &headerTest::testFindAllFields1)); + add("FindAllFields", testcase(this, "FindAllFields2", &headerTest::testFindAllFields2)); + add("FindAllFields", testcase(this, "FindAllFields3", &headerTest::testFindAllFields3)); suite::main().add("vmime::header", this); } |