This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from forno/develop
Upgrade v1.5.0
- Loading branch information
Showing
9 changed files
with
314 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* BSD 2-Clause License | ||
Copyright (c) 2016, Doi Yusuke | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "ics3/ics" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(AngleConstexprTest, CreateWithGetRaw) { | ||
// constexpr test | ||
constexpr auto defDeg = ics::Angle::newDegree(); | ||
constexpr auto defRad = ics::Angle::newRadian(); | ||
static_assert(defDeg == 0, "Angle default cast error"); | ||
static_assert(defRad.get() == 0, "Angle default get() error"); | ||
static_assert(defDeg.getRaw() == 7500, "Angle default must is 7500"); | ||
static_assert(defDeg.getRaw() == defRad.getRaw(), "Angle have different default"); | ||
constexpr auto degree1 = ics::Angle::newDegree(90); | ||
constexpr auto radian1 = ics::Angle::newRadian(ics::Angle::PI / 2); | ||
static_assert(degree1.getRaw() == radian1.getRaw(), "difference: 90 deg <-> pi/2 rad"); | ||
constexpr auto degree2 = ics::Angle::newDegree(30); | ||
constexpr auto radian2 = ics::Angle::newRadian(ics::Angle::PI / 6); | ||
static_assert(degree2.getRaw() == radian2.getRaw(), "difference: 30 deg <-> pi/6 rad"); | ||
constexpr auto degree_cast = ics::Angle::newDegree(50); | ||
constexpr auto cast1 = static_cast<double>(degree_cast); | ||
constexpr double cast2 {degree_cast}; | ||
static_assert(cast1 == cast2, "difference: angle cast to doubles. miss? impossible lol"); | ||
} | ||
|
||
TEST(AngleCreateTest, NewFactoryWithGetAndGetRaw) { | ||
// runtime test | ||
auto degree = ics::Angle::newDegree(); | ||
auto radian = ics::Angle::newRadian(); | ||
EXPECT_EQ(degree.get(), radian.get()); | ||
EXPECT_EQ(degree.getRaw(), radian.getRaw()); | ||
EXPECT_THROW(ics::Angle::newDegree(136), std::out_of_range); | ||
} | ||
|
||
TEST(AngleMethodTest, SetWithGetRaw) { | ||
auto degree = ics::Angle::newDegree(0); | ||
auto radian = ics::Angle::newRadian(0); | ||
degree.set(90); | ||
radian.set(ics::Angle::PI / 2); | ||
EXPECT_EQ(degree.getRaw(), radian.getRaw()); | ||
degree.set(-60); | ||
radian.set(-ics::Angle::PI / 3); | ||
EXPECT_EQ(degree.getRaw(), radian.getRaw()); | ||
EXPECT_THROW(degree.set(150), std::out_of_range); | ||
EXPECT_THROW(radian.set(ics::Angle::PI), std::out_of_range); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* BSD 2-Clause License | ||
Copyright (c) 2016, Doi Yusuke | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "ics3/ics" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(BaudrateContexprTest, Baudrate115200) { | ||
constexpr auto baudrate115200 = ics::Baudrate::RATE115200(); | ||
static_assert(baudrate115200 == 10, "Baudrate: not equal 10"); | ||
static_assert(baudrate115200.get() == 10, "Baudrate: romdata error"); | ||
static_assert(baudrate115200.getSpeed() == B115200, "Baudrate: getSpeed method error"); | ||
static_assert(static_cast<uint8_t>(baudrate115200) == 10, "cast to Baudrate::type(uint8_t)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* BSD 2-Clause License | ||
Copyright (c) 2016, Doi Yusuke | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
#include "ics3/ics" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(EepParamConstexprTest, EepParam) { | ||
constexpr auto current = ics::EepParam::current(); | ||
static_assert(63 == current.get(), "current error"); | ||
constexpr auto stretch = ics::EepParam::stretch(244); | ||
static_assert(244 == stretch.get(), "strech error"); | ||
} | ||
|
||
TEST(EepParamCreateTest, Correct) { | ||
auto speed = ics::EepParam::speed(); | ||
EXPECT_EQ(speed.get(), 127); | ||
auto speed2 = ics::EepParam::newEepParam(speed, 60); | ||
EXPECT_EQ(speed2.get(), 60); | ||
} | ||
|
||
TEST(EepParamCreateTest, Invalid) { | ||
EXPECT_THROW(ics::EepParam::flag(10), std::invalid_argument); | ||
auto speed = ics::EepParam::speed(); | ||
EXPECT_THROW(ics::EepParam::newEepParam(speed, 130), std::out_of_range); | ||
} | ||
|
||
TEST(EepParamMethodSetTest, Correct) { | ||
// runtime test | ||
auto speed = ics::EepParam::speed(); | ||
speed.set(100); | ||
EXPECT_EQ(100, speed.get()); | ||
} | ||
|
||
TEST(EepParamMethodSetTest, Invalid) { | ||
auto speed = ics::EepParam::speed(); | ||
EXPECT_THROW(speed.set(200), std::out_of_range); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.