Skip to content

Commit

Permalink
convert test progress
Browse files Browse the repository at this point in the history
  • Loading branch information
zussel authored and Sascha Kühl committed May 8, 2024
1 parent 1db2f95 commit 7eb9899
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions include/matador/utils/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,41 @@ unsigned long long to_unsigned_long_long(const char *source);
template < typename DestType >
void convert(DestType &dest, const std::string &source, typename std::enable_if<std::is_integral<DestType>::value && std::is_unsigned<DestType>::value>::type* = nullptr)
{
dest = to_unsigned_long_long(source.c_str());
dest = static_cast<DestType>(to_unsigned_long_long(source.c_str()));
}

template < typename DestType >
void convert(DestType &dest, const char *source, typename std::enable_if<std::is_integral<DestType>::value && std::is_unsigned<DestType>::value>::type* = nullptr)
{
dest = to_unsigned_long_long(source);
dest = static_cast<DestType>(to_unsigned_long_long(source));
}

long long to_long_long(const char *source);

template < typename DestType >
void convert(DestType &dest, const std::string &source, typename std::enable_if<std::is_integral<DestType>::value && std::is_signed<DestType>::value>::type* = nullptr)
{
dest = to_long_long(source.c_str());
dest = static_cast<DestType>(to_long_long(source.c_str()));
}

template < typename DestType >
void convert(DestType &dest, const char *source, typename std::enable_if<std::is_integral<DestType>::value && std::is_signed<DestType>::value>::type* = nullptr)
{
dest = to_long_long(source);
dest = static_cast<DestType>(to_long_long(source));
}

long double to_double(const char *source);

template < typename DestType >
void convert(DestType &dest, const std::string &source, typename std::enable_if<std::is_floating_point<DestType>::value>::type* = nullptr)
{
dest = to_double(source.c_str());
dest = static_cast<DestType>(to_double(source.c_str()));
}

template < typename DestType >
void convert(DestType &dest, const char *source, typename std::enable_if<std::is_floating_point<DestType>::value>::type* = nullptr)
{
dest = to_double(source);
dest = static_cast<DestType>(to_double(source));
}

template < typename DestType >
Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ SET (TEST_TOOLS_SOURCES
utils/DependencyInjectionTest.cpp
utils/DependencyInjectionTest.hpp
utils/VersionTest.cpp
utils/VersionTest.hpp)
utils/VersionTest.hpp
utils/ConvertTest.cpp
utils/ConvertTest.hpp)

SET (TEST_JSON_SOURCES
json/JsonTestUnit.cpp
Expand Down
1 change: 1 addition & 0 deletions test/test_matador.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "matador/utils/os.hpp"

#include "utils/ConvertTest.hpp"
#include "utils/TimeTestUnit.hpp"
#include "utils/Base64Test.hpp"
#include "utils/BufferViewTest.hpp"
Expand Down
2 changes: 1 addition & 1 deletion test/utils/BlobTestUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace matador;
BlobTestUnit::BlobTestUnit()
: unit_test("blob", "blob test unit")
{
add_test("create", std::bind(&BlobTestUnit::test_create, this), "create blob");
add_test("create", [this] { test_create(); }, "create blob");
}

void BlobTestUnit::test_create()
Expand Down

0 comments on commit 7eb9899

Please sign in to comment.