aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-07-20 23:34:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:50:13 +0200
commitab80c5bbc86d45032564b73757e8b09c5ad4f798 (patch)
treee59f69aa55a486750bee744a80df29b6c19ef88a /tests
parent3dd30d705bf9ec6ca8973483100258655cd357f4 (diff)
Initial commit
Diffstat (limited to 'tests')
-rw-r--r--tests/.vscode/c_cpp_properties.json17
-rw-r--r--tests/.vscode/launch.json27
-rw-r--r--tests/.vscode/settings.json8
-rw-r--r--tests/main.cpp47
4 files changed, 99 insertions, 0 deletions
diff --git a/tests/.vscode/c_cpp_properties.json b/tests/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..6ffabe5
--- /dev/null
+++ b/tests/.vscode/c_cpp_properties.json
@@ -0,0 +1,17 @@
+{
+ "configurations": [
+ {
+ "name": "Linux",
+ "includePath": [
+ "${workspaceFolder}/**"
+ ],
+ "defines": [],
+ "compilerPath": "/opt/cuda/bin/gcc",
+ "cStandard": "c11",
+ "cppStandard": "c++17",
+ "intelliSenseMode": "clang-x64",
+ "compileCommands": "${workspaceFolder}/compile_commands.json"
+ }
+ ],
+ "version": 4
+} \ No newline at end of file
diff --git a/tests/.vscode/launch.json b/tests/.vscode/launch.json
new file mode 100644
index 0000000..a1e2431
--- /dev/null
+++ b/tests/.vscode/launch.json
@@ -0,0 +1,27 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "(gdb) Launch",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${workspaceFolder}/sibs-build/debug/test",
+ "args": [],
+ "stopAtEntry": false,
+ "cwd": "${workspaceFolder}",
+ "environment": [],
+ "externalConsole": true,
+ "MIMode": "gdb",
+ "setupCommands": [
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": true
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/.vscode/settings.json b/tests/.vscode/settings.json
new file mode 100644
index 0000000..b8354d0
--- /dev/null
+++ b/tests/.vscode/settings.json
@@ -0,0 +1,8 @@
+{
+ "files.associations": {
+ "array": "cpp",
+ "initializer_list": "cpp",
+ "string_view": "cpp",
+ "utility": "cpp"
+ }
+} \ No newline at end of file
diff --git a/tests/main.cpp b/tests/main.cpp
new file mode 100644
index 0000000..dfcd357
--- /dev/null
+++ b/tests/main.cpp
@@ -0,0 +1,47 @@
+#include <cstdio>
+#include <cstdlib>
+#include <vector>
+#include <sibs/Functional.hpp>
+
+void assertEquals(int expected, int actual)
+{
+ if(actual != expected)
+ {
+ fprintf(stderr, "Assert failed: Expected %d, got %d\n", expected, actual);
+ exit(1);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ std::vector<int> vec1 = { 1, 2, 3, 4, 5 };
+ std::vector<int> vec2 = { 6, 7, 8, 9, 10 };
+ int sum = 0;
+
+ sibs::Function<int> func1(vec1.data(), vec1.data() + vec1.size());
+ for(auto value : func1)
+ {
+ printf("func1 value: %d\n", value);
+ sum += value;
+ }
+ assertEquals(15, sum);
+ sum = 0;
+
+ sibs::Function<int> func2(vec2);
+ for(auto value : func2)
+ {
+ printf("func2 value: %d\n", value);
+ sum += value;
+ }
+ assertEquals(40, sum);
+ sum = 0;
+
+ for(auto value : func1.merge(func2))
+ {
+ printf("func1 and func2 value: %d\n", value);
+ sum += value;
+ }
+ assertEquals(55, sum);
+
+ return 0;
+}