mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			49 lines
		
	
	
		
			955 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			955 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright Benoit Blanchon 2014-2016
 | |
| // MIT License
 | |
| //
 | |
| // Arduino JSON library
 | |
| // https://github.com/bblanchon/ArduinoJson
 | |
| // If you like this project, please add a star!
 | |
| 
 | |
| #include <gtest/gtest.h>
 | |
| #include <ArduinoJson.h>
 | |
| 
 | |
| class Issue67 : public testing::Test {
 | |
|  public:
 | |
|   void whenInputIs(double value) { _variant = value; }
 | |
| 
 | |
|   void outputMustBe(const char* expected) {
 | |
|     char buffer[1024];
 | |
|     _variant.printTo(buffer, sizeof(buffer));
 | |
|     ASSERT_STREQ(expected, buffer);
 | |
|   }
 | |
| 
 | |
|  private:
 | |
|   JsonVariant _variant;
 | |
| };
 | |
| 
 | |
| TEST_F(Issue67, BigPositiveDouble) {
 | |
|   whenInputIs(1e100);
 | |
|   outputMustBe("1e+100");
 | |
| }
 | |
| 
 | |
| TEST_F(Issue67, BigNegativeDouble) {
 | |
|   whenInputIs(-1e100);
 | |
|   outputMustBe("-1e+100");
 | |
| }
 | |
| 
 | |
| TEST_F(Issue67, Zero) {
 | |
|   whenInputIs(0.0);
 | |
|   outputMustBe("0.00");
 | |
| }
 | |
| 
 | |
| TEST_F(Issue67, SmallPositiveDouble) {
 | |
|   whenInputIs(111.111);
 | |
|   outputMustBe("111.11");
 | |
| }
 | |
| 
 | |
| TEST_F(Issue67, SmallNegativeDouble) {
 | |
|   whenInputIs(-111.111);
 | |
|   outputMustBe("-111.11");
 | |
| }
 |