diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-01-24 17:52:53 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-01-24 17:52:53 +0100 |
commit | c07ad72f016930e2aba6471d0e2e9625b935bf9a (patch) | |
tree | 03aa7b7c737a7a70321ef25d67c2fbd892cd76db /longbow/src/LongBow/test | |
parent | 9fc2b9ec49c54ec2d5f0164bbedc1c78732c464c (diff) |
Remove cframework files from master
Change-Id: I02f17ede1cf97986a8b8852ed6d6a28fc016f590
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'longbow/src/LongBow/test')
25 files changed, 0 insertions, 2365 deletions
diff --git a/longbow/src/LongBow/test/.gitignore b/longbow/src/LongBow/test/.gitignore deleted file mode 100644 index 182506bc..00000000 --- a/longbow/src/LongBow/test/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -*.gcda -*.gcno -*.gcov -*.longbow -*.log -test_longBow_ArrayList -test_longBow_Backtrace -test_longBow_Config -test_longBow_Debug -test_longBow_Fixture -test_longBow_Memory -test_longBow_Main -test_longBow_OpenFile -test_longBow_Report -test_longBow_Runner -test_longBow_Runtime -test_longBow_Status -test_longBow_TestCase -test_longBow_TestCaseClipBoard -test_longBow_Properties -test_longBow_UnitTesting -test_longBow_Empty -test_longBow_File -test_longBow_String -test_longBow_Thread -test_longBow_CommandLineOptions -test_longBow_Expected -test_assertions -test_longBow_Properties -test_longBow_MeasureTime diff --git a/longbow/src/LongBow/test/CMakeLists.txt b/longbow/src/LongBow/test/CMakeLists.txt deleted file mode 100644 index 5eba0444..00000000 --- a/longbow/src/LongBow/test/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Enable gcov output for the tests -add_definitions(--coverage) -set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " --coverage") - - -macro(AddTest testFile) - add_executable(${ARGV0} ${ARGV0}.c) - target_link_libraries(${ARGV0} longbow longbow-ansiterm) - add_test(${ARGV0} ${ARGV0}) - set_target_properties(${ARGV0} PROPERTIES FOLDER Test) -endmacro(AddTest) - -set(TestsExpectedToFail - test_longBow_Expected; -) - -# test_assertions; - -set(TestsExpectedToPass - test_MemoryLeaks; - test_longBow_ArrayList; - test_longBow_Config; - test_longBow_Fixture; - test_longBow_Memory; - test_longBow_Location; - test_fixtureConfiguration; - test_longBow_Backtrace; - test_longBow_CommandLineOptions; - test_longBow_Debug; - test_longBow_Main; - test_longBow_MeasureTime; - test_longBow_OpenFile; - test_longBow_Properties; - test_longBow_Runner; - test_longBow_Runtime; - test_longBow_Status; - test_longBow_String; - test_longBow_TestCase; - test_longBow_TestCaseClipBoard; - test_longBow_UnitTesting - ) - -foreach(test ${TestsExpectedToPass}) - AddTest(${test}) -endforeach() - -foreach(test ${TestsExpectedToFail}) - AddTest(${test}) - set_tests_properties(${test} PROPERTIES WILL_FAIL TRUE) -endforeach() - - diff --git a/longbow/src/LongBow/test/test_MemoryLeaks.c b/longbow/src/LongBow/test/test_MemoryLeaks.c deleted file mode 100755 index f5eb4160..00000000 --- a/longbow/src/LongBow/test/test_MemoryLeaks.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -#include <LongBow/testing.h> -#include <LongBow/debugging.h> - -#include <inttypes.h> - -#include "../private/longBow_Memory.h" - -LONGBOW_TEST_RUNNER(test_MemoryLeaks) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(test_MemoryLeaks) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(test_MemoryLeaks) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ -// LONGBOW_RUN_TEST_CASE(Global, myTest); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, myTest) -{ -} - -int -main(int argc, char *argv[argc]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_MemoryLeaks); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - assertTrue(longBowMemory_OutstandingAllocations() == 0, "Memory leaks %" PRId64, longBowMemory_OutstandingAllocations()); - - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_assertions.c b/longbow/src/LongBow/test/test_assertions.c deleted file mode 100755 index f20d0e5b..00000000 --- a/longbow/src/LongBow/test/test_assertions.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 <stdbool.h> - -int -main(int argc, char *argv[argc]) -{ - assertTrue(false, "Must fail."); -} diff --git a/longbow/src/LongBow/test/test_fixtureConfiguration.c b/longbow/src/LongBow/test/test_fixtureConfiguration.c deleted file mode 100755 index 92023f48..00000000 --- a/longbow/src/LongBow/test/test_fixtureConfiguration.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -#include <LongBow/testing.h> -#include <LongBow/debugging.h> - -LONGBOW_TEST_RUNNER(test_fixtureConfiguration) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(test_fixtureConfiguration) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(test_fixtureConfiguration) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_OPTIONS(Global, .enabled = false) -{ - LONGBOW_RUN_TEST_CASE(Global, myTest); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, myTest) -{ -} - -int -main(int argc, char *argv[argc]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_fixtureConfiguration); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_ArrayList.c b/longbow/src/LongBow/test/test_longBow_ArrayList.c deleted file mode 100644 index 5ce70885..00000000 --- a/longbow/src/LongBow/test/test_longBow_ArrayList.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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/testing.h> - -#include <stdio.h> -#include <stdint.h> -#include <inttypes.h> - -#include "../private/longBow_ArrayList.h" -#include "../private/longBow_Memory.h" - -// Include the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -LONGBOW_TEST_RUNNER(longBow_ArrayList) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_ArrayList) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_ArrayList) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, CreateDestroy); - LONGBOW_RUN_TEST_CASE(Global, longBowArrayList_Add); -} - -uint64_t _setupAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _setupAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - uint64_t leaks = longBowMemory_OutstandingAllocations() - _setupAllocations; - if (leaks != 0) { - printf("leaks %" PRId64 " allocations.\n", leaks); - } - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, CreateDestroy) -{ - LongBowArrayList *list = longBowArrayList_Create((void (*)(void **))longBowMemory_Deallocate); - - longBowArrayList_Destroy(&list); -} - -LONGBOW_TEST_CASE(Global, longBowArrayList_Add) -{ - LongBowArrayList *list = longBowArrayList_Create((void (*)(void **))longBowMemory_Deallocate); - - char *thing = longBowMemory_StringCopy("name"); - longBowArrayList_Add(list, thing); - - longBowArrayList_Destroy(&list); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_ArrayList); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Backtrace.c b/longbow/src/LongBow/test/test_longBow_Backtrace.c deleted file mode 100755 index 40582b85..00000000 --- a/longbow/src/LongBow/test/test_longBow_Backtrace.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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_Backtrace.h" - -#include <stdio.h> -#include "../testing.h" -#include <LongBow/private/longBow_Memory.h> - -// Include the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -LONGBOW_TEST_RUNNER(longBow_Backtrace) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Backtrace) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Backtrace) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, LongBowBacktrace_ToString); - LONGBOW_RUN_TEST_CASE(Global, longBowBacktrace_Create); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, LongBowBacktrace_ToString) -{ - LongBowBacktrace *backtrace = longBowBacktrace_Create(100, 0); - char *result = longBowBacktrace_ToString(backtrace); - - assertNotNull(result, "Expected non-null result from LongBowBacktrace_ToString()"); - - longBowMemory_Deallocate((void **) &result); - longBowBacktrace_Destroy(&backtrace); -} - -LONGBOW_TEST_CASE(Global, longBowBacktrace_Create) -{ - LongBowBacktrace *backtrace = longBowBacktrace_Create(100, 0); - assertNotNull(backtrace, "Expected non-null result from longBowBacktrace_Create()"); - longBowBacktrace_Destroy(&backtrace); - assertNull(backtrace, "Expected LongBowBacktrace_Destroy() to set the pointer to null"); - - backtrace = longBowBacktrace_Create(100, 1); - longBowBacktrace_Destroy(&backtrace); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Backtrace); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_CommandLineOptions.c b/longbow/src/LongBow/test/test_longBow_CommandLineOptions.c deleted file mode 100755 index b63375fe..00000000 --- a/longbow/src/LongBow/test/test_longBow_CommandLineOptions.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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/testing.h> -#include <LongBow/debugging.h> - -LONGBOW_TEST_RUNNER(test_longBow_CommandLineOptions) -{ - printf("test_longBow_CommandLineOptions\n"); - - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(testFixture); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(test_longBow_CommandLineOptions) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(test_longBow_CommandLineOptions) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(testFixture) -{ - printf(" testFixture\n"); - LONGBOW_RUN_TEST_CASE(testFixture, testCase); -} - -LONGBOW_TEST_FIXTURE_SETUP(testFixture) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(testFixture) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(testFixture, testCase) -{ - printf(" testCase\n"); -} - -int -main(int argc, char *argv[argc]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_longBow_CommandLineOptions); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Config.c b/longbow/src/LongBow/test/test_longBow_Config.c deleted file mode 100755 index 98589d32..00000000 --- a/longbow/src/LongBow/test/test_longBow_Config.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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/testing.h> - -#include <stdio.h> -#include <inttypes.h> - -#include <LongBow/longBow_Config.h> -#include "../private/longBow_Memory.h" - -LONGBOW_TEST_RUNNER(longBow_Config) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Config) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Config) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, CreateDestroy); -} - -uint64_t _setupAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _setupAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - uint64_t leaks = longBowMemory_OutstandingAllocations() - _setupAllocations; - if (leaks != 0) { - printf("leaks %" PRId64 " allocations.\n", leaks); - } - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, CreateDestroy) -{ - LongBowConfig *config = longBowConfig_Create(0, NULL, NULL); - - longBowConfig_Destroy(&config); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Config); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - if (longBowMemory_OutstandingAllocations() != 0) { - printf("%" PRId64 " allocation leaks.", longBowMemory_OutstandingAllocations()); - } - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Debug.c b/longbow/src/LongBow/test/test_longBow_Debug.c deleted file mode 100755 index 30805d4a..00000000 --- a/longbow/src/LongBow/test/test_longBow_Debug.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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/testing.h> - -// Include the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -LONGBOW_TEST_RUNNER(longBow_Debug) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Debug) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Debug) -{ - 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; -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Debug); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Expected.c b/longbow/src/LongBow/test/test_longBow_Expected.c deleted file mode 100755 index 7b49cb89..00000000 --- a/longbow/src/LongBow/test/test_longBow_Expected.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Expected) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Expected) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Expected) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, ExpectFailure); - LONGBOW_RUN_TEST_CASE(Global, ExpectSuccess); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE_EXPECTS(Global, ExpectSuccess, .event = &LongBowAssertEvent) -{ - assertTrue(false, "This must be successful by failing."); -} - -LONGBOW_TEST_CASE_EXPECTS(Global, ExpectFailure, .event = &LongBowAssertEvent) -{ - assertNull(NULL, "This must fail to fail."); -} - -int -main(int argc, char *argv[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Expected); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Fixture.c b/longbow/src/LongBow/test/test_longBow_Fixture.c deleted file mode 100644 index 599b4be5..00000000 --- a/longbow/src/LongBow/test/test_longBow_Fixture.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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 <inttypes.h> -#include <LongBow/testing.h> -#include <LongBow/private/longBow_Memory.h> - -LONGBOW_TEST_RUNNER(longBow_Fixture) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(CreateDestroy); - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Fixture) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Fixture) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(CreateDestroy) -{ - LONGBOW_RUN_TEST_CASE(CreateDestroy, LongBowTestFixture_Create_Destroy); -} - -LONGBOW_TEST_FIXTURE_SETUP(CreateDestroy) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(CreateDestroy) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(CreateDestroy, LongBowTestFixture_Create_Destroy) -{ - uint64_t allocations = longBowMemory_OutstandingAllocations(); - LongBowTestRunner *runner = longBowTestRunner_Create("runner", NULL, NULL, NULL); - - LongBowTestFixture *fixture = longBowTestFixture_Create(runner, "fixture", NULL, NULL, NULL); - assertNotNull(fixture, "Expected non-null result from LongBowTestFixture_Create"); - longBowTestFixture_Destroy(&fixture); - longBowTestRunner_Destroy(&runner); - assertTrue(longBowMemory_OutstandingAllocations() == allocations, - "Memory leaks %" PRId64, longBowMemory_OutstandingAllocations()); -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowTestFixture_GetRunner); - LONGBOW_RUN_TEST_CASE(Global, longBowTestFixture_GetClipBoard); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - LongBowTestRunner *runner = longBowTestRunner_Create("testRunner", NULL, NULL, NULL); - LongBowTestFixture *fixture = longBowTestFixture_Create(runner, "testFixture", NULL, NULL, NULL); - - longBowClipBoard_Set(testClipBoard, "runner", runner); - longBowClipBoard_Set(testClipBoard, "fixture", fixture); - longBowTestCase_SetClipBoardData(testCase, fixture); - - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - LongBowTestFixture *fixture = longBowTestCase_GetClipBoardData(testCase); - - LongBowTestRunner *runner = longBowTestFixture_GetRunner(fixture); - - longBowTestRunner_Destroy(&runner); - longBowTestFixture_Destroy(&fixture); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowTestFixture_GetRunner) -{ - LongBowTestRunner *xrunner = longBowClipBoard_Get(testClipBoard, "runner"); - LongBowTestFixture *xfixture = longBowClipBoard_Get(testClipBoard, "fixture"); - LongBowTestFixture *fixture = longBowTestCase_GetClipBoardData(testCase); - LongBowTestRunner *runner = longBowTestFixture_GetRunner(fixture); - - assertTrue(xrunner == runner, "Expected runner to be equal."); - assertTrue(xfixture == fixture, "Expected runner to be equal."); - - assertNotNull(runner, "Expected the test runner to not be null"); -} - -LONGBOW_TEST_CASE(Global, longBowTestFixture_GetClipBoard) -{ - LongBowTestFixture *fixture = longBowTestCase_GetClipBoardData(testCase); - LongBowClipBoard *clipboard = longBowTestFixture_GetClipBoard(fixture); - assertNotNull(clipboard, "Expected non-null result from longBowTestFixture_GetClipBoard"); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Fixture); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Location.c b/longbow/src/LongBow/test/test_longBow_Location.c deleted file mode 100755 index 9ed77079..00000000 --- a/longbow/src/LongBow/test/test_longBow_Location.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Location) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Location) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Location) -{ - 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; -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Location); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Main.c b/longbow/src/LongBow/test/test_longBow_Main.c deleted file mode 100755 index f8be93ed..00000000 --- a/longbow/src/LongBow/test/test_longBow_Main.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Main) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Main) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Main) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowMain); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowMain) -{ - LongBowStatus expected = LONGBOW_STATUS_SUCCEEDED; - - int actual = longBowMain(0, NULL, NULL); - assertTrue(expected == actual, "Expected %d, actual %d", expected, actual); -} - -int -main(int argc, char *argv[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Main); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_MeasureTime.c b/longbow/src/LongBow/test/test_longBow_MeasureTime.c deleted file mode 100644 index 294c7c60..00000000 --- a/longbow/src/LongBow/test/test_longBow_MeasureTime.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Runner. -#include "../longBow_MeasureTime.c" - -#include <stdint.h> -#include <inttypes.h> -#include <LongBow/private/longBow_Memory.h> -#include <LongBow/unit-test.h> - -LONGBOW_TEST_RUNNER(longBow_MeasureTime) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified here, but every test must be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Static); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_MeasureTime) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_MeasureTime) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime_CountDown); - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime_Report); - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime_Start); - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime_Stop); - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime_Destroy); - LONGBOW_RUN_TEST_CASE(Global, longBowMeasureTime); -} - -uint64_t _setupAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _setupAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - uint64_t leaks = longBowMemory_OutstandingAllocations() - _setupAllocations; - if (leaks != 0) { - printf("%s leaks %" PRId64 " allocations.\n", longBowTestCase_GetFullName(testCase), leaks); - return LONGBOW_STATUS_MEMORYLEAK; - } - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime_CountDown) -{ - LongBowMeasureTime *measure = longBowMeasureTime_Start(1); - assertTrue(measure->iterations == 1, "Expected iterations to be 1, actual %d", measure->iterations); - - longBowMeasureTime_CountDown(measure); - assertTrue(measure->iterations == 0, "Expected iterations to be 0, actual %d", measure->iterations); - - longBowMeasureTime_Destroy(&measure); -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime_Report) -{ - LongBowMeasureTime *measure = longBowMeasureTime_Start(1); - assertTrue(measure->iterations == 1, "Expected iterations to be 1, actual %d", measure->iterations); - - longBowMeasureTime_Report(measure, __FILE__, __func__, __LINE__); - - longBowMeasureTime_Destroy(&measure); -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime_Start) -{ - LongBowMeasureTime *measure = longBowMeasureTime_Start(1); - assertNotNull(measure, "Expected longBowMeasureTime_Start to return non-NULL result."); - - longBowMeasureTime_Destroy(&measure); -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime_Stop) -{ - LongBowMeasureTime *measure = longBowMeasureTime_Start(1); - assertNotNull(measure, "Expected longBowMeasureTime_Start to return non-NULL result."); - sleep(2); - longBowMeasureTime_Stop(measure); - - uint64_t nanos = longBowMeasureTime_GetNanoseconds(measure); - assertTrue(nanos >= 1000000000ULL, "Expected more than 1,000,000 ns to have elapsed."); - - longBowMeasureTime_Destroy(&measure); -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime_Destroy) -{ - LongBowMeasureTime *measure = longBowMeasureTime_Start(1); - assertNotNull(measure, "Expected longBowMeasureTime_Start to return non-NULL result."); - - longBowMeasureTime_Destroy(&measure); - assertNull(measure, "Expected longBowMeasureTime_Destroy to NULL the pointer."); -} - -LONGBOW_TEST_CASE(Global, longBowMeasureTime) -{ - longBowMeasureTime(1) - { - sleep(2); - } -} - -LONGBOW_TEST_FIXTURE(Static) -{ -} - -LONGBOW_TEST_FIXTURE_SETUP(Static) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Static) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -int -main(int argc, char *argv[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_MeasureTime); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Memory.c b/longbow/src/LongBow/test/test_longBow_Memory.c deleted file mode 100755 index d1943860..00000000 --- a/longbow/src/LongBow/test/test_longBow_Memory.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 "../private/longBow_Memory.c" - -#include <LongBow/unit-test.h> -#include <LongBow/debugging.h> - -LONGBOW_TEST_RUNNER(test_longBow_Memory) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(test_longBow_Memory) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(test_longBow_Memory) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowMemory_Allocate); - LONGBOW_RUN_TEST_CASE(Global, longBowMemory_Reallocate); - LONGBOW_RUN_TEST_CASE(Global, longBowMemory_StringCopy); -} - -static uint64_t _setupAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _setupAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - if (longBowMemory_OutstandingAllocations() != _setupAllocations) { - printf("%s Memory leak\n", longBowTestCase_GetFullName(testCase)); - return LONGBOW_STATUS_MEMORYLEAK; - } - - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowMemory_Allocate) -{ - void *memory = longBowMemory_Allocate(10); - assertNotNull(memory, "Return value from longBowMemory_Allocate(10) cannot be NULL."); - longBowMemory_Deallocate((void **) &memory); - assertNull(memory, "longBowMemory_Deallocated must NULL the pointer."); -} - -LONGBOW_TEST_CASE(Global, longBowMemory_Reallocate) -{ - void *memory = longBowMemory_Allocate(10); - assertNotNull(memory, "Return value from longBowMemory_Allocate(10) cannot be NULL."); - - memory = longBowMemory_Reallocate(memory, 100); - assertNotNull(memory, "Return value from longBowMemory_Reallocate cannot be NULL."); - - longBowMemory_Deallocate((void **) &memory); - assertNull(memory, "longBowMemory_Deallocated must NULL the pointer."); -} - -LONGBOW_TEST_CASE(Global, longBowMemory_Reallocate_NULL) -{ - void *memory = longBowMemory_Reallocate(NULL, 100); - assertNotNull(memory, "Return value from longBowMemory_Reallocate cannot be NULL."); - - longBowMemory_Deallocate((void **) &memory); - assertNull(memory, "longBowMemory_Deallocated must NULL the pointer."); -} - -LONGBOW_TEST_CASE(Global, longBowMemory_StringCopy) -{ - char *expected = "Hello World"; - - char *actual = longBowMemory_StringCopy(expected); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - longBowMemory_Deallocate((void **) &actual); -} - -int -main(int argc, char *argv[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_longBow_Memory); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_OpenFile.c b/longbow/src/LongBow/test/test_longBow_OpenFile.c deleted file mode 100755 index 2a881fdb..00000000 --- a/longbow/src/LongBow/test/test_longBow_OpenFile.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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/testing.h> -#include "../private/longBow_ArrayList.h" -#include "../private/longBow_OpenFile.h" - -LONGBOW_TEST_RUNNER(longBow_Files) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Files) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Files) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBow_OpenFiles); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBow_OpenFiles) -{ - LongBowArrayList *list = longBowOpenFile_CurrentlyOpen(); - assertTrue(longBowArrayList_Length(list) > 0, "Expected the number of open files to be > 0"); - - longBowArrayList_Destroy(&list); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Files); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Properties.c b/longbow/src/LongBow/test/test_longBow_Properties.c deleted file mode 100755 index 736a8141..00000000 --- a/longbow/src/LongBow/test/test_longBow_Properties.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Framework. - -#include <LongBow/testing.h> -#include <LongBow/debugging.h> - -#include <stdio.h> -#include <inttypes.h> - -#include <LongBow/longBow_Properties.h> -#include "../private/longBow_Memory.h" - -LONGBOW_TEST_RUNNER(test_longBow_Properties) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(test_longBow_Properties) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(test_longBow_Properties) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, CreateDestroy); - LONGBOW_RUN_TEST_CASE(Global, longBowProperties_Set); - LONGBOW_RUN_TEST_CASE(Global, longBowProperties_Get); - LONGBOW_RUN_TEST_CASE(Global, longBowProperties_Length); - LONGBOW_RUN_TEST_CASE(Global, longBowProperties_Exists); -} - -static uint64_t _setupAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _setupAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - uint64_t leaks = longBowMemory_OutstandingAllocations() - _setupAllocations; - if (leaks != 0) { - printf("%s leaks %" PRId64 " allocations.\n", longBowTestCase_GetFullName(testCase), leaks); - return LONGBOW_STATUS_MEMORYLEAK; - } - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, CreateDestroy) -{ - LongBowProperties *properties = longBowProperties_Create(); - longBowProperties_Destroy(&properties); -} - -LONGBOW_TEST_CASE(Global, longBowProperties_Set) -{ - LongBowProperties *properties = longBowProperties_Create(); - longBowProperties_Set(properties, "name", "value"); - longBowProperties_Destroy(&properties); -} - -LONGBOW_TEST_CASE(Global, longBowProperties_Get) -{ - LongBowProperties *properties = longBowProperties_Create(); - char *expected = "value"; - longBowProperties_Set(properties, "name", expected); - - const char *actual = longBowProperties_Get(properties, "name"); - - assertTrue(strcmp(expected, actual) == 0, "Expected %s, actual %s", expected, actual); - longBowProperties_Destroy(&properties); -} - -LONGBOW_TEST_CASE(Global, longBowProperties_Length) -{ - LongBowProperties *properties = longBowProperties_Create(); - assertTrue(longBowProperties_Length(properties) == 0, "Expected empty longBowProperties to be 0 length"); - - char *expected = "value"; - longBowProperties_Set(properties, "name", expected); - assertTrue(longBowProperties_Length(properties) == 1, "Expected longBowProperties to be 1 length"); - - const char *actual = longBowProperties_Get(properties, "name"); - - assertTrue(strcmp(expected, actual) == 0, "Expected %s, actual %s", expected, actual); - longBowProperties_Destroy(&properties); -} - -LONGBOW_TEST_CASE(Global, longBowProperties_Exists) -{ - char *expected = "value"; - - LongBowProperties *properties = longBowProperties_Create(); - assertFalse(longBowProperties_Exists(properties, expected), "Expected longBowProperties_Exists to be false"); - - longBowProperties_Set(properties, "name", expected); - assertTrue(longBowProperties_Exists(properties, "name"), "Expected longBowProperties_Exists to be true"); - - longBowProperties_Destroy(&properties); -} - -int -main(int argc, char *argv[argc]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(test_longBow_Properties); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Runner.c b/longbow/src/LongBow/test/test_longBow_Runner.c deleted file mode 100755 index 7d7492e9..00000000 --- a/longbow/src/LongBow/test/test_longBow_Runner.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Runner) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Runner) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Runner) -{ - 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; -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Runner); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Runtime.c b/longbow/src/LongBow/test/test_longBow_Runtime.c deleted file mode 100755 index b9d963e9..00000000 --- a/longbow/src/LongBow/test/test_longBow_Runtime.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Runtime) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Runtime) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Runtime) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowRuntime_StackTrace); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowRuntime_StackTrace) -{ - longBowRuntime_StackTrace(1); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Runtime); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_Status.c b/longbow/src/LongBow/test/test_longBow_Status.c deleted file mode 100755 index a1c01eb2..00000000 --- a/longbow/src/LongBow/test/test_longBow_Status.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_Status) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_Status) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_Status) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowStatus_ToString); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowStatus_ToString) -{ - char *expected; - char *actual; - - expected = "Succeeded"; - actual = longBowStatus_ToString(LONGBOW_STATUS_SUCCEEDED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Warning"; - actual = longBowStatus_ToString(LongBowStatus_WARNED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Tear Down Warning"; - actual = longBowStatus_ToString(LongBowStatus_TEARDOWN_WARNED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Skipped"; - actual = longBowStatus_ToString(LONGBOW_STATUS_SKIPPED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Unimplemented"; - actual = longBowStatus_ToString(LongBowStatus_UNIMPLEMENTED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Impotent"; - actual = longBowStatus_ToString(LongBowStatus_IMPOTENT); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Failed"; - actual = longBowStatus_ToString(LONGBOW_STATUS_FAILED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Stopped"; - actual = longBowStatus_ToString(LongBowStatus_STOPPED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Tear Down Failed"; - actual = longBowStatus_ToString(LONGBOW_STATUS_TEARDOWN_FAILED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Setup Failed"; - actual = longBowStatus_ToString(LONGBOW_STATUS_SETUP_FAILED); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - expected = "Memory Leak"; - actual = longBowStatus_ToString(LONGBOW_STATUS_MEMORYLEAK); - assertTrue(strcmp(expected, actual) == 0, "Expected '%s', actual '%s'", expected, actual); - free(actual); - - actual = longBowStatus_ToString(LongBowStatus_SIGNALLED + 1); - assertNotNull(actual, "Expected longBowStatus_ToString to return non-null value"); - free(actual); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_Status); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_String.c b/longbow/src/LongBow/test/test_longBow_String.c deleted file mode 100755 index 96750706..00000000 --- a/longbow/src/LongBow/test/test_longBow_String.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 the file(s) containing the functions to be tested. -// This permits internal static functions to be visible to this Test Runner. -#include <stdio.h> -#include <inttypes.h> - -#include "../private/longBow_String.c" - -#include <LongBow/unit-test.h> - -LONGBOW_TEST_RUNNER(longBow_String) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified here, but every test must be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Static); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_String) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_String) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowString_Create); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Append); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Append_Append); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Format); - - LONGBOW_RUN_TEST_CASE(Global, longBowString_StartsWith_True); - LONGBOW_RUN_TEST_CASE(Global, longBowString_StartsWith_False); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Tokenise); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Tokenise_empty); - LONGBOW_RUN_TEST_CASE(Global, longBowString_Tokenise_NULL); - LONGBOW_RUN_TEST_CASE(Global, longBowString_CoreDump); -} - -static uint64_t _outstandingAllocations; - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - _outstandingAllocations = longBowMemory_OutstandingAllocations(); - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - if (longBowMemory_OutstandingAllocations() > _outstandingAllocations) { - printf("%s: memory leak\n", longBowTestCase_GetName(testCase)); - return LONGBOW_STATUS_MEMORYLEAK; - } - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowString_Create) -{ - LongBowString *string = longBowString_Create(128); - assertNotNull(string, "Expected non-NULL result from longBowString_Create"); - - longBowString_Destroy(&string); - assertNull(string, "Expected the instance pointer to be NULL after longBowString_Destroy"); -} - -LONGBOW_TEST_CASE(Global, longBowString_Append) -{ - char *expected = "Hello World"; - LongBowString *string = longBowString_Create(0); - longBowString_Append(string, expected); - - assertTrue(strcmp(expected, string->buffer) == 0, - "Expected buffer to contain '%s', actual '%s'", expected, string->buffer); - longBowString_Destroy(&string); -} - -LONGBOW_TEST_CASE(Global, longBowString_Append_Append) -{ - char *expected = "Hello World"; - LongBowString *string = longBowString_Create(0); - longBowString_Append(string, "Hello"); - longBowString_Append(string, " "); - longBowString_Append(string, "World"); - - assertTrue(strcmp(expected, string->buffer) == 0, - "Expected buffer to contain '%s', actual '%s'", expected, string->buffer); - longBowString_Destroy(&string); -} - -LONGBOW_TEST_CASE(Global, longBowString_Format) -{ - char *expected = "Hello World"; - LongBowString *string = longBowString_Create(0); - longBowString_Format(string, "%s", expected); - - assertTrue(strcmp(expected, string->buffer) == 0, - "Expected buffer to contain '%s', actual '%s'", expected, string->buffer); - longBowString_Destroy(&string); -} - -LONGBOW_TEST_CASE(Global, longBowString_StartsWith_True) -{ - bool actual = longBowString_StartsWith("abcde", "abc"); - assertTrue(actual, "Expected true"); -} - -LONGBOW_TEST_CASE(Global, longBowString_StartsWith_False) -{ - bool actual = longBowString_StartsWith("abcde", "ayz"); - - assertFalse(actual, "Expected false"); -} - -LONGBOW_TEST_CASE(Global, longBowString_Tokenise) -{ - LongBowArrayList *actual = longBowString_Tokenise("--t.x=10", "-="); - - assertTrue(strcmp("t.x", longBowArrayList_Get(actual, 0)) == 0, - "Expected first token to be t.x, actual %s", (char *) longBowArrayList_Get(actual, 0)); - assertTrue(strcmp("10", longBowArrayList_Get(actual, 1)) == 0, - "Expected first token to be 10, actual %s", (char *) longBowArrayList_Get(actual, 1)); - - longBowArrayList_Destroy(&actual); -} - -LONGBOW_TEST_CASE(Global, longBowString_Tokenise_empty) -{ - LongBowArrayList *actual = longBowString_Tokenise("", "-="); - - assertTrue(longBowArrayList_Length(actual) == 0, "Expected zero length LongBowArrayList, actual %zd", longBowArrayList_Length(actual)); - - longBowArrayList_Destroy(&actual); -} - -LONGBOW_TEST_CASE(Global, longBowString_Tokenise_NULL) -{ - LongBowArrayList *actual = longBowString_Tokenise(NULL, "-="); - - assertTrue(longBowArrayList_Length(actual) == 0, "Expected zero length LongBowArrayList, actual %zd", longBowArrayList_Length(actual)); - - longBowArrayList_Destroy(&actual); -} - -LONGBOW_TEST_CASE(Global, longBowString_CoreDump) -{ - //assertFalse(true, "foo"); -} - -LONGBOW_TEST_FIXTURE(Static) -{ -} - -LONGBOW_TEST_FIXTURE_SETUP(Static) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Static) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -int -main(int argc, char *argv[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_String); - int exitStatus = longBowMain(argc, argv, testRunner, NULL); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_TestCase.c b/longbow/src/LongBow/test/test_longBow_TestCase.c deleted file mode 100755 index 3fe6c8e1..00000000 --- a/longbow/src/LongBow/test/test_longBow_TestCase.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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/testing.h> - -LONGBOW_TEST_RUNNER(longBow_TestCase) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_TestCase) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_TestCase) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, ExpectEvent); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, ExpectEvent) -{ -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_TestCase); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_TestCaseClipBoard.c b/longbow/src/LongBow/test/test_longBow_TestCaseClipBoard.c deleted file mode 100755 index 521a817b..00000000 --- a/longbow/src/LongBow/test/test_longBow_TestCaseClipBoard.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 <inttypes.h> -#include <LongBow/testing.h> -#include <LongBow/private/longBow_Memory.h> - -LONGBOW_TEST_RUNNER(longBow_TestCaseClipBoard) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_TestCaseClipBoard) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_TestCaseClipBoard) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowTestCaseClipBoard_CreateDestroy); - LONGBOW_RUN_TEST_CASE(Global, longBowTestCaseClipBoard_Get); - LONGBOW_RUN_TEST_CASE(Global, longBowTestCaseClipBoard_Set); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_CASE(Global, longBowTestCaseClipBoard_CreateDestroy) -{ - uint64_t allocations = longBowMemory_OutstandingAllocations(); - char *shared = longBowMemory_StringCopy("shared data"); - - LongBowTestCaseClipBoard *clipboard = longBowTestCaseClipBoard_Create(shared); - assertNotNull(clipboard, "Expected non-null result from longBowTestCaseClipBoard_Create"); - - longBowTestCaseClipBoard_Destroy(&clipboard); - longBowMemory_Deallocate((void **) &shared); - - assertTrue(longBowMemory_OutstandingAllocations() == allocations, - "Memory leaks %" PRId64, longBowMemory_OutstandingAllocations()); -} - -LONGBOW_TEST_CASE(Global, longBowTestCaseClipBoard_Get) -{ - char *shared = longBowMemory_StringCopy("shared data"); - - LongBowTestCaseClipBoard *clipboard = longBowTestCaseClipBoard_Create(shared); - - char *actual = longBowTestCaseClipBoard_Get(clipboard); - assertTrue(strcmp(shared, actual) == 0, "Expected %s, actual %s", shared, actual); - - longBowTestCaseClipBoard_Destroy(&clipboard); - longBowMemory_Deallocate((void **) &shared); -} - -LONGBOW_TEST_CASE(Global, longBowTestCaseClipBoard_Set) -{ - char *shared = longBowMemory_StringCopy("shared data"); - - LongBowTestCaseClipBoard *clipboard = longBowTestCaseClipBoard_Create(shared); - - char *expected = longBowMemory_StringCopy("expected"); - - longBowTestCaseClipBoard_Set(clipboard, expected); - char *actual = longBowTestCaseClipBoard_Get(clipboard); - assertTrue(strcmp(expected, actual) == 0, "Expected %s, actual %s", expected, actual); - - longBowTestCaseClipBoard_Destroy(&clipboard); - longBowMemory_Deallocate((void **) &shared); - longBowMemory_Deallocate((void **) &expected); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_TestCaseClipBoard); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} diff --git a/longbow/src/LongBow/test/test_longBow_UnitTesting.c b/longbow/src/LongBow/test/test_longBow_UnitTesting.c deleted file mode 100755 index de0f9c56..00000000 --- a/longbow/src/LongBow/test/test_longBow_UnitTesting.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 "../testing.h" - -LONGBOW_TEST_RUNNER(longBow_UnitTesting) -{ - // The following Test Fixtures will run their corresponding Test Cases. - // Test Fixtures are run in the order specified, but all tests should be idempotent. - // Never rely on the execution order of tests or share state between them. - LONGBOW_RUN_TEST_FIXTURE(Global); - LONGBOW_RUN_TEST_FIXTURE(Local); -} - -// The Test Runner calls this function once before any Test Fixtures are run. -LONGBOW_TEST_RUNNER_SETUP(longBow_UnitTesting) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -// The Test Runner calls this function once after all the Test Fixtures are run. -LONGBOW_TEST_RUNNER_TEARDOWN(longBow_UnitTesting) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE(Global) -{ - LONGBOW_RUN_TEST_CASE(Global, longBowUnitTesting_AssertCompareToContract); -} - -LONGBOW_TEST_FIXTURE_SETUP(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -LONGBOW_TEST_FIXTURE_TEARDOWN(Global) -{ - return LONGBOW_STATUS_SUCCEEDED; -} - -static int -compareTo(const void *a, const void *b) -{ - if (a == NULL) { - if (b == NULL) { - return 0; - } - return -1; - } else { - if (b == NULL) { - return 1; - } - } - - return strcmp(a, b); -} - -LONGBOW_TEST_CASE(Global, longBowUnitTesting_AssertCompareToContract) -{ - char *exemplar = "exemplar"; - void *equivalent[] = { - "exemplar", - NULL, - }; - void *lesser[] = { - "exempla", - NULL, - }; - void *greater[] = { - "exemplarr", - "fexemplarr", - NULL, - }; - - bool expected = true; - bool actual = longBowUnitTesting_AssertCompareToContract(compareTo, exemplar, equivalent, lesser, greater); - - assertTrue(expected == actual, "Expected %d, actual %d", expected, actual); -} - -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[]) -{ - LongBowTestRunner *testRunner = LONGBOW_TEST_RUNNER_CREATE(longBow_UnitTesting); - int exitStatus = LONGBOW_TEST_MAIN(argc, argv, testRunner); - longBowTestRunner_Destroy(&testRunner); - exit(exitStatus); -} |