diff --git a/CMakeLists.txt b/CMakeLists.txt index a58f96ce0..2a79e801e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) if(BUILD_TESTING) # tests + include(AddGoogleTest) enable_testing () add_subdirectory(sdk/core/azure-core/test) endif() diff --git a/sdk/core/azure-core/test/CMakeLists.txt b/sdk/core/azure-core/test/CMakeLists.txt index 0bded533b..ac9932d4a 100644 --- a/sdk/core/azure-core/test/CMakeLists.txt +++ b/sdk/core/azure-core/test/CMakeLists.txt @@ -3,8 +3,6 @@ cmake_minimum_required (VERSION 3.12) -include(AddGoogleTest) - set(TARGET_NAME "azure-core-test") project (${TARGET_NAME} LANGUAGES CXX) diff --git a/sdk/storage/CMakeLists.txt b/sdk/storage/CMakeLists.txt index ecd2fbddd..72e93aa4a 100644 --- a/sdk/storage/CMakeLists.txt +++ b/sdk/storage/CMakeLists.txt @@ -30,10 +30,6 @@ set(AZURE_STORAGE_SOURCE src/common/storage_url_builder.cpp ) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - add_library(azure-storage ${AZURE_STORAGE_HEADER} ${AZURE_STORAGE_SOURCE}) find_package(LibXml2 REQUIRED) @@ -61,5 +57,9 @@ if(BUILD_STORAGE_SAMPLES) add_subdirectory(sample) endif() +if(BUILD_TESTING) + add_subdirectory(test) +endif() + # make sure that users can consume the project as a library. add_library (azure::storage ALIAS azure-storage) diff --git a/sdk/storage/test/CMakeLists.txt b/sdk/storage/test/CMakeLists.txt new file mode 100644 index 000000000..7686042c6 --- /dev/null +++ b/sdk/storage/test/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +cmake_minimum_required (VERSION 3.12) + +if (MSVC) + # There will be many const conparisons in test code. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6326") +endif() + +add_executable ( + azure-storage-test + test_base.hpp + test_base.cpp + block_blob_client_test.cpp + main.cpp +) + +target_link_libraries(azure-storage-test PRIVATE azure-storage) + +add_gtest(azure-storage-test) diff --git a/sdk/storage/test/block_blob_client_test.cpp b/sdk/storage/test/block_blob_client_test.cpp new file mode 100644 index 000000000..cb564a230 --- /dev/null +++ b/sdk/storage/test/block_blob_client_test.cpp @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "test_base.hpp" +#include "blobs/blob.hpp" + +TEST(BlockBlobClientTest, StageBlockTest) +{ + EXPECT_EQ("", std::string(Azure::Storage::Test::TestUtility::k_ACCOUNT_SAS)); +} diff --git a/sdk/storage/test/main.cpp b/sdk/storage/test/main.cpp new file mode 100644 index 000000000..19e7500cb --- /dev/null +++ b/sdk/storage/test/main.cpp @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "gtest/gtest.h" + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/sdk/storage/test/test_base.cpp b/sdk/storage/test/test_base.cpp new file mode 100644 index 000000000..7cb8c545f --- /dev/null +++ b/sdk/storage/test/test_base.cpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "test_base.hpp" + +namespace Azure { namespace Storage { namespace Test { + +constexpr const char* TestUtility::k_STANDARD_STORAGE_CONNECTION_STRING; +constexpr const char* TestUtility::k_PREMIUM_STORAGE_CONNECTION_STRING; +constexpr const char* TestUtility::k_BLOB_STORAGE_CONNECTION_STRING; +constexpr const char* TestUtility::k_PREMIUM_FILE_CONNECTION_STRING; +constexpr const char* TestUtility::k_ADLS_GEN2_CONNECTION_STRING; +constexpr const char* TestUtility::k_ACCOUNT_SAS; + +}}} // namespace Azure::Storage::Test diff --git a/sdk/storage/test/test_base.hpp b/sdk/storage/test/test_base.hpp new file mode 100644 index 000000000..f26a261d5 --- /dev/null +++ b/sdk/storage/test/test_base.hpp @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include "gtest/gtest.h" + +namespace Azure { namespace Storage { namespace Test { + +struct TestUtility + { + constexpr static const char* k_STANDARD_STORAGE_CONNECTION_STRING = ""; + constexpr static const char* k_PREMIUM_STORAGE_CONNECTION_STRING = ""; + constexpr static const char* k_BLOB_STORAGE_CONNECTION_STRING = ""; + constexpr static const char* k_PREMIUM_FILE_CONNECTION_STRING = ""; + constexpr static const char* k_ADLS_GEN2_CONNECTION_STRING = ""; + // TODO: Temporary + constexpr static const char* k_ACCOUNT_SAS = ""; +}; + +}}}