🔨 another try to fix #714
adding std::ios_base::binary when opening all_unicode.json.cbor
This commit is contained in:
		
							parent
							
								
									c4d6626745
								
							
						
					
					
						commit
						5696660eba
					
				
					 2 changed files with 34 additions and 35 deletions
				
			
		| 
						 | 
				
			
			@ -38,18 +38,18 @@ using nlohmann::json;
 | 
			
		|||
 | 
			
		||||
namespace
 | 
			
		||||
{
 | 
			
		||||
  struct nocopy
 | 
			
		||||
  {
 | 
			
		||||
struct nocopy
 | 
			
		||||
{
 | 
			
		||||
    nocopy() = default;
 | 
			
		||||
    nocopy(const nocopy &) = delete;
 | 
			
		||||
    nocopy(const nocopy&) = delete;
 | 
			
		||||
 | 
			
		||||
    int val = 0;
 | 
			
		||||
 | 
			
		||||
    friend void to_json(json& j, const nocopy& n)
 | 
			
		||||
    {
 | 
			
		||||
      j = {{"val", n.val}};
 | 
			
		||||
        j = {{"val", n.val}};
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE("regression tests")
 | 
			
		||||
| 
						 | 
				
			
			@ -1270,40 +1270,39 @@ TEST_CASE("regression tests")
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
        SECTION("issue #714 - throw std::ios_base::failure exception when failbit set to true")
 | 
			
		||||
    SECTION("issue #714 - throw std::ios_base::failure exception when failbit set to true")
 | 
			
		||||
    {
 | 
			
		||||
        {
 | 
			
		||||
            {
 | 
			
		||||
                std::ifstream is;
 | 
			
		||||
                is.exceptions(
 | 
			
		||||
                    is.exceptions()
 | 
			
		||||
                    | std::ios_base::failbit
 | 
			
		||||
                    | std::ios_base::badbit
 | 
			
		||||
                ); // handle different exceptions as 'file not found', 'permission denied'
 | 
			
		||||
            std::ifstream is;
 | 
			
		||||
            is.exceptions(
 | 
			
		||||
                is.exceptions()
 | 
			
		||||
                | std::ios_base::failbit
 | 
			
		||||
                | std::ios_base::badbit
 | 
			
		||||
            ); // handle different exceptions as 'file not found', 'permission denied'
 | 
			
		||||
 | 
			
		||||
                is.open("test/data/regression/working_file.json");
 | 
			
		||||
                CHECK_NOTHROW(nlohmann::json::parse(is));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            {
 | 
			
		||||
                std::ifstream is;
 | 
			
		||||
                is.exceptions(
 | 
			
		||||
                    is.exceptions()
 | 
			
		||||
                    | std::ios_base::failbit
 | 
			
		||||
                    | std::ios_base::badbit
 | 
			
		||||
                ); // handle different exceptions as 'file not found', 'permission denied'
 | 
			
		||||
 | 
			
		||||
                is.open("test/data/json_nlohmann_tests/all_unicode.json.cbor");
 | 
			
		||||
                CHECK_NOTHROW(nlohmann::json::from_cbor(is));
 | 
			
		||||
            }
 | 
			
		||||
            is.open("test/data/regression/working_file.json");
 | 
			
		||||
            CHECK_NOTHROW(nlohmann::json::parse(is));
 | 
			
		||||
        }
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            std::ifstream is;
 | 
			
		||||
            is.exceptions(
 | 
			
		||||
                is.exceptions()
 | 
			
		||||
                | std::ios_base::failbit
 | 
			
		||||
                | std::ios_base::badbit
 | 
			
		||||
            ); // handle different exceptions as 'file not found', 'permission denied'
 | 
			
		||||
 | 
			
		||||
            is.open("test/data/json_nlohmann_tests/all_unicode.json.cbor",
 | 
			
		||||
                    std::ios_base::in | std::ios_base::binary);
 | 
			
		||||
            CHECK_NOTHROW(nlohmann::json::from_cbor(is));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SECTION("issue #805 - copy constructor is used with std::initializer_list constructor.")
 | 
			
		||||
    {
 | 
			
		||||
      nocopy n;
 | 
			
		||||
      json j;
 | 
			
		||||
      j = {{"nocopy", n}};
 | 
			
		||||
      CHECK(j["nocopy"]["val"] == 0);
 | 
			
		||||
        nocopy n;
 | 
			
		||||
        json j;
 | 
			
		||||
        j = {{"nocopy", n}};
 | 
			
		||||
        CHECK(j["nocopy"]["val"] == 0);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue