mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
Changed unit testing framework from Google Test to Catch
This commit is contained in:
@ -5,23 +5,20 @@
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdint.h>
|
||||
#include <ArduinoJson/Polyfills/parseInteger.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Polyfills;
|
||||
|
||||
struct Polyfills_ParseInteger_Tests : testing::Test {
|
||||
template <typename T>
|
||||
void check(const char* input, T expected) {
|
||||
T actual = parseInteger<T>(input);
|
||||
EXPECT_EQ(expected, actual) << input;
|
||||
}
|
||||
};
|
||||
template <typename T>
|
||||
void check(const char* input, T expected) {
|
||||
CAPTURE(input);
|
||||
T actual = parseInteger<T>(input);
|
||||
REQUIRE(expected == actual);
|
||||
}
|
||||
|
||||
#define TEST_(X) TEST_F(Polyfills_ParseInteger_Tests, X)
|
||||
|
||||
TEST_(int8_t) {
|
||||
TEST_CASE("parseInteger<int8_t>()") {
|
||||
check<int8_t>("-128", -128);
|
||||
check<int8_t>("127", 127);
|
||||
check<int8_t>("+127", 127);
|
||||
@ -33,7 +30,7 @@ TEST_(int8_t) {
|
||||
check<int8_t>(NULL, 0);
|
||||
}
|
||||
|
||||
TEST_(int16_t) {
|
||||
TEST_CASE("parseInteger<int16_t>()") {
|
||||
check<int16_t>("-32768", -32768);
|
||||
check<int16_t>("32767", 32767);
|
||||
check<int16_t>("+32767", 32767);
|
||||
@ -45,7 +42,7 @@ TEST_(int16_t) {
|
||||
check<int16_t>(NULL, 0);
|
||||
}
|
||||
|
||||
TEST_(int32_t) {
|
||||
TEST_CASE("parseInteger<int32_t>()") {
|
||||
check<int32_t>("-2147483648", (-2147483647 - 1));
|
||||
check<int32_t>("2147483647", 2147483647);
|
||||
check<int32_t>("+2147483647", 2147483647);
|
||||
@ -56,7 +53,7 @@ TEST_(int32_t) {
|
||||
check<int32_t>("2147483648", (-2147483647 - 1));
|
||||
}
|
||||
|
||||
TEST_(uint8_t) {
|
||||
TEST_CASE("parseInteger<uint8_t>()") {
|
||||
check<uint8_t>("0", 0);
|
||||
check<uint8_t>("255", 255);
|
||||
check<uint8_t>("+255", 255);
|
||||
@ -67,7 +64,7 @@ TEST_(uint8_t) {
|
||||
check<uint8_t>("256", 0);
|
||||
}
|
||||
|
||||
TEST_(uint16_t) {
|
||||
TEST_CASE("parseInteger<uint16_t>()") {
|
||||
check<uint16_t>("0", 0);
|
||||
check<uint16_t>("65535", 65535);
|
||||
check<uint16_t>("+65535", 65535);
|
||||
|
Reference in New Issue
Block a user