diff options
Diffstat (limited to 'Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp')
| -rw-r--r-- | Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp index 0a94a98..35cb1b4 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2016 Isode Limited. | 2 | * Copyright (c) 2010-2018 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -29,7 +29,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { | |||
| 29 | info.setLastName("Tron\xc3\xe7on"); | 29 | info.setLastName("Tron\xc3\xe7on"); |
| 30 | info.setStatus(LinkLocalServiceInfo::Away); | 30 | info.setStatus(LinkLocalServiceInfo::Away); |
| 31 | 31 | ||
| 32 | CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord()); | 32 | auto txtRecord = info.toTXTRecord(); |
| 33 | CPPUNIT_ASSERT(txtRecord); | ||
| 34 | CPPUNIT_ASSERT_EQUAL(createByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), *txtRecord); | ||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | void testCreateFromTXTRecord() { | 37 | void testCreateFromTXTRecord() { |
| @@ -57,7 +59,9 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { | |||
| 57 | info.setStatus(LinkLocalServiceInfo::DND); | 59 | info.setStatus(LinkLocalServiceInfo::DND); |
| 58 | info.setPort(1234); | 60 | info.setPort(1234); |
| 59 | 61 | ||
| 60 | LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(info.toTXTRecord()); | 62 | auto txtRecord = info.toTXTRecord(); |
| 63 | CPPUNIT_ASSERT(txtRecord); | ||
| 64 | LinkLocalServiceInfo info2 = LinkLocalServiceInfo::createFromTXTRecord(*txtRecord); | ||
| 61 | CPPUNIT_ASSERT_EQUAL(info.getFirstName(), info2.getFirstName()); | 65 | CPPUNIT_ASSERT_EQUAL(info.getFirstName(), info2.getFirstName()); |
| 62 | CPPUNIT_ASSERT_EQUAL(info.getLastName(), info2.getLastName()); | 66 | CPPUNIT_ASSERT_EQUAL(info.getLastName(), info2.getLastName()); |
| 63 | CPPUNIT_ASSERT_EQUAL(info.getEMail(), info2.getEMail()); | 67 | CPPUNIT_ASSERT_EQUAL(info.getEMail(), info2.getEMail()); |
| @@ -67,6 +71,13 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { | |||
| 67 | CPPUNIT_ASSERT(info.getStatus() == info2.getStatus()); | 71 | CPPUNIT_ASSERT(info.getStatus() == info2.getStatus()); |
| 68 | CPPUNIT_ASSERT(info.getPort() == info2.getPort()); | 72 | CPPUNIT_ASSERT(info.getPort() == info2.getPort()); |
| 69 | } | 73 | } |
| 74 | |||
| 75 | void testToTXTRecordWithInvalidParameter() { | ||
| 76 | LinkLocalServiceInfo info; | ||
| 77 | info.setFirstName(std::string(256, 'x')); | ||
| 78 | auto txtRecord = info.toTXTRecord(); | ||
| 79 | CPPUNIT_ASSERT(!txtRecord); | ||
| 80 | } | ||
| 70 | }; | 81 | }; |
| 71 | 82 | ||
| 72 | CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalServiceInfoTest); | 83 | CPPUNIT_TEST_SUITE_REGISTRATION(LinkLocalServiceInfoTest); |
Swift