-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重构项目结构,添加依赖管理,更新格式化规则,增加Fibonacci函数及其测试
- Loading branch information
1 parent
0f5ed9d
commit 987b00b
Showing
23 changed files
with
86 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
ColumnLimit: 80 | ||
IndentWidth: 4 | ||
IndentWidth: 4 | ||
AllowShortFunctionsOnASingleLine: false |
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 |
---|---|---|
|
@@ -13,3 +13,4 @@ build/ | |
dist/ | ||
lib/ | ||
bin/ | ||
result/test.json |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "3rd/googletest"] | ||
path = 3rd/googletest | ||
[submodule "deps/gtest"] | ||
path = deps/gtest | ||
url = https://github.com/google/googletest.git | ||
[submodule "deps/cmocka"] | ||
path = deps/cmocka | ||
url = https://github.com/clibs/cmocka.git |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Submodule googletest
deleted from
58d77f
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,4 @@ | ||
#!/bin/bash | ||
|
||
mkdir build | ||
cd build && cmake .. && make |
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,3 @@ | ||
#!/bin/bash | ||
|
||
rm -rf build |
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 @@ | ||
#!/bin/bash | ||
lcov ./result/coverage.info './*' |
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,6 @@ | ||
int fib(int n) { | ||
if (n <= 1) { | ||
return n; | ||
} | ||
return fib(n - 1) + fib(n - 2); | ||
} |
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 @@ | ||
int fib(int n); |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
#include <iostream> | ||
|
||
#include "fib.h" | ||
|
||
#ifndef TEST | ||
int main(int args, char** argv) { | ||
// TODO | ||
std::cout << "hello world!" << std::endl; | ||
int main() { | ||
int n = 0; | ||
printf("Enter a number: "); | ||
scanf("%d", &n); | ||
|
||
int ret = fib(n); | ||
|
||
printf("Sum of Fibonacci series up to %d is %d\n", n, ret); | ||
return 0; | ||
} | ||
#endif |
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 @@ | ||
#!/bin/bash | ||
./bin/test --gtest_output="json:./result/test.json" |
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,28 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "fib.h" | ||
|
||
class FibTestFixture : public ::testing::Test { | ||
protected: | ||
void SetUp() override { | ||
} | ||
|
||
void TearDown() override { | ||
} | ||
}; | ||
|
||
TEST_F(FibTestFixture, HandlesZeroInput) { | ||
EXPECT_EQ(fib(0), 0); | ||
} | ||
|
||
TEST_F(FibTestFixture, HandlesOneInput) { | ||
EXPECT_EQ(fib(1), 1); | ||
} | ||
|
||
TEST_F(FibTestFixture, HandlesPositiveInput) { | ||
EXPECT_EQ(fib(2), 1); | ||
EXPECT_EQ(fib(3), 2); | ||
EXPECT_EQ(fib(4), 3); | ||
EXPECT_EQ(fib(5), 5); | ||
EXPECT_EQ(fib(10), 55); | ||
} |
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,6 @@ | ||
#include <gtest/gtest.h> | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
Empty file.
Binary file not shown.