Skip to content

Commit

Permalink
Add Code workspace configuration + missing test case (#177)
Browse files Browse the repository at this point in the history
* Add Code workspace configuration

* Add test case for string.h

* Add integration tests to workspace
  • Loading branch information
RaniAgus authored Mar 21, 2024
1 parent 72470a6 commit d22eb00
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 3 deletions.
23 changes: 23 additions & 0 deletions commons.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"settings": {
"debug.onTaskErrors": "abort",
"files.associations": {
"*.h": "c",
},
"C_Cpp.errorSquiggles": "disabled",
},
"folders": [
{
"path": "src"
},
{
"path": "tests/unit-tests"
},
{
"path": "tests/integration-tests/temporal"
},
{
"path": "tests/integration-tests/logger"
}
]
}
18 changes: 18 additions & 0 deletions src/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
// for the documentation about the c_cpp_properties.json format
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
18 changes: 18 additions & 0 deletions tests/integration-tests/logger/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
// for the documentation about the c_cpp_properties.json format
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/../../../src"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
32 changes: 32 additions & 0 deletions tests/integration-tests/logger/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// See https://go.microsoft.com/fwlink/?linkid=830387
// for the documentation about the launch.json format
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/commons-integration-test-${workspaceFolderBasename}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${workspaceFolder}/../../../src/build"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build",
}
]
}
43 changes: 43 additions & 0 deletions tests/integration-tests/logger/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"dependsOn": [
"build_sources",
"build_tests"
],
},
{
"label": "build_sources",
"command": "make --no-print-directory -C ../../../src debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "build_tests",
"command": "make debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "clean",
"command": "make clean",
"type": "shell",
"group": {
"kind": "none"
},
"problemMatcher": []
}
]
}
18 changes: 18 additions & 0 deletions tests/integration-tests/temporal/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
// for the documentation about the c_cpp_properties.json format
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/../../../src"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
32 changes: 32 additions & 0 deletions tests/integration-tests/temporal/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// See https://go.microsoft.com/fwlink/?linkid=830387
// for the documentation about the launch.json format
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/commons-integration-test-${workspaceFolderBasename}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${workspaceFolder}/../../../src/build"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build",
}
]
}
43 changes: 43 additions & 0 deletions tests/integration-tests/temporal/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"dependsOn": [
"build_sources",
"build_tests"
],
},
{
"label": "build_sources",
"command": "make --no-print-directory -C ../../../src debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "build_tests",
"command": "make debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "clean",
"command": "make clean",
"type": "shell",
"group": {
"kind": "none"
},
"problemMatcher": []
}
]
}
19 changes: 19 additions & 0 deletions tests/unit-tests/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// See https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
// for the documentation about the c_cpp_properties.json format
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/../../src",
"${workspaceFolder}/../../cspec"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
32 changes: 32 additions & 0 deletions tests/unit-tests/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// See https://go.microsoft.com/fwlink/?linkid=830387
// for the documentation about the launch.json format
"version": "0.2.0",
"configurations": [
{
"name": "test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/commons-unit-test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "${workspaceFolder}/../../src/build:${workspaceFolder}/../../cspec/release"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build",
}
]
}
43 changes: 43 additions & 0 deletions tests/unit-tests/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"dependsOn": [
"build_sources",
"build_tests"
],
},
{
"label": "build_sources",
"command": "make --no-print-directory -C ../../src debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "build_tests",
"command": "make debug",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
},
{
"label": "clean",
"command": "make clean",
"type": "shell",
"group": {
"kind": "none"
},
"problemMatcher": []
}
]
}
17 changes: 14 additions & 3 deletions tests/unit-tests/test_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ context (test_string) {

describe("Split") {

it("split_with_separators") {
char *line = "path//to//file";
char** substrings = string_split(line, "//");
it("split_with_separator_found") {
char *line = "path\\to\\file";
char** substrings = string_split(line, "\\");

should_ptr(substrings) not be null;
should_string(substrings[0]) be equal to ("path");
Expand All @@ -206,6 +206,17 @@ context (test_string) {
string_array_destroy(substrings);
} end

it("split_with_separator_not_found") {
char *line = "path";
char **substrings = string_split(line, "/");

should_ptr(substrings) not be null;
should_string(substrings[0]) be equal to ("path");
should_ptr(substrings[1]) be null;

string_array_destroy(substrings);
} end

it("split_with_empty_string_as_separator") {
char *line = "hello";
char** substrings = string_split(line, "");
Expand Down

0 comments on commit d22eb00

Please sign in to comment.