1 /*
2 	belcard-explanatory-tester.cpp
3 	Copyright (C) 2015  Belledonne Communications SARL
4 
5 	This program is free software: you can redistribute it and/or modify
6 	it under the terms of the GNU General Public License as published by
7 	the Free Software Foundation, either version 3 of the License, or
8 	(at your option) any later version.
9 
10 	This program is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 	GNU General Public License for more details.
14 
15 	You should have received a copy of the GNU General Public License
16 	along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "belcard/belcard.hpp"
20 #include "belcard-tester.hpp"
21 
22 using namespace::std;
23 using namespace::belcard;
24 
categories_property(void)25 static void categories_property(void) {
26 	test_property<BelCardCategories>("CATEGORIES:INTERNET,IETF,INDUSTRY,INFORMATION TECHNOLOGY\r\n");
27 }
28 
note_property(void)29 static void note_property(void) {
30 	test_property<BelCardNote>("NOTE:This fax number is operational 0800 to 1715\\n EST\\, Mon-Fri.\r\n");
31 }
32 
prodid_property(void)33 static void prodid_property(void) {
34 	test_property<BelCardProductId>("PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN\r\n");
35 }
36 
rev_property(void)37 static void rev_property(void) {
38 	test_property<BelCardRevision>("REV:19951031T222710Z\r\n");
39 
40 	shared_ptr<BelCard> card = BelCardGeneric::create<BelCard>();
41 	shared_ptr<BelCardRevision> rev = BelCardGeneric::create<BelCardRevision>();
42 	rev->setValue("AZERTY");
43 	BC_ASSERT_FALSE(BelCardGeneric::isValid(rev));
44 	card->setRevision(rev);
45 	BC_ASSERT_TRUE(card->getRevision() == NULL);
46 
47 	rev->setValue("19951031T222710Z");
48 	BC_ASSERT_TRUE(BelCardGeneric::isValid(rev));
49 	card->setRevision(rev);
50 	BC_ASSERT_TRUE(card->getRevision() != NULL);
51 }
52 
sound_property(void)53 static void sound_property(void) {
54 	test_property<BelCardSound>("SOUND:data:audio/basic;base64,MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0\r\n");
55 }
56 
uid_property(void)57 static void uid_property(void) {
58 	test_property<BelCardUniqueId>("UID:urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6\r\n");
59 }
60 
clientpidmap_property(void)61 static void clientpidmap_property(void) {
62 	test_property<BelCardClientProductIdMap>("CLIENTPIDMAP:1;urn:uuid:3df403f4-5924-4bb7-b077-3c711d9eb34b\r\n");
63 }
64 
url_property(void)65 static void url_property(void) {
66 	test_property<BelCardURL>("URL:http://example.org/restaurant.french/~chezchic.html\r\n");
67 }
68 
69 static test_t tests[] = {
70 	TEST_NO_TAG("CATEGORIES", categories_property),
71 	TEST_NO_TAG("NOTE", note_property),
72 	TEST_NO_TAG("PRODID", prodid_property),
73 	TEST_NO_TAG("REV", rev_property),
74 	TEST_NO_TAG("SOUND", sound_property),
75 	TEST_NO_TAG("UID", uid_property),
76 	TEST_NO_TAG("CLIENTPIDMAP", clientpidmap_property),
77 	TEST_NO_TAG("URL", url_property),
78 };
79 
80 test_suite_t vcard_explanatory_properties_test_suite = {
81 	"Explanatory",
82 	NULL,
83 	NULL,
84 	NULL,
85 	NULL,
86 	sizeof(tests) / sizeof(tests[0]),
87 	tests
88 };
89