Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code workspace configuration + missing test case #177

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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