Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unionized-triangles-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Brandon Lai-Cheong
unionized-triangles-2
Commits
4fd1dbec
Commit
4fd1dbec
authored
4 months ago
by
Brandon Lai-Cheong
Browse files
Options
Downloads
Patches
Plain Diff
new tests
parent
99650f50
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
tests/union_tests.cpp
+91
-8
91 additions, 8 deletions
tests/union_tests.cpp
with
92 additions
and
8 deletions
.gitignore
+
1
−
0
View file @
4fd1dbec
build
build
.vscode/c_cpp_properties.json
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/launch.json
.vscode/settings.json
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/union_tests.cpp
+
91
−
8
View file @
4fd1dbec
#include
"gtest/gtest.h"
#include
"gtest/gtest.h"
#include
<union.h>
#include
<union.h>
#include
<triangle.h>
#include
<triangle.h>
TEST
(
UnionTrivialTests
,
NotTouching
)
{
TEST
(
UnionTrivialTests
,
NotTouching
)
Triangle
t1
=
Triangle
{{
0
,
0
},
{
5
,
0
},
{
2
,
3
},
0
};
{
Triangle
t2
=
Triangle
{{
6
,
0
},
{
10
,
0
},
{
7
,
5
},
0
};
Triangle
t1
=
Triangle
{{
0
,
0
},
{
5
,
0
},
{
2
,
3
},
0
};
Triangle
t2
=
Triangle
{{
6
,
0
},
{
10
,
0
},
{
7
,
5
},
0
};
auto
ts
=
unionize
(
t1
,
t2
);
auto
ts
=
unionize
(
t1
,
t2
);
EXPECT_TRUE
(
ts
.
size
()
==
2
);
EXPECT_TRUE
(
ts
.
size
()
==
2
);
}
}
TEST
(
UnionTests
,
TwoIntersections
)
{
TEST
(
UnionTests
,
TwoIntersections
)
{
auto
t1
=
Triangle
(
Point
{
0
,
0
},
Point
{
5
,
0
},
Point
{
2
,
3
},
0
);
auto
t2
=
Triangle
(
Point
{
3
,
1
},
Point
{
6
,
1
},
Point
{
4
,
3
},
0
);
auto
t1
=
Triangle
(
Point
{
0
,
0
},
Point
{
5
,
0
},
Point
{
2
,
3
},
0
);
auto
t2
=
Triangle
(
Point
{
3
,
1
},
Point
{
6
,
1
},
Point
{
4
,
3
},
0
);
auto
ts
=
unionize
(
t1
,
t2
);
auto
ts
=
unionize
(
t1
,
t2
);
EXPECT_TRUE
(
ts
.
size
()
>
0
);
EXPECT_TRUE
(
ts
.
size
()
>
0
);
}
TEST
(
UnionTests
,
TriangleTreeShapeTest
)
{
// Case 1 t1 covers t2
Triangle
bottom
=
Triangle
({
0
,
5
},
{
3
,
2
},
{
5
,
3
},
1
,
1
);
Triangle
top
=
Triangle
({
0.1
,
7
},
{
5
,
3
},
{
3.2
,
9
},
2
,
2
);
auto
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_1
;
EXPECT_EQ
(
results
,
expected_results_1
);
// Case 2 t2 covers t1
bottom
.
depth
=
3
;
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_2
;
EXPECT_EQ
(
results
,
expected_results_2
);
}
TEST
(
UnionTests
,
FoldTriangleTest
)
{
Triangle
bottom
=
Triangle
({
0
,
5
},
{
3
,
2
},
{
5
,
3
},
1
,
1
);
Triangle
top
=
Triangle
({
0.1
,
9
},
{
5
,
5
},
{
2
,
4
},
2
,
2
);
auto
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_1
;
EXPECT_EQ
(
results
,
expected_results_1
);
bottom
.
depth
=
3
;
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_2
;
EXPECT_EQ
(
results
,
expected_results_2
);
}
TEST
(
UnionTests
,
IceCreamTest
)
{
Triangle
bottom
=
Triangle
({
0
,
5
},
{
3
,
2
},
{
5
,
3
},
1
,
1
);
Triangle
top
=
Triangle
({
-
1
,
5
},
{
2
,
4
},
{
5
,
7
},
2
,
2
);
auto
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_1
;
EXPECT_EQ
(
results
,
expected_results_1
);
bottom
.
depth
=
3
;
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_2
;
EXPECT_EQ
(
results
,
expected_results_2
);
}
TEST
(
UnionTests
,
StarTest
)
{
Triangle
bottom
=
Triangle
({
0
,
3
},
{
2.5
,
6
},
{
5
,
3
},
1
,
1
);
Triangle
top
=
Triangle
({
0
,
5
},
{
2
,
0
},
{
5
,
5
},
2
,
2
);
auto
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_1
;
EXPECT_EQ
(
results
,
expected_results_1
);
bottom
.
depth
=
3
;
results
=
unionize
(
bottom
,
top
);
std
::
vector
<
Triangle
>
expected_results_2
;
EXPECT_EQ
(
results
,
expected_results_2
);
}
}
\ No newline at end of file
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