Sha256: 8ab43f4f013638daf136ce0253a2be6cd2e0ce680e8ca04f3da5cc228f9f58c1

Contents?: true

Size: 911 Bytes

Versions: 16

Compression:

Stored size: 911 Bytes

Contents

// Copyright (c) 2016-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/json/

#include "test.hpp"

#include <tao/json/to_string.hpp>
#include <tao/json/value.hpp>

namespace tao::json
{
   void unit_test()
   {
      value v{ { "foo", 1 } };
      const value cv{ { "fuu", 2 } };

      const value v2{ { "bar", &v } };    // Store a non-owning const pointer to v.
      const value cv2{ { "baz", &cv } };  // Store a non-owning const pointer to cv.

      TEST_ASSERT( to_string( v ) == "{\"foo\":1}" );
      TEST_ASSERT( to_string( cv ) == "{\"fuu\":2}" );

      TEST_ASSERT( to_string( v2 ) == "{\"bar\":{\"foo\":1}}" );

      TEST_ASSERT( v2.at( "bar" ).is_value_ptr() );

      TEST_ASSERT( to_string( cv2 ) == "{\"baz\":{\"fuu\":2}}" );

      TEST_ASSERT( cv2.at( "baz" ).is_value_ptr() );
   }

}  // namespace tao::json

#include "main.hpp"

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.4 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.3 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.2 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/json/src/test/json/value_ptr.cpp
couchbase-3.0.0.alpha.1 ext/third_party/json/src/test/json/value_ptr.cpp