From 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 13 Oct 2024 11:56:14 +0900 Subject: Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder Signed-off-by: Michele Calgaro --- src/tests/Makefile.am | 19 +++ src/tests/checks.h | 181 ++++++++++++++++++++ src/tests/exportertest.h | 42 +++++ src/tests/importertest.h | 45 +++++ src/tests/kretest.cpp | 191 +++++++++++++++++++++ src/tests/kretest.txt | 409 +++++++++++++++++++++++++++++++++++++++++++++ src/tests/mmftest.cpp | 139 +++++++++++++++ src/tests/mmftest.txt | 49 ++++++ src/tests/mx2test.cpp | 72 ++++++++ src/tests/mx2test.txt | 0 src/tests/mxptest.cpp | 72 ++++++++ src/tests/mxptest.txt | 25 +++ src/tests/nyctest.cpp | 100 +++++++++++ src/tests/nyctest.txt | 57 +++++++ src/tests/recipemltest.cpp | 158 +++++++++++++++++ src/tests/recipemltest.txt | 249 +++++++++++++++++++++++++++ src/tests/rezkonvtest.cpp | 155 +++++++++++++++++ src/tests/rezkonvtest.txt | 55 ++++++ src/tests/test_photo.jpg | Bin 0 -> 3369 bytes 19 files changed, 2018 insertions(+) create mode 100644 src/tests/Makefile.am create mode 100644 src/tests/checks.h create mode 100644 src/tests/exportertest.h create mode 100644 src/tests/importertest.h create mode 100644 src/tests/kretest.cpp create mode 100644 src/tests/kretest.txt create mode 100644 src/tests/mmftest.cpp create mode 100644 src/tests/mmftest.txt create mode 100644 src/tests/mx2test.cpp create mode 100644 src/tests/mx2test.txt create mode 100644 src/tests/mxptest.cpp create mode 100644 src/tests/mxptest.txt create mode 100644 src/tests/nyctest.cpp create mode 100644 src/tests/nyctest.txt create mode 100644 src/tests/recipemltest.cpp create mode 100644 src/tests/recipemltest.txt create mode 100644 src/tests/rezkonvtest.cpp create mode 100644 src/tests/rezkonvtest.txt create mode 100644 src/tests/test_photo.jpg (limited to 'src/tests') diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am new file mode 100644 index 0000000..2a5e97b --- /dev/null +++ b/src/tests/Makefile.am @@ -0,0 +1,19 @@ +INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../importers -I$(srcdir)/../exporters $(all_includes) + +AM_LDFLAGS = $(KDE_RPATH) $(all_libraries) + +check_PROGRAMS = kretest mmftest mx2test mxptest rezkonvtest nyctest recipemltest + +noinst_HEADERS = importertest.h exportertest.h + +METASOURCES = AUTO + +LDADD = ../importers/libkrecipesimporters.la ../exporters/libkrecipesexporters.la ../backends/libkrecipesdbs.la ../datablocks/libdatablocks.la $(LIB_TQT) $(LIB_TDEHTML) $(LIB_TDESPELL) + +kretest_SOURCES = kretest.cpp +mmftest_SOURCES = mmftest.cpp +mx2test_SOURCES = mx2test.cpp +mxptest_SOURCES = mxptest.cpp +rezkonvtest_SOURCES = rezkonvtest.cpp +nyctest_SOURCES = nyctest.cpp +recipemltest_SOURCES = recipemltest.cpp diff --git a/src/tests/checks.h b/src/tests/checks.h new file mode 100644 index 0000000..e697814 --- /dev/null +++ b/src/tests/checks.h @@ -0,0 +1,181 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ + +#ifndef CHECKS_H +#define CHECKS_H + +#include +#include + +#include +#include +#include + +#include "datablocks/categorytree.h" +#include "datablocks/rating.h" + +using std::cout; +using std::cerr; +using std::endl; + +void check( const RatingList &rating, const RatingList &base ); + +bool check(const TQString &txt, const TQString &a, const TQString &b) +{ + if ( a != b ) { + cout << "ERROR: Tested " << txt.latin1() << ", expected" << endl; + cout << "'" << b.latin1() << "' (" << b.length() << " chars)" << endl; + cout << "but got" << endl; + cout << "'" << a.latin1() << "' (" << a.length() << " chars)" << endl; + exit( 1 ); + } + + return true; +} + +bool check(const TQString &txt, int a, int b) +{ + if ( a != b ) { + cout << "ERROR: Tested " << txt.latin1() << ", expected" << endl; + cout << "'" << b << "'" << endl; + cout << "but got" << endl; + cout << "'" << a << "'" << endl; + exit( 1 ); + } + + return true; +} + +bool check(const TQString &txt, double a, double b) +{ + if ( fabs(a - b) > 1e-10 ) { + cout << "ERROR: Tested " << txt.latin1() << ", expected" << endl; + cout << "'" << b << "'" << endl; + cout << "but got" << endl; + cout << "'" << a << "'" << endl; + exit( 1 ); + } + + return true; +} + +bool check(const TQString &txt, const TQPixmap &a, const TQPixmap &b) +{ + if ( a.size() != b.size() ) { + + cout << "ERROR: Tested " << txt.latin1() << ": photos differ" << endl; + // exit( 1 ); + } + + return true; +} + +void check( const IngredientData &ing, const IngredientData &base_ing, int ing_num ) +{ + check( TQString::number(ing_num)+": Ingredient name", ing.name, base_ing.name ); + check( TQString::number(ing_num)+": Ingredient amount", ing.amount,base_ing.amount ); + check( TQString::number(ing_num)+": Ingredient amount_offset", ing.amount_offset,base_ing.amount_offset ); + check( TQString::number(ing_num)+": Ingredient singular unit", ing.units.name, base_ing.units.name ); + check( TQString::number(ing_num)+": Ingredient plural unit", ing.units.plural, base_ing.units.plural ); + check( TQString::number(ing_num)+": Ingredient group", ing.group, base_ing.group ); + + ElementList::const_iterator prep_it = ing.prepMethodList.begin(); + ElementList::const_iterator base_prep_it = base_ing.prepMethodList.begin(); + for ( ; prep_it != ing.prepMethodList.end(); ++prep_it, ++base_prep_it ) { + check( TQString::number(ing_num)+": Ingredient prep_method", (*prep_it).name, (*base_prep_it).name ); + } +} + +void check( const Recipe &recipe, const Recipe &base ) +{ + check( "Recipe title", recipe.title, base.title ); + check( "Yield base", recipe.yield.amount, base.yield.amount ); + check( "Yield offset", recipe.yield.amount_offset, base.yield.amount_offset ); + check( "Yield type", recipe.yield.type, base.yield.type ); + check( "Instructions", recipe.instructions, base.instructions ); + check( "Photo", recipe.photo, base.photo ); + + check( recipe.ratingList, base.ratingList ); + + int cat_num = 1; + ElementList::const_iterator cat_it = recipe.categoryList.begin(); + ElementList::const_iterator base_cat_it = base.categoryList.begin(); + for ( ; cat_it != recipe.categoryList.end() || base_cat_it != base.categoryList.end(); ++cat_it, ++base_cat_it ) { + check( TQString::number(cat_num)+": Category", (*cat_it).name, (*base_cat_it).name ); + ++cat_num; + } + check( "category count", cat_num-1, base.categoryList.count() ); + + int author_num = 1; + ElementList::const_iterator author_it = recipe.authorList.begin(); + ElementList::const_iterator base_author_it = base.authorList.begin(); + for ( ; author_it != recipe.authorList.end() || base_author_it != base.authorList.end(); ++author_it, ++base_author_it ) { + check( TQString::number(author_num)+": Author", (*author_it).name, (*base_author_it).name ); + ++author_num; + } + check( "author count", author_num-1, base.authorList.count() ); + + int ing_num = 1; + IngredientList::const_iterator ing_it = recipe.ingList.begin(); + IngredientList::const_iterator base_ing_it = base.ingList.begin(); + for ( ; ing_it != recipe.ingList.end() || base_ing_it != base.ingList.end(); ++ing_it, ++base_ing_it ) { + check( *ing_it, *base_ing_it, ing_num ); + + TQValueList::const_iterator base_sub_it = (*base_ing_it).substitutes.begin(); + for ( TQValueList::const_iterator sub_it = (*ing_it).substitutes.begin(); sub_it != (*ing_it).substitutes.end(); ++sub_it, ++base_sub_it ) { + check( *sub_it, *base_sub_it, ing_num+1000 ); + } + + ++ing_num; + } + check( "ingredient count", ing_num-1, base.ingList.count() ); +} + +bool check( const CategoryTree *catStructure, const CategoryTree *baseCatStructure ) +{ + CategoryTree * it = catStructure->firstChild(); + CategoryTree * base_it = baseCatStructure->firstChild(); + for ( ; it && base_it; it = it->nextSibling(), base_it = base_it->nextSibling() ) { + check( it, base_it ); + + if ( it->category.name != base_it->category.name ) { + printf("FAILED: Category structure differs\n"); + exit(1); + } + } + + if ( base_it != it ) { //these should both be NULL + printf("FAILED: Category structure differs\n"); + exit(1); + } + + return true; +} + +void check( const RatingList &rating, const RatingList &base ) +{ + RatingList::const_iterator rating_it = rating.begin(); + RatingList::const_iterator base_rating_it = base.begin(); + for ( ; rating_it != rating.end() || base_rating_it != base.end(); ++rating_it, ++base_rating_it ) { + check("checking rater",(*rating_it).rater,(*base_rating_it).rater); + check("checking comment",(*rating_it).comment,(*base_rating_it).comment); + + RatingCriteriaList::const_iterator rc_it = (*rating_it).ratingCriteriaList.begin(); + RatingCriteriaList::const_iterator base_rc_it = (*base_rating_it).ratingCriteriaList.begin(); + for ( ; rc_it != (*rating_it).ratingCriteriaList.end() || base_rc_it != (*base_rating_it).ratingCriteriaList.end(); ++rc_it, ++base_rc_it ) { + check("checking criteria name",(*rc_it).name,(*base_rc_it).name); + check("checking stars",(*rc_it).stars,(*base_rc_it).stars); + } + check( "criteria count", int((*rating_it).ratingCriteriaList.count()), int((*base_rating_it).ratingCriteriaList.count()) ); + } + check( "rating count", int(rating.count()), int(base.count()) ); +} + +#endif diff --git a/src/tests/exportertest.h b/src/tests/exportertest.h new file mode 100644 index 0000000..739a57c --- /dev/null +++ b/src/tests/exportertest.h @@ -0,0 +1,42 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ + +#ifndef EXPORTERTEST_H +#define EXPORTERTEST_H + +#include +#include + +#include +#include +#include + +#include "checks.h" + +using std::cout; +using std::cerr; +using std::endl; + +void check( BaseExporter &exporter, const RecipeList &recipeList ) +{ + TQFile file("test.txt"); + if ( file.open( IO_WriteOnly ) ) { + TQTextStream stream(&file); + exporter.writeStream(stream,recipeList); + } + else { + printf("Unable to open file for writing\n"); + exit(1); + } + + file.close(); +} + +#endif diff --git a/src/tests/importertest.h b/src/tests/importertest.h new file mode 100644 index 0000000..f5aff84 --- /dev/null +++ b/src/tests/importertest.h @@ -0,0 +1,45 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ + +#ifndef IMPORTERTEST_H +#define IMPORTERTEST_H + +#include +#include + +#include + +#include "checks.h" +#include "datablocks/categorytree.h" + +using std::cout; +using std::endl; + +void check( const BaseImporter &importer, const Recipe &recipe ) +{ + int recipe_num = 1; + RecipeList recipeList = importer.recipeList(); + for ( RecipeList::const_iterator it = recipeList.begin(); it != recipeList.end(); ++it ) { + printf("Recipe %d... ",recipe_num); + check( *it, recipe ); + printf("successful\n"); + ++recipe_num; + } + + check( "recipe count", recipe_num-1, 2 ); +} + +void check( const BaseImporter &importer, const CategoryTree *baseCatStructure ) +{ + printf("Checking category structure.\n"); + check( importer.categoryStructure(), baseCatStructure ); +} + +#endif diff --git a/src/tests/kretest.cpp b/src/tests/kretest.cpp new file mode 100644 index 0000000..10c88c2 --- /dev/null +++ b/src/tests/kretest.cpp @@ -0,0 +1,191 @@ +/*************************************************************************** +* 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 + +#include +#include + +#include + +#include "kreimporter.h" +#include "kreexporter.h" +#include "importertest.h" +#include "exportertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "kretest"); + + printf("Creating KreImporter.\n"); + KreImporter importer; + + printf("Parsing kretest.txt.\n"); + TQStringList files; files << "kretest.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Cookies_Test"; + recipe.yield.amount = 2; + recipe.yield.amount_offset = 1; + recipe.yield.type = "dozen"; + 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."; + recipe.prepTime = TQTime(0,30); + if ( !recipe.photo.load( "test_photo.jpg", "JPEG" ) ) { + printf("Unable to load test_photo.jpg\n"); + exit(1); + } + + recipe.authorList.append( Element("Colleen Beamer") ); + recipe.authorList.append( Element("Mona Beamer") ); + + Ingredient ing; + ing.name = "granulated sugar"; + ing.amount = 0.75; + ing.amount_offset = 0.25; + ing.units.name = "c."; + ing.groupID = 0; ing.group = "Dry Ingredients"; + recipe.ingList.append( ing ); + + Ingredient ing2; + ing2.name = "brown sugar"; + ing2.amount = 1; + ing2.amount_offset = 0; + ing2.units.name = "c."; + ing2.groupID = 0; ing2.group = "Dry Ingredients"; + recipe.ingList.append( ing2 ); + + Ingredient ing3; + ing3.name = "all-purpose flour"; + ing3.amount = 2; + ing3.units.plural = "c."; + ing3.groupID = 0; ing3.group = "Dry Ingredients"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "baking soda"; + ing4.amount = 1; + ing4.amount_offset = 0; + ing4.units.name = "tsp."; + ing4.groupID = 0; ing4.group = "Dry Ingredients"; + recipe.ingList.append( ing4 ); + + Ingredient ing8; + ing8.name = "shortening"; + ing8.amount = 1; + ing8.amount_offset = 0; + ing8.units.name = "c."; + ing8.prepMethodList.append( Element("softened") ); + ing8.prepMethodList.append( Element("at room temperature") ); + ing8.groupID = 1; ing8.group = "Fat & Liquids"; + recipe.ingList.append( ing8 ); + + Ingredient ing6; + ing6.name = "peanut butter"; + ing6.amount = 1; + ing6.amount_offset = 0; + ing6.units.name = "c."; + ing6.groupID = 1; ing6.group = "Fat & Liquids"; + recipe.ingList.append( ing6 ); + + Ingredient ing5; + ing5.name = "eggs"; + ing5.amount = 2; + ing5.amount_offset = 0; + ing5.units.plural = ""; + ing5.groupID = 1; ing5.group = "Fat & Liquids"; + recipe.ingList.append( ing5 ); + + Ingredient ing7; + ing7.name = "vanilla extract"; + ing7.amount = 1; + ing7.amount_offset = 0; + ing7.units.name = "tsp."; + ing7.groupID = 1; ing7.group = "Fat & Liquids"; + recipe.ingList.append( ing7 ); + + Ingredient ing9; + ing9.name = "a"; + ing9.amount = 1; + ing9.amount_offset = 0; + ing9.units.name = "cup"; + IngredientData ing9_1; + ing9_1.name = "b"; + ing9_1.amount = 2; + ing9_1.amount_offset = 0; + ing9_1.units.plural = "cups"; + IngredientData ing9_2; + ing9_2.name = "c"; + ing9_2.amount = 3; + ing9_2.amount_offset = 0; + ing9_2.units.plural = "cups"; + ing9.substitutes.append(ing9_1); + ing9.substitutes.append(ing9_2); + recipe.ingList.append( ing9 ); + + CategoryTree *catTree = new CategoryTree; + (void)catTree->add( Element("Cookies & Squares",2) ); + (void)catTree->add( Element("Snacks",1) ); + + RatingCriteria rc; + Rating rating1; + rating1.rater = "George McFry"; + rating1.comment = "Good enough"; + + rc.name = "Taste"; + rc.stars = 5.0; + rating1.append(rc); + + Rating rating2; + rating2.rater = "Me"; + rating2.comment = "Yuck, don't eat!"; + + rc.name = "Overall"; + rc.stars = 2.0; + rating2.append(rc); + + rc.name = "Taste"; + rc.stars = 1.5; + rating2.append(rc); + + recipe.ratingList.append(rating1); + recipe.ratingList.append(rating2); + + + check( importer, recipe ); + check( importer, catTree ); + + + RecipeList recipeList; + recipeList.append(recipe); + recipeList.append(recipe); + + printf("Creating KreExporter.\n"); + KreExporter exporter(catTree,"not needed",".kreml"); + check( exporter, recipeList ); + printf("Successfully exported recipes to test.txt.\n"); + + printf("Creating KreImporter to test exported recipes.\n"); + KreImporter importer2; + + printf("Parsing test.txt.\n"); + TQStringList files2; files2 << "test.txt"; + importer2.parseFiles(files2); + TQFile::remove("test.txt"); + check( importer2, recipe ); + check( importer2, catTree ); + printf("Recipe export successful.\n"); + + printf("*** Krecipes importer and exporter passed the tests :-) ***\n"); +} diff --git a/src/tests/kretest.txt b/src/tests/kretest.txt new file mode 100644 index 0000000..35b4ae6 --- /dev/null +++ b/src/tests/kretest.txt @@ -0,0 +1,409 @@ + + + + + + + + + + +Cookies_Test +Colleen Beamer +Mona Beamer + + + + +Snacks +Cookies & Squares + +23dozen +00:30 + + + + +granulated sugar +0.751 +c. + + +brown sugar +1 +c. + + +all-purpose flour +2 +c. + + +baking soda +1 +tsp. + + + + +shortening +1 +c. +softened,at room temperature + + +peanut butter +1 +c. + + +eggs +2 + + + +vanilla extract +1 +tsp. + + + + a + 1 + cup + + + b + 2 + cups + + + c + 3 + cups + + + + + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. + + + George McFry + Good enough + + + Taste + 5 + + + + + Me + Yuck, don't eat! + + + Overall + 2 + + + Taste + 1.5 + + + + + + + +Cookies_Test +Colleen Beamer +Mona Beamer + + + + +Snacks +Cookies & Squares + +23dozen +00:30 + + + + +granulated sugar +0.751 +c. + + +brown sugar +1 +c. + + +all-purpose flour +2 +c. + + +baking soda +1 +tsp. + + + + +shortening +1 +c. +softened,at room temperature + + +peanut butter +1 +c. + + +eggs +2 + + + +vanilla extract +1 +tsp. + + + + a + 1 + cup + + + b + 2 + cups + + + c + 3 + cups + + + + + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. + + + George McFry + Good enough + + + Taste + 5 + + + + + Me + Yuck, don't eat! + + + Overall + 2 + + + Taste + 1.5 + + + + + + diff --git a/src/tests/mmftest.cpp b/src/tests/mmftest.cpp new file mode 100644 index 0000000..453fcaa --- /dev/null +++ b/src/tests/mmftest.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "mmfimporter.h" +#include "mmfexporter.h" +#include "importertest.h" +#include "exportertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "mmftest"); + + printf("Creating MMFImporter.\n"); + MMFImporter importer; + + printf("Parsing mmftest.txt.\n"); + TQStringList files; files << "mmftest.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."; + recipe.prepTime = TQTime(0,30); + + Ingredient ing9; + ing9.name = "a"; + ing9.amount = 1; + ing9.amount_offset = 0; + ing9.units.name = "cup"; + IngredientData ing9_1; + ing9_1.name = "b"; + ing9_1.amount = 2; + ing9_1.amount_offset = 0; + ing9_1.units.plural = "cups"; + IngredientData ing9_2; + ing9_2.name = "c"; + ing9_2.amount = 3; + ing9_2.amount_offset = 0; + ing9_2.units.plural = "cups"; + ing9.substitutes.append(ing9_1); + ing9.substitutes.append(ing9_2); + recipe.ingList.append( ing9 ); + + Ingredient ing2; + ing2.name = "c. granulated sugar"; + ing2.amount = 0.75; + ing2.groupID = 0; ing2.group = "Dry Ingredients"; + recipe.ingList.append( ing2 ); + + Ingredient ing; + ing.name = "c. brown sugar"; + ing.amount = 1; + ing.amount_offset = 0; + ing.groupID = 0; ing.group = "Dry Ingredients"; + recipe.ingList.append( ing ); + + Ingredient ing3; + ing3.name = "c. all-purpose flour"; + ing3.amount = 2; + ing3.groupID = 0; ing3.group = "Dry Ingredients"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "tsp. baking soda"; + ing4.amount = 1; + ing4.groupID = 0; ing4.group = "Dry Ingredients"; + recipe.ingList.append( ing4 ); + + Ingredient ing8; + ing8.name = "c. shortening"; + ing8.amount = 1; + ing8.prepMethodList.append( Element("softened") ); + ing8.prepMethodList.append( Element("at room temperature") ); + ing8.groupID = 1; ing8.group = "Fat & Liquids"; + recipe.ingList.append( ing8 ); + + Ingredient ing6; + ing6.name = "c. peanut butter"; + ing6.amount = 1; + ing6.groupID = 1; ing6.group = "Fat & Liquids"; + recipe.ingList.append( ing6 ); + + Ingredient ing5; + ing5.name = "eggs"; + ing5.amount = 2; + ing5.groupID = 1; ing5.group = "Fat & Liquids"; + recipe.ingList.append( ing5 ); + + Ingredient ing7; + ing7.name = "tsp. vanilla extract"; + ing7.amount = 1; + ing7.groupID = 1; ing7.group = "Fat & Liquids"; + recipe.ingList.append( ing7 ); + + + check( importer, recipe ); + + RecipeList recipeList; + recipeList.append(recipe); + recipeList.append(recipe); + + printf("Creating MMFExporter.\n"); + MMFExporter exporter("not needed",".mmf"); + check( exporter, recipeList ); + printf("Successfully exported recipes to test.txt.\n"); + + printf("Creating MMFImporter to test exported recipes.\n"); + MMFImporter importer2; + + printf("Parsing test.txt.\n"); + TQStringList files2; files2 << "test.txt"; + importer2.parseFiles(files2); + TQFile::remove("test.txt"); + check( importer2, recipe ); + printf("Recipe export successful.\n"); + + printf("*** MM format importer and exporter passed the tests :-) ***\n"); +} diff --git a/src/tests/mmftest.txt b/src/tests/mmftest.txt new file mode 100644 index 0000000..9d13af3 --- /dev/null +++ b/src/tests/mmftest.txt @@ -0,0 +1,49 @@ +----- Exported by Krecipes vSVN_PRE-0.9 [Meal-Master Export Format] ----- + + Title: Cookies_Test + Categories: Snacks, Cookies & Squares + Servings: 2 + + 1 c a, or + 2 c b, or + 3 c c +------------------------------Dry Ingredients------------------------------- + 3/4 c. granulated sugar + 1 c. brown sugar + 2 c. all-purpose flour + 1 tsp. baking soda +-------------------------------Fat & Liquids-------------------------------- + 1 c. shortening; softened, at + -room temperature + 1 c. peanut butter + 2 eggs + 1 tsp. vanilla extract + + Drop by spoonful on greased cookie sheet. Bake in moderate oven. + +----- + +----- Exported by Krecipes vSVN_PRE-0.9 [Meal-Master Export Format] ----- + + Title: Cookies_Test + Categories: Snacks, Cookies & Squares + Servings: 2 + + 1 c a, or + 2 c b, or + 3 c c +------------------------------Dry Ingredients------------------------------- + 3/4 c. granulated sugar + 1 c. brown sugar + 2 c. all-purpose flour + 1 tsp. baking soda +-------------------------------Fat & Liquids-------------------------------- + 1 c. shortening; softened, at + -room temperature + 1 c. peanut butter + 2 eggs + 1 tsp. vanilla extract + + Drop by spoonful on greased cookie sheet. Bake in moderate oven. + +----- diff --git a/src/tests/mx2test.cpp b/src/tests/mx2test.cpp new file mode 100644 index 0000000..daa379e --- /dev/null +++ b/src/tests/mx2test.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "mx2importer.h" +#include "importertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "mx2test"); + + printf("Creating MX2Importer.\n"); + MX2Importer importer; + + printf("Parsing mx2test.txt.\n"); + TQStringList files; files << "mx2test.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Title 1"; + recipe.yield.amount = 2; + recipe.yield.type = "servings"; + recipe.categoryList.append( Element("Category 1") ); + recipe.categoryList.append( Element("Category 2") ); + recipe.instructions = + "Instruction line 1\n" + "Instruction line 2\n" + "Instruction line 3"; + + Ingredient ing; + ing.name = "ingredient 1"; + ing.amount = 1; + ing.units.name = "teaspoon"; + recipe.ingList.append( ing ); + + Ingredient ing2; + ing2.name = "ingredient 2"; + ing2.amount = 3.5; + ing2.units.plural = TQString::null; + recipe.ingList.append( ing2 ); + + Ingredient ing3; + ing3.name = "ingredient 3"; + ing3.amount = 3.5; + ing3.units.plural = "ounces"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "ingredient 4"; + ing4.amount = 3.5; + ing4.units.plural = "ounces"; + recipe.ingList.append( ing4 ); + + check( importer, recipe ); + + printf("Done.\n"); +} diff --git a/src/tests/mx2test.txt b/src/tests/mx2test.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/mxptest.cpp b/src/tests/mxptest.cpp new file mode 100644 index 0000000..3c56a6f --- /dev/null +++ b/src/tests/mxptest.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "mxpimporter.h" +#include "importertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "mxptest"); + + printf("Creating MXPImporter.\n"); + MXPImporter importer; + + printf("Parsing mxptest.txt.\n"); + TQStringList files; files << "mxptest.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Title 1"; + recipe.yield.amount = 2; + recipe.yield.type = "servings"; + recipe.categoryList.append( Element("Category 1") ); + recipe.categoryList.append( Element("Category 2") ); + recipe.instructions = + "Instruction line 1\n" + "Instruction line 2\n" + "Instruction line 3"; + + Ingredient ing; + ing.name = "ingredient 1"; + ing.amount = 1; + ing.units.name = "teaspoon"; + recipe.ingList.append( ing ); + + Ingredient ing2; + ing2.name = "ingredient 2"; + ing2.amount = 3.5; + ing2.units.plural = TQString::null; + recipe.ingList.append( ing2 ); + + Ingredient ing3; + ing3.name = "ingredient 3"; + ing3.amount = 3.5; + ing3.units.plural = "ounces"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "ingredient 4"; + ing4.amount = 3.5; + ing4.units.plural = "ounces"; + recipe.ingList.append( ing4 ); + + check( importer, recipe ); + + printf("Done.\n"); +} diff --git a/src/tests/mxptest.txt b/src/tests/mxptest.txt new file mode 100644 index 0000000..46154c0 --- /dev/null +++ b/src/tests/mxptest.txt @@ -0,0 +1,25 @@ + ----- Exported by Krecipes vSVN_PRE-0.9 [Master Cook Export Format] ----- + + Cookies Test + +Recipe By : Mona Beamer, Colleen Beamer +Serving Size : 2 Preparation Time :0:45 +Categories : Snacks Cookies & Squares + + + Amount Measure Ingredient -- Preparation Method +-------- ------------ -------------------------------- + 3/4 c. granulated sugar + 1 c. brown sugar + 2 c. all-purpose flour + 1 tsp. baking soda + 1 c. shortening -- softened,at room temperature + 1 c. peanut butter + 2 eggs + 1 tsp. vanilla extract + + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. + +Nutr. Assoc. : 0 1374 1021 927 0 1638 1358 797 0 0 0 568 0 532 1611 + diff --git a/src/tests/nyctest.cpp b/src/tests/nyctest.cpp new file mode 100644 index 0000000..724b6a0 --- /dev/null +++ b/src/tests/nyctest.cpp @@ -0,0 +1,100 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "nycgenericimporter.h" +#include "importertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "nyctest"); + + printf("Creating NYCGenericImporter.\n"); + NYCGenericImporter importer; + + printf("Parsing nyctest.txt.\n"); + TQStringList files; files << "nyctest.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Cookies_Test"; + recipe.yield.amount = 2; + recipe.yield.type = "dozen"; + 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."; + //recipe.prepTime = TQTime(0,30); + + recipe.authorList.append( Element("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") ); + ing8.prepMethodList.append( Element("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 = "whole"; + 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"); +} diff --git a/src/tests/nyctest.txt b/src/tests/nyctest.txt new file mode 100644 index 0000000..ad0720b --- /dev/null +++ b/src/tests/nyctest.txt @@ -0,0 +1,57 @@ +@@@@@ Exported by Krecipes vSVN_PRE-0.9 [Now You're Cooking! Export Format] + +Cookies_Test + +Snacks, Cookies & Squares + +3/4 c. granulated sugar +1 c. brown sugar +2 c. all-purpose flour +1 tsp. baking soda +1 c. shortening -- softened,at room temperature +1 c. peanut butter +2 whole eggs +1 tsp. vanilla extract + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. + +NYC Nutrition Analysis (per serving or yield unit): water=70.33 g; calories=394.5; protein=3.14 g; total fat=18 g; carbohydrate=56.94 g; dietary fiber=3.57 g; ash=1.18 g; calcium=14.36 mg; phosphorus=37.48 mg; iron=1.59 mg; sodium=339.7 mg; potassium=111.7 mg; magnesium=10.26 mg; zinc=0.25 mg; copper=0.08 mg; manganese=0.32 mg; vitamin A=160.3 IU; vitamin E=1.43 mg ATE; thiamin=0.2 mg; riboflavin=0.14 mg; niacin=1.6 mg; pantothenic acid=0.13 mg; vitamin B6=0.04 mg; folate=35.9 ug; vitamin C=4.13 mg; saturated fat=5.77 g; monounsaturated fat=6.83 g; polyunsaturated fat=4.41 g; caffeine=1.16 mg; selenium=10.13 ug; refuse=3.34%; %cal as carb:prot:fat=57:3:40; WW Pts=8.7; (complete analysis) + +Contributor: Colleen Beamer + +Yield: 2 dozen + +NYC Nutrilink: N5504^19335,N193^02021,N182^02010,N197^02025 +NYC Nutrilink: N218^02047,N5662^20081,N3906^14355,N1896^09153 +NYC Nutrilink: N1766^09003,N599^04522,U3^18402 + +** Exported from Now You're Cooking! v5.64 ** + +@@@@@ Exported by Krecipes vSVN_PRE-0.9 [Now You're Cooking! Export Format] + +Cookies_Test + +Snacks, Cookies & Squares + +3/4 c. granulated sugar +1 c. brown sugar +2 c. all-purpose flour +1 tsp. baking soda +1 c. shortening -- softened,at room temperature +1 c. peanut butter +2 whole eggs +1 tsp. vanilla extract + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. + +NYC Nutrition Analysis (per serving or yield unit): water=70.33 g; calories=394.5; protein=3.14 g; total fat=18 g; carbohydrate=56.94 g; dietary fiber=3.57 g; ash=1.18 g; calcium=14.36 mg; phosphorus=37.48 mg; iron=1.59 mg; sodium=339.7 mg; potassium=111.7 mg; magnesium=10.26 mg; zinc=0.25 mg; copper=0.08 mg; manganese=0.32 mg; vitamin A=160.3 IU; vitamin E=1.43 mg ATE; thiamin=0.2 mg; riboflavin=0.14 mg; niacin=1.6 mg; pantothenic acid=0.13 mg; vitamin B6=0.04 mg; folate=35.9 ug; vitamin C=4.13 mg; saturated fat=5.77 g; monounsaturated fat=6.83 g; polyunsaturated fat=4.41 g; caffeine=1.16 mg; selenium=10.13 ug; refuse=3.34%; %cal as carb:prot:fat=57:3:40; WW Pts=8.7; (complete analysis) + +Contributor: Colleen Beamer + +Yield: 2 dozen + +NYC Nutrilink: N5504^19335,N193^02021,N182^02010,N197^02025 +NYC Nutrilink: N218^02047,N5662^20081,N3906^14355,N1896^09153 +NYC Nutrilink: N1766^09003,N599^04522,U3^18402 + +** Exported from Now You're Cooking! v5.64 ** \ No newline at end of file diff --git a/src/tests/recipemltest.cpp b/src/tests/recipemltest.cpp new file mode 100644 index 0000000..eb11880 --- /dev/null +++ b/src/tests/recipemltest.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "recipemlimporter.h" +#include "recipemlexporter.h" +#include "importertest.h" +#include "exportertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "recipemltest"); + + printf("Creating RecipeMLImporter.\n"); + RecipeMLImporter importer; + + printf("Parsing recipemltest.txt.\n"); + TQStringList files; files << "recipemltest.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Cookies_Test"; + recipe.yield.amount = 2; + recipe.yield.amount_offset = 1; + recipe.yield.type = "dozen"; + 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."; + recipe.prepTime = TQTime(0,30); + + recipe.authorList.append( Element("Colleen Beamer") ); + recipe.authorList.append( Element("Mona Beamer") ); + + Ingredient ing; + ing.name = "granulated sugar"; + ing.amount = 0.75; + ing.amount_offset = 0.25; + ing.units.name = "c."; + ing.groupID = 0; ing.group = "Dry Ingredients"; + recipe.ingList.append( ing ); + + Ingredient ing2; + ing2.name = "brown sugar"; + ing2.amount = 1; + ing2.amount_offset = 0; + ing2.units.name = "c."; + ing2.groupID = 0; ing2.group = "Dry Ingredients"; + recipe.ingList.append( ing2 ); + + Ingredient ing3; + ing3.name = "all-purpose flour"; + ing3.amount = 2; + ing3.units.plural = "c."; + ing3.groupID = 0; ing3.group = "Dry Ingredients"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "baking soda"; + ing4.amount = 1; + ing4.amount_offset = 0; + ing4.units.name = "tsp."; + ing4.groupID = 0; ing4.group = "Dry Ingredients"; + recipe.ingList.append( ing4 ); + + Ingredient ing8; + ing8.name = "shortening"; + ing8.amount = 1; + ing8.amount_offset = 0; + ing8.units.name = "c."; + ing8.prepMethodList.append( Element("softened") ); + ing8.prepMethodList.append( Element("at room temperature") ); + ing8.groupID = 1; ing8.group = "Fat & Liquids"; + recipe.ingList.append( ing8 ); + + Ingredient ing6; + ing6.name = "peanut butter"; + ing6.amount = 1; + ing6.amount_offset = 0; + ing6.units.name = "c."; + ing6.groupID = 1; ing6.group = "Fat & Liquids"; + recipe.ingList.append( ing6 ); + + Ingredient ing5; + ing5.name = "eggs"; + ing5.amount = 2; + ing5.amount_offset = 0; + ing5.units.plural = ""; + ing5.groupID = 1; ing5.group = "Fat & Liquids"; + recipe.ingList.append( ing5 ); + + Ingredient ing7; + ing7.name = "vanilla extract"; + ing7.amount = 1; + ing7.amount_offset = 0; + ing7.units.name = "tsp."; + ing7.groupID = 1; ing7.group = "Fat & Liquids"; + recipe.ingList.append( ing7 ); + + Ingredient ing9; + ing9.name = "a"; + ing9.amount = 1; + ing9.amount_offset = 0; + ing9.units.name = "cup"; + IngredientData ing9_1; + ing9_1.name = "b"; + ing9_1.amount = 2; + ing9_1.amount_offset = 0; + ing9_1.units.plural = "cups"; + IngredientData ing9_2; + ing9_2.name = "c"; + ing9_2.amount = 3; + ing9_2.amount_offset = 0; + ing9_2.units.plural = "cups"; + ing9.substitutes.append(ing9_1); + ing9.substitutes.append(ing9_2); + recipe.ingList.append( ing9 ); + + check( importer, recipe ); + + RecipeList recipeList; + recipeList.append(recipe); + recipeList.append(recipe); + + printf("Creating RecipeMLExporter.\n"); + RecipeMLExporter exporter("not needed",".mmf"); + check( exporter, recipeList ); + printf("Successfully exported recipes to test.txt.\n"); + + printf("Creating RecipeMLImporter to test exported recipes.\n"); + RecipeMLImporter importer2; + + printf("Parsing test.txt.\n"); + TQStringList files2; files2 << "test.txt"; + importer2.parseFiles(files2); + TQFile::remove("test.txt"); + check( importer2, recipe ); + printf("Recipe export successful.\n"); + + printf("*** RecipeML importer and exporter passed the tests :-) ***\n"); + + printf("Done.\n"); +} diff --git a/src/tests/recipemltest.txt b/src/tests/recipemltest.txt new file mode 100644 index 0000000..330f757 --- /dev/null +++ b/src/tests/recipemltest.txt @@ -0,0 +1,249 @@ + + + + + Cookies_Test + + Colleen Beamer + Mona Beamer + + + Snacks + Cookies & Squares + + + + 2 + 3 + + dozen + + + + + + + + Dry Ingredients + + + + + 0.75 + 1 + + + c. + + granulated sugar + + + + 1 + c. + + brown sugar + + + + 2 + c. + + all-purpose flour + + + + 1 + tsp. + + baking soda + + + + Fat & Liquids + + + 1 + c. + + shortening + softened,at room temperature + + + + 1 + c. + + peanut butter + + + + 2 + + + eggs + + + + 1 + tsp. + + vanilla extract + + + + + 1 + cup + + a + + + + 2 + cups + + b + + + + + 3 + cups + + c + + + + + + Drop by spoonful on greased cookie sheet. Bake in moderate oven. + + + + + Cookies_Test + + Colleen Beamer + Mona Beamer + + + Snacks + Cookies & Squares + + + + 2 + 3 + + dozen + + + + + + + + Dry Ingredients + + + + + 0.75 + 1 + + + c. + + granulated sugar + + + + 1 + c. + + brown sugar + + + + 2 + c. + + all-purpose flour + + + + 1 + tsp. + + baking soda + + + + Fat & Liquids + + + 1 + c. + + shortening + softened,at room temperature + + + + 1 + c. + + peanut butter + + + + 2 + + + eggs + + + + 1 + tsp. + + vanilla extract + + + + + 1 + cup + + a + + + + 2 + cups + + b + + + + + 3 + cups + + c + + + + + + Drop by spoonful on greased cookie sheet. Bake in moderate oven. + + + \ No newline at end of file diff --git a/src/tests/rezkonvtest.cpp b/src/tests/rezkonvtest.cpp new file mode 100644 index 0000000..d9b8022 --- /dev/null +++ b/src/tests/rezkonvtest.cpp @@ -0,0 +1,155 @@ +/*************************************************************************** +* 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 + +#include + +#include +using std::cout; +using std::endl; + +#include "rezkonvimporter.h" +#include "rezkonvexporter.h" +#include "importertest.h" +#include "exportertest.h" + +int +main(int argc, char *argv[]) +{ + TDEApplication a(argc, argv, "rezkonvtest"); + + printf("Creating RezkonvImporter.\n"); + RezkonvImporter importer; + + printf("Parsing rezkonvtest.txt.\n"); + TQStringList files; files << "rezkonvtest.txt"; + importer.parseFiles(files); + + Recipe recipe; + recipe.title = "Cookies_Test"; + recipe.yield.amount = 2; + recipe.yield.amount_offset = 1; + recipe.yield.type = "dozen"; + recipe.categoryList.append( Element("Snacks") ); + recipe.categoryList.append( Element("Cookies & Squares") ); + recipe.instructions = + "\n\nDrop by spoonful on greased cookie sheet. Bake in moderate oven."; + + recipe.authorList.append( Element("Mona Beamer") ); + recipe.authorList.append( Element("Colleen Beamer") ); + + Ingredient ing9; + ing9.name = "a"; + ing9.amount = 1; + ing9.amount_offset = 0; + ing9.units.name = "cup"; + IngredientData ing9_1; + ing9_1.name = "b"; + ing9_1.amount = 2; + ing9_1.amount_offset = 0; + ing9_1.units.plural = "cups"; + IngredientData ing9_2; + ing9_2.name = "c"; + ing9_2.amount = 3; + ing9_2.amount_offset = 0; + ing9_2.units.plural = "cups"; + ing9.substitutes.append(ing9_1); + ing9.substitutes.append(ing9_2); + recipe.ingList.append( ing9 ); + + Ingredient ing; + ing.name = "granulated sugar"; + ing.amount = 0.75; + ing.amount_offset = 0.25; + ing.units.name = "c."; + ing.groupID = 0; ing.group = "Dry Ingredients"; + recipe.ingList.append( ing ); + + Ingredient ing2; + ing2.name = "brown sugar"; + ing2.amount = 1; + ing2.amount_offset = 0; + ing2.units.name = "c."; + ing2.groupID = 0; ing2.group = "Dry Ingredients"; + recipe.ingList.append( ing2 ); + + Ingredient ing3; + ing3.name = "all-purpose flour"; + ing3.amount = 2; + ing3.units.plural = "c."; + ing3.groupID = 0; ing3.group = "Dry Ingredients"; + recipe.ingList.append( ing3 ); + + Ingredient ing4; + ing4.name = "baking soda"; + ing4.amount = 1; + ing4.amount_offset = 0; + ing4.units.name = "tsp."; + ing4.groupID = 0; ing4.group = "Dry Ingredients"; + recipe.ingList.append( ing4 ); + + Ingredient ing8; + ing8.name = "shortening"; + ing8.amount = 1; + ing8.amount_offset = 0; + ing8.units.name = "c."; + ing8.prepMethodList.append( Element("softened") ); + ing8.prepMethodList.append( Element("at room temperature") ); + ing8.groupID = 1; ing8.group = "Fat & Liquids"; + recipe.ingList.append( ing8 ); + + Ingredient ing6; + ing6.name = "peanut butter"; + ing6.amount = 1; + ing6.amount_offset = 0; + ing6.units.name = "c."; + ing6.groupID = 1; ing6.group = "Fat & Liquids"; + recipe.ingList.append( ing6 ); + + Ingredient ing5; + ing5.name = "eggs"; + ing5.amount = 2; + ing5.amount_offset = 0; + ing5.units.plural = ""; + ing5.groupID = 1; ing5.group = "Fat & Liquids"; + recipe.ingList.append( ing5 ); + + Ingredient ing7; + ing7.name = "vanilla extract"; + ing7.amount = 1; + ing7.amount_offset = 0; + ing7.units.name = "tsp."; + ing7.groupID = 1; ing7.group = "Fat & Liquids"; + recipe.ingList.append( ing7 ); + + check( importer, recipe ); + + RecipeList recipeList; + recipeList.append(recipe); + recipeList.append(recipe); + + printf("Creating RezkonvExporter.\n"); + RezkonvExporter exporter("not needed",".rk"); + check( exporter, recipeList ); + printf("Successfully exported recipes to test.txt.\n"); + + printf("Creating RezkonvImporter to test exported recipes.\n"); + RezkonvImporter importer2; + + printf("Parsing test.txt.\n"); + TQStringList files2; files2 << "test.txt"; + importer2.parseFiles(files2); + TQFile::remove("test.txt"); + check( importer2, recipe ); + printf("Recipe export successful.\n"); + + printf("Done.\n"); +} diff --git a/src/tests/rezkonvtest.txt b/src/tests/rezkonvtest.txt new file mode 100644 index 0000000..38e4ac2 --- /dev/null +++ b/src/tests/rezkonvtest.txt @@ -0,0 +1,55 @@ +========== REZKONV-Rezept - RezkonvSuite v0.97.1 + + Titel: Cookies_Test +Kategorien: Snacks, Cookies & Squares + Menge: 2-3 dozen + + 1 cup a, or + 2 cups b, or + 3 cups c +========================== Dry Ingredients ========================== + 3/4-1 c. granulated sugar + 1 c. brown sugar + 2 c. all-purpose flour + 1 tsp. baking soda + +=========================== Fat & Liquids =========================== + 1 c. shortening, softened,at room temperature + 1 c. peanut butter + 2 eggs + 1 tsp. vanilla extract + +============================== QUELLE ============================== + Mona Beamer + -- Colleen Beamer + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. +===== + +========== REZKONV-Rezept - RezkonvSuite v0.97.1 + + Titel: Cookies_Test +Kategorien: Snacks, Cookies & Squares + Menge: 2-3 dozen + + 1 cup a, or + 2 cups b, or + 3 cups c +========================== Dry Ingredients ========================== + 3/4-1 c. granulated sugar + 1 c. brown sugar + 2 c. all-purpose flour + 1 tsp. baking soda + +=========================== Fat & Liquids =========================== + 1 c. shortening, softened,at room temperature + 1 c. peanut butter + 2 eggs + 1 tsp. vanilla extract + +============================== QUELLE ============================== + Mona Beamer + -- Colleen Beamer + +Drop by spoonful on greased cookie sheet. Bake in moderate oven. +===== diff --git a/src/tests/test_photo.jpg b/src/tests/test_photo.jpg new file mode 100644 index 0000000..3ebe035 Binary files /dev/null and b/src/tests/test_photo.jpg differ -- cgit v1.2.1