Ejemplo n.º 1
0
TEST(ByteArrayTest, DefaultConstruction)
{
	ByteArray ba;

	ASSERT_TRUE(ba.isNull());
	ASSERT_TRUE(ba.isEmpty());
	ASSERT_EQ(ba.length(), 0);

	ByteArray clone = ba;

	ASSERT_TRUE(clone.isNull());
	ASSERT_TRUE(clone.isEmpty());
	ASSERT_EQ(clone.length(), 0);
}
Ejemplo n.º 2
0
bool BitmapData::initWithFile(const std::string &path) {
    _filePath = FileUtils::getInstance()->getFullPath(path);
    ByteArray *data = FileUtils::getInstance()->getFileData(_filePath, "rb");
    bool result = false;
    if (!data->isNull()) {
        result = initWithData(data->getBytes(), data->getLength());
    }
    delete data;
    return result;
}
Ejemplo n.º 3
0
TEST(ByteArrayTest, Clear)
{
	ByteArray ba = "This is a test";
	ba.clear();
	ASSERT_FALSE(ba.isNull());
	ASSERT_TRUE(ba.isEmpty());

	ba = "This is a test";
	ByteArray clone = ba;

	ba.clear();

	ASSERT_FALSE(ba.isNull());
	ASSERT_TRUE(ba.isEmpty());

	ASSERT_FALSE(clone.isNull());
	ASSERT_FALSE(clone.isEmpty());

	clone.clear();

	ASSERT_FALSE(clone.isNull());
	ASSERT_TRUE(clone.isEmpty());
}
Ejemplo n.º 4
0
TEST(ByteArrayTest, ConstructionFromSharedCopy)
{
	ByteArray ba("This is a test");
	ByteArray clone = ba;

	ASSERT_FALSE(ba.isNull());
	ASSERT_FALSE(ba.isEmpty());
	ASSERT_EQ(ba.length(), 14);
	ASSERT_STRCASEEQ(ba, "This is a test");

	ASSERT_FALSE(clone.isNull());
	ASSERT_FALSE(clone.isEmpty());
	ASSERT_EQ(clone.length(), 14);
	ASSERT_STRCASEEQ(clone, "This is a test");
}
Ejemplo n.º 5
0
TEST_F(ByteArrayTest, BasicTest) {
    ByteArray data;
    EXPECT_EQ(true, data.isNull());

    data = ByteArray(10);
    EXPECT_EQ(false, data.isNull());
    EXPECT_EQ(10, data.length());
    data.assign("hogehoge", 0, 8);
    EXPECT_EQ(10, data.length());
    EXPECT_EQ("hogehoge", string(data.data(), 8));
    EXPECT_NE("fuga", string(data.data(), 8));

    data = passArray(data);
    EXPECT_EQ(false, data.isNull());
    EXPECT_EQ(10, data.length());
    EXPECT_EQ("hogehoge", string(data.data(), 8));
    EXPECT_NE("fuga", string(data.data(), 8));


    ByteArray data2("0123456789abcdef", 16);
    EXPECT_EQ(false, data2.isNull());
    EXPECT_EQ(16, data2.length());
    EXPECT_EQ("0123456789abcdef", string(data2.data(), 16));

    ByteArray data3("xyz", 3);
    ByteArray concated = data2 + data3;
    EXPECT_EQ(false, concated.isNull());
    EXPECT_EQ(16 + 3, concated.length());
    EXPECT_EQ("0123456789abcdefxyz", string(concated.data(), 16 + 3));
    concated[10] = 'p';
    EXPECT_EQ("0123456789pbcdefxyz", string(concated.data(), 16 + 3));

    data3.data()[1] = 'c';
    concated = data3 + data2;
    EXPECT_EQ(false, concated.isNull());
    EXPECT_EQ(16 + 3, concated.length());
    EXPECT_EQ("xcz0123456789abcdef", string(concated.data(), 16 + 3));

    data.reset();
    EXPECT_EQ(true, data.isNull());
}