Fix tests path.

This commit is contained in:
2021-10-05 04:38:55 +01:00
parent fe8e157f89
commit 15fdd85481
9 changed files with 67 additions and 11 deletions

View File

@@ -6,9 +6,9 @@ add_subdirectory(lib)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/random
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/random)
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
# 'Google_Tests_run' is the target name
# 'test1.cpp tests2.cpp' are source files with tests
add_executable(tests_run adler32.cpp crc16.cpp crc32.cpp crc64.cpp fletcher16.cpp fletcher32.cpp spamsum.cpp)
add_executable(tests_run adler32.cpp crc16.cpp crc16_ccitt.cpp crc32.cpp crc64.cpp fletcher16.cpp fletcher32.cpp spamsum.cpp)
target_link_libraries(tests_run gtest gtest_main "Aaru.Checksums.Native")

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class adler32Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class crc16Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,10 +2,11 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../crc16_ccitt.h"
#include "../library.h"
#include "../crc16_ccitt.h"
#include "gtest/gtest.h"
#define EXPECTED_CRC16_CCITT 0x3640
@@ -24,7 +25,13 @@ class crc16_ccittFixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class crc32Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class crc64Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class fletcher16Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class fletcher32Fixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);

View File

@@ -2,6 +2,7 @@
// Created by claunia on 5/10/21.
//
#include <climits>
#include <cstdint>
#include "../library.h"
@@ -24,7 +25,13 @@ class spamsumFixture : public ::testing::Test
protected:
void SetUp()
{
FILE* file = fopen("/home/claunia/random", "rb");
char path[PATH_MAX];
char filename[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(filename, PATH_MAX, "%s/data/random", path);
FILE* file = fopen(filename, "rb");
buffer = (const uint8_t*)malloc(1048576);
fread((void*)buffer, 1, 1048576, file);
fclose(file);