Неопределенная ссылка - Тесты Platformio - PullRequest
0 голосов
/ 28 августа 2018

В настоящее время я использую платформу PlatformIO и разрабатываю собственную библиотеку. Для этого я собираюсь использовать тестирование модуля pio, но, к сожалению, это хлопотно. Необходимый код ниже:

тест / test_unit.cpp #include

#include "../src/models/unit.h"


// void setUp(void) {
// // set stuff up here
// }

// void tearDown(void) {
// // clean stuff up here
// }

void test_unit_printable(void) {
    String prefix = "K", unit = "m";
    const char* expected = "Km";
    const char* actual;
    BaseUnit bunit(prefix, unit);
    String bunit_p = bunit.printable();

    actual = bunit_p.c_str();

    TEST_ASSERT_EQUAL_STRING(expected, actual);
}

void setup() {
    UNITY_BEGIN();    
    RUN_TEST(test_unit_printable);
    UNITY_END(); 
}

void loop() {
}

ЦСИ / модели / unit.h

#ifndef UNIT_H
#define UNIT_H

#include "Arduino.h"

class BaseUnit {
    public:
        BaseUnit() {};
        BaseUnit(String prefix_, String label_);
        ~BaseUnit() {};

        String printable();

    public:
        String prefix;
        String label;
};

#endif

ЦСИ / модели / unit.cpp

#include "unit.h"

BaseUnit::BaseUnit(String prefix_, String label_){
    prefix = prefix_;
    label = label_;
}

String BaseUnit::printable(){
    return prefix + label;
}

Ошибка во время теста:

/tmp/ccI0alHK.ltrans0.ltrans.o: In function `test_unit_printable()':
ccI0alHK.ltrans0.o:(.text+0x58a): undefined reference to `BaseUnit::BaseUnit(String, String)'
ccI0alHK.ltrans0.o:(.text+0x5a8): undefined reference to `BaseUnit::printable()'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...