summaryrefslogtreecommitdiffstats
path: root/src/tests/mxptest.cpp
blob: 1c6db993f1ebe151443389c761071816d676e4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
*   Copyright (C) 2005 by                                                 *
*   Jason Kivlighn (jkivlighn@gmail.com)                                  *
*                                                                         *
*   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 2 of the License, or     *
*   (at your option) any later version.                                   *
***************************************************************************/

#include <tdeaboutdata.h>
#include <tdeapplication.h>
#include <tdecmdlineargs.h>

#include <tqstring.h>

#include <iostream>
using std::cout;
using std::endl;

#include "mxpimporter.h"
#include "importertest.h"

int
main(int argc, char *argv[])
{
	TDEAboutData *about = new TDEAboutData("mxptest", I18N_NOOP("mxptest"), "1.0",
	        nullptr, TDEAboutData::License_GPL, nullptr, nullptr, nullptr, nullptr);
	TDECmdLineArgs::init(argc, argv, about);
	TDEApplication::disableAutoDcopRegistration(); // will reduce noise when we run without X11
	TDEApplication a(/* allowStyles =*/ false, /* GUIenabled =*/ false);

	printf("Creating MXPImporter.\n");
	MXPImporter importer;

	printf("Parsing mxptest.txt.\n");
	TQStringList files; files << "mxptest.txt";
	importer.parseFiles(files);

	Recipe recipe;
	recipe.title = "Cookies Test";
	recipe.yield.amount = 2;
	recipe.yield.type = "servings";
	recipe.categoryList.append( Element("Snacks",1) );
	recipe.categoryList.append( Element("Cookies & Squares",2) );
	recipe.instructions = 
		"Drop by spoonful on greased cookie sheet.  Bake in moderate oven.\n"
		"\n"
		"Nutr. Assoc. : 0 1374 1021 927 0 1638 1358 797 0 0 0 568 0 532 1611";
	recipe.prepTime = TQTime(0,45);

	recipe.authorList.append( Element("Mona Beamer, Colleen Beamer") );

	Ingredient ing;
	ing.name = "granulated sugar";
	ing.amount = 0.75;
	ing.units.name = "c.";
	recipe.ingList.append( ing );

	Ingredient ing2;
	ing2.name = "brown sugar";
	ing2.amount = 1;
	ing2.units.name = "c.";
	recipe.ingList.append( ing2 );

	Ingredient ing3;
	ing3.name = "all-purpose flour";
	ing3.amount = 2;
	ing3.units.plural = "c.";
	recipe.ingList.append( ing3 );

	Ingredient ing4;
	ing4.name = "baking soda";
	ing4.amount = 1;
	ing4.units.name = "tsp.";
	recipe.ingList.append( ing4 );

	Ingredient ing8;
	ing8.name = "shortening";
	ing8.amount = 1;
	ing8.units.name = "c.";
	ing8.prepMethodList.append( Element("softened,at room temperature") );
	recipe.ingList.append( ing8 );

	Ingredient ing6;
	ing6.name = "peanut butter";
	ing6.amount = 1;
	ing6.units.name = "c.";
	recipe.ingList.append( ing6 );

	Ingredient ing5;
	ing5.name = "eggs";
	ing5.amount = 2;
	ing5.units.plural = "";
	recipe.ingList.append( ing5 );

	Ingredient ing7;
	ing7.name = "vanilla extract";
	ing7.amount = 1;
	ing7.units.name = "tsp.";
	recipe.ingList.append( ing7 );
	
	check( importer, recipe );

	printf("Done.\n");
}