Line | |
---|
1 | // Copyright Benoit Blanchon 2014-2016
|
---|
2 | // MIT License
|
---|
3 | //
|
---|
4 | // Arduino JSON library
|
---|
5 | // https://github.com/bblanchon/ArduinoJson
|
---|
6 | // If you like this project, please add a star!
|
---|
7 |
|
---|
8 | #include <gtest/gtest.h>
|
---|
9 | #include <ArduinoJson.h>
|
---|
10 |
|
---|
11 | class Issue67 : public testing::Test {
|
---|
12 | public:
|
---|
13 | void whenInputIs(double value) { _variant = value; }
|
---|
14 |
|
---|
15 | void outputMustBe(const char* expected) {
|
---|
16 | char buffer[1024];
|
---|
17 | _variant.printTo(buffer, sizeof(buffer));
|
---|
18 | ASSERT_STREQ(expected, buffer);
|
---|
19 | }
|
---|
20 |
|
---|
21 | private:
|
---|
22 | JsonVariant _variant;
|
---|
23 | };
|
---|
24 |
|
---|
25 | TEST_F(Issue67, BigPositiveDouble) {
|
---|
26 | whenInputIs(1e100);
|
---|
27 | outputMustBe("1e+100");
|
---|
28 | }
|
---|
29 |
|
---|
30 | TEST_F(Issue67, BigNegativeDouble) {
|
---|
31 | whenInputIs(-1e100);
|
---|
32 | outputMustBe("-1e+100");
|
---|
33 | }
|
---|
34 |
|
---|
35 | TEST_F(Issue67, Zero) {
|
---|
36 | whenInputIs(0.0);
|
---|
37 | outputMustBe("0.00");
|
---|
38 | }
|
---|
39 |
|
---|
40 | TEST_F(Issue67, SmallPositiveDouble) {
|
---|
41 | whenInputIs(111.111);
|
---|
42 | outputMustBe("111.11");
|
---|
43 | }
|
---|
44 |
|
---|
45 | TEST_F(Issue67, SmallNegativeDouble) {
|
---|
46 | whenInputIs(-111.111);
|
---|
47 | outputMustBe("-111.11");
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.