diff --git a/.github/ISSUE_TEMPLATE/api-deprecation.md b/.github/ISSUE_TEMPLATE/api-deprecation.md new file mode 100644 index 00000000..74e4c785 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/api-deprecation.md @@ -0,0 +1,25 @@ +--- +name: API deprecation +about: Suggest the deprecation of an API component defined by ArduinoCore-API. +title: "" +labels: enhancement +assignees: "" +--- + +### API component + + + +### Description + + + + +### Replacement API component + + + + +### Additional information + + diff --git a/.github/ISSUE_TEMPLATE/api-improvement.md b/.github/ISSUE_TEMPLATE/api-improvement.md new file mode 100644 index 00000000..1cfa43bb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/api-improvement.md @@ -0,0 +1,24 @@ +--- +name: API improvement +about: Suggest an improvement to an existing API component. +title: "" +labels: enhancement +assignees: "" +--- + +### API component + + + +### Description + + + +### Is this a breaking change? + + + + +### Additional information + + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..cc410ae0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Report problems with the code in this repository. +title: "" +labels: bug +assignees: "" +--- + +### Description + + + +### Environment + +- Boards platform name: +- Boards platform version (as shown in Boards Manager): +- ArduinoCore-API version (if you manually installed it): + +### Current behavior + + + +### Expected behavior + + + +### Additional information + + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..af023790 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +contact_links: + - name: Learn about the Arduino language + url: https://www.arduino.cc/reference/en + about: User documentation is available at the Arduino language reference. + - name: Support request + url: https://forum.arduino.cc/ + about: We can help you out on the Arduino Forum! + - name: Discuss ArduinoCore-API development + url: https://groups.google.com/a/arduino.cc/g/developers + about: Arduino Developers Mailing List diff --git a/.github/ISSUE_TEMPLATE/new-api-component.md b/.github/ISSUE_TEMPLATE/new-api-component.md new file mode 100644 index 00000000..15991f46 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new-api-component.md @@ -0,0 +1,15 @@ +--- +name: New API component +about: Suggest the addition of a new API component to ArduinoCore-API. +title: "" +labels: enhancement +assignees: "" +--- + +### Description + + + +### Additional information + + diff --git a/.github/ISSUE_TEMPLATE/other-enhancement.md b/.github/ISSUE_TEMPLATE/other-enhancement.md new file mode 100644 index 00000000..c72cea49 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other-enhancement.md @@ -0,0 +1,22 @@ +--- +name: Other enhancement +about: + Suggest an improvement for this project that doesn't fit in the specific categories + above. +title: "" +labels: enhancement +assignees: "" +--- + +### Description + + + +### Is this a breaking change? + + + + +### Additional information + + diff --git a/README.md b/README.md index 16367ce5..506569a8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ As of now, the following official cores are utilising ArduinoCore-API: * [megaavr](https://github.com/arduino/ArduinoCore-megaAVR) * [mbed](https://github.com/arduino/ArduinoCore-mbed) * [samd](https://github.com/arduino/ArduinoCore-samd) +* [renesas](https://github.com/arduino/ArduinoCore-renesas) There's an ongoing effort to port the others, while maintainers of third-party cores are strongly invited to follow the same route in order to stay up-to-date with the new language features. For backwards compatibility, every revision of this repo will increase the `ARDUINO_API_VERSION` define. @@ -77,6 +78,8 @@ In order to compile a core which is implementing ArduinoCore-API you'll need to tar --exclude='*.git*' -cjhvf $yourcore-$version.tar.bz2 $yourcore/ ``` +The API is coded to the C++11 standard and the core's compiler must be able to support that version of the language. + Documentation for how to integrate with a Arduino core (which is necessary if you do not download the Arduino core via the Boards Manager) can be found here: * [ArduinoCore-megaavr](https://github.com/arduino/ArduinoCore-megaavr#developing) * [ArduinoCore-mbed](https://github.com/arduino/ArduinoCore-mbed#clone-the-repository-in-sketchbookhardwarearduino-git) diff --git a/api/CanMsg.h b/api/CanMsg.h index dfece0d6..eaa3f0ed 100644 --- a/api/CanMsg.h +++ b/api/CanMsg.h @@ -45,7 +45,8 @@ class CanMsg : public Printable , data_length{min(can_data_len, MAX_DATA_LENGTH)} , data{0} { - memcpy(data, can_data_ptr, data_length); + if (data_length && can_data_ptr) + memcpy(data, can_data_ptr, data_length); } CanMsg() : CanMsg(0, 0, nullptr) { } @@ -54,7 +55,8 @@ class CanMsg : public Printable { this->id = other.id; this->data_length = other.data_length; - memcpy(this->data, other.data, this->data_length); + if (this->data_length && other.data) + memcpy(this->data, other.data, this->data_length); } virtual ~CanMsg() { } @@ -65,7 +67,8 @@ class CanMsg : public Printable { this->id = other.id; this->data_length = other.data_length; - memcpy(this->data, other.data, this->data_length); + if (this->data_length && other.data) + memcpy(this->data, other.data, this->data_length); } return (*this); } diff --git a/api/CanMsgRingbuffer.cpp b/api/CanMsgRingbuffer.cpp index c358a10a..e62db89a 100644 --- a/api/CanMsgRingbuffer.cpp +++ b/api/CanMsgRingbuffer.cpp @@ -40,7 +40,7 @@ void CanMsgRingbuffer::enqueue(CanMsg const & msg) _buf[_head] = msg; _head = next(_head); - _num_elems++; + _num_elems = _num_elems + 1; } CanMsg CanMsgRingbuffer::dequeue() @@ -50,7 +50,7 @@ CanMsg CanMsgRingbuffer::dequeue() CanMsg const msg = _buf[_tail]; _tail = next(_tail); - _num_elems--; + _num_elems = _num_elems - 1; return msg; } diff --git a/api/IPAddress.cpp b/api/IPAddress.cpp index 1d775906..05b41bc1 100644 --- a/api/IPAddress.cpp +++ b/api/IPAddress.cpp @@ -97,14 +97,14 @@ IPAddress::IPAddress(const char *address) String IPAddress::toString4() const { char szRet[16]; - sprintf(szRet,"%u.%u.%u.%u", _address.bytes[IPADDRESS_V4_BYTES_INDEX], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 1], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 2], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3]); + snprintf(szRet, sizeof(szRet), "%u.%u.%u.%u", _address.bytes[IPADDRESS_V4_BYTES_INDEX], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 1], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 2], _address.bytes[IPADDRESS_V4_BYTES_INDEX + 3]); return String(szRet); } String IPAddress::toString6() const { char szRet[40]; - sprintf(szRet,"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", + snprintf(szRet, sizeof(szRet), "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3], _address.bytes[4], _address.bytes[5], _address.bytes[6], _address.bytes[7], _address.bytes[8], _address.bytes[9], _address.bytes[10], _address.bytes[11], diff --git a/api/String.cpp b/api/String.cpp index 1b3e1047..a13d6b82 100644 --- a/api/String.cpp +++ b/api/String.cpp @@ -63,7 +63,6 @@ String::String(const __FlashStringHelper *pstr) *this = pstr; } -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) String::String(String &&rval) : buffer(rval.buffer) , capacity(rval.capacity) @@ -73,7 +72,6 @@ String::String(String &&rval) rval.capacity = 0; rval.len = 0; } -#endif String::String(char c) { @@ -213,7 +211,6 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length) return *this; } -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) void String::move(String &rhs) { if (this != &rhs) @@ -229,7 +226,6 @@ void String::move(String &rhs) rhs.capacity = 0; } } -#endif String & String::operator = (const String &rhs) { @@ -241,13 +237,11 @@ String & String::operator = (const String &rhs) return *this; } -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) String & String::operator = (String &&rval) { move(rval); return *this; } -#endif String & String::operator = (const char *cstr) { diff --git a/api/String.h b/api/String.h index f94f4add..380fc4e1 100644 --- a/api/String.h +++ b/api/String.h @@ -72,9 +72,7 @@ class String String(const uint8_t *cstr, unsigned int length) : String((const char*)cstr, length) {} String(const String &str); String(const __FlashStringHelper *str); - #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) String(String &&rval); - #endif explicit String(char c); explicit String(unsigned char, unsigned char base=10); explicit String(int, unsigned char base=10); @@ -98,9 +96,7 @@ class String String & operator = (const String &rhs); String & operator = (const char *cstr); String & operator = (const __FlashStringHelper *str); - #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) String & operator = (String &&rval); - #endif // concatenate (works w/ built-in types) @@ -233,9 +229,7 @@ class String // copy and move String & copy(const char *cstr, unsigned int length); String & copy(const __FlashStringHelper *pstr, unsigned int length); - #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) void move(String &rhs); - #endif }; class StringSumHelper : public String diff --git a/api/deprecated-avr-comp/avr/dtostrf.c.impl b/api/deprecated-avr-comp/avr/dtostrf.c.impl index 96987a8f..f410886c 100644 --- a/api/deprecated-avr-comp/avr/dtostrf.c.impl +++ b/api/deprecated-avr-comp/avr/dtostrf.c.impl @@ -29,9 +29,12 @@ char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { asm(".global _printf_float"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" char fmt[20]; sprintf(fmt, "%%%d.%df", width, prec); sprintf(sout, fmt, val); return sout; +#pragma GCC diagnostic pop } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7d9e26ab..9deb8feb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,7 @@ project(test-ArduinoCore-API) ########################################################################## -include_directories(../api) +include_directories(..) include_directories(include) include_directories(external/catch/v2.13.9/include) @@ -33,6 +33,7 @@ set(TEST_SRCS src/CanMsg/test_isStandardId.cpp src/CanMsg/test_operator_assignment.cpp src/CanMsg/test_printTo.cpp + src/CanMsgRingbuffer/test_available.cpp src/Common/test_makeWord.cpp src/Common/test_map.cpp src/Common/test_max.cpp @@ -106,6 +107,7 @@ set(TEST_SRCS set(TEST_DUT_SRCS ../api/CanMsg.cpp + ../api/CanMsgRingbuffer.cpp ../api/Common.cpp ../api/IPAddress.cpp ../api/String.cpp diff --git a/test/include/MillisFake.h b/test/include/MillisFake.h index da21049b..be078bd0 100644 --- a/test/include/MillisFake.h +++ b/test/include/MillisFake.h @@ -9,7 +9,7 @@ * INCLUDE **************************************************************************************/ -#include +#include /************************************************************************************** * FUNCTION DECLARATION diff --git a/test/include/PrintMock.h b/test/include/PrintMock.h index 87c83313..d41e78fa 100644 --- a/test/include/PrintMock.h +++ b/test/include/PrintMock.h @@ -11,7 +11,7 @@ #include -#include +#include /************************************************************************************** * CLASS DECLARATION diff --git a/test/include/PrintableMock.h b/test/include/PrintableMock.h index cfc00555..39121928 100644 --- a/test/include/PrintableMock.h +++ b/test/include/PrintableMock.h @@ -11,7 +11,7 @@ #include -#include +#include /************************************************************************************** * CLASS DECLARATION diff --git a/test/include/StreamMock.h b/test/include/StreamMock.h index 91eb3c26..a7d9da1a 100644 --- a/test/include/StreamMock.h +++ b/test/include/StreamMock.h @@ -11,7 +11,7 @@ #include -#include +#include /************************************************************************************** * CLASS DECLARATION diff --git a/test/src/CanMsg/test_CanExtendedId.cpp b/test/src/CanMsg/test_CanExtendedId.cpp index 72f8ece5..a812f08b 100644 --- a/test/src/CanMsg/test_CanExtendedId.cpp +++ b/test/src/CanMsg/test_CanExtendedId.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_CanMsg.cpp b/test/src/CanMsg/test_CanMsg.cpp index 14b8a76a..03704623 100644 --- a/test/src/CanMsg/test_CanMsg.cpp +++ b/test/src/CanMsg/test_CanMsg.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_CanMsg_CopyCtor.cpp b/test/src/CanMsg/test_CanMsg_CopyCtor.cpp index b303369a..ccf62931 100644 --- a/test/src/CanMsg/test_CanMsg_CopyCtor.cpp +++ b/test/src/CanMsg/test_CanMsg_CopyCtor.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_CanStandardId.cpp b/test/src/CanMsg/test_CanStandardId.cpp index 02496241..81d2301d 100644 --- a/test/src/CanMsg/test_CanStandardId.cpp +++ b/test/src/CanMsg/test_CanStandardId.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_isExtendedId.cpp b/test/src/CanMsg/test_isExtendedId.cpp index 3a12ab8f..242866e9 100644 --- a/test/src/CanMsg/test_isExtendedId.cpp +++ b/test/src/CanMsg/test_isExtendedId.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_isStandardId.cpp b/test/src/CanMsg/test_isStandardId.cpp index 718d2535..a73bf7c1 100644 --- a/test/src/CanMsg/test_isStandardId.cpp +++ b/test/src/CanMsg/test_isStandardId.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_operator_assignment.cpp b/test/src/CanMsg/test_operator_assignment.cpp index ae2d2ecb..0dd35543 100644 --- a/test/src/CanMsg/test_operator_assignment.cpp +++ b/test/src/CanMsg/test_operator_assignment.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * NAMESPACE diff --git a/test/src/CanMsg/test_printTo.cpp b/test/src/CanMsg/test_printTo.cpp index dd1fb4b8..bf532c81 100644 --- a/test/src/CanMsg/test_printTo.cpp +++ b/test/src/CanMsg/test_printTo.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include /************************************************************************************** diff --git a/test/src/CanMsgRingbuffer/test_available.cpp b/test/src/CanMsgRingbuffer/test_available.cpp new file mode 100644 index 00000000..684eaeec --- /dev/null +++ b/test/src/CanMsgRingbuffer/test_available.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Arduino. All rights reserved. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + +#include + +#include + +/************************************************************************************** + * TEST CODE + **************************************************************************************/ + +TEST_CASE ("'available' should return 0 for empty CanMsg ring buffer", "[CanMsgRingbuffer-available-01]") +{ + arduino::CanMsgRingbuffer ringbuffer; + REQUIRE(ringbuffer.available() == 0); +} + +TEST_CASE ("'available' should return number of elements in CanMsg ringbuffer", "[CanMsgRingbuffer-available-02]") +{ + arduino::CanMsgRingbuffer ringbuffer; + arduino::CanMsg msg; + ringbuffer.enqueue(msg); + REQUIRE(ringbuffer.available() == 1); + ringbuffer.enqueue(msg); + REQUIRE(ringbuffer.available() == 2); + ringbuffer.dequeue(); + REQUIRE(ringbuffer.available() == 1); +} diff --git a/test/src/Common/test_makeWord.cpp b/test/src/Common/test_makeWord.cpp index 2e0a29dc..dcb3ea33 100644 --- a/test/src/Common/test_makeWord.cpp +++ b/test/src/Common/test_makeWord.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Common/test_map.cpp b/test/src/Common/test_map.cpp index aef3e72a..59441cac 100644 --- a/test/src/Common/test_map.cpp +++ b/test/src/Common/test_map.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Common/test_max.cpp b/test/src/Common/test_max.cpp index 6612cc95..ccb5e5e1 100644 --- a/test/src/Common/test_max.cpp +++ b/test/src/Common/test_max.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE @@ -53,7 +53,7 @@ TEST_CASE ("Calling 'max(a,b)' with type(a) != type(b)", "[max-04]") { uint32_t const a = 32; uint64_t const b = 10; - REQUIRE(typeid(max(a,b)) == typeid(unsigned long)); + REQUIRE(typeid(max(a,b)) == typeid(uint64_t)); } WHEN("type(A) = int8_t, type(b) = int16_t") { @@ -71,6 +71,6 @@ TEST_CASE ("Calling 'max(a,b)' with type(a) != type(b)", "[max-04]") { int32_t const a = -32; int64_t const b = -10; - REQUIRE(typeid(max(a,b)) == typeid(long)); + REQUIRE(typeid(max(a,b)) == typeid(int64_t)); } } diff --git a/test/src/Common/test_min.cpp b/test/src/Common/test_min.cpp index 2298dc6c..750f41ae 100644 --- a/test/src/Common/test_min.cpp +++ b/test/src/Common/test_min.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE @@ -53,7 +53,7 @@ TEST_CASE ("Calling 'min(a,b)' with type(a) != type(b)", "[min-04]") { uint32_t const a = 32; uint64_t const b = 10; - REQUIRE(typeid(min(a,b)) == typeid(unsigned long)); + REQUIRE(typeid(min(a,b)) == typeid(uint64_t)); } WHEN("type(A) = int8_t, type(b) = int16_t") { @@ -71,6 +71,6 @@ TEST_CASE ("Calling 'min(a,b)' with type(a) != type(b)", "[min-04]") { int32_t const a = -32; int64_t const b = -10; - REQUIRE(typeid(min(a,b)) == typeid(long)); + REQUIRE(typeid(min(a,b)) == typeid(int64_t)); } } diff --git a/test/src/IPAddress/test_IPAddress.cpp b/test/src/IPAddress/test_IPAddress.cpp index d12db0f3..6b66e118 100644 --- a/test/src/IPAddress/test_IPAddress.cpp +++ b/test/src/IPAddress/test_IPAddress.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_IPAddress6.cpp b/test/src/IPAddress/test_IPAddress6.cpp index a6941b71..3a8a5315 100644 --- a/test/src/IPAddress/test_IPAddress6.cpp +++ b/test/src/IPAddress/test_IPAddress6.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_fromString.cpp b/test/src/IPAddress/test_fromString.cpp index 2c918052..d058b529 100644 --- a/test/src/IPAddress/test_fromString.cpp +++ b/test/src/IPAddress/test_fromString.cpp @@ -8,8 +8,8 @@ #include -#include -#include +#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_fromString6.cpp b/test/src/IPAddress/test_fromString6.cpp index a0f09c73..deb54458 100644 --- a/test/src/IPAddress/test_fromString6.cpp +++ b/test/src/IPAddress/test_fromString6.cpp @@ -8,8 +8,8 @@ #include -#include -#include +#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_operator_assignment.cpp b/test/src/IPAddress/test_operator_assignment.cpp index e9fc8691..fdf641d4 100644 --- a/test/src/IPAddress/test_operator_assignment.cpp +++ b/test/src/IPAddress/test_operator_assignment.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_operator_comparison.cpp b/test/src/IPAddress/test_operator_comparison.cpp index c3283b71..3978c8e2 100644 --- a/test/src/IPAddress/test_operator_comparison.cpp +++ b/test/src/IPAddress/test_operator_comparison.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_operator_comparison6.cpp b/test/src/IPAddress/test_operator_comparison6.cpp index a5e1b87c..da03a0b3 100644 --- a/test/src/IPAddress/test_operator_comparison6.cpp +++ b/test/src/IPAddress/test_operator_comparison6.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_operator_parentheses.cpp b/test/src/IPAddress/test_operator_parentheses.cpp index 27fce3a5..c1c2e375 100644 --- a/test/src/IPAddress/test_operator_parentheses.cpp +++ b/test/src/IPAddress/test_operator_parentheses.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_operator_parentheses6.cpp b/test/src/IPAddress/test_operator_parentheses6.cpp index 5b4740c8..b4575f4e 100644 --- a/test/src/IPAddress/test_operator_parentheses6.cpp +++ b/test/src/IPAddress/test_operator_parentheses6.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/IPAddress/test_printTo.cpp b/test/src/IPAddress/test_printTo.cpp index 05e43fa5..a0ed7c16 100644 --- a/test/src/IPAddress/test_printTo.cpp +++ b/test/src/IPAddress/test_printTo.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include /************************************************************************************** diff --git a/test/src/IPAddress/test_printTo6.cpp b/test/src/IPAddress/test_printTo6.cpp index 621008af..7d924b63 100644 --- a/test/src/IPAddress/test_printTo6.cpp +++ b/test/src/IPAddress/test_printTo6.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include /************************************************************************************** diff --git a/test/src/IPAddress/test_toString.cpp b/test/src/IPAddress/test_toString.cpp index a5a5f004..f36ae549 100644 --- a/test/src/IPAddress/test_toString.cpp +++ b/test/src/IPAddress/test_toString.cpp @@ -8,8 +8,8 @@ #include -#include -#include +#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Print/test_availableForWrite.cpp b/test/src/Print/test_availableForWrite.cpp index 47f599cf..c5dfbcda 100644 --- a/test/src/Print/test_availableForWrite.cpp +++ b/test/src/Print/test_availableForWrite.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/test/src/Print/test_clearWriteError.cpp b/test/src/Print/test_clearWriteError.cpp index 295f4984..720a1210 100644 --- a/test/src/Print/test_clearWriteError.cpp +++ b/test/src/Print/test_clearWriteError.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/test/src/Print/test_getWriteError.cpp b/test/src/Print/test_getWriteError.cpp index ef2b1435..3b616411 100644 --- a/test/src/Print/test_getWriteError.cpp +++ b/test/src/Print/test_getWriteError.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/test/src/Print/test_print.cpp b/test/src/Print/test_print.cpp index ac731a89..2598b7f7 100644 --- a/test/src/Print/test_print.cpp +++ b/test/src/Print/test_print.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include diff --git a/test/src/Print/test_println.cpp b/test/src/Print/test_println.cpp index 977ed532..2d2d7306 100644 --- a/test/src/Print/test_println.cpp +++ b/test/src/Print/test_println.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include diff --git a/test/src/Ringbuffer/test_available.cpp b/test/src/Ringbuffer/test_available.cpp index 3a79e5bc..75b86a7f 100644 --- a/test/src/Ringbuffer/test_available.cpp +++ b/test/src/Ringbuffer/test_available.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_availableForStore.cpp b/test/src/Ringbuffer/test_availableForStore.cpp index 7d73d8da..5b8415f6 100644 --- a/test/src/Ringbuffer/test_availableForStore.cpp +++ b/test/src/Ringbuffer/test_availableForStore.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_clear.cpp b/test/src/Ringbuffer/test_clear.cpp index 165a5bbb..93da03a2 100644 --- a/test/src/Ringbuffer/test_clear.cpp +++ b/test/src/Ringbuffer/test_clear.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_isFull.cpp b/test/src/Ringbuffer/test_isFull.cpp index 8d9c4aaa..c575981e 100644 --- a/test/src/Ringbuffer/test_isFull.cpp +++ b/test/src/Ringbuffer/test_isFull.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_peek.cpp b/test/src/Ringbuffer/test_peek.cpp index 3811dd39..9efe28ea 100644 --- a/test/src/Ringbuffer/test_peek.cpp +++ b/test/src/Ringbuffer/test_peek.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_read_char.cpp b/test/src/Ringbuffer/test_read_char.cpp index de754275..babc27df 100644 --- a/test/src/Ringbuffer/test_read_char.cpp +++ b/test/src/Ringbuffer/test_read_char.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/Ringbuffer/test_store_char.cpp b/test/src/Ringbuffer/test_store_char.cpp index 6e127b28..0becdc0f 100644 --- a/test/src/Ringbuffer/test_store_char.cpp +++ b/test/src/Ringbuffer/test_store_char.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/String/StringPrinter.h b/test/src/String/StringPrinter.h index f338a902..1ddee147 100644 --- a/test/src/String/StringPrinter.h +++ b/test/src/String/StringPrinter.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace Catch { /** diff --git a/test/src/String/test_String.cpp b/test/src/String/test_String.cpp index 461f2d08..6d1b8152 100644 --- a/test/src/String/test_String.cpp +++ b/test/src/String/test_String.cpp @@ -10,7 +10,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_characterAccessFunc.cpp b/test/src/String/test_characterAccessFunc.cpp index d0f02383..49d257af 100644 --- a/test/src/String/test_characterAccessFunc.cpp +++ b/test/src/String/test_characterAccessFunc.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_compareTo.cpp b/test/src/String/test_compareTo.cpp index 9aef1ee7..74a3da7b 100644 --- a/test/src/String/test_compareTo.cpp +++ b/test/src/String/test_compareTo.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" @@ -27,13 +27,13 @@ TEST_CASE ("Testing String::compareTo(const String &)", "[String-compareTo-01]") WHEN ("str2 is empty") { arduino::String str1("Hello"), str2; - REQUIRE(str1.compareTo(str2) == strcmp(str1.c_str(), str2.c_str())); + REQUIRE(str1.compareTo(str2) > 0); } WHEN ("str1 is empty") { arduino::String str1, str2("Hello"); - REQUIRE(str1.compareTo(str2) == strcmp(str1.c_str(), str2.c_str())); + REQUIRE(str1.compareTo(str2) < 0); } } @@ -47,14 +47,14 @@ TEST_CASE ("Testing String::compareTo(const char *)", "[String-compareTo-02]") WHEN ("Passed string is empty") { - arduino::String str1("Hello"), str2(""); - REQUIRE(str1.compareTo("") == strcmp(str1.c_str(), str2.c_str())); + arduino::String str("Hello"); + REQUIRE(str.compareTo("") > 0); } WHEN ("Passed string is compared with empty string") { - arduino::String str1, str2("Hello"); - REQUIRE(str1.compareTo("Hello") == strcmp(str1.c_str(), str2.c_str())); + arduino::String str; + REQUIRE(str.compareTo("") == 0); } } @@ -64,8 +64,8 @@ TEST_CASE ("Testing String::compareTo(const char *) with empty buffer", "[String { char *buffer = NULL; - arduino::String str1("Hello"); - REQUIRE(str1.compareTo(buffer) != 0); + arduino::String str("Hello"); + REQUIRE(str.compareTo(buffer) != 0); } WHEN ("First string does NOT have a valid buffer") @@ -73,8 +73,8 @@ TEST_CASE ("Testing String::compareTo(const char *) with empty buffer", "[String char *buffer1 = NULL; char *buffer2 = NULL; - arduino::String str1(buffer1); - REQUIRE(str1.compareTo(buffer2) == 0); + arduino::String str(buffer1); + REQUIRE(str.compareTo(buffer2) == 0); } } diff --git a/test/src/String/test_comparisonFunc.cpp b/test/src/String/test_comparisonFunc.cpp index 89a7f3be..3b49bacc 100644 --- a/test/src/String/test_comparisonFunc.cpp +++ b/test/src/String/test_comparisonFunc.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_concat.cpp b/test/src/String/test_concat.cpp index b7390b64..ef6c6fa1 100644 --- a/test/src/String/test_concat.cpp +++ b/test/src/String/test_concat.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_indexOf.cpp b/test/src/String/test_indexOf.cpp index bcaf65ef..9f32a07e 100644 --- a/test/src/String/test_indexOf.cpp +++ b/test/src/String/test_indexOf.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_lastIndexOf.cpp b/test/src/String/test_lastIndexOf.cpp index 2ae95f54..7f776fa6 100644 --- a/test/src/String/test_lastIndexOf.cpp +++ b/test/src/String/test_lastIndexOf.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_length.cpp b/test/src/String/test_length.cpp index 3b47faed..fae358fa 100644 --- a/test/src/String/test_length.cpp +++ b/test/src/String/test_length.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_move.cpp b/test/src/String/test_move.cpp index d37630c4..a2529b50 100644 --- a/test/src/String/test_move.cpp +++ b/test/src/String/test_move.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "StringPrinter.h" @@ -31,7 +31,14 @@ TEST_CASE("Testing String move assignment", "[String-move-02]") TEST_CASE("Testing String move self assignment", "[String-move-03]") { +#if (defined(GCC_VERSION) && GCC_VERSION >= 13) || (defined(__clang_major__) && __clang_major__ >= 14) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wself-move" +#endif arduino::String a("src"); a = std::move(a); REQUIRE(a == "src"); +#if defined(GCC_VERSION) && GCC_VERSION >= 13 +#pragma GCC diagnostic pop +#endif } diff --git a/test/src/String/test_operators.cpp b/test/src/String/test_operators.cpp index 67cb39be..5a3b677c 100644 --- a/test/src/String/test_operators.cpp +++ b/test/src/String/test_operators.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_remove.cpp b/test/src/String/test_remove.cpp index e8c19536..17b8dabb 100644 --- a/test/src/String/test_remove.cpp +++ b/test/src/String/test_remove.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_replace.cpp b/test/src/String/test_replace.cpp index d4f28bf5..cfcaead0 100644 --- a/test/src/String/test_replace.cpp +++ b/test/src/String/test_replace.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_substring.cpp b/test/src/String/test_substring.cpp index 8fa43086..bb05d439 100644 --- a/test/src/String/test_substring.cpp +++ b/test/src/String/test_substring.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_toDouble.cpp b/test/src/String/test_toDouble.cpp index 246f25d4..af6960e9 100644 --- a/test/src/String/test_toDouble.cpp +++ b/test/src/String/test_toDouble.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_toFloat.cpp b/test/src/String/test_toFloat.cpp index afef02c5..75cf94b2 100644 --- a/test/src/String/test_toFloat.cpp +++ b/test/src/String/test_toFloat.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_toInt.cpp b/test/src/String/test_toInt.cpp index 43397b76..060fdd27 100644 --- a/test/src/String/test_toInt.cpp +++ b/test/src/String/test_toInt.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_toLowerCase.cpp b/test/src/String/test_toLowerCase.cpp index 1ff81e91..9f6f7c9d 100644 --- a/test/src/String/test_toLowerCase.cpp +++ b/test/src/String/test_toLowerCase.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_toUpperCase.cpp b/test/src/String/test_toUpperCase.cpp index b8ae6aaf..1bcf93fb 100644 --- a/test/src/String/test_toUpperCase.cpp +++ b/test/src/String/test_toUpperCase.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/String/test_trim.cpp b/test/src/String/test_trim.cpp index 539d6568..c5168ecd 100644 --- a/test/src/String/test_trim.cpp +++ b/test/src/String/test_trim.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include "StringPrinter.h" diff --git a/test/src/WCharacter/test_isAscii.cpp b/test/src/WCharacter/test_isAscii.cpp index 8c2763c4..c6792719 100644 --- a/test/src/WCharacter/test_isAscii.cpp +++ b/test/src/WCharacter/test_isAscii.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isControl.cpp b/test/src/WCharacter/test_isControl.cpp index 157c8bc8..adb41ccf 100644 --- a/test/src/WCharacter/test_isControl.cpp +++ b/test/src/WCharacter/test_isControl.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isDigit.cpp b/test/src/WCharacter/test_isDigit.cpp index 58b1808a..146a863b 100644 --- a/test/src/WCharacter/test_isDigit.cpp +++ b/test/src/WCharacter/test_isDigit.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isHexadecimalDigit.cpp b/test/src/WCharacter/test_isHexadecimalDigit.cpp index 0eba5846..486a3e44 100644 --- a/test/src/WCharacter/test_isHexadecimalDigit.cpp +++ b/test/src/WCharacter/test_isHexadecimalDigit.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isLowerCase.cpp b/test/src/WCharacter/test_isLowerCase.cpp index 79e1dbc4..9b05b458 100644 --- a/test/src/WCharacter/test_isLowerCase.cpp +++ b/test/src/WCharacter/test_isLowerCase.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/WCharacter/test_isPunct.cpp b/test/src/WCharacter/test_isPunct.cpp index 5f6875d1..7e6b49dc 100644 --- a/test/src/WCharacter/test_isPunct.cpp +++ b/test/src/WCharacter/test_isPunct.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isSpace.cpp b/test/src/WCharacter/test_isSpace.cpp index c96557d6..29ed8107 100644 --- a/test/src/WCharacter/test_isSpace.cpp +++ b/test/src/WCharacter/test_isSpace.cpp @@ -10,7 +10,7 @@ #include -#include +#include /************************************************************************************** * CONSTANTS diff --git a/test/src/WCharacter/test_isUpperCase.cpp b/test/src/WCharacter/test_isUpperCase.cpp index e21e33db..598bb55b 100644 --- a/test/src/WCharacter/test_isUpperCase.cpp +++ b/test/src/WCharacter/test_isUpperCase.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/WCharacter/test_isWhitespace.cpp b/test/src/WCharacter/test_isWhitespace.cpp index 6eb3f7a6..483c6477 100644 --- a/test/src/WCharacter/test_isWhitespace.cpp +++ b/test/src/WCharacter/test_isWhitespace.cpp @@ -8,7 +8,7 @@ #include -#include +#include /************************************************************************************** * TEST CODE diff --git a/test/src/WCharacter/test_toAscii.cpp b/test/src/WCharacter/test_toAscii.cpp index b071702f..96a2cfb9 100644 --- a/test/src/WCharacter/test_toAscii.cpp +++ b/test/src/WCharacter/test_toAscii.cpp @@ -6,13 +6,11 @@ * INCLUDE **************************************************************************************/ -#undef _GNU_SOURCE - #include #include -#include +#include /************************************************************************************** * CONSTANTS @@ -47,4 +45,4 @@ TEST_CASE ("toAscii(...) is called with a invalid casted ascii character", "[toA TEST_CASE ("toAscii(...) is called with a character larger than 1 byte", "[toAscii-04]") { REQUIRE(arduino::toAscii(0x3030) == 0x30); -} \ No newline at end of file +} diff --git a/test/src/dtostrf.cpp b/test/src/dtostrf.cpp index 0635b492..0700debb 100644 --- a/test/src/dtostrf.cpp +++ b/test/src/dtostrf.cpp @@ -6,7 +6,7 @@ * INCLUDE **************************************************************************************/ -#include +#include #include @@ -18,7 +18,7 @@ extern "C" { #endif -#include +#include #ifdef __cplusplus } // extern "C" diff --git a/test/src/itoa.cpp b/test/src/itoa.cpp index 84d640c3..292d0ef0 100644 --- a/test/src/itoa.cpp +++ b/test/src/itoa.cpp @@ -6,7 +6,7 @@ * INCLUDE **************************************************************************************/ -#include +#include #include #include @@ -27,24 +27,36 @@ std::string radixToFmtString(int const radix) char * itoa(int value, char * str, int radix) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" sprintf(str, radixToFmtString(radix).c_str(), value); +#pragma GCC diagnostic pop return str; } char * ltoa(long value, char * str, int radix) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" sprintf(str, radixToFmtString(radix).c_str(), value); +#pragma GCC diagnostic pop return str; } char * utoa(unsigned value, char *str, int radix) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" sprintf(str, radixToFmtString(radix).c_str(), value); +#pragma GCC diagnostic pop return str; } char * ultoa(unsigned long value, char * str, int radix) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" sprintf(str, radixToFmtString(radix).c_str(), value); +#pragma GCC diagnostic pop return str; }