Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaofan Chen
ogs
Commits
4e5c18db
Commit
4e5c18db
authored
3 years ago
by
Christoph Lehmann
Committed by
Dmitri Naumov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[T] Adapted and extended weighted point unit tests
parent
8392f6c6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/MathLib/TestWeightedPoint.cpp
+153
-26
153 additions, 26 deletions
Tests/MathLib/TestWeightedPoint.cpp
with
153 additions
and
26 deletions
Tests/MathLib/TestWeightedPoint.cpp
+
153
−
26
View file @
4e5c18db
...
...
@@ -9,43 +9,170 @@
#include
<gtest/gtest.h>
#include
"MathLib/TemplateWeightedPoint.h"
#include
"MathLib/WeightedPoint.h"
TEST
(
MathLib
,
WeightedPoint0D
)
{
std
::
array
<
double
,
0
>
const
pnt
{};
double
const
w
=
50.0
;
MathLib
::
WeightedPoint
const
wpnt_0d
(
pnt
,
w
);
ASSERT_EQ
(
0
,
wpnt_0d
.
getDimension
());
ASSERT_EQ
(
w
,
wpnt_0d
.
getWeight
());
}
TEST
(
MathLib
,
WeightedPoint1D
)
{
std
::
array
<
double
,
1
>
pnt
;
pnt
[
0
]
=
0.5
;
double
w
=
100.0
;
MathLib
::
WeightedPoint1D
wpnt_1d
(
pnt
,
w
);
std
::
array
<
double
,
1
>
pnt
{
0.5
};
double
const
w
=
100.0
;
MathLib
::
WeightedPoint
const
wpnt_1d
(
pnt
,
w
);
ASSERT_NEAR
(
pnt
[
0
],
wpnt_1d
[
0
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
w
,
wpnt_1d
.
getWeight
(),
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_EQ
(
1
,
wpnt_1d
.
getDimension
());
ASSERT_EQ
(
pnt
[
0
],
wpnt_1d
[
0
]);
ASSERT_EQ
(
w
,
wpnt_1d
.
getWeight
());
}
TEST
(
MathLib
,
WeightedPoint2D
)
{
std
::
array
<
double
,
2
>
pnt
;
pnt
[
0
]
=
0.1
;
pnt
[
1
]
=
0.2
;
double
w
=
200.0
;
MathLib
::
WeightedPoint2D
wpnt_2d
(
pnt
,
w
);
std
::
array
<
double
,
2
>
const
pnt
{
0.1
,
0.2
};
double
const
w
=
200.0
;
MathLib
::
WeightedPoint
const
wpnt_2d
(
pnt
,
w
);
ASSERT_NEAR
(
pnt
[
0
],
wpnt_2d
[
0
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
pnt
[
1
],
wpnt_2d
[
1
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
w
,
wpnt_2d
.
getWeight
(),
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_EQ
(
2
,
wpnt_2d
.
getDimension
());
ASSERT_EQ
(
pnt
[
0
],
wpnt_2d
[
0
]);
ASSERT_EQ
(
pnt
[
1
],
wpnt_2d
[
1
]);
ASSERT_EQ
(
w
,
wpnt_2d
.
getWeight
());
}
TEST
(
MathLib
,
WeightedPoint3D
)
{
std
::
array
<
double
,
3
>
pnt
;
pnt
[
0
]
=
0.1
;
pnt
[
1
]
=
0.2
;
pnt
[
2
]
=
0.3
;
double
w
=
300.0
;
MathLib
::
WeightedPoint3D
wpnt_3d
(
pnt
,
w
);
ASSERT_NEAR
(
pnt
[
0
],
wpnt_3d
[
0
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
pnt
[
1
],
wpnt_3d
[
1
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
pnt
[
2
],
wpnt_3d
[
2
],
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
w
,
wpnt_3d
.
getWeight
(),
std
::
numeric_limits
<
double
>::
epsilon
());
std
::
array
<
double
,
3
>
const
pnt
{
0.1
,
0.2
,
0.3
};
double
const
w
=
300.0
;
MathLib
::
WeightedPoint
const
wpnt_3d
(
pnt
,
w
);
ASSERT_EQ
(
3
,
wpnt_3d
.
getDimension
());
ASSERT_EQ
(
pnt
[
0
],
wpnt_3d
[
0
]);
ASSERT_EQ
(
pnt
[
1
],
wpnt_3d
[
1
]);
ASSERT_EQ
(
pnt
[
2
],
wpnt_3d
[
2
]);
ASSERT_EQ
(
w
,
wpnt_3d
.
getWeight
());
}
TEST
(
MathLib
,
WeightedPointEquality3D
)
{
MathLib
::
WeightedPoint
const
orig
{
std
::
array
{
0.1
,
0.2
,
0.3
},
0.4
};
{
MathLib
::
WeightedPoint
const
same
{
std
::
array
{
0.1
,
0.2
,
0.3
},
0.4
};
ASSERT_EQ
(
orig
,
same
);
}
{
MathLib
::
WeightedPoint
const
diff_x
{
std
::
array
{
0.15
,
0.2
,
0.3
},
0.4
};
ASSERT_NE
(
orig
,
diff_x
);
}
{
MathLib
::
WeightedPoint
const
diff_y
{
std
::
array
{
0.1
,
0.25
,
0.3
},
0.4
};
ASSERT_NE
(
orig
,
diff_y
);
}
{
MathLib
::
WeightedPoint
const
diff_z
{
std
::
array
{
0.1
,
0.2
,
0.35
},
0.4
};
ASSERT_NE
(
orig
,
diff_z
);
}
{
MathLib
::
WeightedPoint
const
diff_w
{
std
::
array
{
0.1
,
0.2
,
0.3
},
0.45
};
ASSERT_NE
(
orig
,
diff_w
);
}
{
MathLib
::
WeightedPoint
const
diff_dim0
{
std
::
array
<
double
,
0
>
{},
0.4
};
ASSERT_NE
(
orig
,
diff_dim0
);
}
{
MathLib
::
WeightedPoint
const
diff_dim1
{
std
::
array
{
0.1
},
0.4
};
ASSERT_NE
(
orig
,
diff_dim1
);
}
{
MathLib
::
WeightedPoint
const
diff_dim2
{
std
::
array
{
0.1
,
0.2
},
0.4
};
ASSERT_NE
(
orig
,
diff_dim2
);
}
}
TEST
(
MathLib
,
WeightedPointEquality2D
)
{
MathLib
::
WeightedPoint
const
orig
{
std
::
array
{
0.1
,
0.2
},
0.4
};
{
MathLib
::
WeightedPoint
const
same
{
std
::
array
{
0.1
,
0.2
},
0.4
};
ASSERT_EQ
(
orig
,
same
);
}
{
MathLib
::
WeightedPoint
const
diff_x
{
std
::
array
{
0.15
,
0.2
},
0.4
};
ASSERT_NE
(
orig
,
diff_x
);
}
{
MathLib
::
WeightedPoint
const
diff_y
{
std
::
array
{
0.1
,
0.25
},
0.4
};
ASSERT_NE
(
orig
,
diff_y
);
}
{
MathLib
::
WeightedPoint
const
diff_w
{
std
::
array
{
0.1
,
0.2
},
0.45
};
ASSERT_NE
(
orig
,
diff_w
);
}
{
MathLib
::
WeightedPoint
const
diff_dim0
{
std
::
array
<
double
,
0
>
{},
0.4
};
ASSERT_NE
(
orig
,
diff_dim0
);
}
{
MathLib
::
WeightedPoint
const
diff_dim1
{
std
::
array
{
0.1
},
0.4
};
ASSERT_NE
(
orig
,
diff_dim1
);
}
}
TEST
(
MathLib
,
WeightedPointEquality1D
)
{
MathLib
::
WeightedPoint
const
orig
{
std
::
array
{
0.1
},
0.4
};
{
MathLib
::
WeightedPoint
const
same
{
std
::
array
{
0.1
},
0.4
};
ASSERT_EQ
(
orig
,
same
);
}
{
MathLib
::
WeightedPoint
const
diff_x
{
std
::
array
{
0.15
},
0.4
};
ASSERT_NE
(
orig
,
diff_x
);
}
{
MathLib
::
WeightedPoint
const
diff_w
{
std
::
array
{
0.1
},
0.45
};
ASSERT_NE
(
orig
,
diff_w
);
}
{
MathLib
::
WeightedPoint
const
diff_dim0
{
std
::
array
<
double
,
0
>
{},
0.4
};
ASSERT_NE
(
orig
,
diff_dim0
);
}
}
TEST
(
MathLib
,
WeightedPointEquality0D
)
{
MathLib
::
WeightedPoint
const
orig
{
0.4
};
{
MathLib
::
WeightedPoint
const
same
{
0.4
};
ASSERT_EQ
(
orig
,
same
);
}
{
MathLib
::
WeightedPoint
const
diff_w
{
0.45
};
ASSERT_NE
(
orig
,
diff_w
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment