constexpr removed. base64 test

This commit is contained in:
lganzzzo 2018-10-17 12:22:24 +03:00
parent 69e2ee9f96
commit 766b4803aa
15 changed files with 136 additions and 22 deletions

View File

@ -249,6 +249,8 @@ if(OATPP_BUILD_TESTS)
test/core/data/mapping/type/TypeTest.hpp
test/encoding/UnicodeTest.cpp
test/encoding/UnicodeTest.hpp
test/encoding/Base64Test.cpp
test/encoding/Base64Test.hpp
test/parser/json/mapping/DeserializerTest.cpp
test/parser/json/mapping/DeserializerTest.hpp
test/parser/json/mapping/DTOMapperPerfTest.cpp

View File

@ -17,7 +17,7 @@ jobs:
mv `ls -A | grep -v oatpp` ./oatpp/
- task: CMake@1
- script: |
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DOATPP_INSTALL=OFF -DOATPP_BUILD_TESTS=ON
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DOATPP_INSTALL=OFF -DOATPP_BUILD_TESTS=ON
make
displayName: 'CMake'
workingDirectory: oatpp

View File

@ -29,6 +29,8 @@ namespace oatpp { namespace data { namespace mapping { namespace type {
namespace __class {
const char* const Void::CLASS_NAME = "Void";
Type* Void::getType(){
static Type type(CLASS_NAME, nullptr);
return &type;

View File

@ -38,7 +38,7 @@ class Type; // FWD
namespace __class {
class Void {
public:
constexpr static const char* const CLASS_NAME = "Void";
static const char* const CLASS_NAME;
static Type* getType();
};
}

View File

@ -27,6 +27,9 @@
namespace oatpp { namespace data{ namespace stream {
const char* const Errors::ERROR_ASYNC_FAILED_TO_WRITE_DATA = "ERROR_ASYNC_FAILED_TO_WRITE_DATA";
const char* const Errors::ERROR_ASYNC_FAILED_TO_READ_DATA = "ERROR_ASYNC_FAILED_TO_READ_DATA";
os::io::Library::v_size OutputStream::writeAsString(v_int32 value){
v_char8 a[100];
v_int32 size = utils::conversion::int32ToCharSequence(value, &a[0]);

View File

@ -43,8 +43,8 @@ public:
constexpr static os::io::Library::v_size ERROR_IO_RETRY = -1003;
constexpr static os::io::Library::v_size ERROR_IO_PIPE = -1004;
constexpr static const char* const ERROR_ASYNC_FAILED_TO_WRITE_DATA = "ERROR_ASYNC_FAILED_TO_WRITE_DATA";
constexpr static const char* const ERROR_ASYNC_FAILED_TO_READ_DATA = "ERROR_ASYNC_FAILED_TO_READ_DATA";
static const char* const ERROR_ASYNC_FAILED_TO_WRITE_DATA;
static const char* const ERROR_ASYNC_FAILED_TO_READ_DATA;
};
class OutputStream {

View File

@ -26,6 +26,14 @@
namespace oatpp { namespace encoding {
const char* const Base64::ALPHABET_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const char* const Base64::ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";
const char* const Base64::ALPHABET_BASE64_URL_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-";
const char* const Base64::ALPHABET_BASE64_AUXILIARY_CHARS = "+/=";
const char* const Base64::ALPHABET_BASE64_URL_AUXILIARY_CHARS = "-_=";
const char* const Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS = "._-";
v_char8 Base64::getAlphabetCharIndex(v_char8 a, const char* auxiliaryChars) {
if(a >= 'A' && a <='Z') {
return a - 'A';

View File

@ -49,16 +49,16 @@ public:
/**
* Alphabet is array of 65 chars. 64 chars encoding chars, and 65th padding char
*/
constexpr static const char* ALPHABET_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
constexpr static const char* ALPHABET_BASE64_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";
constexpr static const char* ALPHABET_BASE64_URL_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-";
static const char* const ALPHABET_BASE64;
static const char* const ALPHABET_BASE64_URL;
static const char* const ALPHABET_BASE64_URL_SAFE;
/**
* alphabet auxiliary chars - last 3 chars of alphabet including padding char.
*/
constexpr static const char* ALPHABET_BASE64_AUXILIARY_CHARS = "+/=";
constexpr static const char* ALPHABET_BASE64_URL_AUXILIARY_CHARS = "-_=";
constexpr static const char* ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS = "._-";
static const char* const ALPHABET_BASE64_AUXILIARY_CHARS;
static const char* const ALPHABET_BASE64_URL_AUXILIARY_CHARS;
static const char* const ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS;
/**
* Returns size of encoding result of a string of the given size

View File

@ -219,7 +219,6 @@ Deserializer::AbstractObjectWrapper Deserializer::readValue(const Type* const ty
} else if(typeName == oatpp::data::mapping::type::__class::AbstractListMap::CLASS_NAME){
return readListMapValue(type, caret, config);
} else {
OATPP_LOGD("test", "value skipped of type: '%s'", typeName);
skipValue(caret);
}

View File

@ -132,7 +132,6 @@ public:
} else if(type->name == oatpp::data::mapping::type::__class::AbstractListMap::CLASS_NAME){
return readListMap(type, caret, config);
}
OATPP_LOGD("test", "unknown type '%s'", type->name);
return AbstractObjectWrapper::empty();
}

View File

@ -1,12 +1,15 @@
#include "oatpp/test/parser/json/mapping/DeserializerTest.hpp"
#include "oatpp/test/parser/json/mapping/DTOMapperPerfTest.hpp"
#include "oatpp/test/parser/json/mapping/DTOMapperTest.hpp"
#include "oatpp/test/encoding/UnicodeTest.hpp"
#include "oatpp/test/encoding/Base64Test.hpp"
#include "oatpp/test/core/data/mapping/type/TypeTest.hpp"
#include "oatpp/test/core/base/collection/LinkedListTest.hpp"
#include "oatpp/test/core/base/memory/MemoryPoolTest.hpp"
#include "oatpp/test/core/base/memory/PerfTest.hpp"
#include "oatpp/test/encoding/UnicodeTest.hpp"
#include "oatpp/test/parser/json/mapping/DeserializerTest.hpp"
#include "oatpp/test/parser/json/mapping/DTOMapperPerfTest.hpp"
#include "oatpp/test/parser/json/mapping/DTOMapperTest.hpp"
#include "oatpp/core/concurrency/SpinLock.hpp"
#include "oatpp/core/base/Environment.hpp"
@ -33,14 +36,15 @@ public:
};
void runTests() {
//OATPP_RUN_TEST(oatpp::test::collection::LinkedListTest);
//OATPP_RUN_TEST(oatpp::test::memory::MemoryPoolTest);
//OATPP_RUN_TEST(oatpp::test::memory::PerfTest);
//OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest);
OATPP_RUN_TEST(oatpp::test::memory::MemoryPoolTest);
OATPP_RUN_TEST(oatpp::test::memory::PerfTest);
OATPP_RUN_TEST(oatpp::test::collection::LinkedListTest);
OATPP_RUN_TEST(oatpp::test::core::data::mapping::type::TypeTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperPerfTest);
OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DTOMapperTest);
OATPP_RUN_TEST(oatpp::test::encoding::Base64Test);
OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest);
}
}

View File

@ -0,0 +1,54 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi, <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#include "Base64Test.hpp"
#include "oatpp/encoding/Base64.hpp"
namespace oatpp { namespace test { namespace encoding {
bool Base64Test::onRun() {
oatpp::String message = "oat++ web framework";
oatpp::String messageEncoded = "b2F0Kysgd2ViIGZyYW1ld29yaw==";
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message);
OATPP_LOGD(TAG, "encoded='%s'", encoded->c_str());
OATPP_ASSERT(encoded->equals(messageEncoded.get()));
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded);
OATPP_ASSERT(message->equals(decoded.get()));
}
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE);
OATPP_LOGD(TAG, "encoded='%s'", encoded->c_str());
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS);
OATPP_ASSERT(message->equals(decoded.get()));
}
return true;
}
}}}

View File

@ -0,0 +1,40 @@
/***************************************************************************
*
* Project _____ __ ____ _ _
* ( _ ) /__\ (_ _)_| |_ _| |_
* )(_)( /(__)\ )( (_ _)(_ _)
* (_____)(__)(__)(__) |_| |_|
*
*
* Copyright 2018-present, Leonid Stryzhevskyi, <lganzzzo@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
***************************************************************************/
#ifndef oatpp_test_encoding_Base64Test_hpp
#define oatpp_test_encoding_Base64Test_hpp
#include "oatpp/test/UnitTest.hpp"
namespace oatpp { namespace test { namespace encoding {
class Base64Test : public UnitTest{
public:
Base64Test():UnitTest("TEST[encoding::Base64Test]"){}
bool onRun() override;
};
}}}
#endif /* oatpp_test_encoding_Base64Test_hpp */

View File

@ -120,6 +120,9 @@ const char* const Header::HOST = "Host";
const char* const Header::USER_AGENT = "User-Agent";
const char* const Header::SERVER = "Server";
const char* const Range::UNIT_BYTES = "bytes";
const char* const ContentRange::UNIT_BYTES = "bytes";
oatpp::String Range::toString() const {
oatpp::data::stream::ChunkedBuffer stream;
stream.write(units->getData(), units->getSize());

View File

@ -158,7 +158,7 @@ public:
class Range {
public:
constexpr static const char* UNIT_BYTES = "bytes";
static const char* const UNIT_BYTES;
private:
Range()
: units(nullptr)
@ -190,7 +190,7 @@ public:
class ContentRange {
public:
constexpr static const char* UNIT_BYTES = "bytes";
static const char* const UNIT_BYTES;
private:
ContentRange()
: units(nullptr)