Native tests run again

This commit is contained in:
Martin Bauer
2020-06-07 10:59:16 +02:00
parent d895d85273
commit 5558151c91
13 changed files with 95 additions and 75 deletions

View File

@@ -1,6 +1,12 @@
#pragma once
inline void _assert(const char* expression, const char* message, const char* file, int line)
#ifndef PLATFORM_NATIVE
// ---------------------------------- Arduino -------------------------------------------------------------
#include <Arduino.h>
inline void _assert(const char *expression, const char *message, const char *file, int line)
{
Serial.print("Assert ");
Serial.print(file);
@@ -12,9 +18,58 @@ inline void _assert(const char* expression, const char* message, const char* fil
Serial.println(message);
}
template< typename T>
inline String toString(const T & t) {
template <typename T>
inline String toString(const T &t)
{
return String(t);
}
#define assert_msg(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
#else
// ---------------------------------- Native -----------------------------------------------------------------
#include <string>
#include <cstdint>
#include <cstring>
#include <arpa/inet.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
typedef uint32_t uint_t;
typedef std::string String;
typedef uint8_t byte;
typedef const char *PGM_P;
using std::max;
using std::min;
inline uint32_t strlen_P(PGM_P str)
{
return std::strlen(str);
}
inline const char *F(const char *in) { return in; }
inline void _assert(const char *expression, const char *message, const char *file, int line)
{
std::cerr << "Assert " << file << ":" << line << " '" << expression << "' failed." << std::endl;
std::cerr << message << std::endl;
abort();
}
template <typename T>
inline std::string toString(const T &t)
{
std::stringstream stream;
stream << t;
return stream.str();
}
#define assert_msg(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))
#endif

View File

@@ -1,5 +1,7 @@
#pragma once
#include "Dtypes.h"
#ifdef PLATFORM_ESP32
#include "SPIFFS.h"
@@ -93,7 +95,6 @@ namespace portablefs
#include <string>
#include <fstream>
#include <filesystem>
#include "MockDtypes.h"
namespace fs = std::filesystem;

View File

@@ -1,46 +0,0 @@
#pragma once
#include <string>
#include <cstdint>
#include <cstring>
#include <arpa/inet.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
typedef uint32_t uint_t;
typedef std::string String;
typedef uint8_t byte;
typedef const char * PGM_P;
using std::min;
using std::max;
inline uint32_t strlen_P(PGM_P str) {
return std::strlen(str);
}
inline const char * F( const char * in) { return in; }
inline void _assert(const char* expression, const char* message, const char* file, int line)
{
std::cerr << "Assert " << file << ":" << line << " '" << expression << "' failed." << std::endl;
std::cerr << message << std::endl;
abort();
}
template< typename T>
inline std::string toString(const T & t) {
std::stringstream stream;
stream << t;
return stream.str();
}
class String : public std::string
{};
#define assert(EXPRESSION, MSG) ((EXPRESSION) ? (void)0 : _assert(#EXPRESSION, #MSG, __FILE__, __LINE__))