forked from pEp.foundation/CXX-project-template

1 changed files with 44 additions and 0 deletions
@ -0,0 +1,44 @@ |
|||||
|
// This file is under GNU General Public License 3.0
|
||||
|
// see LICENSE.txt
|
||||
|
#include "hello_world.hh" |
||||
|
#include <iostream> |
||||
|
|
||||
|
// 2 Reasons why this 'using namespace' is okay
|
||||
|
// 1. We cannot put main() in the namespace pEp,
|
||||
|
// 2. If we were to extract parts of this file into a header-extension (hxx) as a template function/class
|
||||
|
// we would be in the namespace pEp anyways.
|
||||
|
using namespace pEp; |
||||
|
|
||||
|
int main() |
||||
|
{ |
||||
|
std::cout << "Test Hello World" << std::endl; |
||||
|
{ |
||||
|
std::cout << "Test non-template func" << std::endl; |
||||
|
std::string ret = HelloWorld::hello_world(); |
||||
|
std::cout << ret << std::endl; |
||||
|
assert(ret == "hello world"); |
||||
|
} |
||||
|
|
||||
|
{ |
||||
|
std::cout << "Test invoke generated template for std::string" << std::endl; |
||||
|
std::string ret = HelloWorld::hello_world("pEp"); |
||||
|
std::cout << ret << std::endl; |
||||
|
assert(ret == "pEp"); |
||||
|
} |
||||
|
|
||||
|
{ |
||||
|
std::cout << "Test specialization for int" << std::endl; |
||||
|
int ret = HelloWorld::hello_world(404); |
||||
|
std::cout << ret << std::endl; |
||||
|
assert(ret == 808); |
||||
|
} |
||||
|
|
||||
|
{ |
||||
|
std::cout << "Test specialization for double" << std::endl; |
||||
|
double ret = HelloWorld::hello_world(4.04); |
||||
|
std::cout << ret << std::endl; |
||||
|
assert(ret == 8.08); |
||||
|
} |
||||
|
std::cout << "All tests passed" << std::endl; |
||||
|
return 0; |
||||
|
} |
Loading…
Reference in new issue