Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wordle
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
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
repos.tanguy.cavagna
sequencial programming
wordle
Commits
63a13d1e
Commit
63a13d1e
authored
2 years ago
by
tanguy.cavagna
Browse files
Options
Downloads
Patches
Plain Diff
Added tool init/detroy test and fixed leaks due to unproper setup prior test
parent
d44389f1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
test.c
+1
-0
1 addition, 0 deletions
test.c
tool/test/tool-test.c
+7
-0
7 additions, 0 deletions
tool/test/tool-test.c
tool/test/tool-test.h
+1
-0
1 addition, 0 deletions
tool/test/tool-test.h
tool/tool.c
+1
-0
1 addition, 0 deletions
tool/tool.c
wordle/test/wordle-test.c
+7
-7
7 additions, 7 deletions
wordle/test/wordle-test.c
with
17 additions
and
7 deletions
test.c
+
1
−
0
View file @
63a13d1e
...
@@ -24,6 +24,7 @@ int main(void) {
...
@@ -24,6 +24,7 @@ int main(void) {
RUN_TEST
(
test_generate_pattern_should_return_all_0
);
RUN_TEST
(
test_generate_pattern_should_return_all_0
);
// Tool
// Tool
RUN_TEST
(
test_tool_init_destroy
);
RUN_TEST
(
test_compute_matches_should_remain_BALAI
);
RUN_TEST
(
test_compute_matches_should_remain_BALAI
);
return
UNITY_END
();
return
UNITY_END
();
...
...
This diff is collapsed.
Click to expand it.
tool/test/tool-test.c
+
7
−
0
View file @
63a13d1e
#include
"tool-test.h"
#include
"tool-test.h"
void
test_tool_init_destroy
(
void
)
{
set_gamemode
(
TOOL_ASSISTED
);
initialize_game
();
destroy_game
();
}
void
test_compute_matches_should_remain_BALAI
(
void
)
{
void
test_compute_matches_should_remain_BALAI
(
void
)
{
// Arrange
// Arrange
char
**
target
=
malloc
(
sizeof
(
char
*
));
char
**
target
=
malloc
(
sizeof
(
char
*
));
...
...
This diff is collapsed.
Click to expand it.
tool/test/tool-test.h
+
1
−
0
View file @
63a13d1e
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
"../../wordle/wordle.h"
#include
"../../wordle/wordle.h"
#include
"../tool.h"
#include
"../tool.h"
void
test_tool_init_destroy
(
void
);
void
test_compute_matches_should_remain_BALAI
(
void
);
void
test_compute_matches_should_remain_BALAI
(
void
);
#endif
#endif
This diff is collapsed.
Click to expand it.
tool/tool.c
+
1
−
0
View file @
63a13d1e
...
@@ -191,6 +191,7 @@ void init_tool() {
...
@@ -191,6 +191,7 @@ void init_tool() {
void
destroy_tool
()
{
void
destroy_tool
()
{
for
(
int
i
=
0
;
i
<
remaining_bank_count
;
i
++
)
for
(
int
i
=
0
;
i
<
remaining_bank_count
;
i
++
)
free
(
remaining_bank
[
i
]);
free
(
remaining_bank
[
i
]);
free
(
remaining_bank
);
free
(
remaining_bank
);
if
(
possibilities
!=
NULL
)
if
(
possibilities
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
wordle/test/wordle-test.c
+
7
−
7
View file @
63a13d1e
#include
"wordle-test.h"
#include
"wordle-test.h"
void
test_gamemode_should_be_solo
(
void
)
{
void
test_gamemode_should_be_solo
(
void
)
{
initialize_game
();
set_gamemode
(
SOLO
);
set_gamemode
(
SOLO
);
initialize_game
();
TEST_ASSERT_EQUAL_INT
(
SOLO
,
get_gamemode
());
TEST_ASSERT_EQUAL_INT
(
SOLO
,
get_gamemode
());
destroy_game
();
destroy_game
();
}
}
void
test_gamemode_should_be_versus
(
void
)
{
void
test_gamemode_should_be_versus
(
void
)
{
initialize_game
();
set_gamemode
(
VERSUS
);
set_gamemode
(
VERSUS
);
initialize_game
();
TEST_ASSERT_EQUAL_INT
(
VERSUS
,
get_gamemode
());
TEST_ASSERT_EQUAL_INT
(
VERSUS
,
get_gamemode
());
destroy_game
();
destroy_game
();
}
}
void
test_gamemode_should_be_computer
(
void
)
{
void
test_gamemode_should_be_computer
(
void
)
{
initialize_game
();
set_gamemode
(
TOOL_ASSISTED
);
set_gamemode
(
TOOL_ASSISTED
);
initialize_game
();
TEST_ASSERT_EQUAL_INT
(
TOOL_ASSISTED
,
get_gamemode
());
TEST_ASSERT_EQUAL_INT
(
TOOL_ASSISTED
,
get_gamemode
());
destroy_game
();
destroy_game
();
}
}
void
test_answer_shoud_be_balai
(
void
)
{
void
test_answer_shoud_be_balai
(
void
)
{
set_gamemode
(
SOLO
);
initialize_game
();
initialize_game
();
char
target
[
WORD_LENGHT
+
1
]
=
"BALAI"
;
char
target
[
WORD_LENGHT
+
1
]
=
"BALAI"
;
set_gamemode
(
SOLO
);
set_answer
(
target
);
set_answer
(
target
);
TEST_ASSERT_EQUAL_STRING
(
target
,
get_answer
());
TEST_ASSERT_EQUAL_STRING
(
target
,
get_answer
());
...
@@ -36,8 +36,8 @@ void test_answer_shoud_be_balai(void) {
...
@@ -36,8 +36,8 @@ void test_answer_shoud_be_balai(void) {
}
}
void
test_validate_letter_should_be_false
(
void
)
{
void
test_validate_letter_should_be_false
(
void
)
{
initialize_game
();
set_gamemode
(
SOLO
);
set_gamemode
(
SOLO
);
initialize_game
();
for
(
int
i
=
'\0'
;
i
<=
'@'
;
i
++
)
for
(
int
i
=
'\0'
;
i
<=
'@'
;
i
++
)
TEST_ASSERT_FALSE
(
validate_letter
(
i
));
TEST_ASSERT_FALSE
(
validate_letter
(
i
));
...
@@ -45,8 +45,8 @@ void test_validate_letter_should_be_false(void) {
...
@@ -45,8 +45,8 @@ void test_validate_letter_should_be_false(void) {
}
}
void
test_validate_letter_should_be_true
(
void
)
{
void
test_validate_letter_should_be_true
(
void
)
{
initialize_game
();
set_gamemode
(
SOLO
);
set_gamemode
(
SOLO
);
initialize_game
();
for
(
int
i
=
'a'
;
i
<=
'z'
;
i
++
)
for
(
int
i
=
'a'
;
i
<=
'z'
;
i
++
)
TEST_ASSERT_TRUE
(
validate_letter
(
i
));
TEST_ASSERT_TRUE
(
validate_letter
(
i
));
...
@@ -57,9 +57,9 @@ void test_validate_letter_should_be_true(void) {
...
@@ -57,9 +57,9 @@ void test_validate_letter_should_be_true(void) {
}
}
void
test_generate_pattern_should_return_all_0
(
void
)
{
void
test_generate_pattern_should_return_all_0
(
void
)
{
set_gamemode
(
SOLO
);
initialize_game
();
initialize_game
();
Pattern
target
[
WORD_LENGHT
]
=
{
WRONG
,
WRONG
,
WRONG
,
WRONG
,
WRONG
};
Pattern
target
[
WORD_LENGHT
]
=
{
WRONG
,
WRONG
,
WRONG
,
WRONG
,
WRONG
};
set_gamemode
(
SOLO
);
set_answer
(
"BALAI"
);
set_answer
(
"BALAI"
);
set_try
(
"PONTS"
);
set_try
(
"PONTS"
);
...
...
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