Skip to content
Snippets Groups Projects
Select Git revision
  • f06e922c25a373b93fb423ef16db28c5588a1254
  • main default protected
  • dev protected
  • f-linkahead-rename
  • f-real-id
  • f-filesystem-import
  • f-filesystem-link
  • f-filesystem-directory
  • f-filesystem-core
  • f-filesystem-cleanup
  • f-filesystem-main
  • f-name
  • keep_changes
  • f-permission-checks-2
  • f-mysql8-tests
  • f-retrieve-history
  • t-distinct-parents
  • v8.1.0
  • v8.0.0
  • v7.0.2
  • v7.0.1
  • v7.0.0
  • v6.0.1
  • v6.0.0
  • v5.0.0
  • v4.1.0
  • v4.0.0
  • v3.0
  • v2.0.30
29 results

index.rst

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    linkahead_test_utility.h.in 4.73 KiB
    /*
     *
     * This file is a part of the LinkAhead Project.
     *
     * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
     * Copyright (C) 2021-2024 IndiScale GmbH <info@indiscale.com>
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as
     * published by the Free Software Foundation, either version 3 of the
     * License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program. If not, see <https://www.gnu.org/licenses/>.
     *
     */
    
    #ifndef CAOSDB_TEST_UTILITY_H
    #define CAOSDB_TEST_UTILITY_H
    #include <string>
    /**
     * @file caosdb_test_utility.h
     * @brief Utility for the unit tests
     * @author Timm Fitschen
     * @date 2021-07-07
     */
    #define EXPECT_THROW_MESSAGE(statement, exception_type, message)                                   \
      EXPECT_THROW(                                                                                    \
        try { statement; } catch (const exception_type &e) {                                           \
          EXPECT_EQ(std::string(e.what()), message);                                                   \
          throw;                                                                                       \
        },                                                                                             \
        exception_type)
    #define ASSERT_THROW_MESSAGE(statement, exception_type, message)                                   \
      ASSERT_THROW(                                                                                    \
        try { statement; } catch (const exception_type &e) {                                           \
          ASSERT_EQ(std::string(e.what()), message);                                                   \
          throw;                                                                                       \
        },                                                                                             \
        exception_type)
    #define EXPECT_THROW_STARTS_WITH(statement, exception_type, pattern)                               \
      EXPECT_THROW(                                                                                    \
        try { statement; } catch (const exception_type &e) {                                           \
          auto pat_s = std::string(pattern);                                                           \
          EXPECT_EQ(std::string(e.what()).substr(0, pat_s.size()), pat_s);                             \
          throw;                                                                                       \
        },                                                                                             \
        exception_type)
    #define ASSERT_THROW_STARTS_WITH(statement, exception_type, message)                               \
      ASSERT_THROW(                                                                                    \
        try { statement; } catch (const exception_type &e) {                                           \
          auto pat_s = std::string(pattern);                                                           \
          ASSERT_EQ(std::string(e.what()).substr(0, pat_s.size()), pat_s);                             \
          throw;                                                                                       \
        },                                                                                             \
        exception_type)
    #define EXPECT_NULL(statement)                                                                     \
      if (statement != nullptr) {                                                                      \
        FAIL() << "Should be a nullptr";                                                               \
      } else {                                                                                         \
        SUCCEED();                                                                                     \
      }
    #define ASSERT_NULL(statement)                                                                     \
      if (statement != nullptr) {                                                                      \
        ADD_FAIL() << "Should be a nullptr";                                                           \
      } else {                                                                                         \
        SUCCEED();                                                                                     \
      }
    #endif
    
    const std::string TEST_DATA_DIR = "@TEST_DATA_DIR@";