1 /////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 // 5 // This code is licensed under the MIT License (MIT). 6 // 7 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 // THE SOFTWARE. 14 // 15 /////////////////////////////////////////////////////////////////////////////// 16 17 #include <catch/catch.hpp> 18 19 #include <gsl/gsl> 20 21 #include <functional> 22 23 #include <memory> 24 25 using namespace gsl; 26 27 void f(int* i) { *i += 1; } 28 29 TEST_CASE("basic_test") 30 { 31 owner<int*> p = new int(120); 32 CHECK(*p == 120); 33 f(p); 34 CHECK(*p == 121); 35 delete p; 36 } 37 38 TEST_CASE("check_pointer_constraint") 39 { 40 #ifdef CONFIRM_COMPILATION_ERRORS 41 { 42 owner<int> integerTest = 10; 43 owner<std::shared_ptr<int>> sharedPtrTest(new int(10)); 44 } 45 #endif 46 } 47