Test dependencies
This commit is contained in:
@@ -2,8 +2,15 @@ name: testing
|
||||
gpid: examples
|
||||
semv: 1.0.0
|
||||
|
||||
targets:
|
||||
- name: fibonacci
|
||||
type: archive
|
||||
srcs:
|
||||
- ./fibonacci.cpp
|
||||
|
||||
tests:
|
||||
- name: factorial_test
|
||||
type: program
|
||||
deps: [fibonacci]
|
||||
srcs:
|
||||
- ./entry.cpp
|
||||
@@ -1,13 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
extern "C" int fibonacci(int nth);
|
||||
|
||||
int factorial(int start) {
|
||||
if (start < 0)
|
||||
return 0;
|
||||
|
||||
auto result = 1;
|
||||
for (auto index = 2; index < start; index++)
|
||||
for (auto index = start; index > 0; index--)
|
||||
result *= index;
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
return factorial(5) == 120;
|
||||
auto resultA = factorial(5) == 120;
|
||||
auto resultB = fibonacci(5) == 5;
|
||||
std::cout << "Result A: " << resultA << std::endl;
|
||||
std::cout << "Result B: " << resultB << std::endl;
|
||||
return !(resultA && resultB);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
extern "C" int fibonacci(int nth) {
|
||||
int next;
|
||||
int temp1 = 0;
|
||||
int temp2 = 1;
|
||||
for (int index = 1; index <= nth; index++) {
|
||||
next = temp1 + temp2;
|
||||
temp1 = temp2;
|
||||
temp2 = next;
|
||||
}
|
||||
|
||||
return nth;
|
||||
}
|
||||
Reference in New Issue
Block a user