-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added run time polymorphism test file
- Loading branch information
Showing
5 changed files
with
73 additions
and
2 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
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
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,52 @@ | ||
/************************************************************************** | ||
This file is part of the C++ library "homog2d", dedicated to | ||
handle 2D lines and points, see https://github.com/skramm/homog2d | ||
Author & Copyright 2019-2023 Sebastien Kramm | ||
Contact: [email protected] | ||
Licence: MPL v2 | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
**************************************************************************/ | ||
|
||
/** | ||
\file homog2d_test_rtp.cpp | ||
\brief This program will test the RunTime Polymorphism capabilities | ||
*/ | ||
|
||
|
||
#define CATCH_CONFIG_RUNNER // alternative: main provided here | ||
#include "catch.hpp" | ||
|
||
#define HOMOG2D_TEST_MODE | ||
#define HOMOG2D_ENABLE_RTP | ||
#include "../homog2d.hpp" | ||
|
||
using namespace h2d; | ||
|
||
int main( int, char*) | ||
{ | ||
Segment seg; | ||
CPolyline pol; | ||
Circle cir; | ||
FRect rect; | ||
std::vector<std::shared_ptr<detail::Root>> vec; | ||
vec.push_back( std::make_shared<Circle>(cir) ); | ||
vec.push_back( std::make_shared<CPolyline>(pol) ); | ||
vec.push_back( std::make_shared<Segment>(seg) ); | ||
vec.push_back( std::make_shared<FRect>(rect) ); | ||
|
||
for( auto& e: vec ) | ||
{ | ||
std::cout << getString(e->type()) << ": " << *e | ||
<< "\n -area = " << e->area() | ||
<< "\n -length = " << e->length() | ||
<< '\n'; | ||
} | ||
} |
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,4 @@ | ||
// Polyline: cannot create an open polyline as a RCP | ||
|
||
OPolyline op(4,5); | ||
|
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,7 @@ | ||
// make sure that translate() requires numeric values | ||
|
||
Circle c1; | ||
FRect r; | ||
r.translate( c1, 3 ); | ||
|
||
|