/*   vcard_tests
     Author: GimÃ©nez, Christian.

     Copyright (C) 2018 GimÃ©nez, Christian

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     at your option) any later version.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

     13 may 2018
*/


:- module(vcard_tests, [	      
	  ]).
/** <module> vcard_tests: 


*/

:- license(gplv3).

:- use_module('../prolog/vcard').
:- use_module(library(readutil)).

:- begin_tests(vcard, []).

test(vcard) :-
    read_file_to_codes('test1.vcf', Codes, []),
    vcard(A, Codes, []),
    A = vcard(
	    version(`3.0`),
	    contents(
		[
		    content([], `FN`, [], `Name`),
		    content([], `TEL`, [param(`TYPE`, [`cell`])], `0123 456-789`),
		    content([], `IMPP`, [], `xmpp:myxmpp@host.com`),
		    content([], `ADR`,[
				param(`TYPE`, [`home`]),
				param(`LABEL`, [`A label`])],
			    `;;A value;;;;`),
		    content([], `BDAY`, [], `19900102`)
		])).
		  
test(params) :-
    vcard:params([param(`TYPE`, [`work`]), param(`LABEL`, [`My work`])],
	   `;TYPE=work;LABEL="My work"`, []).

test(contentline) :-
    contentline(content([],`FN`, [], `Name`), `FN:Name\r\n`, []).
test(contentline) :-
    contentline(content([],
			`ADR`,
			[param(`TYPE`, [`work`]),
			 param(`LABEL`, [`My work`])],
			`;;geo:-01\\,-02?z=03;;;;`),
		`ADR;TYPE=work;LABEL="My work":;;geo:-01\\,-02?z=03;;;;\r\n`,
		[]).


test(name) :-
    name(`SOURCE`, `SOURCE`, []).
test(name) :-
    name(`KIND`, `KIND`, []).
test(name) :-
    name(`FN`, `FN`, []).
test(name) :-
    name(`N`, `N`, []).
test(name) :-
    name(`NICKNAME`, `NICKNAME`, []).
test(name) :-
    name(`PHOTO`, `PHOTO`, []).
test(name) :-
    name(`BDAY`, `BDAY`, []).
test(name) :-
    name(`ANNIVERSARY`, `ANNIVERSARY`, []).
test(name) :-
    name(`GENDER`, `GENDER`, []).
test(name) :-
    name(`ADR`, `ADR`, []).
test(name) :-
    name(`TEL`, `TEL`, []).
test(name) :-
    name(`EMAIL`, `EMAIL`, []).
test(name) :-
    name(`IMPP`, `IMPP`, []).
test(name) :-
    name(`LANG`, `LANG`, []).
test(name) :-
    name(`TZ`, `TZ`, []).
test(name) :-
    name(`GEO`, `GEO`, []).
test(name) :-
    name(`TITLE`, `TITLE`, []).
test(name) :-
    name(`ROLE`, `ROLE`, []).
test(name) :-
    name(`LOGO`, `LOGO`, []).
test(name) :-
    name(`ORG`, `ORG`, []).
test(name) :-
    name(`MEMBER`, `MEMBER`, []).
test(name) :-
    name(`RELATED`, `RELATED`, []).
test(name) :-
    name(`CATEGORIES`, `CATEGORIES`, []).
test(name) :-
    name(`NOTE`, `NOTE`, []).
test(name) :-
    name(`PRODID`, `PRODID`, []).
test(name) :-
    name(`REV`, `REV`, []).
test(name) :-
    name(`SOUND`, `SOUND`, []).
test(name) :-
    name(`UID`, `UID`, []).
test(name) :-
    name(`CLIENTPIDMAP`, `CLIENTPIDMAP`, []).
test(name) :-
    name(`URL`, `URL`, []).
test(name) :-
    name(`KEY`, `KEY`, []).
test(name) :-
    name(`FBURL`, `FBURL`, []).
test(name) :-
    name(`CALADRURI`, `CALADRURI`, []).
test(name) :-
    name(`CALURI`, `CALURI`, []).
test(name) :-
    name(`XML`, `XML`, []).
test(name) :-
    name(`X-Name`, `X-Name`,[]).

test(param) :-
    param(param(`TYPE`, [`home`]),
	  `TYPE=home`, []).
test(param) :-
    param(param(`LABEL`, [`An address`]),
	  `LABEL="An address"`, []).

test(iana_token) :-
    vcard:iana_token(`test`, `test`, []).
test(iana_token) :-
    vcard:iana_token(`test1`, `test1`, []).
test(iana_token) :-
    vcard:iana_token(`A-test-10`, `A-test-10`,[]).

test(folded_string) :-
    vcard:folded_string(`testing one line`,
			`testing one line\r\n`, []).
test(folded_string) :-
    vcard:folded_string(
	      `test and more test`,
	      `test and\r\n more test\r\n`, []).



%% test(value) :-
%%     vcard:value().


:- end_tests(vcard).




