Sha256: c0217d433fff5676ccfe6940319ba52bd009158ed42cfb7e944a7083d2df5e29

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

Contents

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

#include "test.hpp"
#include "test_types.hpp"

#include <tao/json.hpp>

namespace tao::json
{
   void test_base64( const value& v, const std::string& j )
   {
      TEST_ASSERT( to_string< events::binary_to_base64 >( v ) == j );
   }

   void test_base64url( const value& v, const std::string& j )
   {
      TEST_ASSERT( to_string< events::binary_to_base64url >( v ) == j );
   }

   void test_exception( const value& v )
   {
      TEST_THROWS( to_string< events::binary_to_exception >( v ) );
   }

   void test_hex( const value& v, const std::string& j )
   {
      TEST_ASSERT( to_string< events::binary_to_hex >( v ) == j );
   }

   void unit_test()
   {
      value v = null;

      test_base64( v, "null" );
      test_base64url( v, "null" );
      test_hex( v, "null" );

      v = empty_binary;

      test_base64( v, "\"\"" );
      test_base64url( v, "\"\"" );
      test_exception( v );
      test_hex( v, "\"\"" );

      v = binary{ std::byte( 0 ), std::byte( 255 ), std::byte( 42 ), std::byte( 99 ) };

      test_base64( v, "\"AP8qYw==\"" );
      test_base64url( v, "\"AP8qYw\"" );
      test_exception( v );
      test_hex( v, "\"00FF2A63\"" );
   }

}  // 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/events_binary_to.cpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.4 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.3 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.2 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/json/src/test/json/events_binary_to.cpp
couchbase-3.0.0.alpha.1 ext/third_party/json/src/test/json/events_binary_to.cpp