forked from EvergreenCrypto/docker-finance
container: root: refactor scope for internal/common types
Avoid programmer/compiler confusion for internal/common types.
This commit is contained in:
@@ -38,9 +38,6 @@ namespace dfi
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace crypto
|
||||
{
|
||||
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \namespace dfi::crypto::common
|
||||
//! \brief Common "interface" (specializations) to library-specific implementations
|
||||
//! \warning Not for direct public consumption (use library namespace instead)
|
||||
@@ -85,7 +82,9 @@ class Hash final : public t_impl
|
||||
template <
|
||||
typename t_hash,
|
||||
typename t_message,
|
||||
std::enable_if_t<type::is_signature_with_trivial<t_message>, bool> = true>
|
||||
std::enable_if_t<
|
||||
::dfi::internal::type::is_signature_with_trivial<t_message>,
|
||||
bool> = true>
|
||||
std::string encode(const t_message message)
|
||||
{
|
||||
return t_impl::template encode<t_hash, std::string>(message);
|
||||
@@ -109,7 +108,8 @@ class Hash final : public t_impl
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_string<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_string<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
std::string encode(const t_container<t_args...>& message)
|
||||
{
|
||||
@@ -134,7 +134,8 @@ class Hash final : public t_impl
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_value_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_value_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<std::string> encode(const t_container<t_args...>& message)
|
||||
{
|
||||
@@ -159,7 +160,8 @@ class Hash final : public t_impl
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_mapped_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_mapped_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<typename t_container<t_args...>::key_type, std::string> encode(
|
||||
const t_container<t_args...>& message)
|
||||
|
||||
@@ -58,9 +58,6 @@ namespace crypto
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace impl
|
||||
{
|
||||
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \namespace dfi::crypto::impl::common
|
||||
//! \brief Common implementation among all crypto implementations
|
||||
//! \since docker-finance 1.0.0
|
||||
@@ -90,7 +87,9 @@ class HashImpl : public ::dfi::internal::Transform<t_impl>
|
||||
typename t_hash,
|
||||
typename t_decoded,
|
||||
typename t_encoded,
|
||||
std::enable_if_t<type::is_signature_with_trivial<t_decoded>, bool> = true>
|
||||
std::enable_if_t<
|
||||
::dfi::internal::type::is_signature_with_trivial<t_decoded>,
|
||||
bool> = true>
|
||||
t_encoded encoder_impl(const t_decoded decoded)
|
||||
{
|
||||
static_assert(
|
||||
@@ -109,7 +108,8 @@ class HashImpl : public ::dfi::internal::Transform<t_impl>
|
||||
{
|
||||
message.push_back(static_cast<unsigned char>(decoded));
|
||||
}
|
||||
else if constexpr (type::is_real_integral<t_decoded>::value)
|
||||
else if constexpr (::dfi::internal::type::is_real_integral<
|
||||
t_decoded>::value)
|
||||
{
|
||||
message.assign(std::to_string(decoded));
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class HashImpl : public ::dfi::internal::Transform<t_impl>
|
||||
typename t_decoded,
|
||||
typename t_encoded,
|
||||
std::enable_if_t<
|
||||
type::has_const_iterator<t_decoded>::value
|
||||
::dfi::internal::type::has_const_iterator<t_decoded>::value
|
||||
&& !std::is_same_v<t_decoded, std::string_view>,
|
||||
bool> = true>
|
||||
t_encoded encoder_impl(const t_decoded& decoded)
|
||||
@@ -155,7 +155,8 @@ namespace botan
|
||||
//! \ingroup cpp_API_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
//! \todo Support large/split messages
|
||||
class Hash : public common::HashImpl<botan::Hash>, public type::Hash
|
||||
class Hash : public common::HashImpl<botan::Hash>,
|
||||
public ::dfi::internal::type::Hash
|
||||
{
|
||||
public:
|
||||
Hash() = default;
|
||||
@@ -277,7 +278,8 @@ namespace cryptopp
|
||||
//! \ingroup cpp_API_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
//! \todo Support large/split messages
|
||||
class Hash : public common::HashImpl<cryptopp::Hash>, public type::Hash
|
||||
class Hash : public common::HashImpl<cryptopp::Hash>,
|
||||
public ::dfi::internal::type::Hash
|
||||
{
|
||||
public:
|
||||
Hash() = default;
|
||||
@@ -417,7 +419,8 @@ namespace libsodium
|
||||
//! \ingroup cpp_API_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
//! \todo Support large/split messages
|
||||
class Hash : public common::HashImpl<libsodium::Hash>, public type::Hash
|
||||
class Hash : public common::HashImpl<libsodium::Hash>,
|
||||
public ::dfi::internal::type::Hash
|
||||
{
|
||||
public:
|
||||
//! \note
|
||||
|
||||
@@ -54,9 +54,6 @@ namespace impl
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \brief Generic Random implementation common among all library-specific implementations
|
||||
//! \ingroup cpp_API_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
@@ -79,7 +76,7 @@ class RandomImpl : public ::dfi::internal::Random<t_impl>
|
||||
t_random generate_impl()
|
||||
{
|
||||
static_assert(
|
||||
type::is_real_integral<t_random>::value,
|
||||
::dfi::internal::type::is_real_integral<t_random>::value,
|
||||
"Random interface has changed");
|
||||
|
||||
return this->t_impl::that()->template generate<t_random>();
|
||||
@@ -120,7 +117,7 @@ class Random : public common::RandomImpl<botan::Random>
|
||||
t_random generate_impl()
|
||||
{
|
||||
static_assert(
|
||||
type::is_real_integral<t_random>::value,
|
||||
::dfi::internal::type::is_real_integral<t_random>::value,
|
||||
"Random interface has changed");
|
||||
|
||||
static_assert(
|
||||
@@ -128,7 +125,7 @@ class Random : public common::RandomImpl<botan::Random>
|
||||
|| std::is_same_v<t_random, uint32_t>,
|
||||
"Invalid type (only uint16_t or uint32_t supported)");
|
||||
|
||||
::dfi::common::throw_ex_if<type::RuntimeError>(
|
||||
::dfi::common::throw_ex_if<::dfi::common::type::RuntimeError>(
|
||||
!m_csprng.is_seeded(), "Botan is not seeded");
|
||||
|
||||
// WARNING: DO *NOT* set_high_bit to true here!
|
||||
@@ -181,7 +178,7 @@ class Random : public common::RandomImpl<cryptopp::Random>
|
||||
{
|
||||
// NOTE: signed/unsigned types are supported (up to uint32_t)
|
||||
static_assert(
|
||||
type::is_real_integral<t_random>::value,
|
||||
::dfi::internal::type::is_real_integral<t_random>::value,
|
||||
"Random interface has changed");
|
||||
|
||||
static_assert(
|
||||
@@ -240,7 +237,7 @@ class Random : public common::RandomImpl<libsodium::Random>
|
||||
t_random generate_impl()
|
||||
{
|
||||
static_assert(
|
||||
type::is_real_integral<t_random>::value,
|
||||
::dfi::internal::type::is_real_integral<t_random>::value,
|
||||
"Random interface has changed");
|
||||
|
||||
// signed or uint64_t types are not supported
|
||||
|
||||
@@ -47,9 +47,6 @@ namespace utility
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace impl
|
||||
{
|
||||
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \brief Misc tools
|
||||
//! \ingroup cpp_API_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
#include "./internal/impl/random.hh"
|
||||
#include "./internal/type.hh"
|
||||
|
||||
//! \namespace dfi
|
||||
//! \since docker-finance 1.0.0
|
||||
@@ -71,7 +72,9 @@ class Random final : public t_impl
|
||||
//! \return t_random Random number of type t_random
|
||||
template <
|
||||
typename t_random = uint32_t,
|
||||
std::enable_if_t<type::is_real_integral<t_random>::value, bool> = true>
|
||||
std::enable_if_t<
|
||||
::dfi::internal::type::is_real_integral<t_random>::value,
|
||||
bool> = true>
|
||||
t_random generate()
|
||||
{
|
||||
return t_impl::template generate<t_random>();
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace utility
|
||||
{
|
||||
|
||||
namespace common = ::dfi::common;
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \brief Misc utility tools
|
||||
//! \ingroup cpp_utils
|
||||
@@ -145,7 +144,8 @@ class Byte final : public impl::Byte
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_value_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_value_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<t_encoded> encode(const t_container<t_args...>& byte)
|
||||
{
|
||||
@@ -156,7 +156,8 @@ class Byte final : public impl::Byte
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_mapped_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_mapped_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<typename t_container<t_args...>::key_type, t_encoded> encode(
|
||||
const t_container<t_args...>& byte)
|
||||
@@ -174,7 +175,8 @@ class Byte final : public impl::Byte
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_value_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_value_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<t_decoded> decode(const t_container<t_args...>& byte)
|
||||
{
|
||||
@@ -185,7 +187,8 @@ class Byte final : public impl::Byte
|
||||
template <typename...> typename t_container,
|
||||
typename... t_args,
|
||||
std::enable_if_t<
|
||||
type::is_signature_with_mapped_type_allocator<t_container<t_args...>>,
|
||||
::dfi::internal::type::is_signature_with_mapped_type_allocator<
|
||||
t_container<t_args...>>,
|
||||
bool> = true>
|
||||
t_container<typename t_container<t_args...>::key_type, t_decoded> decode(
|
||||
const t_container<t_args...>& byte)
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
|
||||
#include "../../src/hash.hh"
|
||||
|
||||
namespace type = dfi::internal::type;
|
||||
|
||||
//! \namespace dfi
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace dfi
|
||||
@@ -129,15 +127,16 @@ struct HashInterface : protected HashData
|
||||
//! \brief Hash mock implementation
|
||||
//! \since docker-finance 1.0.0
|
||||
struct HashImpl : public ::dfi::internal::Transform<HashImpl>,
|
||||
public type::Hash
|
||||
public ::dfi::internal::type::Hash
|
||||
{
|
||||
//! \brief Implements trivial type mock Hash encoder
|
||||
template <
|
||||
typename t_hash,
|
||||
typename t_decoded,
|
||||
typename t_encoded,
|
||||
std::enable_if_t<type::is_signature_with_trivial<t_decoded>, bool> =
|
||||
true>
|
||||
std::enable_if_t<
|
||||
::dfi::internal::type::is_signature_with_trivial<t_decoded>,
|
||||
bool> = true>
|
||||
t_encoded encoder_impl(const t_decoded decoded)
|
||||
{
|
||||
static_assert(
|
||||
@@ -155,7 +154,7 @@ struct HashInterface : protected HashData
|
||||
typename t_decoded,
|
||||
typename t_encoded,
|
||||
std::enable_if_t<
|
||||
type::has_const_iterator<t_decoded>::value
|
||||
::dfi::internal::type::has_const_iterator<t_decoded>::value
|
||||
&& !std::is_same_v<t_decoded, std::string_view>,
|
||||
bool> = true>
|
||||
t_encoded encoder_impl(const t_decoded& decoded)
|
||||
|
||||
@@ -65,7 +65,7 @@ TEST_F(RuntimeError, throw_ex_if) // cppcheck-suppress syntaxError
|
||||
{
|
||||
common::throw_ex_if<common::type::RuntimeError>(false, what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::RuntimeError);
|
||||
ASSERT_EQ(ex.what(), what);
|
||||
@@ -78,7 +78,7 @@ TEST_F(RuntimeError, throw_ex)
|
||||
{
|
||||
common::throw_ex<common::type::RuntimeError>(what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::RuntimeError);
|
||||
// NOTE: no case for ex.what() because message is formatted within function
|
||||
@@ -91,22 +91,22 @@ TEST_F(RuntimeError, rethrow)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw type::RuntimeError(what);
|
||||
throw common::type::RuntimeError(what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::RuntimeError);
|
||||
ASSERT_EQ(ex.what(), what);
|
||||
throw;
|
||||
}
|
||||
},
|
||||
type::Exception);
|
||||
common::type::Exception);
|
||||
}
|
||||
|
||||
TEST_F(RuntimeError, copy_assignment)
|
||||
{
|
||||
type::RuntimeError one(what);
|
||||
type::RuntimeError two;
|
||||
common::type::RuntimeError one(what);
|
||||
common::type::RuntimeError two;
|
||||
|
||||
two = one;
|
||||
|
||||
@@ -116,8 +116,8 @@ TEST_F(RuntimeError, copy_assignment)
|
||||
|
||||
TEST_F(RuntimeError, copy_ctor)
|
||||
{
|
||||
type::RuntimeError one(what);
|
||||
type::RuntimeError two(one);
|
||||
common::type::RuntimeError one(what);
|
||||
common::type::RuntimeError two(one);
|
||||
|
||||
ASSERT_EQ(one.type(), two.type());
|
||||
ASSERT_STREQ(one.what(), two.what());
|
||||
@@ -125,8 +125,8 @@ TEST_F(RuntimeError, copy_ctor)
|
||||
|
||||
TEST_F(RuntimeError, move_assignment)
|
||||
{
|
||||
type::RuntimeError one(what);
|
||||
type::RuntimeError two;
|
||||
common::type::RuntimeError one(what);
|
||||
common::type::RuntimeError two;
|
||||
|
||||
two = std::move(one);
|
||||
|
||||
@@ -136,8 +136,8 @@ TEST_F(RuntimeError, move_assignment)
|
||||
|
||||
TEST_F(RuntimeError, move_ctor)
|
||||
{
|
||||
type::RuntimeError one(what);
|
||||
type::RuntimeError two(std::move(one));
|
||||
common::type::RuntimeError one(what);
|
||||
common::type::RuntimeError two(std::move(one));
|
||||
|
||||
ASSERT_EQ(one.type(), two.type());
|
||||
ASSERT_STRNE(one.what(), two.what());
|
||||
@@ -159,7 +159,7 @@ TEST_F(InvalidArgument, throw_ex_if)
|
||||
{
|
||||
common::throw_ex_if<common::type::InvalidArgument>(false, what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::InvalidArgument);
|
||||
ASSERT_EQ(ex.what(), what);
|
||||
@@ -172,7 +172,7 @@ TEST_F(InvalidArgument, throw_ex)
|
||||
{
|
||||
common::throw_ex<common::type::InvalidArgument>(what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::InvalidArgument);
|
||||
// NOTE: no case for ex.what() because message is formatted within function
|
||||
@@ -185,22 +185,22 @@ TEST_F(InvalidArgument, rethrow)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw type::InvalidArgument(what);
|
||||
throw common::type::InvalidArgument(what);
|
||||
}
|
||||
catch (const type::Exception& ex)
|
||||
catch (const common::type::Exception& ex)
|
||||
{
|
||||
ASSERT_EQ(ex.type(), t_type::InvalidArgument);
|
||||
ASSERT_EQ(ex.what(), what);
|
||||
throw;
|
||||
}
|
||||
},
|
||||
type::Exception);
|
||||
common::type::Exception);
|
||||
}
|
||||
|
||||
TEST_F(InvalidArgument, copy_assignment)
|
||||
{
|
||||
type::InvalidArgument one(what);
|
||||
type::InvalidArgument two;
|
||||
common::type::InvalidArgument one(what);
|
||||
common::type::InvalidArgument two;
|
||||
|
||||
two = one;
|
||||
|
||||
@@ -210,8 +210,8 @@ TEST_F(InvalidArgument, copy_assignment)
|
||||
|
||||
TEST_F(InvalidArgument, copy_ctor)
|
||||
{
|
||||
type::InvalidArgument one(what);
|
||||
type::InvalidArgument two(one);
|
||||
common::type::InvalidArgument one(what);
|
||||
common::type::InvalidArgument two(one);
|
||||
|
||||
ASSERT_EQ(one.type(), two.type());
|
||||
ASSERT_STREQ(one.what(), two.what());
|
||||
@@ -219,8 +219,8 @@ TEST_F(InvalidArgument, copy_ctor)
|
||||
|
||||
TEST_F(InvalidArgument, move_assignment)
|
||||
{
|
||||
type::InvalidArgument one(what);
|
||||
type::InvalidArgument two;
|
||||
common::type::InvalidArgument one(what);
|
||||
common::type::InvalidArgument two;
|
||||
|
||||
two = std::move(one);
|
||||
|
||||
@@ -230,8 +230,8 @@ TEST_F(InvalidArgument, move_assignment)
|
||||
|
||||
TEST_F(InvalidArgument, move_ctor)
|
||||
{
|
||||
type::InvalidArgument one(what);
|
||||
type::InvalidArgument two(std::move(one));
|
||||
common::type::InvalidArgument one(what);
|
||||
common::type::InvalidArgument two(std::move(one));
|
||||
|
||||
ASSERT_EQ(one.type(), two.type());
|
||||
ASSERT_STRNE(one.what(), two.what());
|
||||
|
||||
@@ -293,35 +293,37 @@ struct CommonFree : public ::testing::Test, public ::dfi::tests::CommonFixture
|
||||
TEST_F(CommonFree, Line)
|
||||
{
|
||||
ASSERT_NO_THROW(common::line(""));
|
||||
ASSERT_THROW(common::line("a bar without a foo"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line("a bar without a foo"), common::type::RuntimeError);
|
||||
ASSERT_NO_THROW(common::line("#define FOO 1"));
|
||||
}
|
||||
|
||||
TEST_F(CommonFree, add_include_dir)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
common::add_include_dir("/should-not-exist"), type::RuntimeError);
|
||||
common::add_include_dir("/should-not-exist"), common::type::RuntimeError);
|
||||
ASSERT_NO_THROW(common::add_include_dir("/usr/include"));
|
||||
}
|
||||
|
||||
TEST_F(CommonFree, add_linked_lib)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
common::add_linked_lib("/should-not-exist.so"), type::RuntimeError);
|
||||
common::add_linked_lib("/should-not-exist.so"),
|
||||
common::type::RuntimeError);
|
||||
ASSERT_NO_THROW(common::add_linked_lib("/usr/lib/LLVMgold.so"));
|
||||
}
|
||||
|
||||
TEST_F(CommonFree, remove_linked_lib)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
common::remove_linked_lib("/should-not-exist.so"), type::RuntimeError);
|
||||
common::remove_linked_lib("/should-not-exist.so"),
|
||||
common::type::RuntimeError);
|
||||
ASSERT_NO_THROW(common::add_linked_lib("/usr/lib/LLVMgold.so"));
|
||||
ASSERT_NO_THROW(common::remove_linked_lib("/usr/lib/LLVMgold.so"));
|
||||
}
|
||||
|
||||
TEST_F(CommonFree, get_env)
|
||||
{
|
||||
ASSERT_THROW(common::get_env("should-not-exist"), type::RuntimeError);
|
||||
ASSERT_THROW(common::get_env("should-not-exist"), common::type::RuntimeError);
|
||||
ASSERT_NO_THROW(common::get_env("DOCKER_FINANCE_VERSION"));
|
||||
}
|
||||
|
||||
@@ -381,8 +383,9 @@ struct CommonFreeFiles : public ::testing::Test,
|
||||
|
||||
TEST_F(CommonFreeFiles, LoadSingle)
|
||||
{
|
||||
ASSERT_THROW(common::load({path_1 + "should-not-exist"}), type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_foo foo;"), type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::load({path_1 + "should-not-exist"}), common::type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_foo foo;"), common::type::RuntimeError);
|
||||
|
||||
ASSERT_NO_THROW(common::load(path_1));
|
||||
ASSERT_NO_THROW(common::line("my_foo foo;"));
|
||||
@@ -393,8 +396,8 @@ TEST_F(CommonFreeFiles, LoadMultiple)
|
||||
ASSERT_THROW(
|
||||
common::load(
|
||||
{{path_1 + "should-not-exist"}, {path_2 + "nor-should-this"}}),
|
||||
type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_bar bar;"), type::RuntimeError);
|
||||
common::type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_bar bar;"), common::type::RuntimeError);
|
||||
|
||||
ASSERT_NO_THROW(common::load({path_1, path_2}));
|
||||
ASSERT_NO_THROW(common::line("my_bar bar;"));
|
||||
@@ -406,7 +409,7 @@ TEST_F(CommonFreeFiles, UnloadSingle)
|
||||
ASSERT_NO_THROW(common::line("my_foo foo;"));
|
||||
|
||||
ASSERT_NO_THROW(common::unload(path_1));
|
||||
ASSERT_THROW(common::line("my_foo foo;"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_foo foo;"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(CommonFreeFiles, UnloadMultiple)
|
||||
@@ -416,8 +419,8 @@ TEST_F(CommonFreeFiles, UnloadMultiple)
|
||||
ASSERT_NO_THROW(common::line("my_bar bar;"));
|
||||
|
||||
ASSERT_NO_THROW(common::unload({path_1, path_2}));
|
||||
ASSERT_THROW(common::line("my_foo foo;"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_bar bar;"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_foo foo;"), common::type::RuntimeError);
|
||||
ASSERT_THROW(common::line("my_bar bar;"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(CommonFreeFiles, ReloadSingle)
|
||||
@@ -778,10 +781,11 @@ struct MacroFreeFiles : public ::testing::Test,
|
||||
TEST_F(MacroFreeFiles, LoadSingle)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
::dfi::macro::load("macro/should-not/exist.C"), type::RuntimeError);
|
||||
::dfi::macro::load("macro/should-not/exist.C"),
|
||||
common::type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line("dfi::macro::common::crypto::botan::Hash h;"),
|
||||
type::RuntimeError);
|
||||
common::type::RuntimeError);
|
||||
|
||||
// TODO(afiore): macro loading should not need to be prepended with "macro/"
|
||||
// (see TODO in common impl regarding plugins-like functionality)
|
||||
@@ -820,9 +824,9 @@ struct PluginCommands : public ::testing::Test,
|
||||
|
||||
TEST_F(PluginCommands, LoadUnloadSingleInvalidFile)
|
||||
{
|
||||
ASSERT_THROW(plugin::load(kInvalidFile), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), type::RuntimeError);
|
||||
ASSERT_THROW(plugin::unload(kInvalidFile), type::RuntimeError);
|
||||
ASSERT_THROW(plugin::load(kInvalidFile), common::type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), common::type::RuntimeError);
|
||||
ASSERT_THROW(plugin::unload(kInvalidFile), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, LoadUnloadSingleSimpleNoArg)
|
||||
@@ -830,7 +834,7 @@ TEST_F(PluginCommands, LoadUnloadSingleSimpleNoArg)
|
||||
ASSERT_NO_THROW(plugin::load(kValidFile));
|
||||
ASSERT_NO_THROW(common::line(kValidArg));
|
||||
ASSERT_NO_THROW(plugin::unload(kValidFile));
|
||||
ASSERT_THROW(common::line(kValidArg), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, LoadUnloadSingleSimpleWithArg)
|
||||
@@ -838,11 +842,13 @@ TEST_F(PluginCommands, LoadUnloadSingleSimpleWithArg)
|
||||
ASSERT_NO_THROW(plugin::load(kValidFile, kValidArg + " e.example1();"));
|
||||
ASSERT_NO_THROW(plugin::unload(kValidFile));
|
||||
|
||||
ASSERT_THROW(plugin::load(kValidFile, kInvalidArg), type::InvalidArgument);
|
||||
ASSERT_THROW(
|
||||
plugin::load(kValidFile, kInvalidArg), common::type::InvalidArgument);
|
||||
ASSERT_NO_THROW(common::line(kValidArg)); // File is still loaded
|
||||
|
||||
ASSERT_NO_THROW(plugin::unload(kValidFile, kValidArg + " e.example1();"));
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example1();"), type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example1();"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, LoadUnloadSinglePluggable)
|
||||
@@ -863,7 +869,7 @@ TEST_F(PluginCommands, LoadUnloadSinglePluggable)
|
||||
plugin::load(
|
||||
plugin::common::PluginPath{kValidFile},
|
||||
plugin::common::PluginArgs{kInvalidArg, kInvalidArg}),
|
||||
type::InvalidArgument);
|
||||
common::type::InvalidArgument);
|
||||
|
||||
ASSERT_NO_THROW(common::line(kValidArg));
|
||||
|
||||
@@ -873,18 +879,20 @@ TEST_F(PluginCommands, LoadUnloadSinglePluggable)
|
||||
plugin::common::PluginArgs{
|
||||
kValidArg + " /* load code */", kValidArg + " e.example2();"}));
|
||||
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example1();"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example2();"), type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example1();"), common::type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example2();"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
// TODO(afiore): multiple load
|
||||
|
||||
TEST_F(PluginCommands, ReloadSingleInvalidFile)
|
||||
{
|
||||
ASSERT_THROW(plugin::load(kInvalidFile), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), type::RuntimeError);
|
||||
ASSERT_THROW(plugin::reload(kInvalidFile), type::RuntimeError);
|
||||
ASSERT_THROW(plugin::unload(kInvalidFile), type::RuntimeError);
|
||||
ASSERT_THROW(plugin::load(kInvalidFile), common::type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), common::type::RuntimeError);
|
||||
ASSERT_THROW(plugin::reload(kInvalidFile), common::type::RuntimeError);
|
||||
ASSERT_THROW(plugin::unload(kInvalidFile), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, ReloadSingleSimpleNoArg)
|
||||
@@ -909,11 +917,11 @@ TEST_F(PluginCommands, ReloadSingleSimpleWithArg)
|
||||
|
||||
ASSERT_THROW(
|
||||
plugin::reload(kValidFile, {" /* valid load code */", kInvalidArg}),
|
||||
type::InvalidArgument);
|
||||
common::type::InvalidArgument);
|
||||
|
||||
ASSERT_THROW(
|
||||
plugin::reload(kValidFile, {kInvalidArg, " /* valid unload code */"}),
|
||||
type::InvalidArgument);
|
||||
common::type::InvalidArgument);
|
||||
|
||||
ASSERT_NO_THROW(common::line(kValidArg));
|
||||
|
||||
@@ -923,7 +931,8 @@ TEST_F(PluginCommands, ReloadSingleSimpleWithArg)
|
||||
{kValidArg + " /* load code */", kValidArg + " /* unload code */"}));
|
||||
|
||||
ASSERT_NO_THROW(plugin::unload(kValidFile, kValidArg + " e.example1();"));
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example1();"), type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example1();"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, ReloadSinglePluggable)
|
||||
@@ -944,7 +953,7 @@ TEST_F(PluginCommands, ReloadSinglePluggable)
|
||||
plugin::load(
|
||||
plugin::common::PluginPath{kValidFile},
|
||||
plugin::common::PluginArgs{kInvalidArg, kInvalidArg}),
|
||||
type::InvalidArgument);
|
||||
common::type::InvalidArgument);
|
||||
|
||||
ASSERT_NO_THROW(common::line(kValidArg));
|
||||
|
||||
@@ -962,10 +971,13 @@ TEST_F(PluginCommands, ReloadSinglePluggable)
|
||||
plugin::common::PluginArgs{
|
||||
kValidArg + " /* load code */", kValidArg + " e.example3();"}));
|
||||
|
||||
ASSERT_THROW(common::line(kValidArg), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example1();"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example2();"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg + " e.example3();"), type::RuntimeError);
|
||||
ASSERT_THROW(common::line(kValidArg), common::type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example1();"), common::type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example2();"), common::type::RuntimeError);
|
||||
ASSERT_THROW(
|
||||
common::line(kValidArg + " e.example3();"), common::type::RuntimeError);
|
||||
}
|
||||
|
||||
TEST_F(PluginCommands, LoaderNPI)
|
||||
|
||||
Reference in New Issue
Block a user