diff options
author | Michele Papalini <micpapal+fdio@cisco.com> | 2017-02-24 08:00:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2017-02-24 08:00:33 +0000 |
commit | 4df7f4cc98b6288177df256e1db70ddc3f7d00db (patch) | |
tree | 55e71277b419e4830ae641868ab8e751c8b86972 /longbow/src/examples | |
parent | f28308bd99381ef5f1e178e2e1f870f245e35873 (diff) | |
parent | ec688b4723a041044226358bcd4dd6e2da39da49 (diff) |
Merge "Initial commit: cframework. Longbow and Libparc" into cframework/master
Diffstat (limited to 'longbow/src/examples')
28 files changed, 1503 insertions, 0 deletions
diff --git a/longbow/src/examples/.gitignore b/longbow/src/examples/.gitignore new file mode 100644 index 00000000..1b4775c8 --- /dev/null +++ b/longbow/src/examples/.gitignore @@ -0,0 +1,5 @@ +*.gcno +*.gcda +*.dSYM +*.gcov +testLongBow diff --git a/longbow/src/examples/example1.c b/longbow/src/examples/example1.c new file mode 100755 index 00000000..31bbadbf --- /dev/null +++ b/longbow/src/examples/example1.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * example1.c + * + */ + +#include <unistd.h> +#include <stdbool.h> +#include <signal.h> + +int +alwaysTrue() +{ + return true; +} + +int +alwaysFalse() +{ + return false; +} + +int +alwaysSignalled() +{ + kill(getpid(), SIGTERM); + return true; +} diff --git a/longbow/src/examples/minimal.c b/longbow/src/examples/minimal.c new file mode 100755 index 00000000..47f7e7fe --- /dev/null +++ b/longbow/src/examples/minimal.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * minimal.c + * + */ + +int +alwaysSucceed() +{ + return 1; +} diff --git a/longbow/src/examples/pointer.c b/longbow/src/examples/pointer.c new file mode 100755 index 00000000..0a0fef95 --- /dev/null +++ b/longbow/src/examples/pointer.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <LongBow/runtime.h> +#include <unistd.h> +#include <string.h> + +void +function(char *pointer) +{ + assertNotNull(pointer, "The pointer cannot be NULL."); + + write(1, pointer, strlen(pointer)); +} + +int +main(int argc, char *argv[]) +{ + function(0); +} diff --git a/longbow/src/examples/require.c b/longbow/src/examples/require.c new file mode 100755 index 00000000..31055aa8 --- /dev/null +++ b/longbow/src/examples/require.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include "../runtime.h" + +# define longBowAssert(eventPointer, condition, ...) \ + longBowRuntime_EventEvaluation(eventPointer); \ + if (longBowIsFalse(condition) && \ + (longBowRuntime_EventTrigger(eventPointer, longBowLocation_Create(__FILE__, longBow_function, __LINE__), #condition, __VA_ARGS__), true)) \ + for (; true; abort()) + + +int +main(int argc, char *argv[argc]) +{ + int condition = 1; + + longBowAssert(&LongBowAssertEvent, condition == 1, "Message %d", 2) + { + printf("Should not have Triggered\n"); + }; + longBowAssert(&LongBowAssertEvent, condition == 0, "Message %d", 2) + { + printf("Triggered\n"); + }; + + longBowAssert(&LongBowAssertEvent, condition == 0, "Message %d", 2); +} diff --git a/longbow/src/examples/testAssertion.c b/longbow/src/examples/testAssertion.c new file mode 100755 index 00000000..eb60db91 --- /dev/null +++ b/longbow/src/examples/testAssertion.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../runtime.h" + +int +main(int argc, char *argv[]) +{ + assertTrue(0, "Force this assertion."); +} diff --git a/longbow/src/examples/testClipboard.c b/longbow/src/examples/testClipboard.c new file mode 100755 index 00000000..1e6a5b94 --- /dev/null +++ b/longbow/src/examples/testClipboard.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + */ +#include <stdio.h> +#include <string.h> + +#include <LongBow/testing.h> +#include <LongBow/debugging.h> + +LONGBOW_TEST_RUNNER(testClipboard) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(testClipboard) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(testClipboard) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, testClipboard); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + char *testData = strdup("Hello World"); + longBowTestCase_SetClipBoardData(testCase, testData, free); + + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, testClipboard) +{ + char *testData = longBowTestCase_GetClipBoardData(testCase); + printf("Shared state '%s'\n", testData); +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(testClipboard); + int exitStatus = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + exit(exitStatus); +} diff --git a/longbow/src/examples/testExample1.c b/longbow/src/examples/testExample1.c new file mode 100755 index 00000000..d26294a1 --- /dev/null +++ b/longbow/src/examples/testExample1.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include "../unit-test.h" + +#include "example1.c" + +LONGBOW_TEST_RUNNER(example1) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); + LONGBOW_RUN_TEST_FIXTURE(Local); +} + +LONGBOW_TEST_RUNNER_SETUP(example1) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(example1) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, strlen); + LONGBOW_RUN_TEST_CASE(Global, alwaysFail); + LONGBOW_RUN_TEST_CASE(Global, alwaysSignalled); + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysFail) +{ + assertTrue(alwaysFalse(), "This test must always fail.") + { + printf("And this is extra code that is executed when the assertion fails"); + } +} + +LONGBOW_TEST_CASE(Global, alwaysSignalled) +{ + kill(getpid(), SIGTERM); +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + assertTrue(alwaysTrue(), "This test must always succeed."); +} + +LONGBOW_TEST_CASE(Global, strlen) +{ + assertNotNull(NULL, "Parameter must be a non-null char pointer."); +} + +LONGBOW_TEST_FIXTURE(Local) +{ +} + +LONGBOW_TEST_FIXTURE_SETUP(Local) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Local) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(example1); + exit(longBowMain(argc, argv, testRunner, NULL)); +} diff --git a/longbow/src/examples/testLongBow.c b/longbow/src/examples/testLongBow.c new file mode 100755 index 00000000..7c1fd949 --- /dev/null +++ b/longbow/src/examples/testLongBow.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * test_LongBow.c + * + */ + +#include <stdio.h> +#include <sys/types.h> +#include <signal.h> +#include <sys/errno.h> + +#include "../unit-test.h" + + +LONGBOW_TEST_RUNNER(LongBow) +{ + LONGBOW_RUN_TEST_FIXTURE(LongBowFixture); +} + +LONGBOW_TEST_RUNNER_SETUP(LongBow) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(LongBow) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(LongBowFixture) +{ + LONGBOW_RUN_TEST_CASE(LongBowFixture, alwaysSucceed); + LONGBOW_RUN_TEST_CASE(LongBowFixture, alwaysUnimplemented); + LONGBOW_RUN_TEST_CASE(LongBowFixture, alwaysImpotent); +} + +LONGBOW_TEST_FIXTURE_SETUP(LongBowFixture) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(LongBowFixture) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(LongBowFixture, testErrno) +{ + errno = ENOENT; + assertTrue(0, "Errno test"); +} + +LONGBOW_TEST_CASE(LongBowFixture, alwaysSucceed) +{ + assertTrue(1, "alwaysSucceed"); +} + +LONGBOW_TEST_CASE(LongBowFixture, alwaysImpotent) +{ +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, testEvent, .event = &LongBowAssertEvent) +{ + assertTrue(0, "testEvent"); +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, alwaysFail, .status = LONGBOW_STATUS_FAILED, .event = &LongBowAssertEvent) +{ + assertTrue(0, "alwaysFail"); +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, alwaysSigTERM, .status = LONGBOW_STATUS_SIGNAL(SIGTERM)) +{ + kill(getpid(), SIGTERM); +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, alwaysSEGV, .event = &LongBowEventSIGSEGV) +{ + int *p = 0; + int i = *p; + printf("not used %d\n", i); +} + +LONGBOW_TEST_CASE(LongBowFixture, alwaysUnimplemented) +{ + testUnimplemented("alwaysUnimplemented"); +} + +LONGBOW_TEST_CASE(LongBowFixture, alwaysWarn) +{ + testWarn("alwaysWarn"); +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, alwaysSkip, .event = &LongBowTestSkippedEvent) +{ + testSkip("alwaysSkip"); +} + +LONGBOW_TEST_CASE_EXPECTS(LongBowFixture, alwaysTrap, .status = LONGBOW_STATUS_FAILED) +{ + trapNotImplemented("alwaysTrap"); +} + +LONGBOW_TEST_FIXTURE(TestTearDownWarning) +{ + LONGBOW_RUN_TEST_CASE(TestTearDownWarning, alwaysFail); + LONGBOW_RUN_TEST_CASE(TestTearDownWarning, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(TestTearDownWarning) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(TestTearDownWarning) +{ + return LONGBOW_STATUS_TEARDOWN_WARNED; +} + +LONGBOW_TEST_CASE(TestTearDownWarning, alwaysFail) +{ + assertTrue(0, "alwaysFail"); +} + +LONGBOW_TEST_CASE(TestTearDownWarning, alwaysSucceed) +{ + assertTrue(1, "alwaysSucceed"); +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(LongBow); + int status = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + + exit(status); +} diff --git a/longbow/src/examples/testRunnerSkipped.c b/longbow/src/examples/testRunnerSkipped.c new file mode 100755 index 00000000..f071678d --- /dev/null +++ b/longbow/src/examples/testRunnerSkipped.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + */ + +#include <stdio.h> + +#include <LongBow/unit-test.h> + +LONGBOW_TEST_RUNNER(Example1) +{ + LONGBOW_RUN_TEST_FIXTURE(FixtureA); +} + +LONGBOW_TEST_RUNNER_SETUP(Example1) +{ + return LONGBOW_STATUS_SETUP_SKIPTESTS; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(Example1) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(FixtureA) +{ + LONGBOW_RUN_TEST_CASE(FixtureA, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(FixtureA) +{ + assertTrue(0, "This should have been skipped and never be called."); + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(FixtureA) +{ + assertTrue(0, "This should have been skipped and never be called."); + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(FixtureA, alwaysSucceed) +{ + assertTrue(0, "This should have been skipped and never be called."); +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(Example1); + int status = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + + exit(status); +} diff --git a/longbow/src/examples/testTearDown.c b/longbow/src/examples/testTearDown.c new file mode 100755 index 00000000..183563d9 --- /dev/null +++ b/longbow/src/examples/testTearDown.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + */ +#include <stdio.h> +#include <string.h> + +#include <LongBow/testing.h> +#include <LongBow/debugging.h> + +LONGBOW_TEST_RUNNER(testTearDown) +{ + LONGBOW_RUN_TEST_FIXTURE(Succeeded); + LONGBOW_RUN_TEST_FIXTURE(Warned); +} + +LONGBOW_TEST_RUNNER_SETUP(testTearDown) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(testTearDown) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Succeeded) +{ + LONGBOW_RUN_TEST_CASE(Succeeded, testTearDown); +} + +LONGBOW_TEST_FIXTURE_SETUP(Succeeded) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Succeeded) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Succeeded, testTearDown) +{ + assertTrue(true, ""); +} + + +LONGBOW_TEST_FIXTURE(Warned) +{ + LONGBOW_RUN_TEST_CASE(Warned, alwaysWarn); +} + +LONGBOW_TEST_FIXTURE_SETUP(Warned) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Warned) +{ + return LONGBOW_STATUS_TEARDOWN_WARNED; +} + +LONGBOW_TEST_CASE(Warned, alwaysWarn) +{ + assertTrue(true, ""); +} + + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(testTearDown); + int exitStatus = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + exit(exitStatus); +} diff --git a/longbow/src/examples/testUnimplemented.c b/longbow/src/examples/testUnimplemented.c new file mode 100755 index 00000000..3ccf18d1 --- /dev/null +++ b/longbow/src/examples/testUnimplemented.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../unit-test.h" + +LONGBOW_TEST_RUNNER(Unimplemented) +{ + LONGBOW_RUN_TEST_FIXTURE(Unimplemented); +} + +LONGBOW_TEST_RUNNER_SETUP(Unimplemented) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(Unimplemented) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Unimplemented) +{ + LONGBOW_RUN_TEST_CASE(Unimplemented, Unimplemented); +} + +LONGBOW_TEST_FIXTURE_SETUP(Unimplemented) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Unimplemented) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Unimplemented, Unimplemented) +{ + testUnimplemented("Unimplemented"); +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(Unimplemented); + int status = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + + exit(status); +} diff --git a/longbow/src/examples/test_minimal.c b/longbow/src/examples/test_minimal.c new file mode 100755 index 00000000..5089071c --- /dev/null +++ b/longbow/src/examples/test_minimal.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "../unit-test.h" + +#include "minimal.c" + +LONGBOW_TEST_RUNNER(Example1) +{ + LONGBOW_RUN_TEST_FIXTURE(FixtureA); +} + +LONGBOW_TEST_RUNNER_SETUP(Example1) +{ + return true; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(Example1) +{ + return true; +} + +LONGBOW_TEST_FIXTURE(FixtureA) +{ + LONGBOW_RUN_TEST_CASE(FixtureA, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(FixtureA) +{ + return true; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(FixtureA) +{ + return true; +} + +LONGBOW_TEST_CASE(FixtureA, alwaysSucceed) +{ + assertTrue(alwaysSucceed(), "This must always succeed."); +} + +int +main(int argc, char *argv[]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(Example1); + int status = longBowMain(argc, argv, testRunner, NULL); + longBowTestRunner_Destroy(&testRunner); + + exit(status); +} diff --git a/longbow/src/examples/tutorial/.gitignore b/longbow/src/examples/tutorial/.gitignore new file mode 100644 index 00000000..fb63b40b --- /dev/null +++ b/longbow/src/examples/tutorial/.gitignore @@ -0,0 +1,3 @@ +test_tutorial11 +test_tutorial12 +test_tutorial13 diff --git a/longbow/src/examples/tutorial/test_tutorial1.c b/longbow/src/examples/tutorial/test_tutorial1.c new file mode 100644 index 00000000..311b5357 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial1.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" diff --git a/longbow/src/examples/tutorial/test_tutorial10.c b/longbow/src/examples/tutorial/test_tutorial10.c new file mode 100644 index 00000000..2eb62dc4 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial10.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + bool result = alwaysSucceed(); + + assertTrue(result, "This test must always succeed."); +} + +int +main(int argc, char *argv[argc]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(myTutorialTest); + int status = LONGBOW_TEST_MAIN(argc, argv, testRunner); + + longBowTestRunner_Destroy(&testRunner); + exit(status); +} diff --git a/longbow/src/examples/tutorial/test_tutorial11.c b/longbow/src/examples/tutorial/test_tutorial11.c new file mode 100644 index 00000000..58d44ed4 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial11.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); + LONGBOW_RUN_TEST_CASE(Global, alwaysFail); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + bool result = alwaysSucceed(); + + assertTrue(result, "This test must always succeed."); +} + +LONGBOW_TEST_CASE(Global, alwaysFail) +{ + bool result = alwaysFail(); + + assertTrue(result, "This test will fail."); +} + +int +main(int argc, char *argv[argc]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(myTutorialTest); + int status = LONGBOW_TEST_MAIN(argc, argv, testRunner); + + longBowTestRunner_Destroy(&testRunner); + exit(status); +} diff --git a/longbow/src/examples/tutorial/test_tutorial12.c b/longbow/src/examples/tutorial/test_tutorial12.c new file mode 100644 index 00000000..63a2dc52 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial12.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Static); + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); + LONGBOW_RUN_TEST_CASE(Global, alwaysFail); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + bool result = alwaysSucceed(); + + assertTrue(result, "This test must always succeed."); +} + +LONGBOW_TEST_CASE(Global, alwaysFail) +{ + bool result = alwaysFail(); + + assertTrue(result, "This test will fail."); +} + + +LONGBOW_TEST_FIXTURE(Static) +{ + LONGBOW_RUN_TEST_CASE(Static, _privateFunction); +} + +LONGBOW_TEST_FIXTURE_SETUP(Static) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Static) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Static, _privateFunction) +{ + bool result = _privateFunction(); + + assertTrue(result, "This test must always succeed."); +} + +int +main(int argc, char *argv[argc]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(myTutorialTest); + int status = LONGBOW_TEST_MAIN(argc, argv, testRunner); + + longBowTestRunner_Destroy(&testRunner); + exit(status); +} diff --git a/longbow/src/examples/tutorial/test_tutorial13.c b/longbow/src/examples/tutorial/test_tutorial13.c new file mode 100644 index 00000000..6d35c9b6 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial13.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Static); + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); + LONGBOW_RUN_TEST_CASE(Global, alwaysFail); + LONGBOW_RUN_TEST_CASE(Global, blowUp); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + bool result = alwaysSucceed(); + + assertTrue(result, "This test must always succeed."); +} + +LONGBOW_TEST_CASE(Global, alwaysFail) +{ + bool result = alwaysFail(); + + assertTrue(result, "This test will fail."); +} + +LONGBOW_TEST_CASE_EXPECTS(Global, blowUp, .event = &LongBowEventSIGSEGV) +{ + blowUp(); + + assertTrue(false, "This will not be executed"); +} + + +LONGBOW_TEST_FIXTURE(Static) +{ + LONGBOW_RUN_TEST_CASE(Static, _privateFunction); +} + +LONGBOW_TEST_FIXTURE_SETUP(Static) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Static) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Static, _privateFunction) +{ + bool result = _privateFunction(); + + assertTrue(result, "This test must always succeed."); +} + +int +main(int argc, char *argv[argc]) +{ + LongBowRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(myTutorialTest); + int status = LONGBOW_TEST_MAIN(argc, argv, testRunner); + + longBowTestRunner_Destroy(&testRunner); + exit(status); +} diff --git a/longbow/src/examples/tutorial/test_tutorial2.c b/longbow/src/examples/tutorial/test_tutorial2.c new file mode 100644 index 00000000..68e1d39a --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial2.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> diff --git a/longbow/src/examples/tutorial/test_tutorial3.c b/longbow/src/examples/tutorial/test_tutorial3.c new file mode 100644 index 00000000..fb635846 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial3.c @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ +} diff --git a/longbow/src/examples/tutorial/test_tutorial4.c b/longbow/src/examples/tutorial/test_tutorial4.c new file mode 100644 index 00000000..b8461fe4 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial4.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} diff --git a/longbow/src/examples/tutorial/test_tutorial5.c b/longbow/src/examples/tutorial/test_tutorial5.c new file mode 100644 index 00000000..c51ba7ac --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial5.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} diff --git a/longbow/src/examples/tutorial/test_tutorial6.c b/longbow/src/examples/tutorial/test_tutorial6.c new file mode 100644 index 00000000..a87c2466 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial6.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ +} diff --git a/longbow/src/examples/tutorial/test_tutorial7.c b/longbow/src/examples/tutorial/test_tutorial7.c new file mode 100644 index 00000000..25601997 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial7.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} diff --git a/longbow/src/examples/tutorial/test_tutorial8.c b/longbow/src/examples/tutorial/test_tutorial8.c new file mode 100644 index 00000000..35fad611 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial8.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + diff --git a/longbow/src/examples/tutorial/test_tutorial9.c b/longbow/src/examples/tutorial/test_tutorial9.c new file mode 100644 index 00000000..c92fc459 --- /dev/null +++ b/longbow/src/examples/tutorial/test_tutorial9.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +* / + +#include "tutorial.c" + +#include <LongBow/unit-test.h> + + +LONGBOW_TEST_RUNNER(myTutorialTest) +{ + LONGBOW_RUN_TEST_FIXTURE(Global); +} + +LONGBOW_TEST_RUNNER_SETUP(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_RUNNER_TEARDOWN(myTutorialTest) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE(Global) +{ + LONGBOW_RUN_TEST_CASE(Global, alwaysSucceed); +} + +LONGBOW_TEST_FIXTURE_SETUP(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_FIXTURE_TEARDOWN(Global) +{ + return LONGBOW_STATUS_SUCCEEDED; +} + +LONGBOW_TEST_CASE(Global, alwaysSucceed) +{ + bool result = alwaysSucceed(); + + assertTrue(result, "This test must always succeed."); +} diff --git a/longbow/src/examples/tutorial/tutorial.c b/longbow/src/examples/tutorial/tutorial.c new file mode 100755 index 00000000..ff296423 --- /dev/null +++ b/longbow/src/examples/tutorial/tutorial.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <unistd.h> +#include <stdbool.h> +#include <signal.h> + +static bool +_privateFunction() +{ + return true; +} + +bool +alwaysSucceed() +{ + return _privateFunction(); +} + +bool +alwaysFail() +{ + return false; +} + +bool +blowUp() +{ + char *p = 0; + *p = 0; + + return true; +} |