% $Id: windowlayoutexamples_tests.erl,v 1.2 2013/11/06 13:44:18 leavens Exp leavens $ -module(windowlayoutexamples_tests). -export([main/0,test_addToSize/0,test_doubleSize/0,test_totalWidth/0]). -import(windowlayoutexamples,[addToSize/2,doubleSize/1,totalWidth/1]). -import(testing,[dotests/2,eqTest/3,run_tests/1,startTesting/1]). -include("window.hrl"). -spec main() -> integer(). main() -> test_addToSize(), test_doubleSize(), test_totalWidth(). % Some test data, which is shared among the testing functions. olympics() -> #window{wname = "olympics", width = 50, height = 33}. news() -> #window{wname = "news", width = 20, height = 10}. eh() -> {horizontal, []}. ev() -> {vertical, []}. olynews() -> {horizontal, [olympics(), news()]}. test_addToSize() -> dotests("addToSize tests $Revision: 1.2 $", [eqTest(addToSize(10,olympics()), "==", #window{wname = "olympics", width = 60, height = 43}), eqTest(addToSize(100,eh()), "==", eh()), eqTest(addToSize(5,ev()), "==", ev()), eqTest(addToSize(100,olynews()), "==", {horizontal, [#window{wname = "olympics", width = 150, height = 133}, #window{wname = "news", width = 120, height = 110}]}) ]). test_doubleSize() -> dotests("doubleSize tests $Revision: 1.2 $", [eqTest(doubleSize(olympics()), "==", #window{wname = "olympics", width = 100, height = 66}), eqTest(doubleSize(eh()), "==", eh()), eqTest(doubleSize(ev()), "==", ev()), eqTest(doubleSize(olynews()), "==", {horizontal, [#window{wname = "olympics", width = 100, height = 66}, #window{wname = "news", width = 40, height = 20}]}) ]). test_totalWidth() -> dotests("totalWidth tests $Revision: 1.2 $", [eqTest(totalWidth(olympics()), "==", 50), eqTest(totalWidth(eh()), "==", 0), eqTest(totalWidth(ev()), "==", 0), eqTest(totalWidth(olynews()), "==", 70) ]).