mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge branch 'master' into dev/neilmac/spec
This commit is contained in:
commit
eed99d8599
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
tests/unittest-cpp
|
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
tests/CMakeFiles
|
tests/CMakeFiles
|
||||||
tests/Debug
|
tests/Debug
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "tests/unittest-cpp"]
|
||||||
|
path = tests/unittest-cpp
|
||||||
|
url = https://github.com/Microsoft/unittest-cpp.git
|
@ -56,7 +56,6 @@ install:
|
|||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
- git clone --depth 1 https://github.com/Microsoft/unittest-cpp tests/unittest-cpp
|
|
||||||
- cmake -H. -Bb -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_INSTALL_PREFIX=$PWD/o -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
- cmake -H. -Bb -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_INSTALL_PREFIX=$PWD/o -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||||
- cmake --build b
|
- cmake --build b
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#define GSL_CONTRACTS_H
|
#define GSL_CONTRACTS_H
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
//
|
//
|
||||||
// There are three configuration options for this GSL implementation's behavior
|
// There are three configuration options for this GSL implementation's behavior
|
||||||
@ -42,10 +43,6 @@
|
|||||||
// GSL.assert: assertions
|
// GSL.assert: assertions
|
||||||
//
|
//
|
||||||
|
|
||||||
#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace gsl
|
namespace gsl
|
||||||
{
|
{
|
||||||
struct fail_fast : public std::runtime_error
|
struct fail_fast : public std::runtime_error
|
||||||
@ -54,6 +51,8 @@ struct fail_fast : public std::runtime_error
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||||
|
|
||||||
#define Expects(cond) if (!(cond)) \
|
#define Expects(cond) if (!(cond)) \
|
||||||
throw gsl::fail_fast("GSL: Precondition failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__));
|
throw gsl::fail_fast("GSL: Precondition failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__));
|
||||||
#define Ensures(cond) if (!(cond)) \
|
#define Ensures(cond) if (!(cond)) \
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#pragma push_macro("constexpr")
|
#pragma push_macro("constexpr")
|
||||||
#define constexpr
|
#define constexpr
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4127) // conditional expression is constant
|
||||||
|
|
||||||
// MSVC 2013 workarounds
|
// MSVC 2013 workarounds
|
||||||
#if _MSC_VER <= 1800
|
#if _MSC_VER <= 1800
|
||||||
// noexcept is not understood
|
// noexcept is not understood
|
||||||
@ -40,7 +43,6 @@
|
|||||||
// turn off some misguided warnings
|
// turn off some misguided warnings
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4351) // warns about newly introduced aggregate initializer behavior
|
#pragma warning(disable: 4351) // warns about newly introduced aggregate initializer behavior
|
||||||
#pragma warning(disable: 4127) // conditional expression is constant
|
|
||||||
|
|
||||||
#endif // _MSC_VER <= 1800
|
#endif // _MSC_VER <= 1800
|
||||||
|
|
||||||
@ -132,6 +134,8 @@ constexpr typename Cont::value_type& at(Cont& cont, size_t index)
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
#undef constexpr
|
#undef constexpr
|
||||||
#pragma pop_macro("constexpr")
|
#pragma pop_macro("constexpr")
|
||||||
|
|
||||||
|
@ -31,10 +31,16 @@
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
// turn off some warnings that are noisy about our Expects statements
|
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
|
|
||||||
|
// turn off some warnings that are noisy about our Expects statements
|
||||||
#pragma warning(disable : 4127) // conditional expression is constant
|
#pragma warning(disable : 4127) // conditional expression is constant
|
||||||
|
|
||||||
|
// blanket turn off warnings from CppCoreCheck for now
|
||||||
|
// so people aren't annoyed by them when running the tool.
|
||||||
|
// more targeted suppressions will be added in a future update to the GSL
|
||||||
|
#pragma warning(disable: 26481 26482 26483 26485 26490 26491 26492 26493 26495)
|
||||||
|
|
||||||
// No MSVC does constexpr fully yet
|
// No MSVC does constexpr fully yet
|
||||||
#pragma push_macro("constexpr")
|
#pragma push_macro("constexpr")
|
||||||
#define constexpr
|
#define constexpr
|
||||||
|
@ -31,6 +31,14 @@
|
|||||||
#pragma push_macro("constexpr")
|
#pragma push_macro("constexpr")
|
||||||
#define constexpr /* nothing */
|
#define constexpr /* nothing */
|
||||||
|
|
||||||
|
#pragma warning(push)
|
||||||
|
|
||||||
|
// blanket turn off warnings from CppCoreCheck for now
|
||||||
|
// so people aren't annoyed by them when running the tool.
|
||||||
|
// more targeted suppressions will be added in a future update to the GSL
|
||||||
|
#pragma warning(disable: 26481 26482 26483 26485 26490 26491 26492 26493 26495)
|
||||||
|
|
||||||
|
|
||||||
// VS 2013 workarounds
|
// VS 2013 workarounds
|
||||||
#if _MSC_VER <= 1800
|
#if _MSC_VER <= 1800
|
||||||
|
|
||||||
@ -927,12 +935,14 @@ bool operator>=(const T& one, gsl::basic_string_span<CharT, Extent> other) noexc
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// VS 2013 workarounds
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
#undef constexpr
|
#undef constexpr
|
||||||
#pragma pop_macro("constexpr")
|
#pragma pop_macro("constexpr")
|
||||||
|
|
||||||
|
// VS 2013 workarounds
|
||||||
#if _MSC_VER <= 1800
|
#if _MSC_VER <= 1800
|
||||||
|
|
||||||
#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
|
#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.8.7)
|
|||||||
|
|
||||||
project(GSLTests CXX)
|
project(GSLTests CXX)
|
||||||
|
|
||||||
|
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/unittest-cpp/tests)
|
||||||
|
execute_process(COMMAND git submodule update --init WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(unittest-cpp)
|
add_subdirectory(unittest-cpp)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
@ -28,10 +32,6 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/unittest-cpp)
|
|
||||||
message(FATAL_ERROR "Could not find unittest-cpp enlistment. Please run 'git clone https://github.com/Microsoft/unittest-cpp.git unittest-cpp' in the tests directory")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(add_gsl_test name)
|
function(add_gsl_test name)
|
||||||
add_executable(${name} ${name}.cpp ../include/gsl.h ../include/gsl_assert.h ../include/gsl_util.h ../include/multi_span.h ../include/span.h ../include/string_span.h)
|
add_executable(${name} ${name}.cpp ../include/gsl.h ../include/gsl_assert.h ../include/gsl_util.h ../include/multi_span.h ../include/span.h ../include/string_span.h)
|
||||||
target_link_libraries(${name} UnitTest++)
|
target_link_libraries(${name} UnitTest++)
|
||||||
|
1
tests/unittest-cpp
Submodule
1
tests/unittest-cpp
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit dc6b90838014ab985bf3cd74ac17ad9d00e1fbcb
|
Loading…
Reference in New Issue
Block a user