Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed Feb 24, 2024
1 parent f55ee75 commit 8c95bbc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
32 changes: 7 additions & 25 deletions buttons/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string.h>

#define DESCRIBE(X) case X: return #X
#define PROFFIE_TEST


// cruft
Expand Down Expand Up @@ -52,32 +53,13 @@ struct SaberBase {

#define HEX 16

struct Print {
void print(const char* s) { puts(s); }
void print(int v, int base) { fprintf(stdout, "%d", v); }
void print(float v) { fprintf(stdout, "%f", v); }
void write(char s) { putchar(s); }
template<class T>
void println(T s) { print(s); putchar('\n'); }
};

template<typename T, typename X = void> struct PrintHelper {
static void out(Print& p, T& x) { p.print(x); }
};

template<typename T> struct PrintHelper<T, decltype(((T*)0)->printTo(*(Print*)0))> {
static void out(Print& p, T& x) { x.printTo(p); }
};

struct ConsoleHelper : public Print {
template<typename T, typename Enable = void>
ConsoleHelper& operator<<(T v) {
PrintHelper<T>::out(*this, v);
return *this;
}
};

#include "../common/monitoring.h"
#include "../common/stdout.h"
Print standard_print;
Print* default_output = &standard_print;
Print* stdout_output = &standard_print;
ConsoleHelper STDOUT;
Monitoring monitor;

uint64_t loop_cycles = 0;

Expand Down
1 change: 1 addition & 0 deletions common/command_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define COMMON_COMMAND_PARSER_H

#include "linked_list.h"
#include "stdout.h"

// Command parsing linked list base class.
class CommandParser;
Expand Down
22 changes: 11 additions & 11 deletions sound/talkie_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
#define NELEM(X) (sizeof(X)/sizeof((X)[0]))
#define EnableAmplifier()
#define PROGMEM
uint32_t millis() { return 1; }
#define PROFFIE_TEST

#include "../common/monitoring.h"
#include "../common/stdout.h"
Print standard_print;
Print* default_output = &standard_print;
Print* stdout_output = &standard_print;
ConsoleHelper STDOUT;
Monitoring monitor;


int32_t clampi32(int32_t x, int32_t a, int32_t b) {
if (x < a) return a;
Expand All @@ -23,21 +34,10 @@ int16_t clamptoi16(int32_t x) {
return clampi32(x, -32768, 32767);
}

class STDOUTHELPER {
public:
template<class F>
void println(F foo) {
std::cout << foo << std::endl;
}
};
STDOUTHELPER STDOUT;

#include "talkie.h"

CommandParser* parsers = NULL;

#define STRINGIFY(X) std::string((char *)&(X), sizeof(X))

std::string mkchunk(std::string chnk,
std::string data) {
std::string ret = chnk;
Expand Down

0 comments on commit 8c95bbc

Please sign in to comment.