mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 12:32:17 +02:00
Changed unit testing framework from Google Test to Catch
This commit is contained in:
@ -5,41 +5,35 @@
|
||||
// https://bblanchon.github.io/ArduinoJson/
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <ArduinoJson/Polyfills/isInteger.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Polyfills;
|
||||
|
||||
struct Polyfills_IsInteger_Tests : testing::Test {
|
||||
void check(bool expected, const char* input) {
|
||||
bool actual = isInteger(input);
|
||||
EXPECT_EQ(expected, actual) << input;
|
||||
TEST_CASE("isInteger()") {
|
||||
SECTION("Null") {
|
||||
REQUIRE_FALSE(isInteger(NULL));
|
||||
}
|
||||
};
|
||||
#define TEST_(X) TEST_F(Polyfills_IsInteger_Tests, X)
|
||||
|
||||
TEST_(Null) {
|
||||
check(false, NULL);
|
||||
}
|
||||
SECTION("FloatNotInteger") {
|
||||
REQUIRE_FALSE(isInteger("3.14"));
|
||||
REQUIRE_FALSE(isInteger("-3.14"));
|
||||
REQUIRE_FALSE(isInteger("+3.14"));
|
||||
}
|
||||
|
||||
TEST_(FloatNotInteger) {
|
||||
check(false, "3.14");
|
||||
check(false, "-3.14");
|
||||
check(false, "+3.14");
|
||||
}
|
||||
SECTION("Spaces") {
|
||||
REQUIRE_FALSE(isInteger("42 "));
|
||||
REQUIRE_FALSE(isInteger(" 42"));
|
||||
}
|
||||
|
||||
TEST_(Spaces) {
|
||||
check(false, "42 ");
|
||||
check(false, " 42");
|
||||
}
|
||||
SECTION("Valid") {
|
||||
REQUIRE(isInteger("42"));
|
||||
REQUIRE(isInteger("-42"));
|
||||
REQUIRE(isInteger("+42"));
|
||||
}
|
||||
|
||||
TEST_(Valid) {
|
||||
check(true, "42");
|
||||
check(true, "-42");
|
||||
check(true, "+42");
|
||||
}
|
||||
|
||||
TEST_(ExtraSign) {
|
||||
check(false, "--42");
|
||||
check(false, "++42");
|
||||
SECTION("ExtraSign") {
|
||||
REQUIRE_FALSE(isInteger("--42"));
|
||||
REQUIRE_FALSE(isInteger("++42"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user