-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
148 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(Platform.Converters) | ||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_library(${PROJECT_NAME}.Library INTERFACE) | ||
target_include_directories(${PROJECT_NAME}.Library INTERFACE ${PROJECT_NAME}) | ||
|
||
add_executable(${PROJECT_NAME}.Tests ${PROJECT_NAME}.Tests/${PROJECT_NAME}.Tests.cpp) | ||
target_link_libraries(${PROJECT_NAME}.Tests PRIVATE ${PROJECT_NAME}.Library) | ||
target_link_libraries(${PROJECT_NAME}.Tests PRIVATE CONAN_PKG::gtest) | ||
set_target_properties(${PROJECT_NAME}.Tests PROPERTIES CXX_STANDARD 20) |
90 changes: 0 additions & 90 deletions
90
cpp/Platform.Converters.Tests/Platform.Converters.TemplateLibrary.Tests.cpp
This file was deleted.
Oops, something went wrong.
181 changes: 0 additions & 181 deletions
181
cpp/Platform.Converters.Tests/Platform.Converters.TemplateLibrary.Tests.vcxproj
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
cpp/Platform.Converters.Tests/Platform.Converters.TemplateLibrary.Tests.vcxproj.filters
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
cpp/Platform.Converters.Tests/Platform.Converters.Tests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <Platform.Converters.h> | ||
#include <gtest/gtest.h> | ||
|
||
class A | ||
{ | ||
public: | ||
explicit operator std::string() const | ||
{ | ||
return "A"; | ||
} | ||
}; | ||
|
||
class B | ||
{ | ||
friend std::ostream& operator<<(std::ostream& out, const B& obj) | ||
{ | ||
return out << "B"; | ||
} | ||
}; | ||
|
||
struct X {}; | ||
|
||
namespace Platform::Converters::Tests | ||
{ | ||
TEST(ConvertersTests, All) | ||
{ | ||
A a; | ||
A &aReference = a; | ||
A *aPointer = &a; | ||
X x; | ||
X *xPointer = &x; | ||
|
||
ASSERT_EQ(std::string("1"), (Convert<int, std::string>(1))); | ||
// TODO: really, you have a magic compiler? | ||
// ASSERT_EQ(std::string("1.49"), To<std::string>(1.49)); | ||
ASSERT_EQ(std::string("A"), To<std::string>(A())); | ||
ASSERT_EQ(std::string("B"), To<std::string>(B())); | ||
ASSERT_EQ(std::string(""), To<std::string>(std::string(""))); | ||
// TODO: really, you have a magic way of storing types without compression? | ||
// ASSERT_EQ(std::string("instance of class X"), To<std::string>(x)); | ||
|
||
auto pointerToAString = To<std::string>(aPointer); // pointer <6826744964> to <A> | ||
ASSERT_TRUE(pointerToAString.starts_with("pointer <")); | ||
ASSERT_TRUE(pointerToAString.ends_with("> to <A>")); | ||
|
||
auto pointerToXString = To<std::string>(xPointer); // pointer <6826744964> to <instanse of class X> | ||
ASSERT_TRUE(pointerToXString.starts_with("pointer <")); | ||
// TODO: really, you have a magic way of storing types without compression? | ||
// ASSERT_TRUE(pointerToXString.ends_with("> to <instance of class X>")); | ||
|
||
ASSERT_EQ(std::string("null pointer"), (Convert<X*, std::string>(nullptr))); | ||
ASSERT_EQ(std::string("null pointer"), To<std::string>(nullptr)); | ||
|
||
ASSERT_EQ(std::string("A"), (Convert<A&, std::string>(a))); | ||
|
||
ASSERT_EQ(std::string("A"), To<std::string>(aReference)); | ||
ASSERT_EQ(std::string("void pointer <0xa>"), To<std::string>((void *)10)); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.