Loading files
3d097a032This file is pinned to the selected release. Download the original to open it in your design tool.
// Copyright (c) 2026 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <GC_MakeSegment2d.hxx>
#include <gp.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gtest/gtest.h>
TEST(GC_MakeSegment2dTest, FromPoints_BelowResolution_ConfusedPoints)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Pnt2d aP2(0.5 * gp::Resolution(), 0.0);
GC_MakeSegment2d aMaker(aP1, aP2);
EXPECT_FALSE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_ConfusedPoints);
}
TEST(GC_MakeSegment2dTest, FromPoints_AboveResolution_Done)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Pnt2d aP2(1.0e-150, 0.0);
GC_MakeSegment2d aMaker(aP1, aP2);
EXPECT_TRUE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_Done);
}
TEST(GC_MakeSegment2dTest, FromPoints_AtResolution_ConfusedPoints)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Pnt2d aP2(gp::Resolution(), 0.0);
GC_MakeSegment2d aMaker(aP1, aP2);
EXPECT_FALSE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_ConfusedPoints);
}
TEST(GC_MakeSegment2dTest, FromPointDir_BelowResolutionParameter_ConfusedPoints)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Dir2d aDir(1.0, 0.0);
const gp_Pnt2d aP2(0.5 * gp::Resolution(), 3.0);
GC_MakeSegment2d aMaker(aP1, aDir, aP2);
EXPECT_FALSE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_ConfusedPoints);
}
TEST(GC_MakeSegment2dTest, FromPointDir_AboveResolutionParameter_Done)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Dir2d aDir(1.0, 0.0);
const gp_Pnt2d aP2(2.0 * gp::Resolution(), 3.0);
GC_MakeSegment2d aMaker(aP1, aDir, aP2);
EXPECT_TRUE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_Done);
}
TEST(GC_MakeSegment2dTest, FromPointDir_AtResolutionParameter_ConfusedPoints)
{
const gp_Pnt2d aP1(0.0, 0.0);
const gp_Dir2d aDir(1.0, 0.0);
const gp_Pnt2d aP2(gp::Resolution(), 5.0);
GC_MakeSegment2d aMaker(aP1, aDir, aP2);
EXPECT_FALSE(aMaker.IsDone());
EXPECT_EQ(aMaker.Status(), gce_ConfusedPoints);
}