[yast-commit] r65078 - /branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp
Author: mvidner Date: Thu Jul 28 16:25:30 2011 New Revision: 65078 URL: http://svn.opensuse.org/viewcvs/yast?rev=65078&view=rev Log: New module: Assert Assert::Equal(readability, good); Assert::EqualMsg(0, user_id, "you must be root to run these tests"); Assert::Equal("Oh Assert, how could I have lived without you so long?", Mode::mood()); Added: branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp (with props) Added: branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp?rev=65078&view=auto ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp (added) +++ branches/SuSE-Code-11-SP2-Branch/yast2/library/modules/Assert.ycp Thu Jul 28 16:25:30 2011 @@ -0,0 +1,36 @@ +/** + * File: Assert.ycp + * Summary: Assertions for test cases + * Authors: Martin Vidner <mvidner@suse.cz> + */ +{ +module "Assert"; + +/** + * @param expected expected value of test + * @param actual actual value of test + * @param fail_message will be logged if test fails + * @return whether test succeeds + */ +global boolean EqualMsg(any expected, any actual, string fail_message) { + if (expected == actual) { + return true; + } + else { + y2error ("%1", fail_message); + return false; + } +} + +/** + * @param expected expected value of test + * @param actual actual value of test + * @return whether test succeeds + */ +global boolean Equal(any expected, any actual) { + string fail_message = sformat ("assertion failure, expected '%1', got '%2'", expected, actual); + return EqualMsg(expected, actual, fail_message); +} + +/* EOF */ +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn2.opensuse.org