Skip to content
Snippets Groups Projects
Select Git revision
  • 8f12901c9ed86c9544020f58564ee1b687bf0df8
  • main default protected
  • f-sss4grpc
  • dev
  • 108-implement-rpc-call-for-server-side-scripting
  • f-windows-conan-create
  • f-to-string
  • f-update-requirements
  • f-related-projects
  • f-role
  • f-remote-path
  • f-rel-path
  • f-consol-message
  • v0.3.0
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.2
  • v0.1.1
  • v0.1
  • v0.0.19
  • v0.0.18
  • v0.0.16
  • v0.0.15
  • v0.0.10
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
33 results

linkahead_test_utility.h.in

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@";