Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f407f0f837 | |||
| 56430b513e | |||
| ffdd2439dd | |||
| d591cef798 |
@ -107,6 +107,8 @@ void test_treeSize_returns_correct_size()
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
|
|
||||||
|
printf("\n============================\n Bintree tests\n============================\n");
|
||||||
|
|
||||||
RUN_TEST(test_addToTree_single_element);
|
RUN_TEST(test_addToTree_single_element);
|
||||||
RUN_TEST(test_addToTree_multiple_elements_and_size);
|
RUN_TEST(test_addToTree_multiple_elements_and_size);
|
||||||
|
|||||||
@ -16,9 +16,7 @@ static void dublicateRandomEntry (unsigned int *numbers, unsigned int len)
|
|||||||
if (numbers && len > 2)
|
if (numbers && len > 2)
|
||||||
{
|
{
|
||||||
unsigned int dubIndx = rand() % (len - 1);
|
unsigned int dubIndx = rand() % (len - 1);
|
||||||
unsigned int copyIndx;
|
unsigned int copyIndx = rand() % len;
|
||||||
|
|
||||||
copyIndx = rand() % len;
|
|
||||||
|
|
||||||
numbers[len - 1] = numbers[dubIndx];
|
numbers[len - 1] = numbers[dubIndx];
|
||||||
|
|
||||||
@ -69,7 +67,7 @@ unsigned int *createNumbers(unsigned int len)
|
|||||||
// Duplicate one random entry
|
// Duplicate one random entry
|
||||||
dublicateRandomEntry(numbers, len);
|
dublicateRandomEntry(numbers, len);
|
||||||
|
|
||||||
clearTree(root); //Notwendigkeit muss noch restlichem Code entnommen werden
|
clearTree(root);
|
||||||
return numbers;
|
return numbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
UNITY_BEGIN();
|
UNITY_BEGIN();
|
||||||
|
|
||||||
|
printf("\n============================\n Numbers tests\n============================\n");
|
||||||
|
|
||||||
RUN_TEST(test_createNumbers_no_null);
|
RUN_TEST(test_createNumbers_no_null);
|
||||||
RUN_TEST(test_createNumbers_has_exactly_one_duplicate);
|
RUN_TEST(test_createNumbers_has_exactly_one_duplicate);
|
||||||
RUN_TEST(test_createNumbers_has_correct_value_range);
|
RUN_TEST(test_createNumbers_has_correct_value_range);
|
||||||
|
|||||||
@ -15,6 +15,10 @@ StackNode *push(StackNode *stack, void *data)
|
|||||||
{
|
{
|
||||||
StackNode *newNode;
|
StackNode *newNode;
|
||||||
newNode = (StackNode *)malloc(sizeof(StackNode));
|
newNode = (StackNode *)malloc(sizeof(StackNode));
|
||||||
|
if (!newNode)
|
||||||
|
printf("Speicherfehler: nicht genug Speicher");
|
||||||
|
return stack;
|
||||||
|
|
||||||
newNode->data = data;
|
newNode->data = data;
|
||||||
|
|
||||||
// ,-→ bedeutet Liste war leer - das neue Element hat keinen Nachfolger (next = NULL)
|
// ,-→ bedeutet Liste war leer - das neue Element hat keinen Nachfolger (next = NULL)
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#if __APPLE__
|
||||||
// Defines strict posix compliance for CLOCK_MONOTONIC
|
|
||||||
#define _POSIX_C_SOURCE 199309L
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __APPLE__ || __linux__
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
static struct timespec start = {0, 0};
|
static struct timespec start = {0, 0};
|
||||||
|
|
||||||
@ -20,15 +14,14 @@ void startTimer()
|
|||||||
double stopTimer()
|
double stopTimer()
|
||||||
{
|
{
|
||||||
struct timespec end;
|
struct timespec end;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
|
|
||||||
unsigned long long delta_us = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
unsigned long long delta_us = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
||||||
|
|
||||||
double measuredSeconds = (double)delta_us / 1000000.;
|
double measuredSeconds = (double)delta_us / 1000000.;
|
||||||
|
|
||||||
if (start.tv_nsec > 0)
|
if(start.tv_nsec > 0) {
|
||||||
{
|
|
||||||
start.tv_nsec = 0;
|
start.tv_nsec = 0;
|
||||||
start.tv_sec = 0;
|
start.tv_sec = 0;
|
||||||
}
|
}
|
||||||
@ -52,7 +45,7 @@ double stopTimer()
|
|||||||
{
|
{
|
||||||
double measuredSeconds = (clock() - (double)startClocks) / CLOCKS_PER_SEC;
|
double measuredSeconds = (clock() - (double)startClocks) / CLOCKS_PER_SEC;
|
||||||
|
|
||||||
if (startClocks > 0)
|
if(startClocks > 0)
|
||||||
startClocks = 0;
|
startClocks = 0;
|
||||||
else
|
else
|
||||||
measuredSeconds = -1;
|
measuredSeconds = -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user