Skip to content

Commit

Permalink
added testcases.
Browse files Browse the repository at this point in the history
  • Loading branch information
treefrogframework committed Feb 21, 2022
1 parent f56a02f commit b9c5fd4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ build: off
# to run your custom scripts instead of automatic MSBuild
build_script:
- cmd: call "%INIT_BAT%" %VCVARARG%
- cmd: set PATH=%QT_PATH%\bin;C:\tools\vcpkg\installed\x86-windows\tools;%PATH%
- cmd: set PATH=%QT_PATH%\bin;%PATH%
- cmd: echo %PATH%
- cmd: qmake
- cmd: qmake CONFIG+=release
- cmd: nmake
- cmd: release\cpi.exe tests\helloworld.cpp
- cmd: release\cpi.exe tests\sqrt.cpp 7
- cmd: release\cpi.exe tests\fibonacci.cpp 10
21 changes: 21 additions & 0 deletions tests/fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <functional>
#include <iostream>


int main(int argc, char *argv[])
{
if (argc != 2) {
return 0;
}

std::function<int64_t(int64_t)> fib = [&fib](int64_t n) {
if (n == 0 || n == 1) {
return n;
} else {
return fib(n - 2) + fib(n - 1);
}
};

std::cout << "fibonacci: " << fib(atoi(argv[1])) << std::endl;
return 0;
}
7 changes: 7 additions & 0 deletions tests/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <iostream>

int main()
{
std::cout << "Hello world\n";
return 0;
}
19 changes: 19 additions & 0 deletions tests/sqrt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <cmath>
#include <cstdlib>
#include <iostream>


int main(int argc, char *argv[])
{
if (argc != 2) {
return 0;
}

auto square = [](int n) { return n * n; }; // lambda expressions

std::cout << "sqrt: " << sqrt(atoi(argv[1])) << std::endl;
std::cout << "square: " << square(atoi(argv[1])) << std::endl;
return 0;
}

// CompileOptions: -lm

0 comments on commit b9c5fd4

Please sign in to comment.