Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp_8_galaxy
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arnaud.devevey
tp_8_galaxy
Commits
7acbc444
Commit
7acbc444
authored
6 years ago
by
arnaud.devevey
Browse files
Options
Downloads
Patches
Plain Diff
debut aprem
parent
94362057
No related branches found
No related tags found
No related merge requests found
Pipeline
#6069
failed
6 years ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
perso/box.c
+22
-29
22 additions, 29 deletions
perso/box.c
perso/box.h
+5
-5
5 additions, 5 deletions
perso/box.h
perso/tests.h
+17
-0
17 additions, 0 deletions
perso/tests.h
with
44 additions
and
34 deletions
perso/box.c
+
22
−
29
View file @
7acbc444
...
@@ -8,23 +8,23 @@
...
@@ -8,23 +8,23 @@
* *
* *
* * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * */
Box
*
new_box
(
double
new_x0
,
double
new_y0
,
double
new_x1
,
double
new_y1
)
{
Box
new_box
(
double
new_x0
,
double
new_y0
,
double
new_x1
,
double
new_y1
)
{
Box
*
temp_box
=
malloc
(
sizeof
(
Box
))
;
Box
temp_box
;
if
(
new_x0
>
new_x1
)
{
if
(
new_x0
>
new_x1
)
{
temp_box
->
x0
=
new_x1
;
temp_box
.
x0
=
new_x1
;
temp_box
->
x1
=
new_x0
;
temp_box
.
x1
=
new_x0
;
}
else
{
}
else
{
temp_box
->
x0
=
new_x0
;
temp_box
.
x0
=
new_x0
;
temp_box
->
x1
=
new_x1
;
temp_box
.
x1
=
new_x1
;
}
}
if
(
new_y0
>
new_y1
)
{
if
(
new_y0
>
new_y1
)
{
temp_box
->
y0
=
new_y1
;
temp_box
.
y0
=
new_y1
;
temp_box
->
y1
=
new_y0
;
temp_box
.
y1
=
new_y0
;
}
else
{
}
else
{
temp_box
->
y0
=
new_y0
;
temp_box
.
y0
=
new_y0
;
temp_box
->
y1
=
new_y1
;
temp_box
.
y1
=
new_y1
;
}
}
...
@@ -32,7 +32,7 @@ Box* new_box(double new_x0, double new_y0, double new_x1, double new_y1) {
...
@@ -32,7 +32,7 @@ Box* new_box(double new_x0, double new_y0, double new_x1, double new_y1) {
}
}
Box
*
divide_in_four
(
Box
*
box
)
{
Box
*
divide_in_four
(
Box
box
)
{
/*
/*
(x0 ; y0)
(x0 ; y0)
...
@@ -49,13 +49,13 @@ Box* divide_in_four(Box* box) {
...
@@ -49,13 +49,13 @@ Box* divide_in_four(Box* box) {
*/
*/
Box
*
b0
=
new_box
(
box
->
x0
,
box
->
y0
,
box
->
x1
/
2
,
box
->
y1
/
2
);
Box
b0
=
new_box
(
box
.
x0
,
box
.
y0
,
box
.
x1
/
2
.
0
,
box
.
y1
/
2
.
0
);
Box
*
b1
=
new_box
(
box
->
x1
/
2
,
box
->
y0
,
box
->
x1
,
box
->
y1
/
2
);
Box
b1
=
new_box
(
box
.
x1
/
2
.
0
,
box
.
y0
,
box
.
x1
,
box
.
y1
/
2
.
0
);
Box
*
b2
=
new_box
(
box
->
x0
,
box
->
y1
/
2
,
box
->
x1
/
2
,
box
->
y1
);
Box
b2
=
new_box
(
box
.
x0
,
box
.
y1
/
2
.
0
,
box
.
x1
/
2
.
0
,
box
.
y1
);
Box
*
b3
=
new_box
(
box
->
x1
/
2
,
box
->
y1
/
2
,
box
->
x1
,
box
->
y1
);
Box
b3
=
new_box
(
box
.
x1
/
2
.
0
,
box
.
y1
/
2
.
0
,
box
.
x1
,
box
.
y1
);
// pointeur ou pas?
// pointeur ou pas?
Box
*
sub_boxes
[]
=
malloc
(
4
*
sizeof
(
Box
*
));
Box
*
sub_boxes
=
malloc
(
4
*
sizeof
(
Box
));
sub_boxes
[
0
]
=
b0
;
sub_boxes
[
0
]
=
b0
;
sub_boxes
[
1
]
=
b1
;
sub_boxes
[
1
]
=
b1
;
sub_boxes
[
2
]
=
b2
;
sub_boxes
[
2
]
=
b2
;
...
@@ -105,33 +105,26 @@ void print_box(Box box) {
...
@@ -105,33 +105,26 @@ void print_box(Box box) {
void
tests_box
()
{
void
tests_box
()
{
printf
(
"TESTS BOX :
\n
"
);
printf
(
"TESTS BOX :
\n
"
);
Box
*
b1
=
new_box
(
0
.
0
,
0
.
0
,
3
.
0
,
3
.
0
);
Box
b1
=
new_box
(
0
.
0
,
0
.
0
,
3
.
0
,
3
.
0
);
Box
*
b2
=
divide_in_four
(
b1
);
Box
*
b2
=
divide_in_four
(
b1
);
tests_box_new
(
b1
);
tests_box_divide
(
b2
);
tests_box_divide
(
b2
);
tests_box_include
(
b1
);
tests_box_include
(
b1
);
free
(
b1
);
free
(
b2
);
free
(
b2
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
void
tests_box_new
(
Box
*
b1
)
{
void
tests_box_divide
(
Box
*
b
)
{
TEST
(
b1
!=
NULL
);
Box
box_test
=
new_box
(
1
.
5
,
0
.
0
,
3
.
0
,
1
.
5
);
}
TEST
(
box_test
.
x0
==
b
[
1
].
x0
&&
box_test
.
x1
==
b
[
1
].
x1
&&
box_test
.
y0
==
b
[
1
].
y0
&&
box_test
.
y1
==
b
[
1
].
y1
);
void
tests_box_divide
(
Box
*
b2
)
{
// COMPLETER APRES AVOIR FINI DIVIDE()
printf
(
"bla"
);
}
}
void
tests_box_include
(
Box
*
b1
)
{
void
tests_box_include
(
Box
b1
)
{
Vector
*
vector
=
new_vec
(
1
.
0
,
2
.
0
);
Vector
*
vector
=
new_vec
(
1
.
0
,
2
.
0
);
TEST
(
is_inside
(
*
b1
,
*
vector
));
TEST
(
is_inside
(
b1
,
*
vector
));
free
(
vector
);
free
(
vector
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
perso/box.h
+
5
−
5
View file @
7acbc444
...
@@ -23,10 +23,10 @@ typedef struct __box {
...
@@ -23,10 +23,10 @@ typedef struct __box {
* * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * */
// crée une nouvelle box
// crée une nouvelle box
Box
*
new_box
(
double
new_x0
,
double
new_y0
,
double
new_x1
,
double
new_y1
);
Box
new_box
(
double
new_x0
,
double
new_y0
,
double
new_x1
,
double
new_y1
);
// divise une box en quatre parties égales
// divise une box en quatre parties égales
Box
*
divide_in_four
(
Box
*
box
);
Box
*
divide_in_four
(
Box
box
);
// détérmine si une position est dans la box
// détérmine si une position est dans la box
bool
is_inside
(
Box
box
,
Vector
vector
);
bool
is_inside
(
Box
box
,
Vector
vector
);
...
@@ -39,8 +39,8 @@ void print_box(Box box);
...
@@ -39,8 +39,8 @@ void print_box(Box box);
void
tests_box
();
void
tests_box
();
void
tests_box_new
(
Box
*
b
1
);
//
void tests_box_new(Box b);
void
tests_box_divide
(
Box
*
b
2
);
void
tests_box_divide
(
Box
*
b
);
void
tests_box_include
(
Box
*
b
1
);
void
tests_box_include
(
Box
b
);
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
perso/tests.h
0 → 100644
+
17
−
0
View file @
7acbc444
#ifndef __TESTS_H__
#define __TESTS_H__
#define TEST(x) \
if (x) \
PRT_OK else PRT_NOK
// OK print en vert, error en rouge
#define PRT_OK printf("\t%s() : %sok%s\n", __func__, "\t[\x1B[32m", "\x1B[0m]");
#define PRT_NOK printf("\t%s() : %serror%s\n", __func__, "\t[\x1B[31m", "\x1B[0m]");
#endif
\ 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