Compare commits
6
Commits
96a97c07c9
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a872252a | ||
|
|
de9e0a3357 | ||
|
|
746b9b7219 | ||
|
|
1f3fba80ec | ||
|
|
1d363980f6 | ||
|
|
4ce3a6aac0
|
+60
-1
@@ -1,3 +1,62 @@
|
|||||||
doble_initial.exe
|
# ---> C
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
*.exe
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
Startcode/doble_initial
|
||||||
|
Startcode/doble
|
||||||
|
Startcode/unitTests
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
||||||
|
|
||||||
|
# IDE folders
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|||||||
Vendored
-18
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "windows-gcc-x64",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**"
|
|
||||||
],
|
|
||||||
"compilerPath": "C:/ProgramData/mingw64/mingw64/bin/gcc.exe",
|
|
||||||
"cStandard": "${default}",
|
|
||||||
"cppStandard": "${default}",
|
|
||||||
"intelliSenseMode": "windows-gcc-x64",
|
|
||||||
"compilerArgs": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
Vendored
-24
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "C/C++ Runner: Debug Session",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [],
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"externalConsole": true,
|
|
||||||
"cwd": "c:/Users/Max-R/I2Pr/info2Praktikum-DobleSpiel",
|
|
||||||
"program": "c:/Users/Max-R/I2Pr/info2Praktikum-DobleSpiel/build/Debug/outDebug",
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "gdb",
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Vendored
-59
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
|
||||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
|
||||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
|
||||||
"C_Cpp_Runner.cStandard": "",
|
|
||||||
"C_Cpp_Runner.cppStandard": "",
|
|
||||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
|
||||||
"C_Cpp_Runner.useMsvc": false,
|
|
||||||
"C_Cpp_Runner.warnings": [
|
|
||||||
"-Wall",
|
|
||||||
"-Wextra",
|
|
||||||
"-Wpedantic",
|
|
||||||
"-Wshadow",
|
|
||||||
"-Wformat=2",
|
|
||||||
"-Wcast-align",
|
|
||||||
"-Wconversion",
|
|
||||||
"-Wsign-conversion",
|
|
||||||
"-Wnull-dereference"
|
|
||||||
],
|
|
||||||
"C_Cpp_Runner.msvcWarnings": [
|
|
||||||
"/W4",
|
|
||||||
"/permissive-",
|
|
||||||
"/w14242",
|
|
||||||
"/w14287",
|
|
||||||
"/w14296",
|
|
||||||
"/w14311",
|
|
||||||
"/w14826",
|
|
||||||
"/w44062",
|
|
||||||
"/w44242",
|
|
||||||
"/w14905",
|
|
||||||
"/w14906",
|
|
||||||
"/w14263",
|
|
||||||
"/w44265",
|
|
||||||
"/w14928"
|
|
||||||
],
|
|
||||||
"C_Cpp_Runner.enableWarnings": true,
|
|
||||||
"C_Cpp_Runner.warningsAsError": false,
|
|
||||||
"C_Cpp_Runner.compilerArgs": [],
|
|
||||||
"C_Cpp_Runner.linkerArgs": [],
|
|
||||||
"C_Cpp_Runner.includePaths": [],
|
|
||||||
"C_Cpp_Runner.includeSearch": [
|
|
||||||
"*",
|
|
||||||
"**/*"
|
|
||||||
],
|
|
||||||
"C_Cpp_Runner.excludeSearch": [
|
|
||||||
"**/build",
|
|
||||||
"**/build/**",
|
|
||||||
"**/.*",
|
|
||||||
"**/.*/**",
|
|
||||||
"**/.vscode",
|
|
||||||
"**/.vscode/**"
|
|
||||||
],
|
|
||||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
|
||||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
|
||||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
|
||||||
"C_Cpp_Runner.showCompilationTime": false,
|
|
||||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
|
||||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,2 +1 @@
|
|||||||
krisp;4986
|
|
||||||
player1;3999
|
player1;3999
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
FLAGS = -g -Wall -lm
|
FLAGS = -g -Wall -lm
|
||||||
ASAN_FLAGS = -fsanitize=address
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
include makefile_windows.variables
|
include makefile_windows.variables
|
||||||
@@ -37,20 +36,14 @@ $(program_obj_files): %.o: %.c
|
|||||||
# Unit Tests
|
# Unit Tests
|
||||||
# --------------------------
|
# --------------------------
|
||||||
unitTests:
|
unitTests:
|
||||||
TEST_BIN = runTests
|
echo "needs to be implemented"
|
||||||
|
|
||||||
unitTests: stack.o test_stack.o
|
|
||||||
$(CC) $(FLAGS) $(ASAN_FLAGS) -I$(unityfolder) -o $(TEST_BIN) stack.o test_stack.o $(unityfolder)/unity.c
|
|
||||||
|
|
||||||
test_stack.o: test_stack.c
|
|
||||||
$(CC) $(FLAGS) -I$(unityfolder) -c test_stack.c -o test_stack.o
|
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Clean
|
# Clean
|
||||||
# --------------------------
|
# --------------------------
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
rm -f *.o doble
|
del /f *.o doble
|
||||||
else
|
else
|
||||||
rm -f *.o doble
|
rm -f *.o doble
|
||||||
endif
|
endif
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include "stack.h"
|
||||||
|
|
||||||
|
//TODO: grundlegende Stackfunktionen implementieren:
|
||||||
|
/* * `push`: legt ein Element oben auf den Stack,
|
||||||
|
* `pop`: entfernt das oberste Element,
|
||||||
|
* `top`: liefert das oberste Element zurück,
|
||||||
|
* `clearStack`: gibt den gesamten Speicher frei. */
|
||||||
|
|
||||||
|
// Pushes data as pointer onto the stack.
|
||||||
|
StackNode *push(StackNode *stack, void *data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
||||||
|
// freed by caller.)
|
||||||
|
StackNode *pop(StackNode *stack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the data of the top element.
|
||||||
|
void *top(StackNode *stack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clears stack and releases all memory.
|
||||||
|
void clearStack(StackNode *stack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef STACK_H
|
||||||
|
#define STACK_H
|
||||||
|
|
||||||
|
/* A stack is a special type of queue which uses the LIFO (last in, first out) principle.
|
||||||
|
This means that with each new element all other elements are pushed deeper into the stack.
|
||||||
|
The latest element is taken from the stack. */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
//TODO: passenden Datentyp als struct anlegen
|
||||||
|
|
||||||
|
// Pushes data as pointer onto the stack.
|
||||||
|
StackNode *push(StackNode *stack, void *data);
|
||||||
|
|
||||||
|
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
||||||
|
// freed by caller.)
|
||||||
|
StackNode *pop(StackNode *stack);
|
||||||
|
|
||||||
|
// Returns the data of the top element.
|
||||||
|
void *top(StackNode *stack);
|
||||||
|
|
||||||
|
// Clears stack and releases all memory.
|
||||||
|
void clearStack(StackNode *stack);
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,85 +0,0 @@
|
|||||||
#include "stack.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/*typedef struct {
|
|
||||||
|
|
||||||
void *data;
|
|
||||||
struct StackNode *next;
|
|
||||||
|
|
||||||
} StackNode;*/
|
|
||||||
|
|
||||||
// TODO: grundlegende Stackfunktionen implementieren:
|
|
||||||
/* * `push`: legt ein Element oben auf den Stack,
|
|
||||||
* `pop`: entfernt das oberste Element,
|
|
||||||
* `top`: liefert das oberste Element zurück,
|
|
||||||
* `clearStack`: gibt den gesamten Speicher frei. */
|
|
||||||
|
|
||||||
StackNode *createNode(void *data)
|
|
||||||
{
|
|
||||||
|
|
||||||
StackNode *node =
|
|
||||||
malloc(sizeof(StackNode)); // Speicher reservieren, Speicherplatz für das
|
|
||||||
// struct StackNode
|
|
||||||
|
|
||||||
if (node == NULL)
|
|
||||||
return NULL; // Speicher konnte nicht reserviert werden
|
|
||||||
|
|
||||||
node->data = data; // Zeiger auf data neuer node
|
|
||||||
node->next = NULL; // nächster Zeiger ist NULL, Ende der Liste
|
|
||||||
|
|
||||||
return node; // pointer auf den neuen Knoten zurückgeben
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pushes data as pointer onto the stack.
|
|
||||||
StackNode *push(StackNode *stack, void *data)
|
|
||||||
{
|
|
||||||
StackNode *newNode = createNode(data); // Speicher für neuen Knoten
|
|
||||||
// reservieren
|
|
||||||
|
|
||||||
if (newNode == NULL)
|
|
||||||
{ // wenn Speicher nicht reserviert werden konnte, wird
|
|
||||||
// stack unverändert zurückgegeben
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
newNode->next = stack; // pointer verschieben
|
|
||||||
|
|
||||||
return newNode; // Zeiger auf neuen Speicherbereich zurückgeben
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
|
||||||
// freed by caller.)
|
|
||||||
StackNode *pop(StackNode *stack)
|
|
||||||
{
|
|
||||||
if (stack == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
StackNode *nextNode = stack->next;
|
|
||||||
|
|
||||||
free(stack);
|
|
||||||
|
|
||||||
stack = NULL;
|
|
||||||
|
|
||||||
return nextNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the data of the top element.
|
|
||||||
void *top(StackNode *stack) { return stack != NULL ? stack->data : NULL; }
|
|
||||||
|
|
||||||
// Clears stack and releases all memory.
|
|
||||||
void clearStack(StackNode **stack)
|
|
||||||
{
|
|
||||||
while (*stack != NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
StackNode *next = (*stack)->next;
|
|
||||||
free(*stack);
|
|
||||||
(*stack)->data = NULL;
|
|
||||||
(*stack)->next = NULL;
|
|
||||||
(*stack)->prev = NULL;
|
|
||||||
(*stack) = next;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#ifndef STACK_H
|
|
||||||
#define STACK_H
|
|
||||||
|
|
||||||
/* A stack is a special type of queue which uses the LIFO (last in, first out)
|
|
||||||
principle. This means that with each new element all other elements are pushed
|
|
||||||
deeper into the stack. The latest element is taken from the stack. */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
// TODO: passenden Datentyp als struct anlegen
|
|
||||||
|
|
||||||
typedef struct StackNode {
|
|
||||||
|
|
||||||
void *data;
|
|
||||||
struct StackNode *next;
|
|
||||||
struct StackNode *prev;
|
|
||||||
|
|
||||||
} StackNode;
|
|
||||||
|
|
||||||
StackNode *createNode(void *data);
|
|
||||||
|
|
||||||
typedef struct StackNode {
|
|
||||||
|
|
||||||
void *data;
|
|
||||||
struct StackNode *next;
|
|
||||||
struct StackNode *prev;
|
|
||||||
|
|
||||||
} StackNode;
|
|
||||||
|
|
||||||
StackNode *createNode(void *data);
|
|
||||||
|
|
||||||
// Pushes data as pointer onto the stack.
|
|
||||||
StackNode *push(StackNode *stack, void *data);
|
|
||||||
|
|
||||||
// Deletes the top element of the stack (latest added element) and releases its
|
|
||||||
// memory. (Pointer to data has to be freed by caller.)
|
|
||||||
StackNode *pop(StackNode *stack);
|
|
||||||
|
|
||||||
// Returns the data of the top element.
|
|
||||||
void *top(StackNode *stack);
|
|
||||||
|
|
||||||
// Clears stack and releases all memory.
|
|
||||||
void clearStack(StackNode **stack);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
#include "unity.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "stack.h"
|
|
||||||
|
|
||||||
void test_createNode(void) {
|
|
||||||
|
|
||||||
int testInt = 26;
|
|
||||||
|
|
||||||
StackNode *testNode = createNode(&testInt);
|
|
||||||
|
|
||||||
TEST_ASSERT_NOT_NULL(testNode);
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_PTR(&testInt, testNode->data);
|
|
||||||
|
|
||||||
TEST_ASSERT_NULL(testNode->next);
|
|
||||||
|
|
||||||
free(testNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_pushDataToStack(void) {}
|
|
||||||
|
|
||||||
void test_deleteTopElement(void) {}
|
|
||||||
|
|
||||||
void test_returnData(void) {}
|
|
||||||
|
|
||||||
void test_clearStack(void) {
|
|
||||||
|
|
||||||
int testInts[] = {1, 2, 3, 4, 5};
|
|
||||||
StackNode *testStack = NULL;
|
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
|
|
||||||
testStack = push(testStack, &testInts[i]);
|
|
||||||
}
|
|
||||||
//printf("testints: %d,%d,%d,%d,%d",testInts[0],testInts[1],testInts[2],testInts[3],testInts[4]);
|
|
||||||
|
|
||||||
clearStack(&testStack);
|
|
||||||
TEST_ASSERT_NULL(testStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUp(void) {}
|
|
||||||
void tearDown(void) {}
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
|
|
||||||
UNITY_BEGIN();
|
|
||||||
|
|
||||||
printf("------------------------stack test------------------------\n");
|
|
||||||
RUN_TEST(test_createNode);
|
|
||||||
RUN_TEST(test_pushDataToStack);
|
|
||||||
RUN_TEST(test_deleteTopElement);
|
|
||||||
RUN_TEST(test_returnData);
|
|
||||||
RUN_TEST(test_clearStack);
|
|
||||||
RUN_TEST(test_clearStack);
|
|
||||||
|
|
||||||
return UNITY_END();
|
|
||||||
}
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user