"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unittest/stringbuffertest.cpp" between
rapidjson-1.0.2.tar.gz and rapidjson-1.1.0.tar.gz

About: RapidJSON is a fast JSON parser/generator for C++ with both SAX/DOM style API.

stringbuffertest.cpp  (rapidjson-1.0.2):stringbuffertest.cpp  (rapidjson-1.1.0)
skipping to change at line 19 skipping to change at line 19
// //
// Unless required by applicable law or agreed to in writing, software distribut ed // Unless required by applicable law or agreed to in writing, software distribut ed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // 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 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License. // specific language governing permissions and limitations under the License.
#include "unittest.h" #include "unittest.h"
#include "rapidjson/stringbuffer.h" #include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h" #include "rapidjson/writer.h"
#ifdef __clang__
RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(c++98-compat)
#endif
using namespace rapidjson; using namespace rapidjson;
TEST(StringBuffer, InitialSize) { TEST(StringBuffer, InitialSize) {
StringBuffer buffer; StringBuffer buffer;
EXPECT_EQ(0u, buffer.GetSize()); EXPECT_EQ(0u, buffer.GetSize());
EXPECT_STREQ("", buffer.GetString()); EXPECT_STREQ("", buffer.GetString());
} }
TEST(StringBuffer, Put) { TEST(StringBuffer, Put) {
StringBuffer buffer; StringBuffer buffer;
buffer.Put('A'); buffer.Put('A');
EXPECT_EQ(1u, buffer.GetSize()); EXPECT_EQ(1u, buffer.GetSize());
EXPECT_STREQ("A", buffer.GetString()); EXPECT_STREQ("A", buffer.GetString());
} }
TEST(StringBuffer, PutN_Issue672) {
GenericStringBuffer<UTF8<>, MemoryPoolAllocator<> > buffer;
EXPECT_EQ(0, buffer.GetSize());
rapidjson::PutN(buffer, ' ', 1);
EXPECT_EQ(1, buffer.GetSize());
}
TEST(StringBuffer, Clear) { TEST(StringBuffer, Clear) {
StringBuffer buffer; StringBuffer buffer;
buffer.Put('A'); buffer.Put('A');
buffer.Put('B'); buffer.Put('B');
buffer.Put('C'); buffer.Put('C');
buffer.Clear(); buffer.Clear();
EXPECT_EQ(0u, buffer.GetSize()); EXPECT_EQ(0u, buffer.GetSize());
EXPECT_STREQ("", buffer.GetString()); EXPECT_STREQ("", buffer.GetString());
} }
skipping to change at line 72 skipping to change at line 84
buffer.Put('D'); buffer.Put('D');
buffer.Put('E'); buffer.Put('E');
buffer.Pop(3); buffer.Pop(3);
EXPECT_EQ(2u, buffer.GetSize()); EXPECT_EQ(2u, buffer.GetSize());
EXPECT_STREQ("AB", buffer.GetString()); EXPECT_STREQ("AB", buffer.GetString());
} }
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
#if 0 // Many old compiler does not support these. Turn it off temporaily.
#include <type_traits> #include <type_traits>
TEST(StringBuffer, Traits) { TEST(StringBuffer, Traits) {
static_assert( std::is_constructible<StringBuffer>::value, ""); static_assert( std::is_constructible<StringBuffer>::value, "");
static_assert( std::is_default_constructible<StringBuffer>::value, ""); static_assert( std::is_default_constructible<StringBuffer>::value, "");
#ifndef _MSC_VER #ifndef _MSC_VER
static_assert(!std::is_copy_constructible<StringBuffer>::value, ""); static_assert(!std::is_copy_constructible<StringBuffer>::value, "");
#endif #endif
static_assert( std::is_move_constructible<StringBuffer>::value, ""); static_assert( std::is_move_constructible<StringBuffer>::value, "");
skipping to change at line 109 skipping to change at line 123
static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, ""); static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, "");
static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, ""); static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, "");
static_assert( std::is_destructible<StringBuffer>::value, ""); static_assert( std::is_destructible<StringBuffer>::value, "");
#ifndef _MSC_VER #ifndef _MSC_VER
static_assert(std::is_nothrow_destructible<StringBuffer>::value, ""); static_assert(std::is_nothrow_destructible<StringBuffer>::value, "");
#endif #endif
} }
#endif
TEST(StringBuffer, MoveConstructor) { TEST(StringBuffer, MoveConstructor) {
StringBuffer x; StringBuffer x;
x.Put('A'); x.Put('A');
x.Put('B'); x.Put('B');
x.Put('C'); x.Put('C');
x.Put('D'); x.Put('D');
EXPECT_EQ(4u, x.GetSize()); EXPECT_EQ(4u, x.GetSize());
EXPECT_STREQ("ABCD", x.GetString()); EXPECT_STREQ("ABCD", x.GetString());
skipping to change at line 151 skipping to change at line 167
StringBuffer y; StringBuffer y;
// y = x; // does not compile (!is_copy_assignable) // y = x; // does not compile (!is_copy_assignable)
y = std::move(x); y = std::move(x);
EXPECT_EQ(0u, x.GetSize()); EXPECT_EQ(0u, x.GetSize());
EXPECT_EQ(4u, y.GetSize()); EXPECT_EQ(4u, y.GetSize());
EXPECT_STREQ("ABCD", y.GetString()); EXPECT_STREQ("ABCD", y.GetString());
} }
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
#ifdef __clang__
RAPIDJSON_DIAG_POP
#endif
 End of changes. 5 change blocks. 
0 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)