aceunit-commit Mailing List for AceUnit (Page 21)
Status: Beta
Brought to you by:
christianhujer
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(139) |
Nov
(77) |
Dec
(32) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(55) |
Feb
(11) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(9) |
Oct
(75) |
Nov
(57) |
Dec
(21) |
2009 |
Jan
(14) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(24) |
Sep
(11) |
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
(21) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
From: <chr...@us...> - 2007-10-14 11:54:23
|
Revision: 82 http://aceunit.svn.sourceforge.net/aceunit/?rev=82&view=rev Author: christianhujer Date: 2007-10-14 04:54:19 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Added a TODO. Modified Paths: -------------- trunk/TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-10-14 11:53:42 UTC (rev 81) +++ trunk/TODO 2007-10-14 11:54:19 UTC (rev 82) @@ -5,3 +5,4 @@ * Make internal functions static in C code. * Test AceUnit with AceUnit * Test GenTest with JUnit +* Turn runFixture in a non-void function that returns whether one or more test cases failed. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-14 11:53:39
|
Revision: 81 http://aceunit.svn.sourceforge.net/aceunit/?rev=81&view=rev Author: christianhujer Date: 2007-10-14 04:53:42 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Enabled gcc warnings. Fixed warning about main not returning a value. Modified Paths: -------------- trunk/src/doc/examples/sort/Makefile trunk/src/doc/examples/sort/sortTest.c Modified: trunk/src/doc/examples/sort/Makefile =================================================================== --- trunk/src/doc/examples/sort/Makefile 2007-10-14 11:40:10 UTC (rev 80) +++ trunk/src/doc/examples/sort/Makefile 2007-10-14 11:53:42 UTC (rev 81) @@ -31,4 +31,4 @@ java -jar AceUnit.jar sortTest >sortTest.h runTests: *.c *.h sortTest.h - gcc -g -o runTests *.c + gcc -Wall -g -o runTests *.c Modified: trunk/src/doc/examples/sort/sortTest.c =================================================================== --- trunk/src/doc/examples/sort/sortTest.c 2007-10-14 11:40:10 UTC (rev 80) +++ trunk/src/doc/examples/sort/sortTest.c 2007-10-14 11:53:42 UTC (rev 81) @@ -101,4 +101,5 @@ // In future versions, this part will be auto-generated. int main(int argc, char *argv[]) { runFixture(&sortTestFixture); + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-14 11:40:08
|
Revision: 80 http://aceunit.svn.sourceforge.net/aceunit/?rev=80&view=rev Author: christianhujer Date: 2007-10-14 04:40:10 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Updated release version. Modified Paths: -------------- trunk/src/doc/start.xhtml Modified: trunk/src/doc/start.xhtml =================================================================== --- trunk/src/doc/start.xhtml 2007-10-14 11:13:10 UTC (rev 79) +++ trunk/src/doc/start.xhtml 2007-10-14 11:40:10 UTC (rev 80) @@ -20,7 +20,7 @@ </div> --> <p> - Latest release version: <strong>aceunit-0.1</strong> + Latest release version: <strong>aceunit-0.1.1</strong> </p> <h2>What is AceUnit?</h2> <!-- The description must match the project description at http://sourceforge.net/projects/aceunit/ --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-14 11:13:09
|
Revision: 79 http://aceunit.svn.sourceforge.net/aceunit/?rev=79&view=rev Author: christianhujer Date: 2007-10-14 04:13:10 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Removed TODO that's done now. Modified Paths: -------------- trunk/TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-10-13 22:34:03 UTC (rev 78) +++ trunk/TODO 2007-10-14 11:13:10 UTC (rev 79) @@ -1,4 +1,3 @@ -* Change Java program to use japi-lib-argparser * Create global build.xml for Building releases * Make it run on Windows, too This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 22:34:00
|
Revision: 78 http://aceunit.svn.sourceforge.net/aceunit/?rev=78&view=rev Author: christianhujer Date: 2007-10-13 15:34:03 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Improved code generation source code. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 22:20:08 UTC (rev 77) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 22:34:03 UTC (rev 78) @@ -58,38 +58,43 @@ */ public String getFixtureCode(@NotNull final String basename) { final StringBuilder out = new StringBuilder(); - appendMethodIds(out); - appendMethods(out, "testCase", testMethods); - appendMethods(out, "before", beforeMethods); - appendMethods(out, "after", afterMethods); - appendMethods(out, "beforeClass", beforeClassMethods); - appendMethods(out, "afterClass", afterClassMethods); + out.append(getTestMethodIds()); + out.append(getMethods("testCase", testMethods)); + out.append(getMethods("before", beforeMethods)); + out.append(getMethods("after", afterMethods)); + out.append(getMethods("beforeClass", beforeClassMethods)); + out.append(getMethods("afterClass", afterClassMethods)); out.append("\n"); out.append("TestFixture_t ").append(basename).append("Fixture = {\n testId,\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); return out.toString(); } /** Appends the method list to the specified output. - * @param out Output to append method list to. * @param key Key for which to append the method list, used as variable name. * @param methods List with methods to append. + * @return Source code for the test methods. */ - private void appendMethods(@NotNull final StringBuilder out, @NotNull final String key, @NotNull final MethodList methods) { - out.append("testMethod_t ").append(key).append("[] = {\n"); + private String getMethods(@NotNull final String key, @NotNull final MethodList methods) { + final StringBuilder sb = new StringBuilder(); + sb.append("testMethod_t ").append(key).append("[] = {\n"); for (final String method : methods) { - out.append(" &").append(method).append(",\n"); + sb.append(" &").append(method).append(",\n"); } - out.append(" NULL\n};\n"); + sb.append(" NULL\n};\n"); + return sb.toString(); } - /** Appends the method ids to the specified output. - * @param out output to append method ids to. + /** Returns a String with the source code for the test method ids. + * @return Source code for the test method ids. */ - private void appendMethodIds(@NotNull final StringBuilder out) { - out.append("TestCaseId_t testId[] = {\n"); + public String getTestMethodIds() { + final StringBuilder sb = new StringBuilder(); + sb.append("TestCaseId_t testId[] = {\n"); for (final String method : testMethods) { - out.append(" \"").append(method).append("\","); + sb.append(" \"").append(method).append("\","); } - out.append(" NULL\n};\n"); + sb.append(" NULL\n};\n"); + return sb.toString(); } + } // class MethodLists This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 22:20:06
|
Revision: 77 http://aceunit.svn.sourceforge.net/aceunit/?rev=77&view=rev Author: christianhujer Date: 2007-10-13 15:20:08 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Added options to manual. Modified Paths: -------------- trunk/src/doc/manual.xhtml Modified: trunk/src/doc/manual.xhtml =================================================================== --- trunk/src/doc/manual.xhtml 2007-10-13 22:13:01 UTC (rev 76) +++ trunk/src/doc/manual.xhtml 2007-10-13 22:20:08 UTC (rev 77) @@ -148,5 +148,22 @@ n2 = 1; assertTrue("Comparing 2 with 1 must return a value >0.", compareInt(&n1, &n2) > 0); }]]></pre> + <h2>Options</h2> + <p> + AceUnit supports the following options: + </p> + <dl> + <dt><code>#define ACEUNIT_STATIC_ASSERTIONS</code></dt> + <dd> + By defining this macro you will cause annotations to be equivalent to <code>static</code>. + That way you have easy and flexible control over whether test methods are static or not. + </dd> + <dt><code>#define ACEUNIT_EMBEDDED</code></dt> + <dd> + By defining this macro you will turn AceUnit into embedded mode. + In embedded mode, AceUnit tries to consume as little memory as possible. + For instance, all strings are replaced by 16 bit values. + </dd> + </dl> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 22:13:08
|
Revision: 76 http://aceunit.svn.sourceforge.net/aceunit/?rev=76&view=rev Author: christianhujer Date: 2007-10-13 15:13:01 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Optimized string concatenation. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 21:22:38 UTC (rev 75) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 22:13:01 UTC (rev 76) @@ -88,7 +88,7 @@ private void appendMethodIds(@NotNull final StringBuilder out) { out.append("TestCaseId_t testId[] = {\n"); for (final String method : testMethods) { - out.append(" \"" + method + "\","); + out.append(" \"").append(method).append("\","); } out.append(" NULL\n};\n"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 21:22:35
|
Revision: 75 http://aceunit.svn.sourceforge.net/aceunit/?rev=75&view=rev Author: christianhujer Date: 2007-10-13 14:22:38 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Changed TestCaseId_t to be in a separate array. This reduces memory consumption on some embedded platforms, e.g. Arm. Also removes the need for TestCase_t. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java trunk/src/native/AceUnit.c trunk/src/native/AceUnit.h Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 20:45:20 UTC (rev 74) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 21:22:38 UTC (rev 75) @@ -58,17 +58,14 @@ */ public String getFixtureCode(@NotNull final String basename) { final StringBuilder out = new StringBuilder(); - out.append("TestCase_t testCase[] = {\n"); - for (final String testMethod : testMethods) { - out.append(" TM(").append(testMethod).append("),\n"); - } - out.append(" {NULL, NULL}\n};\n"); + appendMethodIds(out); + appendMethods(out, "testCase", testMethods); appendMethods(out, "before", beforeMethods); appendMethods(out, "after", afterMethods); appendMethods(out, "beforeClass", beforeClassMethods); appendMethods(out, "afterClass", afterClassMethods); out.append("\n"); - out.append("TestFixture_t ").append(basename).append("Fixture = {\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); + out.append("TestFixture_t ").append(basename).append("Fixture = {\n testId,\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); return out.toString(); } @@ -85,4 +82,14 @@ out.append(" NULL\n};\n"); } + /** Appends the method ids to the specified output. + * @param out output to append method ids to. + */ + private void appendMethodIds(@NotNull final StringBuilder out) { + out.append("TestCaseId_t testId[] = {\n"); + for (final String method : testMethods) { + out.append(" \"" + method + "\","); + } + out.append(" NULL\n};\n"); + } } // class MethodLists Modified: trunk/src/native/AceUnit.c =================================================================== --- trunk/src/native/AceUnit.c 2007-10-13 20:45:20 UTC (rev 74) +++ trunk/src/native/AceUnit.c 2007-10-13 21:22:38 UTC (rev 75) @@ -75,13 +75,15 @@ (*secondary)();\ } const testMethod_t *secondary; // beforeClass, before, after, afterClass - const TestCase_t *testCase; + const testMethod_t *testCase; + const TestCaseId_t *testId; + invokeAll(beforeClass); - for (testCase = fixture->testCase; NULL != testCase->testMethod; testCase++) { - currentTestId = testCase->testId; + for (testCase = fixture->testCase, testId = fixture->testId; NULL != *testCase; testCase++, testId++) { + currentTestId = *testId; invokeAll(before); recentError = NULL; - (*testCase->testMethod)(); + (*testCase)(); if (NULL != recentError) { FullPlainLoggerLog(recentError); free(recentError); Modified: trunk/src/native/AceUnit.h =================================================================== --- trunk/src/native/AceUnit.h 2007-10-13 20:45:20 UTC (rev 74) +++ trunk/src/native/AceUnit.h 2007-10-13 21:22:38 UTC (rev 75) @@ -140,28 +140,16 @@ */ typedef void(*testMethod_t)(); -/** Test cases pair test methods with their names for later reference. - * That's required because we want the test case method name for logging but there is no reflection in C. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -typedef struct { - - /** The id of this test case. */ - TestCaseId_t testId; - - /** The test method of this test case. */ - testMethod_t testMethod; - -} TestCase_t; - - /** A Fixture is a collection of test cases sharing the same before, after, beforeClass and afterClass methods. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ typedef struct { + /** The ids of the test cases of this test fixture. */ + TestCaseId_t *testId; + /** The test cases of this test fixture. */ - TestCase_t *testCase; + testMethod_t *testCase; /** The before methods of this test fixture. */ testMethod_t *before; @@ -174,6 +162,7 @@ /** The afterClass methods of this test fixture. */ testMethod_t *afterClass; + } TestFixture_t; /** Records an error. @@ -188,15 +177,6 @@ */ extern void runFixture(const TestFixture_t *const fixture); -/** Define a test case (pair of method's function pointer and name). - * @param X test case to define - */ -#ifdef ACEUNIT_EMBEDDED -// TODO -#else -#define TM(X) { #X, &X } -#endif - /** A Logger logs events during test execution. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 20:45:17
|
Revision: 74 http://aceunit.svn.sourceforge.net/aceunit/?rev=74&view=rev Author: christianhujer Date: 2007-10-13 13:45:20 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Copying bugfix from 0.1 branch to trunk. Modified Paths: -------------- trunk/src/native/AceUnit.h Modified: trunk/src/native/AceUnit.h =================================================================== --- trunk/src/native/AceUnit.h 2007-10-13 20:33:50 UTC (rev 73) +++ trunk/src/native/AceUnit.h 2007-10-13 20:45:20 UTC (rev 74) @@ -105,14 +105,14 @@ * @param message Message, usually with the positive description of why the assertion should not fail. * @param condition Condition to assert. */ -#define assertTrue(message, condition) if (!condition) fail(message) +#define assertTrue(message, condition) if (!condition) { fail(message); } /** Asserts that the specified condition is false. * If the condition is not false, the test case fails and raises an Assertion Error that will be logged. * @param message Message, usually with the positive description of why the assertion should not fail. * @param condition Condition to assert for false. */ -#define assertFalse(message, condition) if (condition) fail(message) +#define assertFalse(message, condition) if (condition) { fail(message); } /** Asserts that two values are equal. * If the values are not equal, the test case fails and raises an Assertion Error that will be logged. @@ -120,7 +120,7 @@ * @param expected Expected value. * @param actual Actual value. */ -#define assertEquals(message, expected, actual) if (!(expected == actual)) fail(message) // TODO: expected vs. actual in message +#define assertEquals(message, expected, actual) if (!(expected == actual)) { fail(message); } // TODO: expected vs. actual in message /** Asserts that two values are not equal. * If the values are equal, the test case fails and raises an {@link AssertionError_t} that will be logged. @@ -128,7 +128,7 @@ * @param unexpected Not expected value. * @param actual Actual value. */ -#define assertNotEquals(message, unexpected, actual) if (unexpected == actual) fail(message) // TODO: expected vs. actual in message +#define assertNotEquals(message, unexpected, actual) if (unexpected == actual) { fail(message); } // TODO: expected vs. actual in message /** Method signature for annotated test methods. * @see #A_Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 20:33:46
|
Revision: 73 http://aceunit.svn.sourceforge.net/aceunit/?rev=73&view=rev Author: christianhujer Date: 2007-10-13 13:33:50 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Created release tag 0.1.1. Added Paths: ----------- tags/0.1.1/ Copied: tags/0.1.1 (from rev 72, branches/0.1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 20:31:28
|
Revision: 72 http://aceunit.svn.sourceforge.net/aceunit/?rev=72&view=rev Author: christianhujer Date: 2007-10-13 13:31:30 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Fixed bug: assertions returned early. Modified Paths: -------------- branches/0.1/src/native/AceUnit.h Modified: branches/0.1/src/native/AceUnit.h =================================================================== --- branches/0.1/src/native/AceUnit.h 2007-10-13 20:28:59 UTC (rev 71) +++ branches/0.1/src/native/AceUnit.h 2007-10-13 20:31:30 UTC (rev 72) @@ -139,14 +139,14 @@ * @param message Message, usually with the positive description of why the assertion should not fail. * @param condition Condition to assert. */ -#define assertTrue(message, condition) if (!condition) fail(message) +#define assertTrue(message, condition) if (!condition) { fail(message); } /** Asserts that the specified condition is false. * If the condition is not false, the test case fails and raises an Assertion Error that will be logged. * @param message Message, usually with the positive description of why the assertion should not fail. * @param condition Condition to assert for false. */ -#define assertFalse(message, condition) if (condition) fail(message) +#define assertFalse(message, condition) if (condition) { fail(message); } /** Asserts that two values are equal. * If the values are not equal, the test case fails and raises an Assertion Error that will be logged. @@ -154,7 +154,7 @@ * @param expected Expected value. * @param actual Actual value. */ -#define assertEquals(message, expected, actual) if (!(expected == actual)) fail(message) // TODO: expected vs. actual in message +#define assertEquals(message, expected, actual) if (!(expected == actual)) { fail(message); } // TODO: expected vs. actual in message /** Asserts that two values are not equal. * If the values are equal, the test case fails and raises an {@link AssertionError_t} that will be logged. @@ -162,7 +162,7 @@ * @param unexpected Not expected value. * @param actual Actual value. */ -#define assertNotEquals(message, unexpected, actual) if (unexpected == actual) fail(message) // TODO: expected vs. actual in message +#define assertNotEquals(message, unexpected, actual) if (unexpected == actual) { fail(message); } // TODO: expected vs. actual in message /** Method signature for annotated test methods. * @see #A_Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 20:28:57
|
Revision: 71 http://aceunit.svn.sourceforge.net/aceunit/?rev=71&view=rev Author: christianhujer Date: 2007-10-13 13:28:59 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Changed gcc options to include debugging. Modified Paths: -------------- trunk/src/doc/examples/sort/Makefile Modified: trunk/src/doc/examples/sort/Makefile =================================================================== --- trunk/src/doc/examples/sort/Makefile 2007-10-13 19:30:58 UTC (rev 70) +++ trunk/src/doc/examples/sort/Makefile 2007-10-13 20:28:59 UTC (rev 71) @@ -31,4 +31,4 @@ java -jar AceUnit.jar sortTest >sortTest.h runTests: *.c *.h sortTest.h - gcc -o runTests *.c + gcc -g -o runTests *.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 19:30:54
|
Revision: 70 http://aceunit.svn.sourceforge.net/aceunit/?rev=70&view=rev Author: christianhujer Date: 2007-10-13 12:30:58 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Simplified runFixture(). Modified Paths: -------------- trunk/src/native/AceUnit.c Modified: trunk/src/native/AceUnit.c =================================================================== --- trunk/src/native/AceUnit.c 2007-10-13 18:26:53 UTC (rev 69) +++ trunk/src/native/AceUnit.c 2007-10-13 19:30:58 UTC (rev 70) @@ -71,32 +71,25 @@ * @param fixture Test fixture to run. */ void runFixture(const TestFixture_t *const fixture) { +#define invokeAll(X) for (secondary = fixture->X; NULL != *secondary; secondary++) {\ + (*secondary)();\ +} + const testMethod_t *secondary; // beforeClass, before, after, afterClass const TestCase_t *testCase; - const testMethod_t *beforeClass; - const testMethod_t *before; - const testMethod_t *after; - const testMethod_t *afterClass; - for (beforeClass = fixture->beforeClass; NULL != *beforeClass; beforeClass++) { - (*beforeClass)(); - } + invokeAll(beforeClass); for (testCase = fixture->testCase; NULL != testCase->testMethod; testCase++) { currentTestId = testCase->testId; - for (before = fixture->before; NULL != *before; before++) { - (*before)(); - } + invokeAll(before); recentError = NULL; (*testCase->testMethod)(); if (NULL != recentError) { FullPlainLoggerLog(recentError); free(recentError); } - for (after = fixture->after; NULL != *after; after++) { - (*after)(); - } + invokeAll(after); } - for (afterClass = fixture->afterClass; NULL != *afterClass; afterClass++) { - (*afterClass)(); - } + invokeAll(afterClass); +#undef invokeAll } // TODO: Add method to run specified test cases from a test fixture. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 18:26:49
|
Revision: 69 http://aceunit.svn.sourceforge.net/aceunit/?rev=69&view=rev Author: christianhujer Date: 2007-10-13 11:26:53 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Fixed bogus @file. Modified Paths: -------------- trunk/src/native/AceUnitAnnotations.h Modified: trunk/src/native/AceUnitAnnotations.h =================================================================== --- trunk/src/native/AceUnitAnnotations.h 2007-10-13 18:20:23 UTC (rev 68) +++ trunk/src/native/AceUnitAnnotations.h 2007-10-13 18:26:53 UTC (rev 69) @@ -27,7 +27,7 @@ /** AceUnit Annotations header file. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @file AceUnit.h + * @file AceUnitAnnotations.h */ /** The super type of annotations. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 18:20:20
|
Revision: 68 http://aceunit.svn.sourceforge.net/aceunit/?rev=68&view=rev Author: christianhujer Date: 2007-10-13 11:20:23 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Improved manual. Modified Paths: -------------- trunk/src/doc/manual.xhtml Modified: trunk/src/doc/manual.xhtml =================================================================== --- trunk/src/doc/manual.xhtml 2007-10-13 17:37:27 UTC (rev 67) +++ trunk/src/doc/manual.xhtml 2007-10-13 18:20:23 UTC (rev 68) @@ -30,22 +30,22 @@ </p> <dl> <!-- Keep the descriptions of the annotations in sync with those in AceUnitAnnotations.h --> - <dt>A_Test</dt> + <dt><code>A_Test</code></dt> <dd>Test annotation, use for test cases.</dd> - <dt>A_Before</dt> + <dt><code>A_Before</code></dt> <dd>Before annotation, use for methods that should be invoked before each test case in a fixture.</dd> - <dt>A_After</dt> + <dt><code>A_After</code></dt> <dd>After annotation, use for methods that should be invoked after each test case in a fixture.</dd> - <dt>A_BeforeClass</dt> + <dt><code>A_BeforeClass</code></dt> <dd>BeforeClass annotation, use for methods that should be invoked once for the fixture before all of its test cases.</dd> - <dt>A_AfterClass</dt> + <dt><code>A_AfterClass</code></dt> <dd>AfterClass annotation, use for methods that should be invoked once for the fixture after all of its test cases.</dd> - <dt>A_Ignore</dt> + <dt><code>A_Ignore</code></dt> <dd> Ignore annotation, use for test cases to ignore. This annotation is only allowed for methods annotated as <code>A_Test</code>. </dd> - <dt>A_IGnoreR(reason)</dt> + <dt><code>A_IGnoreR(reason)</code></dt> <dd> Ignore annotation, use for test cases to ignore. This annotation is only allowed for methods annotated as <code>A_Test</code>. @@ -88,6 +88,15 @@ <dt>Test Fixture</dt> <dd>See <dfn>Fixture</dfn>.</dd> </dl> + <h2>The scheme of writing AceUnit tests</h2> + <p> + Writing AceUnit tests is easy, very easy. + </p> + <ul> + <li>Identify the symbol(s) that you want to test, e.g. <code>fooOp()</code> and <code>fooData</code> from <code>foo.c</code>.</li> + <li>Make sure that the symbols that you want to test are accessible.</li> + <li>Create a new C source, e.g. <code>fooTest.c</code>.</li> + </ul> <h2>Writing your first AceUnit test first software.</h2> <p> Our scenario is developing a sorting algorithm. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 17:37:22
|
Revision: 67 http://aceunit.svn.sourceforge.net/aceunit/?rev=67&view=rev Author: christianhujer Date: 2007-10-13 10:37:27 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Made uploadDoc dependend on transform so uploadDoc will upload uptodate documentation. Modified Paths: -------------- trunk/src/doc/build.xml Modified: trunk/src/doc/build.xml =================================================================== --- trunk/src/doc/build.xml 2007-10-13 17:21:53 UTC (rev 66) +++ trunk/src/doc/build.xml 2007-10-13 17:37:27 UTC (rev 67) @@ -80,7 +80,7 @@ </copy> </target> - <target name="uploadDoc"> + <target name="uploadDoc" depends="transform"> <exec executable="rsync" failonerror="true"> <arg line="-auzv -e ssh docs/ ${user.rsync.username}@${user.rsync.host}:${user.rsync.dir}/htdocs/" /> </exec> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 17:21:49
|
Revision: 66 http://aceunit.svn.sourceforge.net/aceunit/?rev=66&view=rev Author: christianhujer Date: 2007-10-13 10:21:53 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Improved manual. Modified Paths: -------------- trunk/src/doc/manual.xhtml Modified: trunk/src/doc/manual.xhtml =================================================================== --- trunk/src/doc/manual.xhtml 2007-10-13 16:47:04 UTC (rev 65) +++ trunk/src/doc/manual.xhtml 2007-10-13 17:21:53 UTC (rev 66) @@ -16,6 +16,78 @@ AceUnit is JUnit 4.x style, easy, modular and flexible. AceUnit can be used in resource constraint environments, e.g. embedded software development. </p> + <h2>Variants of Unit Test Declaration</h2> + <p> + AceUnit supports <!--two-->the following styles of declaring unit tests: + </p> + <ul> + <li>Declaring test methods with annotations, e.g. <code><em>A_Test</em> void someTest() {...}</code></li> + <!--li>Declaring test methods with a naming convention, e.g. <code>void <em>test</em>Something() {...}</code></li--> + </ul> + <h3>Annotation based testing</h3> + <p> + When declaring tests with annotations, the following annotations are available: + </p> + <dl> + <!-- Keep the descriptions of the annotations in sync with those in AceUnitAnnotations.h --> + <dt>A_Test</dt> + <dd>Test annotation, use for test cases.</dd> + <dt>A_Before</dt> + <dd>Before annotation, use for methods that should be invoked before each test case in a fixture.</dd> + <dt>A_After</dt> + <dd>After annotation, use for methods that should be invoked after each test case in a fixture.</dd> + <dt>A_BeforeClass</dt> + <dd>BeforeClass annotation, use for methods that should be invoked once for the fixture before all of its test cases.</dd> + <dt>A_AfterClass</dt> + <dd>AfterClass annotation, use for methods that should be invoked once for the fixture after all of its test cases.</dd> + <dt>A_Ignore</dt> + <dd> + Ignore annotation, use for test cases to ignore. + This annotation is only allowed for methods annotated as <code>A_Test</code>. + </dd> + <dt>A_IGnoreR(reason)</dt> + <dd> + Ignore annotation, use for test cases to ignore. + This annotation is only allowed for methods annotated as <code>A_Test</code>. + <br /> + <code>reason</code>: Description of the reason why this test case is currently ignored. + </dd> + </dl> + <!-- + <h3>Naming Convention based testing</h3> + <p> + When using the naming convention, the following naming conventions are used: + </p> + <dl> + <dt>test*</dt> + <dd>A test case method.</dd> + <dt>before*</dt> + <dd>Before method, should be invoked before each test case in a fixture. Note: "*" must not match "Class*".</dd> + <dt>after*</dt> + <dd>After method, should be invoked after each test case in a fixture. Note: "*" must not match "Class*".</dd> + <dt>beforeClass*</dt> + <dd>BeforeClass method, should be invoked once for the fixture before all of its test cases.</dd> + <dt>afterClass*</dt> + <dd>AfterClass method, should be invoked once for the fixture after all of its test cases.</dd> + </dl> + --> + <h2>AceUnit Glossary</h2> + <dl> + <dt>Annotation</dt> + <dd>A C preprocessor macro that is defined empty for the compiler but meaningful for the AceUnit test code generator.</dd> + <dt>Class</dt> + <dd>See <dfn>Fixture</dfn>.</dd> + <dt>Fixture</dt> + <dd>A fixture, aka Test Class, is a collection of tests along with operations that shall be performed before or after all or each of the tests contained in the fixture.</dd> + <dt>Test</dt> + <dd>A single test case is a simple C function that will be called to perform the test.</dd> + <dt>Test Case</dt> + <dd>See <dfn>Test</dfn>.</dd> + <dt>Test Class</dt> + <dd>See <dfn>Fixture</dfn>.</dd> + <dt>Test Fixture</dt> + <dd>See <dfn>Fixture</dfn>.</dd> + </dl> <h2>Writing your first AceUnit test first software.</h2> <p> Our scenario is developing a sorting algorithm. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 16:47:03
|
Revision: 65 http://aceunit.svn.sourceforge.net/aceunit/?rev=65&view=rev Author: christianhujer Date: 2007-10-13 09:47:04 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Extracted AceUnitAnnotations.h as separate header file. Modified Paths: -------------- trunk/src/doc/examples/sort/Makefile trunk/src/native/AceUnit.h Added Paths: ----------- trunk/src/native/AceUnitAnnotations.h Property Changed: ---------------- trunk/src/doc/examples/sort/ Property changes on: trunk/src/doc/examples/sort ___________________________________________________________________ Name: svn:ignore - AceUnit.jar FullPlainLogger.c AceUnit.c sortTest.h AceUnit.h runTests + AceUnit.jar FullPlainLogger.c AceUnit.c sortTest.h AceUnit.h runTests AceUnitAnnotations.h Modified: trunk/src/doc/examples/sort/Makefile =================================================================== --- trunk/src/doc/examples/sort/Makefile 2007-10-13 16:32:59 UTC (rev 64) +++ trunk/src/doc/examples/sort/Makefile 2007-10-13 16:47:04 UTC (rev 65) @@ -3,9 +3,9 @@ all: prepare compile clean: - rm -f AceUnit.c AceUnit.h FullPlainLogger.c AceUnit.jar sortTest.h runTests + rm -f AceUnit.c AceUnit.h AceUnitAnnotations.h FullPlainLogger.c AceUnit.jar sortTest.h runTests -prepare: AceUnit.c AceUnit.h FullPlainLogger.c +prepare: AceUnit.c AceUnit.h AceUnitAnnotations.h FullPlainLogger.c AceUnit.c: $(ACE_UNIT_PATH)/native/AceUnit.c cp $< $@ @@ -13,6 +13,9 @@ AceUnit.h: $(ACE_UNIT_PATH)/native/AceUnit.h cp $< $@ +AceUnitAnnotations.h: $(ACE_UNIT_PATH)/native/AceUnitAnnotations.h + cp $< $@ + FullPlainLogger.c: $(ACE_UNIT_PATH)/native/FullPlainLogger.c cp $< $@ Modified: trunk/src/native/AceUnit.h =================================================================== --- trunk/src/native/AceUnit.h 2007-10-13 16:32:59 UTC (rev 64) +++ trunk/src/native/AceUnit.h 2007-10-13 16:47:04 UTC (rev 65) @@ -33,15 +33,7 @@ #include <stdint.h> #endif -/** The super type of annotations. - * Annotations are either ignored by the compiler or you can declare them to create static methods. - * To use the latter, define ACEUNIT_STATIC_ANNOTATIONS. - */ -#ifdef ACEUNIT_STATIC_ANNOTATIONS -#define ACEUNIT_ANNOTATION static -#else -#define ACEUNIT_ANNOTATION -#endif +#include "AceUnitAnnotations.h" /** FixtureId_t specifies a test fixture. * On embedded systems, this is a 16 bit quantity that uniquely identifies the test fixture. @@ -73,32 +65,6 @@ typedef const char* AssertionId_t; #endif -/** Test annotation, use for test cases. */ -#define A_Test ACEUNIT_ANNOTATION - -/** Before annotation, use for methods that should be invoked before each test case in a fixture. */ -#define A_Before ACEUNIT_ANNOTATION - -/** After annotation, use for methods that should be invoked after each test case in a fixture. */ -#define A_After ACEUNIT_ANNOTATION - -/** BeforeClass annotation, use for methods that should be invoked once for the fixture before all of its test cases. */ -#define A_BeforeClass ACEUNIT_ANNOTATION - -/** AfterClass annotation, use for methods that should be invoked once for the fixture after all of its test cases. */ -#define A_AfterClass ACEUNIT_ANNOTATION - -/** Ignore annotation, use for test cases to ignore. - * This annotation is only allowed for methods annotated as {@link #A_Test}. - */ -#define A_Ignore ACEUNIT_ANNOTATION - -/** Ignore annotation, use for test cases to ignore. - * This annotation is only allowed for methods annotated as {@link #A_Test}. - * @param reason Description of the reason why this test case is currently ignored. - */ -#define A_IgnoreR(reason) ACEUNIT_ANNOTATION - /** Creates a new assertion error. * @param message Message to create. */ Added: trunk/src/native/AceUnitAnnotations.h =================================================================== --- trunk/src/native/AceUnitAnnotations.h (rev 0) +++ trunk/src/native/AceUnitAnnotations.h 2007-10-13 16:47:04 UTC (rev 65) @@ -0,0 +1,67 @@ +/* Copyright (c) 2007, Christian Hujer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the AceUnit developers nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** AceUnit Annotations header file. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @file AceUnit.h + */ + +/** The super type of annotations. + * Annotations are either ignored by the compiler or you can declare them to create static methods. + * To use the latter, define ACEUNIT_STATIC_ANNOTATIONS. + */ +#ifdef ACEUNIT_STATIC_ANNOTATIONS +#define ACEUNIT_ANNOTATION static +#else +#define ACEUNIT_ANNOTATION +#endif + +/** Test annotation, use for test cases. */ +#define A_Test ACEUNIT_ANNOTATION + +/** Before annotation, use for methods that should be invoked before each test case in a fixture. */ +#define A_Before ACEUNIT_ANNOTATION + +/** After annotation, use for methods that should be invoked after each test case in a fixture. */ +#define A_After ACEUNIT_ANNOTATION + +/** BeforeClass annotation, use for methods that should be invoked once for the fixture before all of its test cases. */ +#define A_BeforeClass ACEUNIT_ANNOTATION + +/** AfterClass annotation, use for methods that should be invoked once for the fixture after all of its test cases. */ +#define A_AfterClass ACEUNIT_ANNOTATION + +/** Ignore annotation, use for test cases to ignore. + * This annotation is only allowed for methods annotated as {@link #A_Test}. + */ +#define A_Ignore ACEUNIT_ANNOTATION + +/** Ignore annotation, use for test cases to ignore. + * This annotation is only allowed for methods annotated as {@link #A_Test}. + * @param reason Description of the reason why this test case is currently ignored. + */ +#define A_IgnoreR(reason) ACEUNIT_ANNOTATION Property changes on: trunk/src/native/AceUnitAnnotations.h ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 16:32:56
|
Revision: 64 http://aceunit.svn.sourceforge.net/aceunit/?rev=64&view=rev Author: christianhujer Date: 2007-10-13 09:32:59 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Added logger stub. Modified Paths: -------------- trunk/src/native/AceUnit.h Modified: trunk/src/native/AceUnit.h =================================================================== --- trunk/src/native/AceUnit.h 2007-10-13 15:00:26 UTC (rev 63) +++ trunk/src/native/AceUnit.h 2007-10-13 16:32:59 UTC (rev 64) @@ -76,16 +76,16 @@ /** Test annotation, use for test cases. */ #define A_Test ACEUNIT_ANNOTATION -/** Before annotation, use for methods that should be invoked before each test case. */ +/** Before annotation, use for methods that should be invoked before each test case in a fixture. */ #define A_Before ACEUNIT_ANNOTATION -/** After annotation, use for methods that should be invoked after each test case. */ +/** After annotation, use for methods that should be invoked after each test case in a fixture. */ #define A_After ACEUNIT_ANNOTATION -/** BeforeClass annotation, use for methods that should be invoked once for the fixture before all test cases. */ +/** BeforeClass annotation, use for methods that should be invoked once for the fixture before all of its test cases. */ #define A_BeforeClass ACEUNIT_ANNOTATION -/** AfterClass annotation, use for methods that should be invoked once for the fixture after all test cases. */ +/** AfterClass annotation, use for methods that should be invoked once for the fixture after all of its test cases. */ #define A_AfterClass ACEUNIT_ANNOTATION /** Ignore annotation, use for test cases to ignore. @@ -230,3 +230,20 @@ #else #define TM(X) { #X, &X } #endif + +/** A Logger logs events during test execution. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +typedef struct { + + // TODO: method that the runner started running. + // TODO: method that the runner starts a suite. + // TODO: method that the runner starts a fixture. + // TODO: method that the runner starts a testcase. + // TODO: method that the runner failed a testcase. + // TODO: method that the runner ends a testcase. + // TODO: method that the runner ends a fixture. + // TODO: method that the runner ends a suite. + // TODO: method that the runner stopped running. + +} TestLogger_t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 15:00:26
|
Revision: 63 http://aceunit.svn.sourceforge.net/aceunit/?rev=63&view=rev Author: christianhujer Date: 2007-10-13 08:00:26 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Extracted MethodLists class from GenTest. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java Added Paths: ----------- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java trunk/src/java/src/tst/test/net/sf/aceunit/MethodListsTest.java Modified: trunk/src/java/src/prj/net/sf/aceunit/GenTest.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-13 14:55:15 UTC (rev 62) +++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-13 15:00:26 UTC (rev 63) @@ -31,7 +31,6 @@ import java.io.FileReader; import java.io.IOException; import java.io.PrintStream; -import java.util.Arrays; import java.util.List; import net.sf.japi.io.args.ArgParser; import net.sf.japi.io.args.BasicCommand; @@ -44,26 +43,8 @@ */ public class GenTest<T extends Appendable> extends BasicCommand { - /** The list of {@code @Test} methods. */ - private final MethodList testMethods = new MethodList("A_Test"); - - /** The list of {@code @Before} methods. */ - private final MethodList beforeMethods = new MethodList("A_Before"); - - /** The list of {@code @After} methods. */ - private final MethodList afterMethods = new MethodList("A_After"); - - /** The list of {@code @BeforeClass} methods. */ - private final MethodList beforeClassMethods = new MethodList("A_BeforeClass"); - - /** The list of {@code @AfterClass} methods. */ - private final MethodList afterClassMethods = new MethodList("A_AfterClass"); - - /** The list of {@code @Ignore} methods. */ - private final MethodList ignoreMethods = new MethodList("A_Ignore"); - /** All method lists for easy iteration. */ - private final List<MethodList> methodLists = Arrays.asList(testMethods, beforeMethods, afterMethods, beforeClassMethods, afterClassMethods, ignoreMethods); + private final MethodLists methodLists = new MethodLists(); /** Output to write to. */ private final T out; @@ -91,34 +72,10 @@ */ private void perform(@NotNull final String basename) throws IOException { final String cSource = readSource(basename + ".c"); - findMethods(cSource); - out.append("TestCase_t testCase[] = {\n"); - for (final String testMethod : testMethods) { - out.append(" TM(").append(testMethod).append("),\n"); - } - out.append(" {NULL, NULL}\n};\n"); - appendMethods(out, "before", beforeMethods); - appendMethods(out, "after", afterMethods); - appendMethods(out, "beforeClass", beforeClassMethods); - appendMethods(out, "afterClass", afterClassMethods); - out.append("\n"); - out.append("TestFixture_t ").append(basename).append("Fixture = {\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); + methodLists.findMethods(cSource); + out.append(methodLists.getFixtureCode(basename)); } - /** Appends the method list to the specified output. - * @param out Output to append method list to. - * @param key Key for which to append the method list, used as variable name. - * @param methods List with methods to append. - * @throws IOException in case of I/O problems. - */ - private void appendMethods(@NotNull final T out, @NotNull final String key, @NotNull final MethodList methods) throws IOException { - out.append("testMethod_t ").append(key).append("[] = {\n"); - for (final String method : methods) { - out.append(" &").append(method).append(",\n"); - } - out.append(" NULL\n};\n"); - } - /** Reads a source file. * @param filename Filename of the source to read. * @return String with the contents of the specified file. @@ -136,22 +93,12 @@ return sb.toString(); } - /** Finds all methods of all method lists in the specified source. - * @param cSource C source to search. - */ - private void findMethods(@NotNull final String cSource) { - for (final MethodList methodList : methodLists) { - methodList.findMethods(cSource); - } - testMethods.removeAll(ignoreMethods); - } - /** {@inheritDoc} */ - public int run(@NotNull final List<String> strings) throws Exception { - if (strings.size() == 0) { + public int run(@NotNull final List<String> args) throws Exception { + if (args.size() == 0) { help(); } - for (final String basename : strings) { + for (final String basename : args) { perform(basename); } return 0; Added: trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java (rev 0) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java 2007-10-13 15:00:26 UTC (rev 63) @@ -0,0 +1,88 @@ +package net.sf.aceunit; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import org.jetbrains.annotations.NotNull; + +/** Handles all test related methods. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MethodLists { + + /** The list of {@code @Test} methods. */ + private final MethodList testMethods = new MethodList("A_Test"); + + /** The list of {@code @Before} methods. */ + private final MethodList beforeMethods = new MethodList("A_Before"); + + /** The list of {@code @After} methods. */ + private final MethodList afterMethods = new MethodList("A_After"); + + /** The list of {@code @BeforeClass} methods. */ + private final MethodList beforeClassMethods = new MethodList("A_BeforeClass"); + + /** The list of {@code @AfterClass} methods. */ + private final MethodList afterClassMethods = new MethodList("A_AfterClass"); + + /** The list of {@code @Ignore} methods. */ + private final MethodList ignoreMethods = new MethodList("A_Ignore"); + + /** All method lists for easy iteration. */ + private final List<MethodList> methodLists = Arrays.asList(testMethods, beforeMethods, afterMethods, beforeClassMethods, afterClassMethods, ignoreMethods); + + /** Creates MethodLists. */ + public MethodLists() { + } + + /** Returns an unmodifiable view of all method lists. + * @return All method lists. + */ + public Collection<MethodList> getMethodLists() { + return methodLists; + } + + /** Finds all methods of all method lists in the specified source. + * @param cSource C source to search. + */ + public void findMethods(@NotNull final String cSource) { + for (final MethodList methodList : methodLists) { + methodList.findMethods(cSource); + } + testMethods.removeAll(ignoreMethods); + } + + /** Returns a String representing the C-Source code for the fixture. + * @param basename Base name of the fixture. + * @return String with the C-Source for the fixture. + */ + public String getFixtureCode(@NotNull final String basename) { + final StringBuilder out = new StringBuilder(); + out.append("TestCase_t testCase[] = {\n"); + for (final String testMethod : testMethods) { + out.append(" TM(").append(testMethod).append("),\n"); + } + out.append(" {NULL, NULL}\n};\n"); + appendMethods(out, "before", beforeMethods); + appendMethods(out, "after", afterMethods); + appendMethods(out, "beforeClass", beforeClassMethods); + appendMethods(out, "afterClass", afterClassMethods); + out.append("\n"); + out.append("TestFixture_t ").append(basename).append("Fixture = {\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); + return out.toString(); + } + + /** Appends the method list to the specified output. + * @param out Output to append method list to. + * @param key Key for which to append the method list, used as variable name. + * @param methods List with methods to append. + */ + private void appendMethods(@NotNull final StringBuilder out, @NotNull final String key, @NotNull final MethodList methods) { + out.append("testMethod_t ").append(key).append("[] = {\n"); + for (final String method : methods) { + out.append(" &").append(method).append(",\n"); + } + out.append(" NULL\n};\n"); + } + +} // class MethodLists Property changes on: trunk/src/java/src/prj/net/sf/aceunit/MethodLists.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java =================================================================== --- trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java 2007-10-13 14:55:15 UTC (rev 62) +++ trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java 2007-10-13 15:00:26 UTC (rev 63) @@ -35,7 +35,7 @@ */ public class GenTestTest { - // TODO + /** Tests that. */ @Test public void testDummy() {} } // class GenTestTest Added: trunk/src/java/src/tst/test/net/sf/aceunit/MethodListsTest.java =================================================================== --- trunk/src/java/src/tst/test/net/sf/aceunit/MethodListsTest.java (rev 0) +++ trunk/src/java/src/tst/test/net/sf/aceunit/MethodListsTest.java 2007-10-13 15:00:26 UTC (rev 63) @@ -0,0 +1,13 @@ +package test.net.sf.aceunit; + +import org.junit.Test; + +/** Unit Test for {@link net.sf.aceunit.MethodLists}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MethodListsTest { + + @Test + public void testDummy() {} + +} // class MethodListsTest Property changes on: trunk/src/java/src/tst/test/net/sf/aceunit/MethodListsTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 14:55:13
|
Revision: 62 http://aceunit.svn.sourceforge.net/aceunit/?rev=62&view=rev Author: christianhujer Date: 2007-10-13 07:55:15 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Simplified Makefile. Modified Paths: -------------- trunk/src/doc/examples/sort/Makefile Modified: trunk/src/doc/examples/sort/Makefile =================================================================== --- trunk/src/doc/examples/sort/Makefile 2007-10-13 12:02:04 UTC (rev 61) +++ trunk/src/doc/examples/sort/Makefile 2007-10-13 14:55:15 UTC (rev 62) @@ -25,7 +25,7 @@ compile: runTests sortTest.h: AceUnit.jar sortTest.c - java -cp AceUnit.jar net.sf.aceunit.GenTest sortTest >sortTest.h + java -jar AceUnit.jar sortTest >sortTest.h runTests: *.c *.h sortTest.h gcc -o runTests *.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-13 12:02:05
|
Revision: 61 http://aceunit.svn.sourceforge.net/aceunit/?rev=61&view=rev Author: christianhujer Date: 2007-10-13 05:02:04 -0700 (Sat, 13 Oct 2007) Log Message: ----------- Added Unit Tests. Modified Paths: -------------- trunk/src/java/AceUnit.iml trunk/src/java/AceUnit.ipr trunk/src/java/build.xml trunk/src/java/src/prj/net/sf/aceunit/MethodList.java Added Paths: ----------- trunk/src/java/lib/junit-4.4.jar trunk/src/java/src/tst/ trunk/src/java/src/tst/test/ trunk/src/java/src/tst/test/net/ trunk/src/java/src/tst/test/net/sf/ trunk/src/java/src/tst/test/net/sf/aceunit/ trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java trunk/src/java/src/tst/test/net/sf/aceunit/MethodListTest.java Property Changed: ---------------- trunk/src/java/ Property changes on: trunk/src/java ___________________________________________________________________ Name: svn:ignore - AceUnit.jar AceUnit.iws classes + AceUnit.jar AceUnit.iws classes docs Modified: trunk/src/java/AceUnit.iml =================================================================== --- trunk/src/java/AceUnit.iml 2007-10-12 18:52:44 UTC (rev 60) +++ trunk/src/java/AceUnit.iml 2007-10-13 12:02:04 UTC (rev 61) @@ -4,6 +4,7 @@ <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src/prj" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/tst" isTestSource="true" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> @@ -17,7 +18,7 @@ </library> </orderEntry> <orderEntry type="module-library"> - <library> + <library name="Annotations"> <CLASSES> <root url="jar://$MODULE_DIR$/lib/annotations.jar!/" /> </CLASSES> @@ -25,6 +26,15 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module-library"> + <library name="JUnit"> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/junit-4.4.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> <orderEntryProperties /> </component> <component name="copyright"> Modified: trunk/src/java/AceUnit.ipr =================================================================== --- trunk/src/java/AceUnit.ipr 2007-10-12 18:52:44 UTC (rev 60) +++ trunk/src/java/AceUnit.ipr 2007-10-13 12:02:04 UTC (rev 61) @@ -33,14 +33,6 @@ <entry name="?*.tld" /> </wildcardResourcePatterns> </component> - <component name="CompilerWorkspaceConfiguration"> - <option name="COMPILE_IN_BACKGROUND" value="false" /> - <option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true" /> - <option name="CLOSE_MESSAGE_VIEW_IF_SUCCESS" value="true" /> - <option name="COMPILE_DEPENDENT_FILES" value="false" /> - <option name="CLEAR_OUTPUT_DIRECTORY" value="false" /> - <option name="ASSERT_NOT_NULL" value="true" /> - </component> <component name="DependenciesAnalyzeManager"> <option name="myForwardDirection" value="false" /> </component> @@ -259,7 +251,7 @@ <option name="lastEditedConfigurable" value="Project 'Default (Template) Project'" /> </component> <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK"> - <output url="file://$PROJECT_DIR$/out" /> + <output url="file://$PROJECT_DIR$/classes" /> </component> <component name="ResourceManagerContainer"> <option name="myResourceBundles"> @@ -283,10 +275,6 @@ <component name="VcsDirectoryMappings"> <mapping directory="" vcs="svn" /> </component> - <component name="antWorkspaceConfiguration"> - <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" /> - <option name="FILTER_TARGETS" value="false" /> - </component> <component name="com.intellij.jsf.UserDefinedFacesConfigs"> <option name="USER_DEFINED_CONFIGS"> <value> Modified: trunk/src/java/build.xml =================================================================== --- trunk/src/java/build.xml 2007-10-12 18:52:44 UTC (rev 60) +++ trunk/src/java/build.xml 2007-10-13 12:02:04 UTC (rev 61) @@ -79,4 +79,59 @@ </jar> </target> + <target + name = "unittest" + description = "Performs the unit tests." + depends = "compile" + > + <mkdir dir="classes/test" /> + <mkdir dir="docs/test" /> + <javac + srcdir = "src/tst" + destdir = "classes/test" + encoding = "utf-8" + debug = "yes" + target = "1.5" + source = "1.5" + > + <classpath> + <pathelement location="classes/production" /> + <pathelement location="lib/annotations.jar" /> + <pathelement location="lib/japi-lib-argparser-trunk-627.jar" /> + <pathelement location="lib/junit-4.4.jar" /> + </classpath> + </javac> + <copy todir="classes/production"> + <fileset dir="src/prj"> + <include name="**/*.properties" /> + </fileset> + </copy> + <junit + fork="no" + printsummary="yes" + haltonfailure="yes" + > + <classpath> + <pathelement location="classes/production" /> + <pathelement location="classes/test" /> + <pathelement location="lib/annotations.jar" /> + <pathelement location="lib/japi-lib-argparser-trunk-627.jar" /> + <pathelement location="lib/junit-4.4.jar" /> + </classpath> + <formatter type="plain" /> + <formatter type="xml" /> + <batchtest todir="docs/test"> + <fileset dir="src/tst"> + <include name="test/**/*Test.java" /> + <exclude name="test/**/Abstract*Test.java" /> + </fileset> + </batchtest> + </junit> + <junitreport todir="docs/test"> + <fileset dir="docs/test"> + <include name="TEST-*.xml" /> + </fileset> + <report format="frames" todir="docs/test" /> + </junitreport> + </target> </project> Added: trunk/src/java/lib/junit-4.4.jar =================================================================== (Binary files differ) Property changes on: trunk/src/java/lib/junit-4.4.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodList.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2007-10-12 18:52:44 UTC (rev 60) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2007-10-13 12:02:04 UTC (rev 61) @@ -28,6 +28,8 @@ package net.sf.aceunit; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; @@ -37,7 +39,7 @@ /** A MethodList finds and contains all methods of a certain annotation type. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -class MethodList implements Iterable<String> { +public class MethodList implements Iterable<String> { /** The annotation to find. */ @NotNull private final String annotation; @@ -46,8 +48,11 @@ @NotNull private final Pattern pattern; /** The names of the methods found to be annotated. */ - @NotNull private final List<String> methodNames; + @NotNull private final List<String> methodNames = new ArrayList<String>(); + /** The unmodifiable view of {@link #methodNames}. */ + @NotNull private final Collection<String> unmodifiableMethodNames = Collections.unmodifiableCollection(methodNames); + /** Create a MethodList. * The MethodListis initially empty. * Invoke {@link #findMethods(String)} to fill this MethodList. @@ -56,9 +61,15 @@ public MethodList(@NotNull final String annotation) { this.annotation = annotation; this.pattern = Pattern.compile(annotation + "\\s+[^(]+?\\s+([^ (]+)\\("); - methodNames = new ArrayList<String>(); } + /** Returns the annotation this MethodList was created for. + * @return The annotation this MethodList was created for. + */ + @NotNull public String getAnnotation() { + return annotation; + } + /** Finds all annotated methods in the specified C source. * @param cSource C source to search. */ @@ -90,4 +101,11 @@ methodNames.removeAll(list.methodNames); } + /** Returns a collection with all method names. + * @return A collection with all method names. + */ + @NotNull public Collection<String> getMethodNames() { + return unmodifiableMethodNames; + } + } // class MethodList Added: trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java =================================================================== --- trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java (rev 0) +++ trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java 2007-10-13 12:02:04 UTC (rev 61) @@ -0,0 +1,41 @@ +/* Copyright (c) 2007, Christian Hujer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the AceUnit developers nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package test.net.sf.aceunit; + +import net.sf.aceunit.GenTest; +import org.junit.Test; + +/** Unit Test for {@link GenTest}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class GenTestTest { + + // TODO + @Test + public void testDummy() {} +} // class GenTestTest Property changes on: trunk/src/java/src/tst/test/net/sf/aceunit/GenTestTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/java/src/tst/test/net/sf/aceunit/MethodListTest.java =================================================================== --- trunk/src/java/src/tst/test/net/sf/aceunit/MethodListTest.java (rev 0) +++ trunk/src/java/src/tst/test/net/sf/aceunit/MethodListTest.java 2007-10-13 12:02:04 UTC (rev 61) @@ -0,0 +1,166 @@ +/* Copyright (c) 2007, Christian Hujer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the AceUnit developers nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package test.net.sf.aceunit; + +import java.util.ArrayList; +import java.util.List; +import net.sf.aceunit.MethodList; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** Unit Test for {@link MethodList}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MethodListTest { + + /** Tests that the annotation is properly returned. */ + @Test + public void testGetAnnotation() { + final MethodList methodList1 = new MethodList("A_Test"); + final MethodList methodList2 = new MethodList("A_Before"); + Assert.assertEquals("A_Test", methodList1.getAnnotation()); + Assert.assertEquals("A_Before", methodList2.getAnnotation()); + } + + /** Tests that a method list finds a single annotated methods. */ + @Test + public void testFindSingleAnnotatedMethod() { + final MethodList methodList = new MethodList("A_Test"); + final String cSource = "A_Test void test1() {}"; + methodList.findMethods(cSource); + Assert.assertTrue(methodList.contains("test1")); + Assert.assertEquals(1, methodList.getMethodNames().size()); + } + + /** Tests that a method list finds multiple annotated methods. */ + @Test + public void testFindMultipleAnnotatedMethod() { + final MethodList methodList = new MethodList("A_Test"); + final String cSource = "A_Test void test1() {} A_Test void test2() {} A_Test void test3() {}"; + methodList.findMethods(cSource); + Assert.assertTrue(methodList.contains("test1")); + Assert.assertTrue(methodList.contains("test2")); + Assert.assertTrue(methodList.contains("test3")); + Assert.assertEquals(3, methodList.getMethodNames().size()); + } + + /** Tests that a method list finds a single annotated methods even if surrounded by other methods. */ + @Test + public void testFindSingleAnnotatedMethod2() { + final MethodList methodList = new MethodList("A_Test"); + final String cSource = "void dummy1() {} A_Test void test1() {} void dummy2() {}"; + methodList.findMethods(cSource); + assertContains(methodList, "test1"); + assertNotContains(methodList, "dummy1", "dummy2"); + Assert.assertEquals(1, methodList.getMethodNames().size()); + } + + /** Tests that a method list finds multiple annotated methods even if surrounded by other methods. */ + @Test + public void testFindMultipleAnnotatedMethod2() { + final MethodList methodList = new MethodList("A_Test"); + final String cSource = "void dummy1() {} A_Test void test1() {} void dummy2() {} A_Test void test2() {} void dummy3() {} A_Test void test3() {} void dummy4() {}"; + methodList.findMethods(cSource); + assertContains(methodList, "test1", "test2", "test3"); + assertNotContains(methodList, "dummy1", "dummy2", "dummy3", "dummy4"); + Assert.assertEquals(3, methodList.getMethodNames().size()); + } + + /** Tests that removing a method list from another works. */ + @Test + public void testRemoveAll() { + final MethodList tests = new MethodList("A_Test"); + final MethodList ignore = new MethodList("A_Ignore"); + final String cSource = "void dummy1() {} A_Test void test1() {} void dummy2() {} A_Ignore A_Test void test2() {} void dummy3() {} A_Test A_Ignore void test3() {} void dummy4() {} A_Ignore void ignore1() {}"; + tests.findMethods(cSource); + ignore.findMethods(cSource); + + assertContainsOnly(tests, "test1", "test2", "test3"); + assertContainsOnly(ignore, "test2", "test3", "ignore1"); + + tests.removeAll(ignore); + + assertContainsOnly(tests, "test1"); + assertContainsOnly(ignore, "test2", "test3", "ignore1"); // ignore MUST NOT have been modified by removeAll() + } + + /** Tests that the returned iterator works correctly. */ + @Test + public void testIterator() { + final MethodList methodList = new MethodList("A_Test"); + final String cSource = "void dummy1() {} A_Test void test1() {} void dummy2() {} A_Test void test2() {} void dummy3() {} A_Test void test3() {} void dummy4() {}"; + methodList.findMethods(cSource); + final List<String> foundMethods = new ArrayList<String>(); + for (final String methodName : methodList) { + foundMethods.add(methodName); + } + Assert.assertTrue(foundMethods.contains("test1")); + Assert.assertTrue(foundMethods.contains("test2")); + Assert.assertTrue(foundMethods.contains("test3")); + Assert.assertEquals(3, foundMethods.size()); + } + + /** Asserts that a method list contains (at least) the specified method names. + * @param methodList Method list to check. + * @param methodNames Method names to check. + */ + private void assertContains(@NotNull final MethodList methodList, @NotNull final String... methodNames) { + for (final String methodName : methodNames) { + if (!methodList.contains(methodName)) { + Assert.fail("Expected methodList " + methodList + " to contain " + methodName); + } + } + } + + /** Asserts that a method list contains only the specified method names. + * @param methodList Method list to check. + * @param methodNames Method names to check. + */ + private void assertContainsOnly(@NotNull final MethodList methodList, @NotNull final String... methodNames) { + Assert.assertEquals(methodNames.length, methodList.getMethodNames().size()); + for (final String methodName : methodNames) { + if (!methodList.contains(methodName)) { + Assert.fail("Expected methodList " + methodList + " to contain " + methodName); + } + } + } + + /** Asserts that a method list does not contain the specified method names. + * @param methodList Method list to check. + * @param methodNames Method names to check. + */ + private void assertNotContains(@NotNull final MethodList methodList, @NotNull final String... methodNames) { + for (final String methodName : methodNames) { + if (methodList.contains(methodName)) { + Assert.fail("Expected methodList " + methodList + " to not contain " + methodName); + } + } + } + +} // class MethodListTest Property changes on: trunk/src/java/src/tst/test/net/sf/aceunit/MethodListTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-12 18:52:40
|
Revision: 60 http://aceunit.svn.sourceforge.net/aceunit/?rev=60&view=rev Author: christianhujer Date: 2007-10-12 11:52:44 -0700 (Fri, 12 Oct 2007) Log Message: ----------- Fixed bug in help footer. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties Modified: trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties 2007-10-12 18:33:22 UTC (rev 59) +++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties 2007-10-12 18:52:44 UTC (rev 60) @@ -25,4 +25,4 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. helpHeader=Usage: java -jar AceUnit.jar [OPTION] [BASENAME]...\nCreate AceUnit unit test headers for one or more modules with the specified basename (omit .c suffix).\n -helpFooter=Examples:\n java -jar AceUnit.jar sortTest >sortTest.h +helpFooter=Examples:\n java -jar AceUnit.jar sortTest >sortTest.h\n This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-12 18:33:24
|
Revision: 59 http://aceunit.svn.sourceforge.net/aceunit/?rev=59&view=rev Author: christianhujer Date: 2007-10-12 11:33:22 -0700 (Fri, 12 Oct 2007) Log Message: ----------- Turned GenTest into a Command. Modified Paths: -------------- trunk/src/java/build.xml trunk/src/java/src/prj/net/sf/aceunit/GenTest.java Added Paths: ----------- trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties Modified: trunk/src/java/build.xml =================================================================== --- trunk/src/java/build.xml 2007-10-12 18:15:15 UTC (rev 58) +++ trunk/src/java/build.xml 2007-10-12 18:33:22 UTC (rev 59) @@ -54,6 +54,11 @@ <pathelement location="lib/japi-lib-argparser-trunk-627.jar" /> </classpath> </javac> + <copy todir="classes/production"> + <fileset dir="src/prj"> + <include name="**/*.properties" /> + </fileset> + </copy> </target> <target Modified: trunk/src/java/src/prj/net/sf/aceunit/GenTest.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-12 18:15:15 UTC (rev 58) +++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-12 18:33:22 UTC (rev 59) @@ -33,6 +33,8 @@ import java.io.PrintStream; import java.util.Arrays; import java.util.List; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; import org.jetbrains.annotations.NotNull; /** Program for generating the code that's needed to execute a fixture. @@ -40,7 +42,7 @@ * The final version should be in C so a developer is not required to run Java in a C development environment. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class GenTest<T extends Appendable> { +public class GenTest<T extends Appendable> extends BasicCommand { /** The list of {@code @Test} methods. */ private final MethodList testMethods = new MethodList("A_Test"); @@ -63,21 +65,31 @@ /** All method lists for easy iteration. */ private final List<MethodList> methodLists = Arrays.asList(testMethods, beforeMethods, afterMethods, beforeClassMethods, afterClassMethods, ignoreMethods); + /** Output to write to. */ + private final T out; + /** Main program. * @param args Currently the first argument must be the base name of the file to create a fixture for, e.g. "example", without file ending. * @note the interface is subject of change. * @throws IOException in case of I/O problems. */ public static void main(@NotNull final String... args) throws IOException { - new GenTest<PrintStream>(args[0], System.out); + ArgParser.simpleParseAndRun(new GenTest<PrintStream>(System.out), args); } /** Creates a GenTest instance. - * @param basename Basename to generate test for. * @param out Where to write the generated results. * @throws IOException in case of I/O problems. */ - public GenTest(@NotNull final String basename, @NotNull final T out) throws IOException { + public GenTest(@NotNull final T out) throws IOException { + this.out = out; + } + + /** Performs the generation of a test. + * @param basename Basename to generate test for. + * @throws IOException in case of I/O problems. + */ + private void perform(@NotNull final String basename) throws IOException { final String cSource = readSource(basename + ".c"); findMethods(cSource); out.append("TestCase_t testCase[] = {\n"); @@ -134,4 +146,15 @@ testMethods.removeAll(ignoreMethods); } + /** {@inheritDoc} */ + public int run(@NotNull final List<String> strings) throws Exception { + if (strings.size() == 0) { + help(); + } + for (final String basename : strings) { + perform(basename); + } + return 0; + } + } // class GenTest Added: trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties (rev 0) +++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties 2007-10-12 18:33:22 UTC (rev 59) @@ -0,0 +1,28 @@ +# Copyright (c) 2007, Christian Hujer +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the AceUnit developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +helpHeader=Usage: java -jar AceUnit.jar [OPTION] [BASENAME]...\nCreate AceUnit unit test headers for one or more modules with the specified basename (omit .c suffix).\n +helpFooter=Examples:\n java -jar AceUnit.jar sortTest >sortTest.h Property changes on: trunk/src/java/src/prj/net/sf/aceunit/GenTest.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-10-12 18:15:11
|
Revision: 58 http://aceunit.svn.sourceforge.net/aceunit/?rev=58&view=rev Author: christianhujer Date: 2007-10-12 11:15:15 -0700 (Fri, 12 Oct 2007) Log Message: ----------- Added @Nullable / @NotNull annotations. Modified Paths: -------------- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java trunk/src/java/src/prj/net/sf/aceunit/MethodList.java Modified: trunk/src/java/src/prj/net/sf/aceunit/GenTest.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-12 18:11:35 UTC (rev 57) +++ trunk/src/java/src/prj/net/sf/aceunit/GenTest.java 2007-10-12 18:15:15 UTC (rev 58) @@ -33,6 +33,7 @@ import java.io.PrintStream; import java.util.Arrays; import java.util.List; +import org.jetbrains.annotations.NotNull; /** Program for generating the code that's needed to execute a fixture. * This is a prototype in Java. @@ -67,7 +68,7 @@ * @note the interface is subject of change. * @throws IOException in case of I/O problems. */ - public static void main(final String... args) throws IOException { + public static void main(@NotNull final String... args) throws IOException { new GenTest<PrintStream>(args[0], System.out); } @@ -76,7 +77,7 @@ * @param out Where to write the generated results. * @throws IOException in case of I/O problems. */ - public GenTest(final String basename, final T out) throws IOException { + public GenTest(@NotNull final String basename, @NotNull final T out) throws IOException { final String cSource = readSource(basename + ".c"); findMethods(cSource); out.append("TestCase_t testCase[] = {\n"); @@ -84,10 +85,10 @@ out.append(" TM(").append(testMethod).append("),\n"); } out.append(" {NULL, NULL}\n};\n"); - appendMethods(out, "before", beforeMethods); - appendMethods(out, "after", afterMethods); + appendMethods(out, "before", beforeMethods); + appendMethods(out, "after", afterMethods); appendMethods(out, "beforeClass", beforeClassMethods); - appendMethods(out, "afterClass", afterClassMethods); + appendMethods(out, "afterClass", afterClassMethods); out.append("\n"); out.append("TestFixture_t ").append(basename).append("Fixture = {\n testCase,\n before,\n after,\n beforeClass,\n afterClass\n};\n\n"); } @@ -98,7 +99,7 @@ * @param methods List with methods to append. * @throws IOException in case of I/O problems. */ - private void appendMethods(final T out, final String key, final MethodList methods) throws IOException { + private void appendMethods(@NotNull final T out, @NotNull final String key, @NotNull final MethodList methods) throws IOException { out.append("testMethod_t ").append(key).append("[] = {\n"); for (final String method : methods) { out.append(" &").append(method).append(",\n"); @@ -111,7 +112,7 @@ * @return String with the contents of the specified file. * @throws IOException in case of I/O problems. */ - private String readSource(final String filename) throws IOException { + private String readSource(@NotNull final String filename) throws IOException { final File f = new File(filename); final FileReader in = new FileReader(f); final StringBuilder sb = new StringBuilder(); @@ -126,7 +127,7 @@ /** Finds all methods of all method lists in the specified source. * @param cSource C source to search. */ - private void findMethods(final String cSource) { + private void findMethods(@NotNull final String cSource) { for (final MethodList methodList : methodLists) { methodList.findMethods(cSource); } Modified: trunk/src/java/src/prj/net/sf/aceunit/MethodList.java =================================================================== --- trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2007-10-12 18:11:35 UTC (rev 57) +++ trunk/src/java/src/prj/net/sf/aceunit/MethodList.java 2007-10-12 18:15:15 UTC (rev 58) @@ -27,11 +27,12 @@ package net.sf.aceunit; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.util.List; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; /** A MethodList finds and contains all methods of a certain annotation type. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -39,20 +40,20 @@ class MethodList implements Iterable<String> { /** The annotation to find. */ - private final String annotation; + @NotNull private final String annotation; /** The regular expression to use for finding annotated methods. */ - private final Pattern pattern; + @NotNull private final Pattern pattern; /** The names of the methods found to be annotated. */ - private final List<String> methodNames; + @NotNull private final List<String> methodNames; /** Create a MethodList. * The MethodListis initially empty. * Invoke {@link #findMethods(String)} to fill this MethodList. * @param annotation Annotation to find. */ - public MethodList(final String annotation) { + public MethodList(@NotNull final String annotation) { this.annotation = annotation; this.pattern = Pattern.compile(annotation + "\\s+[^(]+?\\s+([^ (]+)\\("); methodNames = new ArrayList<String>(); @@ -61,7 +62,7 @@ /** Finds all annotated methods in the specified C source. * @param cSource C source to search. */ - public void findMethods(final String cSource) { + public void findMethods(@NotNull final String cSource) { methodNames.clear(); final Matcher matcher = pattern.matcher(cSource); while (matcher.find()) { @@ -73,19 +74,19 @@ * @param methodName Method name to look for. * @return <code>true</code> if this MethodList contains a method with the specified name, otherwise <code>false</code>. */ - public boolean contains(final String methodName) { + public boolean contains(@NotNull final String methodName) { return methodNames.contains(methodName); } /** {@inheritDoc} */ - public Iterator<String> iterator() { + @NotNull public Iterator<String> iterator() { return methodNames.iterator(); } /** Removes from this MethodList all methods that are in the specified list. * @param list List with methods that should be removed from this MethodList. */ - public void removeAll(final MethodList list) { + public void removeAll(@NotNull final MethodList list) { methodNames.removeAll(list.methodNames); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |