-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/switch_to_gtest' into develop
- Loading branch information
Showing
8 changed files
with
119 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore the generated test executable | ||
array_merge_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore the generated binary | ||
mergesort_test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "mergesort.h" | ||
|
||
void arrays_match(int size, int a[], int b[]) { | ||
int i; | ||
|
||
for (i=0; i<size; ++i) { | ||
ASSERT_EQ(a[i], b[i]); | ||
} | ||
} | ||
|
||
TEST(Mergesort, HandleEmptyList) { | ||
int a[] = { }; | ||
int b[] = { }; | ||
mergesort(0, b); | ||
arrays_match(0, a, b); | ||
} | ||
|
||
TEST(Mergesort, HandleSingletonList) { | ||
int a[] = { 5 }; | ||
int b[] = { 5 }; | ||
mergesort(1, b); | ||
arrays_match(1, a, b); | ||
} | ||
|
||
TEST(Mergesort, HandleOrderedPair) { | ||
int a[] = { 5, 8 }; | ||
int expected[] = { 5, 8 }; | ||
mergesort(2, a); | ||
arrays_match(2, a, expected); | ||
} | ||
|
||
TEST(Mergesort, HandleUnorderedPair) { | ||
int a[] = { 8, 5 }; | ||
int expected[] = { 5, 8 }; | ||
mergesort(2, a); | ||
arrays_match(2, a, expected); | ||
} | ||
|
||
TEST(Mergesort, HandleMixed) { | ||
int a[] = { 5, 8, 9, 6, 3, 2, 0 }; | ||
int expected[] = { 0, 2, 3, 5, 6, 8, 9 }; | ||
mergesort(7, a); | ||
arrays_match(7, a, expected); | ||
} | ||
|
||
TEST(Mergesort, HandleOrdered) { | ||
int a[] = { 0, 2, 3, 5, 6, 8, 9 }; | ||
int expected[] = { 0, 2, 3, 5, 6, 8, 9 }; | ||
mergesort(7, a); | ||
arrays_match(7, a, expected); | ||
} | ||
|
||
TEST(Mergesort, HandleReversed) { | ||
int a[] = { 9, 8, 6, 5, 3, 2, 0 }; | ||
int expected[] = { 0, 2, 3, 5, 6, 8, 9 }; | ||
mergesort(7, a); | ||
arrays_match(7, a, expected); | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |