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

     Copyright (C) 2016 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/>.

     04 dic 2016
*/


:- module(imf_tests, [	      
	  ]).
/** <module> imf_tests: Tests for IMF.

@author Gimenez, Christian
@license GPLv3
*/

:- license(gplv3).

:- begin_tests(imf).
:- use_module('../prolog/imf').


test(message) :-
    read_file_to_codes('./mail-simple', Codes, []),
    message(message(header(
			[field(`From`, `from@fromhost.com`),
			 field(`To`, `to@tohost.com`),
			 field(`Subject`,`Subject part`),
			 field(`Date`,`Wed,  9 Dec 2015 17:27:50 -0300 (ART)`)]),
		    body(`Hi world\n`)),
	    Codes, []).

test(header_field) :-
    header_field(`Subject`, `Hola mundo como estÃ¡s?`, `Subject: Hola mundo\n\tcomo estÃ¡s?\n`, []).

test(folded_string) :-
    folded_string(`Hola mundo como estÃ¡s?`, `Hola mundo\n\tcomo\n    estÃ¡s?`, []).

test(imf_parse_file) :-
    imf_parse_file('./mail-simple',
		   message(header(
			       [field("From", "from@fromhost.com"),
				field("To", "to@tohost.com"),
				field("Subject","Subject part"),
				field("Date","Wed,  9 Dec 2015 17:27:50 -0300 (ART)")]),
			   body("Hi world\n"))
		  ).

test(date_time) :-
    imf:date_time(date(2017, 11, 6, 19, 10, 07, 10800, -, -), `Mon, 6 Nov 2017 19:10:07 -0300`, []),
    imf:date_time(date(2015, 12, 9, 17, 27, 50, 10800, -, -) ,`Wed, 09 Dec 2015 17:27:50 -0300`, []).
:- end_tests(imf).
