Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
HFTSoftwareProject
testcases
Commits
4a9feeab
Commit
4a9feeab
authored
Sep 24, 2024
by
Younis
Browse files
Add new file InsertionSortTest
parent
416020ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
InsertionSortTest.java
0 → 100644
View file @
4a9feeab
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
public
class
InsertionSortTest
{
@Test
public
void
testInsertionSort
()
{
int
[]
unsortedArray
=
{
7
,
98
,
15
,
38
,
25
,
0
,
12
,
8
,
22
,
83
,
79
,
77
,
63
,
56
,
56
,
2
,
18
,
21
,
24
,
28
};
int
[]
expectedSortedArray
=
{
0
,
2
,
7
,
8
,
12
,
15
,
18
,
21
,
22
,
24
,
25
,
28
,
38
,
56
,
56
,
63
,
77
,
79
,
83
,
98
};
// Test randomFill method
InsertionSort
.
randomFill
(
unsortedArray
);
// Ensure the array is filled with random numbers between 0 and 99
for
(
int
num
:
unsortedArray
)
{
assertTrue
(
num
>=
0
&&
num
<
100
);
}
// Test insertionSort method
InsertionSort
.
insertionSort
(
unsortedArray
);
// Ensure the array is sorted correctly
assertArrayEquals
(
expectedSortedArray
,
unsortedArray
);
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment